packet.cc (10565:23593fdaadcd) packet.cc (10570:dcb908e40547)
1/*
2 * Copyright (c) 2011-2014 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software

--- 160 unchanged lines hidden (view full) ---

169 { SET3(IsRequest, IsFlush, NeedsExclusive), InvalidCmd, "FlushReq" },
170 /* Invalidation Request */
171 { SET3(NeedsExclusive, IsInvalidate, IsRequest),
172 InvalidCmd, "InvalidationReq" },
173};
174
175bool
176Packet::checkFunctional(Printable *obj, Addr addr, bool is_secure, int size,
1/*
2 * Copyright (c) 2011-2014 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software

--- 160 unchanged lines hidden (view full) ---

169 { SET3(IsRequest, IsFlush, NeedsExclusive), InvalidCmd, "FlushReq" },
170 /* Invalidation Request */
171 { SET3(NeedsExclusive, IsInvalidate, IsRequest),
172 InvalidCmd, "InvalidationReq" },
173};
174
175bool
176Packet::checkFunctional(Printable *obj, Addr addr, bool is_secure, int size,
177 uint8_t *data)
177 uint8_t *_data)
178{
179 Addr func_start = getAddr();
180 Addr func_end = getAddr() + getSize() - 1;
181 Addr val_start = addr;
182 Addr val_end = val_start + size - 1;
183
184 if (is_secure != _isSecure || func_start > val_end ||
185 val_start > func_end) {
186 // no intersection
187 return false;
188 }
189
190 // check print first since it doesn't require data
191 if (isPrint()) {
178{
179 Addr func_start = getAddr();
180 Addr func_end = getAddr() + getSize() - 1;
181 Addr val_start = addr;
182 Addr val_end = val_start + size - 1;
183
184 if (is_secure != _isSecure || func_start > val_end ||
185 val_start > func_end) {
186 // no intersection
187 return false;
188 }
189
190 // check print first since it doesn't require data
191 if (isPrint()) {
192 assert(!_data);
192 safe_cast<PrintReqState*>(senderState)->printObj(obj);
193 return false;
194 }
195
193 safe_cast<PrintReqState*>(senderState)->printObj(obj);
194 return false;
195 }
196
196 // if there's no data, there's no need to look further
197 if (!data) {
197 // we allow the caller to pass NULL to signify the other packet
198 // has no data
199 if (!_data) {
198 return false;
199 }
200
201 // offset of functional request into supplied value (could be
202 // negative if partial overlap)
203 int offset = func_start - val_start;
204
205 if (isRead()) {
206 if (func_start >= val_start && func_end <= val_end) {
200 return false;
201 }
202
203 // offset of functional request into supplied value (could be
204 // negative if partial overlap)
205 int offset = func_start - val_start;
206
207 if (isRead()) {
208 if (func_start >= val_start && func_end <= val_end) {
207 memcpy(getPtr(), data + offset, getSize());
209 memcpy(getPtr<uint8_t>(), _data + offset, getSize());
210 // complete overlap, and as the current packet is a read
211 // we are done
208 return true;
209 } else {
210 // Offsets and sizes to copy in case of partial overlap
211 int func_offset;
212 int val_offset;
213 int overlap_size;
214
215 // calculate offsets and copy sizes for the two byte arrays

--- 50 unchanged lines hidden (view full) ---

266 } else if (a < 0 && b > 0) {
267 // Found bytes are superset of copied range. Will move
268 // bytesValidStart towards 0 and bytesValidEnd towards
269 // end of pkt data array. Need to break copy into two
270 // pieces so as to not overwrite previously found data.
271
272 // copy the first half
273 uint8_t *dest = getPtr<uint8_t>() + func_offset;
212 return true;
213 } else {
214 // Offsets and sizes to copy in case of partial overlap
215 int func_offset;
216 int val_offset;
217 int overlap_size;
218
219 // calculate offsets and copy sizes for the two byte arrays

--- 50 unchanged lines hidden (view full) ---

270 } else if (a < 0 && b > 0) {
271 // Found bytes are superset of copied range. Will move
272 // bytesValidStart towards 0 and bytesValidEnd towards
273 // end of pkt data array. Need to break copy into two
274 // pieces so as to not overwrite previously found data.
275
276 // copy the first half
277 uint8_t *dest = getPtr<uint8_t>() + func_offset;
274 uint8_t *src = data + val_offset;
278 uint8_t *src = _data + val_offset;
275 memcpy(dest, src, (bytesValidStart - func_offset));
276
277 // re-calc the offsets and indices to do the copy
278 // required for the second half
279 val_offset += (bytesValidEnd - func_offset);
280 bytesValidStart = func_offset;
281 overlap_size =
282 (func_offset + overlap_size) - bytesValidEnd;

--- 5 unchanged lines hidden (view full) ---

288 panic("BUG: Discontiguous bytes found"
289 "for functional copying!");
290 }
291 }
292 assert(bytesValidEnd <= getSize());
293
294 // copy partial data into the packet's data array
295 uint8_t *dest = getPtr<uint8_t>() + func_offset;
279 memcpy(dest, src, (bytesValidStart - func_offset));
280
281 // re-calc the offsets and indices to do the copy
282 // required for the second half
283 val_offset += (bytesValidEnd - func_offset);
284 bytesValidStart = func_offset;
285 overlap_size =
286 (func_offset + overlap_size) - bytesValidEnd;

--- 5 unchanged lines hidden (view full) ---

292 panic("BUG: Discontiguous bytes found"
293 "for functional copying!");
294 }
295 }
296 assert(bytesValidEnd <= getSize());
297
298 // copy partial data into the packet's data array
299 uint8_t *dest = getPtr<uint8_t>() + func_offset;
296 uint8_t *src = data + val_offset;
300 uint8_t *src = _data + val_offset;
297 memcpy(dest, src, overlap_size);
298
299 // check if we're done filling the functional access
300 bool done = (bytesValidStart == 0) && (bytesValidEnd == getSize());
301 return done;
302 }
303 } else if (isWrite()) {
304 if (offset >= 0) {
301 memcpy(dest, src, overlap_size);
302
303 // check if we're done filling the functional access
304 bool done = (bytesValidStart == 0) && (bytesValidEnd == getSize());
305 return done;
306 }
307 } else if (isWrite()) {
308 if (offset >= 0) {
305 memcpy(data + offset, getConstPtr(),
309 memcpy(_data + offset, getConstPtr<uint8_t>(),
306 (min(func_end, val_end) - func_start) + 1);
307 } else {
308 // val_start > func_start
310 (min(func_end, val_end) - func_start) + 1);
311 } else {
312 // val_start > func_start
309 memcpy(data, getConstPtr() - offset,
313 memcpy(_data, getConstPtr<uint8_t>() - offset,
310 (min(func_end, val_end) - val_start) + 1);
311 }
312 } else {
313 panic("Don't know how to handle command %s\n", cmdString());
314 }
315
316 // keep going with request by default
317 return false;

--- 93 unchanged lines hidden ---
314 (min(func_end, val_end) - val_start) + 1);
315 }
316 } else {
317 panic("Don't know how to handle command %s\n", cmdString());
318 }
319
320 // keep going with request by default
321 return false;

--- 93 unchanged lines hidden ---