More Changes, working towards cache.cc compiling. Headers cleaned up.
[gem5.git] / src / mem / packet.hh
index d5a10d29aacf2b22043719688fd05ce168c3d8ba..3d37686768b427ca7c58b2c9bf5b253c30c6ba61 100644 (file)
 #include "mem/request.hh"
 #include "arch/isa_traits.hh"
 #include "sim/root.hh"
+#include <list>
 
 struct Packet;
 typedef Packet* PacketPtr;
 typedef uint8_t* PacketDataPtr;
+typedef std::list<PacketPtr> PacketList;
+
+//Coherence Flags
+#define NACKED_LINE 1 << 0
+#define SATISFIED 1 << 1
+#define SHARED_LINE 1 << 2
+
+//For statistics we need max number of commands, hard code it at
+//20 for now.  @todo fix later
+#define NUM_MEM_CMDS 1 << 9
 
 /**
  * A Packet is used to encapsulate a transfer between two objects in
@@ -102,6 +113,9 @@ class Packet
 
   public:
 
+    /** Used to calculate latencies for each packet.*/
+    Tick time;
+
     /** The special destination address indicating that the packet
      *   should be routed based on its address. */
     static const short Broadcast = -1;
@@ -149,6 +163,8 @@ class Packet
         IsRequest      = 1 << 4,
         IsResponse     = 1 << 5,
         NeedsResponse  = 1 << 6,
+        IsSWPrefetch    = 1 << 7,
+        IsHWPrefetch    = 1 << 8
     };
 
   public:
@@ -159,26 +175,46 @@ class Packet
         WriteReq       = IsWrite | IsRequest | NeedsResponse,
         WriteReqNoAck  = IsWrite | IsRequest,
         ReadResp       = IsRead  | IsResponse,
-        WriteResp      = IsWrite | IsResponse
+        WriteResp      = IsWrite | IsResponse,
+        Writeback       = IsWrite | IsRequest,
+        SoftPFReq       = IsRead  | IsRequest | IsSWPrefetch | NeedsResponse,
+        HardPFReq       = IsRead  | IsRequest | IsHWPrefetch | NeedsResponse,
+        SoftPFResp      = IsRead  | IsRequest | IsSWPrefetch | IsResponse,
+        HardPFResp      = IsRead  | IsRequest | IsHWPrefetch | IsResponse,
+        InvalidateReq   = IsInvalidate | IsRequest,
+        WriteInvalidateReq = IsWrite | IsInvalidate | IsRequest,
+        UpgradeReq      = IsInvalidate | NeedsResponse
     };
 
     /** Return the string name of the cmd field (for debugging and
      *   tracing). */
     const std::string &cmdString() const;
 
+    /** Reutrn the string to a cmd given by idx. */
+    const std::string &cmdIdxToString(Command idx);
+
+    /** Return the index of this command. */
+    inline int cmdToIndex() const { return (int) cmd; }
+
     /** The command field of the packet. */
     Command cmd;
 
     bool isRead()       { return (cmd & IsRead)  != 0; }
+    bool isWrite()       { return (cmd & IsWrite) != 0; }
     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 isCacheFill() { assert("Unimplemented yet\n" && 0); }
+    bool isNoAllocate() { assert("Unimplemented yet\n" && 0); }
 
     /** Possible results of a packet's request. */
     enum Result
     {
         Success,
         BadAddress,
+        Nacked,
         Unknown
     };
 
@@ -249,6 +285,16 @@ class Packet
         srcValid = false;
     }
 
+    /** 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. */
+    void reinitNacked() {
+        assert(needsResponse() && result == Nacked);
+        dest =  Broadcast;
+        result = Unknown;
+    }
+
+
     /** Set the data pointer to the following value that should not be freed. */
     template <typename T>
     void dataStatic(T *p);