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.
This commit is contained in:
parent
25bfc24999
commit
9779ba2e37
|
@ -68,7 +68,7 @@ using namespace ThePipeline;
|
||||||
|
|
||||||
#if TRACING_ON
|
#if TRACING_ON
|
||||||
static std::string
|
static std::string
|
||||||
printMemData(uint8_t *data, unsigned size)
|
printMemData(const uint8_t *data, unsigned size)
|
||||||
{
|
{
|
||||||
std::stringstream dataStr;
|
std::stringstream dataStr;
|
||||||
for (unsigned pos = 0; pos < size; pos++) {
|
for (unsigned pos = 0; pos < size; pos++) {
|
||||||
|
@ -855,7 +855,7 @@ CacheUnit::doCacheAccess(DynInstPtr inst, uint64_t *write_res,
|
||||||
DPRINTF(InOrderCachePort,
|
DPRINTF(InOrderCachePort,
|
||||||
"[tid:%u]: [sn:%i]: Storing data: %s\n",
|
"[tid:%u]: [sn:%i]: Storing data: %s\n",
|
||||||
tid, inst->seqNum,
|
tid, inst->seqNum,
|
||||||
printMemData(cache_req->dataPkt->getPtr<uint8_t>(),
|
printMemData(cache_req->dataPkt->getConstPtr<uint8_t>(),
|
||||||
cache_req->dataPkt->getSize()));
|
cache_req->dataPkt->getSize()));
|
||||||
|
|
||||||
if (mem_req->isCondSwap()) {
|
if (mem_req->isCondSwap()) {
|
||||||
|
@ -1061,9 +1061,9 @@ CacheUnit::processCacheCompletion(PacketPtr pkt)
|
||||||
DPRINTF(InOrderCachePort,
|
DPRINTF(InOrderCachePort,
|
||||||
"[tid:%u]: [sn:%i]: Bytes loaded were: %s\n",
|
"[tid:%u]: [sn:%i]: Bytes loaded were: %s\n",
|
||||||
tid, inst->seqNum,
|
tid, inst->seqNum,
|
||||||
(split_pkt) ? printMemData(split_pkt->getPtr<uint8_t>(),
|
(split_pkt) ? printMemData(split_pkt->getConstPtr<uint8_t>(),
|
||||||
split_pkt->getSize()) :
|
split_pkt->getSize()) :
|
||||||
printMemData(cache_pkt->getPtr<uint8_t>(),
|
printMemData(cache_pkt->getConstPtr<uint8_t>(),
|
||||||
cache_pkt->getSize()));
|
cache_pkt->getSize()));
|
||||||
} else if(inst->isStore()) {
|
} else if(inst->isStore()) {
|
||||||
assert(cache_pkt->isWrite());
|
assert(cache_pkt->isWrite());
|
||||||
|
@ -1071,9 +1071,9 @@ CacheUnit::processCacheCompletion(PacketPtr pkt)
|
||||||
DPRINTF(InOrderCachePort,
|
DPRINTF(InOrderCachePort,
|
||||||
"[tid:%u]: [sn:%i]: Bytes stored were: %s\n",
|
"[tid:%u]: [sn:%i]: Bytes stored were: %s\n",
|
||||||
tid, inst->seqNum,
|
tid, inst->seqNum,
|
||||||
(split_pkt) ? printMemData(split_pkt->getPtr<uint8_t>(),
|
(split_pkt) ? printMemData(split_pkt->getConstPtr<uint8_t>(),
|
||||||
split_pkt->getSize()) :
|
split_pkt->getSize()) :
|
||||||
printMemData(cache_pkt->getPtr<uint8_t>(),
|
printMemData(cache_pkt->getConstPtr<uint8_t>(),
|
||||||
cache_pkt->getSize()));
|
cache_pkt->getSize()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -503,7 +503,7 @@ FetchUnit::processCacheCompletion(PacketPtr pkt)
|
||||||
|
|
||||||
// Copy Data to pendingFetch queue...
|
// Copy Data to pendingFetch queue...
|
||||||
(*pend_it)->block = new uint8_t[cacheBlkSize];
|
(*pend_it)->block = new uint8_t[cacheBlkSize];
|
||||||
memcpy((*pend_it)->block, cache_pkt->getPtr<uint8_t>(), cacheBlkSize);
|
memcpy((*pend_it)->block, cache_pkt->getConstPtr<uint8_t>(), cacheBlkSize);
|
||||||
(*pend_it)->valid = true;
|
(*pend_it)->valid = true;
|
||||||
|
|
||||||
cache_req->setMemAccPending(false);
|
cache_req->setMemAccPending(false);
|
||||||
|
|
|
@ -355,7 +355,7 @@ Execute::handleMemResponse(MinorDynInstPtr inst,
|
||||||
|
|
||||||
if (is_load && packet->getSize() > 0) {
|
if (is_load && packet->getSize() > 0) {
|
||||||
DPRINTF(MinorMem, "Memory data[0]: 0x%x\n",
|
DPRINTF(MinorMem, "Memory data[0]: 0x%x\n",
|
||||||
static_cast<unsigned int>(packet->getPtr<uint8_t>()[0]));
|
static_cast<unsigned int>(packet->getConstPtr<uint8_t>()[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Complete the memory access instruction */
|
/* Complete the memory access instruction */
|
||||||
|
|
|
@ -560,7 +560,7 @@ LSQ::SplitDataRequest::retireResponse(PacketPtr response)
|
||||||
* by the response fragment */
|
* by the response fragment */
|
||||||
std::memcpy(
|
std::memcpy(
|
||||||
data + (response->req->getVaddr() - request.getVaddr()),
|
data + (response->req->getVaddr() - request.getVaddr()),
|
||||||
response->getPtr<uint8_t>(),
|
response->getConstPtr<uint8_t>(),
|
||||||
response->req->getSize());
|
response->req->getSize());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -388,7 +388,7 @@ DefaultFetch<Impl>::processCacheCompletion(PacketPtr pkt)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(fetchBuffer[tid], pkt->getPtr<uint8_t>(), fetchBufferSize);
|
memcpy(fetchBuffer[tid], pkt->getConstPtr<uint8_t>(), fetchBufferSize);
|
||||||
fetchBufferValid[tid] = true;
|
fetchBufferValid[tid] = true;
|
||||||
|
|
||||||
// Wake up the CPU (if it went to sleep and was waiting on
|
// Wake up the CPU (if it went to sleep and was waiting on
|
||||||
|
|
|
@ -469,7 +469,7 @@ AtomicSimpleCPU::writeMem(uint8_t *data, unsigned size,
|
||||||
|
|
||||||
if (req->isSwap()) {
|
if (req->isSwap()) {
|
||||||
assert(res);
|
assert(res);
|
||||||
memcpy(res, pkt.getPtr<uint8_t>(), fullSize);
|
memcpy(res, pkt.getConstPtr<uint8_t>(), fullSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -173,6 +173,7 @@ MemTest::completeRequest(PacketPtr pkt)
|
||||||
safe_cast<MemTestSenderState *>(pkt->senderState);
|
safe_cast<MemTestSenderState *>(pkt->senderState);
|
||||||
|
|
||||||
uint8_t *data = state->data;
|
uint8_t *data = state->data;
|
||||||
|
// @todo: This should really be a const pointer
|
||||||
uint8_t *pkt_data = pkt->getPtr<uint8_t>();
|
uint8_t *pkt_data = pkt->getPtr<uint8_t>();
|
||||||
|
|
||||||
//Remove the address from the list of outstanding
|
//Remove the address from the list of outstanding
|
||||||
|
|
|
@ -197,7 +197,7 @@ Check::initiateAction()
|
||||||
pkt->dataDynamic(writeData);
|
pkt->dataDynamic(writeData);
|
||||||
|
|
||||||
DPRINTF(RubyTest, "data 0x%x check 0x%x\n",
|
DPRINTF(RubyTest, "data 0x%x check 0x%x\n",
|
||||||
*(pkt->getPtr<uint8_t>()), *writeData);
|
*(pkt->getConstPtr<uint8_t>()), *writeData);
|
||||||
|
|
||||||
// push the subblock onto the sender state. The sequencer will
|
// push the subblock onto the sender state. The sequencer will
|
||||||
// update the subblock on the return
|
// update the subblock on the return
|
||||||
|
|
|
@ -309,7 +309,7 @@ AbstractMemory::checkLockedAddrList(PacketPtr pkt)
|
||||||
A, system()->getMasterName(pkt->req->masterId()), \
|
A, system()->getMasterName(pkt->req->masterId()), \
|
||||||
pkt->getSize(), pkt->getAddr(), \
|
pkt->getSize(), pkt->getAddr(), \
|
||||||
pkt->req->isUncacheable() ? 'U' : 'C'); \
|
pkt->req->isUncacheable() ? 'U' : 'C'); \
|
||||||
DDUMP(MemoryAccess, pkt->getPtr<uint8_t>(), pkt->getSize()); \
|
DDUMP(MemoryAccess, pkt->getConstPtr<uint8_t>(), pkt->getSize()); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
@ -344,7 +344,8 @@ AbstractMemory::access(PacketPtr pkt)
|
||||||
bool overwrite_mem = true;
|
bool overwrite_mem = true;
|
||||||
// keep a copy of our possible write value, and copy what is at the
|
// keep a copy of our possible write value, and copy what is at the
|
||||||
// memory address into the packet
|
// memory address into the packet
|
||||||
std::memcpy(&overwrite_val[0], pkt->getPtr<uint8_t>(), pkt->getSize());
|
std::memcpy(&overwrite_val[0], pkt->getConstPtr<uint8_t>(),
|
||||||
|
pkt->getSize());
|
||||||
std::memcpy(pkt->getPtr<uint8_t>(), hostAddr, pkt->getSize());
|
std::memcpy(pkt->getPtr<uint8_t>(), hostAddr, pkt->getSize());
|
||||||
|
|
||||||
if (pkt->req->isCondSwap()) {
|
if (pkt->req->isCondSwap()) {
|
||||||
|
@ -381,7 +382,7 @@ AbstractMemory::access(PacketPtr pkt)
|
||||||
} else if (pkt->isWrite()) {
|
} else if (pkt->isWrite()) {
|
||||||
if (writeOK(pkt)) {
|
if (writeOK(pkt)) {
|
||||||
if (pmemAddr) {
|
if (pmemAddr) {
|
||||||
memcpy(hostAddr, pkt->getPtr<uint8_t>(), pkt->getSize());
|
memcpy(hostAddr, pkt->getConstPtr<uint8_t>(), pkt->getSize());
|
||||||
DPRINTF(MemoryAccess, "%s wrote %x bytes to address %x\n",
|
DPRINTF(MemoryAccess, "%s wrote %x bytes to address %x\n",
|
||||||
__func__, pkt->getSize(), pkt->getAddr());
|
__func__, pkt->getSize(), pkt->getAddr());
|
||||||
}
|
}
|
||||||
|
@ -416,7 +417,7 @@ AbstractMemory::functionalAccess(PacketPtr pkt)
|
||||||
pkt->makeResponse();
|
pkt->makeResponse();
|
||||||
} else if (pkt->isWrite()) {
|
} else if (pkt->isWrite()) {
|
||||||
if (pmemAddr)
|
if (pmemAddr)
|
||||||
memcpy(hostAddr, pkt->getPtr<uint8_t>(), pkt->getSize());
|
memcpy(hostAddr, pkt->getConstPtr<uint8_t>(), pkt->getSize());
|
||||||
TRACE_PACKET("Write");
|
TRACE_PACKET("Write");
|
||||||
pkt->makeResponse();
|
pkt->makeResponse();
|
||||||
} else if (pkt->isPrint()) {
|
} else if (pkt->isPrint()) {
|
||||||
|
|
2
src/mem/cache/cache.hh
vendored
2
src/mem/cache/cache.hh
vendored
|
@ -287,7 +287,7 @@ class Cache : public BaseCache
|
||||||
bool pending_downgrade = false);
|
bool pending_downgrade = false);
|
||||||
bool satisfyMSHR(MSHR *mshr, PacketPtr pkt, BlkType *blk);
|
bool satisfyMSHR(MSHR *mshr, PacketPtr pkt, BlkType *blk);
|
||||||
|
|
||||||
void doTimingSupplyResponse(PacketPtr req_pkt, uint8_t *blk_data,
|
void doTimingSupplyResponse(PacketPtr req_pkt, const uint8_t *blk_data,
|
||||||
bool already_copied, bool pending_inval);
|
bool already_copied, bool pending_inval);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
12
src/mem/cache/cache_impl.hh
vendored
12
src/mem/cache/cache_impl.hh
vendored
|
@ -357,7 +357,7 @@ Cache<TagStore>::access(PacketPtr pkt, BlkType *&blk,
|
||||||
blk->status &= ~BlkWritable;
|
blk->status &= ~BlkWritable;
|
||||||
++fastWrites;
|
++fastWrites;
|
||||||
}
|
}
|
||||||
std::memcpy(blk->data, pkt->getPtr<uint8_t>(), blkSize);
|
std::memcpy(blk->data, pkt->getConstPtr<uint8_t>(), blkSize);
|
||||||
DPRINTF(Cache, "%s new state is %s\n", __func__, blk->print());
|
DPRINTF(Cache, "%s new state is %s\n", __func__, blk->print());
|
||||||
incHitCount(pkt);
|
incHitCount(pkt);
|
||||||
return true;
|
return true;
|
||||||
|
@ -1211,7 +1211,7 @@ Cache<TagStore>::recvTimingResp(PacketPtr pkt)
|
||||||
completion_time = clockEdge(responseLatency) +
|
completion_time = clockEdge(responseLatency) +
|
||||||
pkt->lastWordDelay;
|
pkt->lastWordDelay;
|
||||||
if (pkt->isRead() && !is_error) {
|
if (pkt->isRead() && !is_error) {
|
||||||
target->pkt->setData(pkt->getPtr<uint8_t>());
|
target->pkt->setData(pkt->getConstPtr<uint8_t>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
target->pkt->makeTimingResponse();
|
target->pkt->makeTimingResponse();
|
||||||
|
@ -1535,7 +1535,7 @@ Cache<TagStore>::handleFill(PacketPtr pkt, BlkType *blk,
|
||||||
|
|
||||||
// if we got new data, copy it in
|
// if we got new data, copy it in
|
||||||
if (pkt->isRead()) {
|
if (pkt->isRead()) {
|
||||||
std::memcpy(blk->data, pkt->getPtr<uint8_t>(), blkSize);
|
std::memcpy(blk->data, pkt->getConstPtr<uint8_t>(), blkSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
blk->whenReady = clockEdge() + responseLatency * clockPeriod() +
|
blk->whenReady = clockEdge() + responseLatency * clockPeriod() +
|
||||||
|
@ -1554,7 +1554,7 @@ Cache<TagStore>::handleFill(PacketPtr pkt, BlkType *blk,
|
||||||
template<class TagStore>
|
template<class TagStore>
|
||||||
void
|
void
|
||||||
Cache<TagStore>::
|
Cache<TagStore>::
|
||||||
doTimingSupplyResponse(PacketPtr req_pkt, uint8_t *blk_data,
|
doTimingSupplyResponse(PacketPtr req_pkt, const uint8_t *blk_data,
|
||||||
bool already_copied, bool pending_inval)
|
bool already_copied, bool pending_inval)
|
||||||
{
|
{
|
||||||
// sanity check
|
// sanity check
|
||||||
|
@ -1810,7 +1810,7 @@ Cache<TagStore>::recvTimingSnoopReq(PacketPtr pkt)
|
||||||
// the packet's invalidate flag is set...
|
// the packet's invalidate flag is set...
|
||||||
assert(pkt->isInvalidate());
|
assert(pkt->isInvalidate());
|
||||||
}
|
}
|
||||||
doTimingSupplyResponse(pkt, wb_pkt->getPtr<uint8_t>(),
|
doTimingSupplyResponse(pkt, wb_pkt->getConstPtr<uint8_t>(),
|
||||||
false, false);
|
false, false);
|
||||||
|
|
||||||
if (pkt->isInvalidate()) {
|
if (pkt->isInvalidate()) {
|
||||||
|
@ -2020,7 +2020,7 @@ Cache<TagStore>::getTimingPacket()
|
||||||
pkt = new Packet(tgt_pkt);
|
pkt = new Packet(tgt_pkt);
|
||||||
pkt->allocate();
|
pkt->allocate();
|
||||||
if (pkt->isWrite()) {
|
if (pkt->isWrite()) {
|
||||||
pkt->setData(tgt_pkt->getPtr<uint8_t>());
|
pkt->setData(tgt_pkt->getConstPtr<uint8_t>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,7 +108,7 @@ StubSlavePort::recvAtomic(PacketPtr packet)
|
||||||
|
|
||||||
DPRINTF(ExternalPort, "StubSlavePort: recvAtomic a: 0x%x size: %d"
|
DPRINTF(ExternalPort, "StubSlavePort: recvAtomic a: 0x%x size: %d"
|
||||||
" data: ...\n", packet->getAddr(), size);
|
" data: ...\n", packet->getAddr(), size);
|
||||||
DDUMP(ExternalPort, packet->getPtr<uint8_t>(), size);
|
DDUMP(ExternalPort, packet->getConstPtr<uint8_t>(), size);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -303,11 +303,11 @@ Packet::checkFunctional(Printable *obj, Addr addr, bool is_secure, int size,
|
||||||
}
|
}
|
||||||
} else if (isWrite()) {
|
} else if (isWrite()) {
|
||||||
if (offset >= 0) {
|
if (offset >= 0) {
|
||||||
memcpy(data + offset, getPtr<uint8_t>(),
|
memcpy(data + offset, getConstPtr<uint8_t>(),
|
||||||
(min(func_end, val_end) - func_start) + 1);
|
(min(func_end, val_end) - func_start) + 1);
|
||||||
} else {
|
} else {
|
||||||
// val_start > func_start
|
// val_start > func_start
|
||||||
memcpy(data, getPtr<uint8_t>() - offset,
|
memcpy(data, getConstPtr<uint8_t>() - offset,
|
||||||
(min(func_end, val_end) - val_start) + 1);
|
(min(func_end, val_end) - val_start) + 1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -186,7 +186,6 @@ class MemCmd
|
||||||
bool needsResponse() const { return testCmdAttrib(NeedsResponse); }
|
bool needsResponse() const { return testCmdAttrib(NeedsResponse); }
|
||||||
bool isInvalidate() const { return testCmdAttrib(IsInvalidate); }
|
bool isInvalidate() const { return testCmdAttrib(IsInvalidate); }
|
||||||
bool hasData() const { return testCmdAttrib(HasData); }
|
bool hasData() const { return testCmdAttrib(HasData); }
|
||||||
bool isReadWrite() const { return isRead() && isWrite(); }
|
|
||||||
bool isLLSC() const { return testCmdAttrib(IsLlsc); }
|
bool isLLSC() const { return testCmdAttrib(IsLlsc); }
|
||||||
bool isSWPrefetch() const { return testCmdAttrib(IsSWPrefetch); }
|
bool isSWPrefetch() const { return testCmdAttrib(IsSWPrefetch); }
|
||||||
bool isHWPrefetch() const { return testCmdAttrib(IsHWPrefetch); }
|
bool isHWPrefetch() const { return testCmdAttrib(IsHWPrefetch); }
|
||||||
|
@ -501,7 +500,6 @@ class Packet : public Printable
|
||||||
bool needsResponse() const { return cmd.needsResponse(); }
|
bool needsResponse() const { return cmd.needsResponse(); }
|
||||||
bool isInvalidate() const { return cmd.isInvalidate(); }
|
bool isInvalidate() const { return cmd.isInvalidate(); }
|
||||||
bool hasData() const { return cmd.hasData(); }
|
bool hasData() const { return cmd.hasData(); }
|
||||||
bool isReadWrite() const { return cmd.isReadWrite(); }
|
|
||||||
bool isLLSC() const { return cmd.isLLSC(); }
|
bool isLLSC() const { return cmd.isLLSC(); }
|
||||||
bool isError() const { return cmd.isError(); }
|
bool isError() const { return cmd.isError(); }
|
||||||
bool isPrint() const { return cmd.isPrint(); }
|
bool isPrint() const { return cmd.isPrint(); }
|
||||||
|
@ -852,11 +850,19 @@ class Packet : public Printable
|
||||||
return (T*)data;
|
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.
|
* return the value of what is pointed to in the packet.
|
||||||
*/
|
*/
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T get();
|
T get() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set the value in the data pointer to v.
|
* 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.
|
* Copy data into the packet from the provided pointer.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
setData(uint8_t *p)
|
setData(const uint8_t *p)
|
||||||
{
|
{
|
||||||
if (p != getPtr<uint8_t>())
|
if (p != getPtr<uint8_t>())
|
||||||
std::memcpy(getPtr<uint8_t>(), p, getSize());
|
std::memcpy(getPtr<uint8_t>(), p, getSize());
|
||||||
|
@ -879,7 +885,7 @@ class Packet : public Printable
|
||||||
* which is aligned to the given block size.
|
* which is aligned to the given block size.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
setDataFromBlock(uint8_t *blk_data, int blkSize)
|
setDataFromBlock(const uint8_t *blk_data, int blkSize)
|
||||||
{
|
{
|
||||||
setData(blk_data + getOffset(blkSize));
|
setData(blk_data + getOffset(blkSize));
|
||||||
}
|
}
|
||||||
|
@ -889,16 +895,16 @@ class Packet : public Printable
|
||||||
* is aligned to the given block size.
|
* is aligned to the given block size.
|
||||||
*/
|
*/
|
||||||
void
|
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.
|
* Copy data from the packet to the memory at the provided pointer.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
writeDataToBlock(uint8_t *blk_data, int blkSize)
|
writeDataToBlock(uint8_t *blk_data, int blkSize) const
|
||||||
{
|
{
|
||||||
writeData(blk_data + getOffset(blkSize));
|
writeData(blk_data + getOffset(blkSize));
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
/** return the value of what is pointed to in the packet. */
|
/** return the value of what is pointed to in the packet. */
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline T
|
inline T
|
||||||
Packet::get()
|
Packet::get() const
|
||||||
{
|
{
|
||||||
assert(flags.isSet(STATIC_DATA|DYNAMIC_DATA));
|
assert(flags.isSet(STATIC_DATA|DYNAMIC_DATA));
|
||||||
assert(sizeof(T) <= size);
|
assert(sizeof(T) <= size);
|
||||||
|
|
|
@ -78,7 +78,7 @@ DataBlock::getData(int offset, int len) const
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DataBlock::setData(uint8_t *data, int offset, int len)
|
DataBlock::setData(const uint8_t *data, int offset, int len)
|
||||||
{
|
{
|
||||||
assert(offset + len <= RubySystem::getBlockSizeBytes());
|
assert(offset + len <= RubySystem::getBlockSizeBytes());
|
||||||
memcpy(&m_data[offset], data, len);
|
memcpy(&m_data[offset], data, len);
|
||||||
|
|
|
@ -59,7 +59,7 @@ class DataBlock
|
||||||
uint8_t getByte(int whichByte) const;
|
uint8_t getByte(int whichByte) const;
|
||||||
const uint8_t *getData(int offset, int len) const;
|
const uint8_t *getData(int offset, int len) const;
|
||||||
void setByte(int whichByte, uint8_t data);
|
void setByte(int whichByte, uint8_t data);
|
||||||
void setData(uint8_t *data, int offset, int len);
|
void setData(const uint8_t *data, int offset, int len);
|
||||||
void copyPartial(const DataBlock & dblk, int offset, int len);
|
void copyPartial(const DataBlock & dblk, int offset, int len);
|
||||||
bool equal(const DataBlock& obj) const;
|
bool equal(const DataBlock& obj) const;
|
||||||
void print(std::ostream& out) const;
|
void print(std::ostream& out) const;
|
||||||
|
|
|
@ -72,7 +72,7 @@ RubyRequest::functionalWrite(Packet *pkt)
|
||||||
Addr mBase = m_PhysicalAddress.getAddress();
|
Addr mBase = m_PhysicalAddress.getAddress();
|
||||||
Addr mTail = mBase + m_Size;
|
Addr mTail = mBase + m_Size;
|
||||||
|
|
||||||
uint8_t * pktData = pkt->getPtr<uint8_t>();
|
const uint8_t * pktData = pkt->getConstPtr<uint8_t>();
|
||||||
|
|
||||||
Addr cBase = std::max(wBase, mBase);
|
Addr cBase = std::max(wBase, mBase);
|
||||||
Addr cTail = std::min(wTail, mTail);
|
Addr cTail = std::min(wTail, mTail);
|
||||||
|
|
|
@ -135,7 +135,7 @@ testAndWrite(Address addr, DataBlock& blk, Packet *pkt)
|
||||||
lineAddr.makeLineAddress();
|
lineAddr.makeLineAddress();
|
||||||
|
|
||||||
if (pktLineAddr == lineAddr) {
|
if (pktLineAddr == lineAddr) {
|
||||||
uint8_t *data = pkt->getPtr<uint8_t>();
|
const uint8_t *data = pkt->getConstPtr<uint8_t>();
|
||||||
unsigned int size_in_bytes = pkt->getSize();
|
unsigned int size_in_bytes = pkt->getSize();
|
||||||
unsigned startByte = pkt->getAddr() - lineAddr.getAddress();
|
unsigned startByte = pkt->getAddr() - lineAddr.getAddress();
|
||||||
|
|
||||||
|
|
|
@ -526,7 +526,7 @@ Sequencer::hitCallback(SequencerRequest* srequest, DataBlock& data,
|
||||||
|
|
||||||
// update the data unless it is a non-data-carrying flush
|
// update the data unless it is a non-data-carrying flush
|
||||||
if (g_system_ptr->m_warmup_enabled) {
|
if (g_system_ptr->m_warmup_enabled) {
|
||||||
data.setData(pkt->getPtr<uint8_t>(),
|
data.setData(pkt->getConstPtr<uint8_t>(),
|
||||||
request_address.getOffset(), pkt->getSize());
|
request_address.getOffset(), pkt->getSize());
|
||||||
} else if (!pkt->isFlush()) {
|
} else if (!pkt->isFlush()) {
|
||||||
if ((type == RubyRequestType_LD) ||
|
if ((type == RubyRequestType_LD) ||
|
||||||
|
@ -538,7 +538,7 @@ Sequencer::hitCallback(SequencerRequest* srequest, DataBlock& data,
|
||||||
data.getData(request_address.getOffset(), pkt->getSize()),
|
data.getData(request_address.getOffset(), pkt->getSize()),
|
||||||
pkt->getSize());
|
pkt->getSize());
|
||||||
} else {
|
} else {
|
||||||
data.setData(pkt->getPtr<uint8_t>(),
|
data.setData(pkt->getConstPtr<uint8_t>(),
|
||||||
request_address.getOffset(), pkt->getSize());
|
request_address.getOffset(), pkt->getSize());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue