summaryrefslogtreecommitdiff
path: root/src/mem/cache/cache_impl.hh
diff options
context:
space:
mode:
authorAndreas Hansson <andreas.hansson@arm.com>2014-12-02 06:07:50 -0500
committerAndreas Hansson <andreas.hansson@arm.com>2014-12-02 06:07:50 -0500
commita2ee51f631199f629f36baf2f59161e25be84bdc (patch)
treeaacd7da2e8084da4990d235bfc959271511d402f /src/mem/cache/cache_impl.hh
parentfa60d5cf272c86cc6819e89984eb94b05dcfb605 (diff)
downloadgem5-a2ee51f631199f629f36baf2f59161e25be84bdc.tar.xz
mem: Make the requests carried by packets const
This adds a basic level of sanity checking to the packet by ensuring that a request is not modified once the packet is created. The only issue that had to be worked around is the relaying of software-prefetches in the cache. The specific situation is now solved by first copying the request, and then creating a new packet accordingly.
Diffstat (limited to 'src/mem/cache/cache_impl.hh')
-rw-r--r--src/mem/cache/cache_impl.hh25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/mem/cache/cache_impl.hh b/src/mem/cache/cache_impl.hh
index 535dc81c2..8e8079d58 100644
--- a/src/mem/cache/cache_impl.hh
+++ b/src/mem/cache/cache_impl.hh
@@ -611,18 +611,21 @@ Cache<TagStore>::recvTimingReq(PacketPtr pkt)
assert(pkt->req->hasPaddr());
// There's no reason to add a prefetch as an additional target
- // to an existing MSHR. If an outstanding request is already
+ // to an existing MSHR. If an outstanding request is already
// in progress, there is nothing for the prefetch to do.
// If this is the case, we don't even create a request at all.
- PacketPtr pf = mshr ? NULL : new Packet(pkt);
-
- if (pf) {
- pf->req = new Request(pkt->req->getPaddr(),
- pkt->req->getSize(),
- pkt->req->getFlags(),
- pkt->req->masterId());
- // The core will clean up prior senderState; we need our own.
- pf->senderState = NULL;
+ PacketPtr pf = nullptr;
+
+ if (!mshr) {
+ // copy the request and create a new SoftPFReq packet
+ RequestPtr req = new Request(pkt->req->getPaddr(),
+ pkt->req->getSize(),
+ pkt->req->getFlags(),
+ pkt->req->masterId());
+ pf = new Packet(req, pkt->cmd);
+ pf->allocate();
+ assert(pf->getAddr() == pkt->getAddr());
+ assert(pf->getSize() == pkt->getSize());
}
pkt->makeTimingResponse();
@@ -632,6 +635,8 @@ Cache<TagStore>::recvTimingReq(PacketPtr pkt)
std::memset(pkt->getPtr<uint8_t>(), 0xFF, pkt->getSize());
cpuSidePort->schedTimingResp(pkt, clockEdge(lat));
+ // If an outstanding request is in progress (we found an
+ // MSHR) this is set to null
pkt = pf;
}