From 9779ba2e37a753df407b976fc4b299d936ea62b8 Mon Sep 17 00:00:00 2001 From: Andreas Hansson Date: Tue, 2 Dec 2014 06:07:36 -0500 Subject: 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. --- src/mem/cache/cache.hh | 2 +- src/mem/cache/cache_impl.hh | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src/mem/cache') diff --git a/src/mem/cache/cache.hh b/src/mem/cache/cache.hh index b9a9a7823..e0bd29752 100644 --- a/src/mem/cache/cache.hh +++ b/src/mem/cache/cache.hh @@ -287,7 +287,7 @@ class Cache : public BaseCache bool pending_downgrade = false); 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); /** diff --git a/src/mem/cache/cache_impl.hh b/src/mem/cache/cache_impl.hh index 66abf6eff..f4099c0ef 100644 --- a/src/mem/cache/cache_impl.hh +++ b/src/mem/cache/cache_impl.hh @@ -357,7 +357,7 @@ Cache::access(PacketPtr pkt, BlkType *&blk, blk->status &= ~BlkWritable; ++fastWrites; } - std::memcpy(blk->data, pkt->getPtr(), blkSize); + std::memcpy(blk->data, pkt->getConstPtr(), blkSize); DPRINTF(Cache, "%s new state is %s\n", __func__, blk->print()); incHitCount(pkt); return true; @@ -1211,7 +1211,7 @@ Cache::recvTimingResp(PacketPtr pkt) completion_time = clockEdge(responseLatency) + pkt->lastWordDelay; if (pkt->isRead() && !is_error) { - target->pkt->setData(pkt->getPtr()); + target->pkt->setData(pkt->getConstPtr()); } } target->pkt->makeTimingResponse(); @@ -1535,7 +1535,7 @@ Cache::handleFill(PacketPtr pkt, BlkType *blk, // if we got new data, copy it in if (pkt->isRead()) { - std::memcpy(blk->data, pkt->getPtr(), blkSize); + std::memcpy(blk->data, pkt->getConstPtr(), blkSize); } blk->whenReady = clockEdge() + responseLatency * clockPeriod() + @@ -1554,7 +1554,7 @@ Cache::handleFill(PacketPtr pkt, BlkType *blk, template void Cache:: -doTimingSupplyResponse(PacketPtr req_pkt, uint8_t *blk_data, +doTimingSupplyResponse(PacketPtr req_pkt, const uint8_t *blk_data, bool already_copied, bool pending_inval) { // sanity check @@ -1810,7 +1810,7 @@ Cache::recvTimingSnoopReq(PacketPtr pkt) // the packet's invalidate flag is set... assert(pkt->isInvalidate()); } - doTimingSupplyResponse(pkt, wb_pkt->getPtr(), + doTimingSupplyResponse(pkt, wb_pkt->getConstPtr(), false, false); if (pkt->isInvalidate()) { @@ -2020,7 +2020,7 @@ Cache::getTimingPacket() pkt = new Packet(tgt_pkt); pkt->allocate(); if (pkt->isWrite()) { - pkt->setData(tgt_pkt->getPtr()); + pkt->setData(tgt_pkt->getConstPtr()); } } } -- cgit v1.2.3