Another thread number removed
[gem5.git] / src / mem / packet.hh
index 1325dfc5b8e65279afdfa34b52c0f3eb540e4b9e..be9bf5f57e8c7b641dfbfdd2e8d927d116e69598 100644 (file)
 #define __MEM_PACKET_HH__
 
 #include "mem/request.hh"
-#include "arch/isa_traits.hh"
+#include "sim/host.hh"
 #include "sim/root.hh"
 #include <list>
+#include <cassert>
 
 struct Packet;
 typedef Packet* PacketPtr;
@@ -55,6 +56,7 @@ typedef std::list<PacketPtr> PacketList;
 #define CACHE_LINE_FILL 1 << 3
 #define COMPRESSED 1 << 4
 #define NO_ALLOCATE 1 << 5
+#define SNOOP_COMMIT 1 << 6
 
 //For statistics we need max number of commands, hard code it at
 //20 for now.  @todo fix later
@@ -216,13 +218,13 @@ class Packet
     bool isRequest()    { return (cmd & IsRequest)  != 0; }
     bool isResponse()   { return (cmd & IsResponse) != 0; }
     bool needsResponse() { return (cmd & NeedsResponse) != 0; }
-    bool isInvalidate()  { return (cmd * IsInvalidate) != 0; }
+    bool isInvalidate()  { return (cmd & IsInvalidate) != 0; }
 
     bool isCacheFill() { return (flags & CACHE_LINE_FILL) != 0; }
     bool isNoAllocate() { return (flags & NO_ALLOCATE) != 0; }
     bool isCompressed() { return (flags & COMPRESSED) != 0; }
 
-    bool nic_pkt() { assert("Unimplemented\n" && 0); }
+    bool nic_pkt() { assert("Unimplemented\n" && 0); return false; }
 
     /** Possible results of a packet's request. */
     enum Result
@@ -247,7 +249,7 @@ class Packet
 
     Addr getAddr() const { assert(addrSizeValid); return addr; }
     int getSize() const { assert(addrSizeValid); return size; }
-    Addr getOffset(int blkSize) const { return req->getPaddr() & (Addr)(blkSize - 1); }
+    Addr getOffset(int blkSize) const { return addr & (Addr)(blkSize - 1); }
 
     void addrOverride(Addr newAddr) { assert(addrSizeValid); addr = newAddr; }
     void cmdOverride(Command newCmd) { cmd = newCmd; }
@@ -265,6 +267,7 @@ class Packet
            result(Unknown)
     {
         flags = 0;
+        time = curTick;
     }
 
     /** Alternate constructor if you are trying to create a packet with
@@ -279,6 +282,7 @@ class Packet
            result(Unknown)
     {
         flags = 0;
+        time = curTick;
     }
 
     /** Destructor. */
@@ -294,6 +298,7 @@ class Packet
         assert(req->validPaddr);
         addr = req->paddr;
         size = req->size;
+        time = req->time;
         addrSizeValid = true;
         result = Unknown;
         if (dynamicData) {
@@ -307,7 +312,7 @@ class Packet
      *   for returning as a response to that request.  Used for timing
      *   accesses only.  For atomic and functional accesses, the
      *   request packet is always implicitly passed back *without*
-     *   modifying the command or destination fields, so this function
+     *   modifying the destination fields, so this function
      *   should not be called. */
     void makeTimingResponse() {
         assert(needsResponse());
@@ -320,6 +325,18 @@ class Packet
         srcValid = false;
     }
 
+    /** Take a request packet and modify it in place to be suitable
+     *   for returning as a response to that request.
+     */
+    void makeAtomicResponse() {
+        assert(needsResponse());
+        assert(isRequest());
+        int icmd = (int)cmd;
+        icmd &= ~(IsRequest);
+        icmd |= IsResponse;
+        cmd = (Command)icmd;
+    }
+
     /** Take a request packet that has been returned as NACKED and modify it so
      * that it can be sent out again. Only packets that need a response can be
      * NACKED, so verify that that is true. */