summaryrefslogtreecommitdiff
path: root/src/mem/packet.hh
diff options
context:
space:
mode:
authorNathan Binkert <binkertn@umich.edu>2006-10-19 23:38:45 -0700
committerNathan Binkert <binkertn@umich.edu>2006-10-19 23:38:45 -0700
commit7245d4530d0c8367fa7b1adadcb55e1e8bd466e7 (patch)
treecf0a90859f0bb3a5c9615f34034aa302b1c73af5 /src/mem/packet.hh
parent5b246a0567193b05d8257fce8c43610ce5b8c253 (diff)
downloadgem5-7245d4530d0c8367fa7b1adadcb55e1e8bd466e7.tar.xz
refactor code for the packet, get rid of packet_impl.hh
and call it packet_access.hh and fix the #includes so things compile right. --HG-- extra : convert_revision : d3626c9715b9f7e51bb3ab8d97e971fad4e0b724
Diffstat (limited to 'src/mem/packet.hh')
-rw-r--r--src/mem/packet.hh85
1 files changed, 64 insertions, 21 deletions
diff --git a/src/mem/packet.hh b/src/mem/packet.hh
index f6197885e..29b421862 100644
--- a/src/mem/packet.hh
+++ b/src/mem/packet.hh
@@ -38,11 +38,12 @@
#ifndef __MEM_PACKET_HH__
#define __MEM_PACKET_HH__
+#include <cassert>
+#include <list>
+
#include "mem/request.hh"
#include "sim/host.hh"
#include "sim/root.hh"
-#include <list>
-#include <cassert>
struct Packet;
typedef Packet* PacketPtr;
@@ -342,10 +343,12 @@ class Packet
srcValid = false;
}
- /** Take a request packet and modify it in place to be suitable
- * for returning as a response to that request.
+ /**
+ * Take a request packet and modify it in place to be suitable for
+ * returning as a response to that request.
*/
- void makeAtomicResponse() {
+ void makeAtomicResponse()
+ {
assert(needsResponse());
assert(isRequest());
int icmd = (int)cmd;
@@ -358,43 +361,83 @@ class Packet
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. */
- void reinitNacked() {
+ /**
+ * 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. */
+ /**
+ * Set the data pointer to the following value that should not be
+ * freed.
+ */
template <typename T>
- void dataStatic(T *p);
+ void
+ dataStatic(T *p)
+ {
+ if(dynamicData)
+ dynamicData = false;
+ data = (PacketDataPtr)p;
+ staticData = true;
+ }
- /** Set the data pointer to a value that should have delete [] called on it.
+ /**
+ * Set the data pointer to a value that should have delete []
+ * called on it.
*/
template <typename T>
- void dataDynamicArray(T *p);
+ void
+ dataDynamicArray(T *p)
+ {
+ assert(!staticData && !dynamicData);
+ data = (PacketDataPtr)p;
+ dynamicData = true;
+ arrayData = true;
+ }
- /** set the data pointer to a value that should have delete called on it. */
+ /**
+ * set the data pointer to a value that should have delete called
+ * on it.
+ */
template <typename T>
- void dataDynamic(T *p);
+ void
+ dataDynamic(T *p)
+ {
+ assert(!staticData && !dynamicData);
+ data = (PacketDataPtr)p;
+ dynamicData = true;
+ arrayData = false;
+ }
- /** return the value of what is pointed to in the packet. */
+ /** get a pointer to the data ptr. */
template <typename T>
- T get();
+ T*
+ getPtr()
+ {
+ assert(staticData || dynamicData);
+ return (T*)data;
+ }
- /** get a pointer to the data ptr. */
+ /** return the value of what is pointed to in the packet. */
template <typename T>
- T* getPtr();
+ T get();
/** set the value in the data pointer to v. */
template <typename T>
void set(T v);
- /** delete the data pointed to in the data pointer. Ok to call to matter how
- * data was allocted. */
+ /**
+ * delete the data pointed to in the data pointer. Ok to call to
+ * matter how data was allocted.
+ */
void deleteData();
/** If there isn't data in the packet, allocate some. */