summaryrefslogtreecommitdiff
path: root/src/mem/packet.cc
diff options
context:
space:
mode:
authorAndreas Hansson <andreas.hansson@arm.com>2014-12-02 06:07:52 -0500
committerAndreas Hansson <andreas.hansson@arm.com>2014-12-02 06:07:52 -0500
commitf012166bb600ebaeefa48e74f7dd7fdfc9742506 (patch)
treed7be12d21ec6629af877b03eeec224c699ac2e29 /src/mem/packet.cc
parenta2ee51f631199f629f36baf2f59161e25be84bdc (diff)
downloadgem5-f012166bb600ebaeefa48e74f7dd7fdfc9742506.tar.xz
mem: Cleanup Packet::checkFunctional and hasData usage
This patch cleans up the use of hasData and checkFunctional in the packet. The hasData function is unfortunately suggesting that it checks if the packet has a valid data pointer, when it does in fact only check if the specific packet type is specified to have a data payload. The confusion led to a bug in checkFunctional. The latter function is also tidied up to avoid name overloading.
Diffstat (limited to 'src/mem/packet.cc')
-rw-r--r--src/mem/packet.cc20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/mem/packet.cc b/src/mem/packet.cc
index 758770824..09b612ad0 100644
--- a/src/mem/packet.cc
+++ b/src/mem/packet.cc
@@ -174,7 +174,7 @@ MemCmd::commandInfo[] =
bool
Packet::checkFunctional(Printable *obj, Addr addr, bool is_secure, int size,
- uint8_t *data)
+ uint8_t *_data)
{
Addr func_start = getAddr();
Addr func_end = getAddr() + getSize() - 1;
@@ -189,12 +189,14 @@ Packet::checkFunctional(Printable *obj, Addr addr, bool is_secure, int size,
// check print first since it doesn't require data
if (isPrint()) {
+ assert(!_data);
safe_cast<PrintReqState*>(senderState)->printObj(obj);
return false;
}
- // if there's no data, there's no need to look further
- if (!data) {
+ // we allow the caller to pass NULL to signify the other packet
+ // has no data
+ if (!_data) {
return false;
}
@@ -204,7 +206,9 @@ Packet::checkFunctional(Printable *obj, Addr addr, bool is_secure, int size,
if (isRead()) {
if (func_start >= val_start && func_end <= val_end) {
- memcpy(getPtr<uint8_t>(), data + offset, getSize());
+ memcpy(getPtr<uint8_t>(), _data + offset, getSize());
+ // complete overlap, and as the current packet is a read
+ // we are done
return true;
} else {
// Offsets and sizes to copy in case of partial overlap
@@ -271,7 +275,7 @@ Packet::checkFunctional(Printable *obj, Addr addr, bool is_secure, int size,
// copy the first half
uint8_t *dest = getPtr<uint8_t>() + func_offset;
- uint8_t *src = data + val_offset;
+ uint8_t *src = _data + val_offset;
memcpy(dest, src, (bytesValidStart - func_offset));
// re-calc the offsets and indices to do the copy
@@ -293,7 +297,7 @@ Packet::checkFunctional(Printable *obj, Addr addr, bool is_secure, int size,
// copy partial data into the packet's data array
uint8_t *dest = getPtr<uint8_t>() + func_offset;
- uint8_t *src = data + val_offset;
+ uint8_t *src = _data + val_offset;
memcpy(dest, src, overlap_size);
// check if we're done filling the functional access
@@ -302,11 +306,11 @@ Packet::checkFunctional(Printable *obj, Addr addr, bool is_secure, int size,
}
} else if (isWrite()) {
if (offset >= 0) {
- memcpy(data + offset, getConstPtr<uint8_t>(),
+ memcpy(_data + offset, getConstPtr<uint8_t>(),
(min(func_end, val_end) - func_start) + 1);
} else {
// val_start > func_start
- memcpy(data, getConstPtr<uint8_t>() - offset,
+ memcpy(_data, getConstPtr<uint8_t>() - offset,
(min(func_end, val_end) - val_start) + 1);
}
} else {