2c2
< * Copyright (c) 2011-2014 ARM Limited
---
> * Copyright (c) 2011-2015 ARM Limited
209a210,211
> if (bytesValid.empty())
> bytesValid.resize(getSize(), true);
220a223,224
> // the one we are checking against starts before and
> // ends before or the same
224a229,230
> // the one we are checking against starts after or the
> // same, and ends after
228a235,237
> // the one we are checking against is completely
> // subsumed in the current packet, possibly starting
> // and ending at the same address
231a241,246
> } else if (val_start < func_start && val_end > func_end) {
> // the current packet is completely subsumed in the
> // one we are checking against
> val_offset = func_start - val_start;
> func_offset = 0;
> overlap_size = func_end - func_start;
233c248,250
< panic("BUG: Missed a case for a partial functional request");
---
> panic("Missed a case for checkFunctional with "
> " %s 0x%x size %d, against 0x%x size %d\n",
> cmdString(), getAddr(), getSize(), addr, size);
236,246c253,256
< // Figure out how much of the partial overlap should be copied
< // into the packet and not overwrite previously found bytes.
< if (bytesValidStart == 0 && bytesValidEnd == 0) {
< // No bytes have been copied yet, just set indices
< // to found range
< bytesValidStart = func_offset;
< bytesValidEnd = func_offset + overlap_size;
< } else {
< // Some bytes have already been copied. Use bytesValid
< // indices and offset values to figure out how much data
< // to copy and where to copy it to.
---
> // copy partial data into the packet's data array
> uint8_t *dest = getPtr<uint8_t>() + func_offset;
> uint8_t *src = _data + val_offset;
> memcpy(dest, src, overlap_size);
248,252c258,261
< // Indice overlap conditions to check
< int a = func_offset - bytesValidStart;
< int b = (func_offset + overlap_size) - bytesValidEnd;
< int c = func_offset - bytesValidEnd;
< int d = (func_offset + overlap_size) - bytesValidStart;
---
> // initialise the tracking of valid bytes if we have not
> // used it already
> if (bytesValid.empty())
> bytesValid.resize(getSize(), false);
254,274c263,264
< if (a >= 0 && b <= 0) {
< // bytes already in pkt data array are superset of
< // found bytes, will not copy any bytes
< overlap_size = 0;
< } else if (a < 0 && d >= 0 && b <= 0) {
< // found bytes will move bytesValidStart towards 0
< overlap_size = bytesValidStart - func_offset;
< bytesValidStart = func_offset;
< } else if (b > 0 && c <= 0 && a >= 0) {
< // found bytes will move bytesValidEnd
< // towards end of pkt data array
< overlap_size =
< (func_offset + overlap_size) - bytesValidEnd;
< val_offset += bytesValidEnd - func_offset;
< func_offset = bytesValidEnd;
< bytesValidEnd += overlap_size;
< } else if (a < 0 && b > 0) {
< // Found bytes are superset of copied range. Will move
< // bytesValidStart towards 0 and bytesValidEnd towards
< // end of pkt data array. Need to break copy into two
< // pieces so as to not overwrite previously found data.
---
> // track if we are done filling the functional access
> bool all_bytes_valid = true;
276,279c266
< // copy the first half
< uint8_t *dest = getPtr<uint8_t>() + func_offset;
< uint8_t *src = _data + val_offset;
< memcpy(dest, src, (bytesValidStart - func_offset));
---
> int i = 0;
281,296c268,270
< // re-calc the offsets and indices to do the copy
< // required for the second half
< val_offset += (bytesValidEnd - func_offset);
< bytesValidStart = func_offset;
< overlap_size =
< (func_offset + overlap_size) - bytesValidEnd;
< func_offset = bytesValidEnd;
< bytesValidEnd += overlap_size;
< } else if ((c > 0 && b > 0)
< || (a < 0 && d < 0)) {
< // region to be copied is discontiguous! Not supported.
< panic("BUG: Discontiguous bytes found"
< "for functional copying!");
< }
< }
< assert(bytesValidEnd <= getSize());
---
> // check up to func_offset
> for (; all_bytes_valid && i < func_offset; ++i)
> all_bytes_valid &= bytesValid[i];
298,301c272,274
< // copy partial data into the packet's data array
< uint8_t *dest = getPtr<uint8_t>() + func_offset;
< uint8_t *src = _data + val_offset;
< memcpy(dest, src, overlap_size);
---
> // update the valid bytes
> for (i = func_offset; i < func_offset + overlap_size; ++i)
> bytesValid[i] = true;
303,305c276,280
< // check if we're done filling the functional access
< bool done = (bytesValidStart == 0) && (bytesValidEnd == getSize());
< return done;
---
> // check the bit after the update we just made
> for (; all_bytes_valid && i < getSize(); ++i)
> all_bytes_valid &= bytesValid[i];
>
> return all_bytes_valid;