summaryrefslogtreecommitdiff
path: root/src/mem
diff options
context:
space:
mode:
authorCurtis Dunham <Curtis.Dunham@arm.com>2014-05-13 12:20:48 -0500
committerCurtis Dunham <Curtis.Dunham@arm.com>2014-05-13 12:20:48 -0500
commite3b19cb294c98466a431950888045c6b5d24b675 (patch)
tree781bcf5ea9fdce45a5747a4d5ef74485ee5e0727 /src/mem
parentafbae1ec95e94b6da441a0269dbd9359a7069e3d (diff)
downloadgem5-e3b19cb294c98466a431950888045c6b5d24b675.tar.xz
mem: Refactor assignment of Packet types
Put the packet type swizzling (that is currently done in a lot of places) into a refineCommand() member function.
Diffstat (limited to 'src/mem')
-rw-r--r--src/mem/packet.hh41
1 files changed, 40 insertions, 1 deletions
diff --git a/src/mem/packet.hh b/src/mem/packet.hh
index 7b9e05945..0c6abe909 100644
--- a/src/mem/packet.hh
+++ b/src/mem/packet.hh
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012-2013 ARM Limited
+ * Copyright (c) 2012-2014 ARM Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
@@ -666,7 +666,46 @@ class Packet : public Printable
flags.set(pkt->flags & (VALID_ADDR|VALID_SIZE));
flags.set(pkt->flags & STATIC_DATA);
+ }
+
+ /**
+ * Change the packet type based on request type.
+ */
+ void
+ refineCommand()
+ {
+ if (cmd == MemCmd::ReadReq) {
+ if (req->isLLSC()) {
+ cmd = MemCmd::LoadLockedReq;
+ }
+ } else if (cmd == MemCmd::WriteReq) {
+ if (req->isLLSC()) {
+ cmd = MemCmd::StoreCondReq;
+ } else if (req->isSwap()) {
+ cmd = MemCmd::SwapReq;
+ }
+ }
+ }
+
+ /**
+ * Constructor-like methods that return Packets based on Request objects.
+ * Will call refineCommand() to fine-tune the Packet type if it's not a
+ * vanilla read or write.
+ */
+ static PacketPtr
+ createRead(Request *req)
+ {
+ PacketPtr pkt = new Packet(req, MemCmd::ReadReq);
+ pkt->refineCommand();
+ return pkt;
+ }
+ static PacketPtr
+ createWrite(Request *req)
+ {
+ PacketPtr pkt = new Packet(req, MemCmd::WriteReq);
+ pkt->refineCommand();
+ return pkt;
}
/**