summaryrefslogtreecommitdiff
path: root/src/mem/packet.hh
diff options
context:
space:
mode:
authorAndreas Hansson <andreas.hansson@arm.com>2014-12-02 06:07:36 -0500
committerAndreas Hansson <andreas.hansson@arm.com>2014-12-02 06:07:36 -0500
commit9779ba2e37a753df407b976fc4b299d936ea62b8 (patch)
treee25e0cf44834427975767e88bf3dcfc6359ed4a8 /src/mem/packet.hh
parent25bfc249998b26403d50587eb66e6ee5e6de5b58 (diff)
downloadgem5-9779ba2e37a753df407b976fc4b299d936ea62b8.tar.xz
mem: Add const getters for write packet data
This patch takes a first step in tightening up how we use the data pointer in write packets. A const getter is added for the pointer itself (getConstPtr), and a number of member functions are also made const accordingly. In a range of places throughout the memory system the new member is used. The patch also removes the unused isReadWrite function.
Diffstat (limited to 'src/mem/packet.hh')
-rw-r--r--src/mem/packet.hh22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/mem/packet.hh b/src/mem/packet.hh
index 8d84a7ccb..fea9dbaae 100644
--- a/src/mem/packet.hh
+++ b/src/mem/packet.hh
@@ -186,7 +186,6 @@ class MemCmd
bool needsResponse() const { return testCmdAttrib(NeedsResponse); }
bool isInvalidate() const { return testCmdAttrib(IsInvalidate); }
bool hasData() const { return testCmdAttrib(HasData); }
- bool isReadWrite() const { return isRead() && isWrite(); }
bool isLLSC() const { return testCmdAttrib(IsLlsc); }
bool isSWPrefetch() const { return testCmdAttrib(IsSWPrefetch); }
bool isHWPrefetch() const { return testCmdAttrib(IsHWPrefetch); }
@@ -501,7 +500,6 @@ class Packet : public Printable
bool needsResponse() const { return cmd.needsResponse(); }
bool isInvalidate() const { return cmd.isInvalidate(); }
bool hasData() const { return cmd.hasData(); }
- bool isReadWrite() const { return cmd.isReadWrite(); }
bool isLLSC() const { return cmd.isLLSC(); }
bool isError() const { return cmd.isError(); }
bool isPrint() const { return cmd.isPrint(); }
@@ -852,11 +850,19 @@ class Packet : public Printable
return (T*)data;
}
+ template <typename T>
+ const T*
+ getConstPtr() const
+ {
+ assert(flags.isSet(STATIC_DATA|DYNAMIC_DATA));
+ return (const T*)data;
+ }
+
/**
* return the value of what is pointed to in the packet.
*/
template <typename T>
- T get();
+ T get() const;
/**
* set the value in the data pointer to v.
@@ -868,7 +874,7 @@ class Packet : public Printable
* Copy data into the packet from the provided pointer.
*/
void
- setData(uint8_t *p)
+ setData(const uint8_t *p)
{
if (p != getPtr<uint8_t>())
std::memcpy(getPtr<uint8_t>(), p, getSize());
@@ -879,7 +885,7 @@ class Packet : public Printable
* which is aligned to the given block size.
*/
void
- setDataFromBlock(uint8_t *blk_data, int blkSize)
+ setDataFromBlock(const uint8_t *blk_data, int blkSize)
{
setData(blk_data + getOffset(blkSize));
}
@@ -889,16 +895,16 @@ class Packet : public Printable
* is aligned to the given block size.
*/
void
- writeData(uint8_t *p)
+ writeData(uint8_t *p) const
{
- std::memcpy(p, getPtr<uint8_t>(), getSize());
+ std::memcpy(p, getConstPtr<uint8_t>(), getSize());
}
/**
* Copy data from the packet to the memory at the provided pointer.
*/
void
- writeDataToBlock(uint8_t *blk_data, int blkSize)
+ writeDataToBlock(uint8_t *blk_data, int blkSize) const
{
writeData(blk_data + getOffset(blkSize));
}