refactor code for the packet, get rid of packet_impl.hh
authorNathan Binkert <binkertn@umich.edu>
Fri, 20 Oct 2006 06:38:45 +0000 (23:38 -0700)
committerNathan Binkert <binkertn@umich.edu>
Fri, 20 Oct 2006 06:38:45 +0000 (23:38 -0700)
and call it packet_access.hh and fix the #includes so
things compile right.

--HG--
extra : convert_revision : d3626c9715b9f7e51bb3ab8d97e971fad4e0b724

30 files changed:
src/arch/alpha/isa/main.isa
src/arch/mips/isa/includes.isa
src/cpu/checker/cpu.cc
src/cpu/checker/cpu_impl.hh
src/cpu/memtest/memtest.cc
src/cpu/o3/fetch.hh
src/cpu/o3/lsq_unit.hh
src/cpu/simple/atomic.cc
src/cpu/simple/base.cc
src/cpu/simple/timing.cc
src/dev/alpha_console.cc
src/dev/ide_ctrl.cc
src/dev/io_device.hh
src/dev/isa_fake.cc
src/dev/isa_fake.hh
src/dev/ns_gige.cc
src/dev/pciconfigall.cc
src/dev/pcidev.cc
src/dev/pcidev.hh
src/dev/sinic.cc
src/dev/tsunami_cchip.cc
src/dev/tsunami_io.cc
src/dev/tsunami_pchip.cc
src/dev/uart8250.cc
src/mem/cache/base_cache.cc
src/mem/packet.cc
src/mem/packet.hh
src/mem/packet_access.hh [new file with mode: 0644]
src/mem/physical.cc
src/mem/port.cc

index 1270bf8d8d4f15ebdee540be3a2d529feab6ac9d..0eb611a6006c9e7b1e75fd6e148f0ed125c20139 100644 (file)
@@ -73,8 +73,9 @@ output exec {{
 #include "config/ss_compatible_fp.hh"
 #include "cpu/base.hh"
 #include "cpu/exetrace.hh"
+#include "mem/packet.hh"
+#include "mem/packet_access.hh"
 #include "sim/sim_exit.hh"
-#include "mem/packet_impl.hh"
 
 using namespace AlphaISA;
 }};
index f58c8adaa3a65619222a526b5978c679a3e890b3..44926d772b36b63c8addc723da3f3eab2f8b49bc 100644 (file)
@@ -74,8 +74,9 @@ output exec {{
 #endif
 #include "cpu/base.hh"
 #include "cpu/exetrace.hh"
+#include "mem/packet.hh"
+#include "mem/packet_access.hh"
 #include "sim/sim_exit.hh"
-#include "mem/packet_impl.hh"
 
 using namespace MipsISA;
 }};
index f6d56eef621104794c86a5e35f078175010d1551..c2c81bf9b14da2aabed677a27d6b137f579ed454 100644 (file)
 #include "cpu/base.hh"
 #include "cpu/checker/cpu.hh"
 #include "cpu/simple_thread.hh"
-#include "cpu/thread_context.hh"
 #include "cpu/static_inst.hh"
-#include "mem/packet_impl.hh"
-#include "sim/byteswap.hh"
+#include "cpu/thread_context.hh"
 
 #if FULL_SYSTEM
 #include "arch/vtophys.hh"
index 8aec7975462041bb8ae48b47bf7e3d8660c3d5d8..7f1efc03663586582c3a5b5ac78cb5e32348e881 100644 (file)
@@ -37,8 +37,6 @@
 #include "cpu/simple_thread.hh"
 #include "cpu/thread_context.hh"
 #include "cpu/static_inst.hh"
-#include "mem/packet_impl.hh"
-#include "sim/byteswap.hh"
 #include "sim/sim_object.hh"
 #include "sim/stats.hh"
 
index cb643e5d9c89c3fb50420035892e9bdb3cf47952..23f2eacbcb8a6038b05865d2236952cda46c89d7 100644 (file)
 
 #include "base/misc.hh"
 #include "base/statistics.hh"
-//#include "cpu/simple_thread.hh"
 #include "cpu/memtest/memtest.hh"
+//#include "cpu/simple_thread.hh"
 //#include "mem/cache/base_cache.hh"
+#include "mem/mem_object.hh"
+#include "mem/port.hh"
+#include "mem/packet.hh"
 //#include "mem/physical.hh"
+#include "mem/request.hh"
 #include "sim/builder.hh"
 #include "sim/sim_events.hh"
 #include "sim/stats.hh"
-#include "mem/packet.hh"
-#include "mem/request.hh"
-#include "mem/port.hh"
-#include "mem/mem_object.hh"
 
 using namespace std;
 
index 280bf0e71b8baa94b2743fbda23a16136ed833e3..5555bff85127e0227edde891c54b2a724649d9c9 100644 (file)
@@ -36,7 +36,7 @@
 #include "base/statistics.hh"
 #include "base/timebuf.hh"
 #include "cpu/pc_event.hh"
-#include "mem/packet_impl.hh"
+#include "mem/packet.hh"
 #include "mem/port.hh"
 #include "sim/eventq.hh"
 
index 11a02e7c70a8bddec787b71d6c1b1b8e95b72af7..0aac466b56418e774de4be4a9865d8c91eeaa4a9 100644 (file)
@@ -40,7 +40,7 @@
 #include "config/full_system.hh"
 #include "base/hashmap.hh"
 #include "cpu/inst_seq.hh"
-#include "mem/packet_impl.hh"
+#include "mem/packet.hh"
 #include "mem/port.hh"
 
 /**
index acda254c35c54249e73480bc1ffed9892ae7e281..fcda974e3448b288fe76364af8d1d9d1c19a4186 100644 (file)
@@ -32,7 +32,8 @@
 #include "arch/utility.hh"
 #include "cpu/exetrace.hh"
 #include "cpu/simple/atomic.hh"
-#include "mem/packet_impl.hh"
+#include "mem/packet.hh"
+#include "mem/packet_access.hh"
 #include "sim/builder.hh"
 #include "sim/system.hh"
 
index 522fe79aacf6ab72194f0eb4274a6c57ce4635c1..a79d3c542af3920e26770bf5c6620bfe27a1b768 100644 (file)
@@ -47,7 +47,7 @@
 #include "cpu/static_inst.hh"
 #include "cpu/thread_context.hh"
 #include "kern/kernel_stats.hh"
-#include "mem/packet_impl.hh"
+#include "mem/packet.hh"
 #include "sim/builder.hh"
 #include "sim/byteswap.hh"
 #include "sim/debug.hh"
index 0cc10ae948f209f3d7fbc4cfe92cb9bec315992d..3ddc938c320d278c86d010a195cff30ba1ecb823 100644 (file)
@@ -32,7 +32,8 @@
 #include "arch/utility.hh"
 #include "cpu/exetrace.hh"
 #include "cpu/simple/timing.hh"
-#include "mem/packet_impl.hh"
+#include "mem/packet.hh"
+#include "mem/packet_access.hh"
 #include "sim/builder.hh"
 #include "sim/system.hh"
 
index 181bbf934a4410101f7e8d8affc11703f643ddcf..299389d0061523b731c61acebc00589992f9f840 100644 (file)
@@ -48,6 +48,8 @@
 #include "dev/platform.hh"
 #include "dev/simconsole.hh"
 #include "dev/simple_disk.hh"
+#include "mem/packet.hh"
+#include "mem/packet_access.hh"
 #include "mem/physical.hh"
 #include "sim/builder.hh"
 #include "sim/sim_object.hh"
index 8007fda5ec6de49a4c0a40b5fb546547b29e8810..b3b7f5927c989e92b3cbfc81f0752546c0453ce4 100644 (file)
@@ -43,6 +43,7 @@
 #include "dev/pcireg.h"
 #include "dev/platform.hh"
 #include "mem/packet.hh"
+#include "mem/packet_access.hh"
 #include "sim/builder.hh"
 #include "sim/sim_object.hh"
 #include "sim/byteswap.hh"
index 24e822a405aa33639cf9435a7433873fa0f88169..654e38a71f34e9262720abe2ccdc95ec295062d4 100644 (file)
@@ -33,9 +33,9 @@
 #define __DEV_IO_DEVICE_HH__
 
 #include "mem/mem_object.hh"
-#include "mem/packet_impl.hh"
-#include "sim/sim_object.hh"
+#include "mem/packet.hh"
 #include "mem/tport.hh"
+#include "sim/sim_object.hh"
 
 class Event;
 class Platform;
index 9622f015c3c9c06f2cf113d0fec5bd1b8e3b239b..82f823e6e5dfdee8805d0e0905f68f8f12efef4b 100644 (file)
@@ -40,6 +40,7 @@
 #include "base/trace.hh"
 #include "dev/isa_fake.hh"
 #include "mem/packet.hh"
+#include "mem/packet_access.hh"
 #include "sim/builder.hh"
 #include "sim/system.hh"
 
index 5166882f8fc1c00781c8ed2c4700e0dbf4c3f939..32b9045ca618799342ed7cffe34a26944c3eeef9 100644 (file)
 #ifndef __ISA_FAKE_HH__
 #define __ISA_FAKE_HH__
 
-#include "dev/tsunami.hh"
 #include "base/range.hh"
 #include "dev/io_device.hh"
+#include "dev/tsunami.hh"
+#include "mem/packet.hh"
 
 /**
  * IsaFake is a device that returns -1 on all reads and
index 704afcf7d2376915ab43c8ec3e92a782625f3b78..77dbf35011a818e6da196d406e04cb77414529d2 100644 (file)
@@ -43,6 +43,7 @@
 #include "dev/ns_gige.hh"
 #include "dev/pciconfigall.hh"
 #include "mem/packet.hh"
+#include "mem/packet_access.hh"
 #include "sim/builder.hh"
 #include "sim/debug.hh"
 #include "sim/host.hh"
index 68013eab89595fbb3eed198fdf7eefccdbbee6c4..d5c5310a2ee6fbeac69cadb0f0893475811dd22d 100644 (file)
@@ -38,6 +38,7 @@
 #include "dev/pcireg.h"
 #include "dev/platform.hh"
 #include "mem/packet.hh"
+#include "mem/packet_access.hh"
 #include "sim/builder.hh"
 #include "sim/system.hh"
 
index b16ddb31af6cf7eac03abb8f0f5da6992735d609..3d25535738ba9d55f0b5b46f0aa24b2a9cda1624 100644 (file)
@@ -47,6 +47,7 @@
 #include "dev/pcidev.hh"
 #include "dev/tsunamireg.h"
 #include "mem/packet.hh"
+#include "mem/packet_access.hh"
 #include "sim/builder.hh"
 #include "sim/byteswap.hh"
 #include "sim/param.hh"
index 22dd6296e630b452f5268285ff7fc0efb4fb4af6..36ae4f49379593a37524443134dbc9473f085d8b 100644 (file)
@@ -40,6 +40,7 @@
 #include "dev/io_device.hh"
 #include "dev/pcireg.h"
 #include "dev/platform.hh"
+#include "sim/byteswap.hh"
 
 #define BAR_IO_MASK 0x3
 #define BAR_MEM_MASK 0xF
index 61fb3aa2467daef1c6db61b38373fd33b15bce1c..0823e30c7c3df3fb12f4190b8840a0021bc7e958 100644 (file)
@@ -38,6 +38,7 @@
 #include "dev/etherlink.hh"
 #include "dev/sinic.hh"
 #include "mem/packet.hh"
+#include "mem/packet_access.hh"
 #include "sim/builder.hh"
 #include "sim/debug.hh"
 #include "sim/eventq.hh"
index 3feb7439ff45046be823d2de93002ebc83773ff9..10f4f58e79728536294097654854324c2f21175d 100644 (file)
 
 #include "arch/alpha/ev5.hh"
 #include "base/trace.hh"
+#include "cpu/intr_control.hh"
+#include "cpu/thread_context.hh"
+#include "dev/tsunami.hh"
 #include "dev/tsunami_cchip.hh"
 #include "dev/tsunamireg.h"
-#include "dev/tsunami.hh"
+#include "mem/packet.hh"
+#include "mem/packet_access.hh"
 #include "mem/port.hh"
-#include "cpu/thread_context.hh"
-#include "cpu/intr_control.hh"
 #include "sim/builder.hh"
 #include "sim/system.hh"
 
index e3da10eb50dbc9ca0e4022966c25029164462d05..f8753edb9d4c41fdec092831a9bea0564b35ba90 100644 (file)
@@ -47,6 +47,8 @@
 #include "dev/tsunami.hh"
 #include "dev/tsunami_io.hh"
 #include "dev/tsunamireg.h"
+#include "mem/packet.hh"
+#include "mem/packet_access.hh"
 #include "mem/port.hh"
 #include "sim/builder.hh"
 #include "sim/system.hh"
index 8a542b9b0709d6ec75e67572efb74f9aad38892a..a24b65436a891d8511dc5d15082ffeef759efa9c 100644 (file)
@@ -42,6 +42,7 @@
 #include "dev/tsunamireg.h"
 #include "dev/tsunami.hh"
 #include "mem/packet.hh"
+#include "mem/packet_access.hh"
 #include "sim/builder.hh"
 #include "sim/system.hh"
 
index b92527b5a95299c48faf942bb352046be12574a2..660bd71ec00cbb3d076e9d02a0d3931bfd5d8082 100644 (file)
@@ -42,6 +42,8 @@
 #include "dev/simconsole.hh"
 #include "dev/uart8250.hh"
 #include "dev/platform.hh"
+#include "mem/packet.hh"
+#include "mem/packet_access.hh"
 #include "sim/builder.hh"
 
 using namespace std;
index e0301a757b3b5bef29e45d4d5c2eae5784cd3a1f..7a8776522a04cf921282f3a7f60115294e613ab7 100644 (file)
  * Definition of BaseCache functions.
  */
 
+#include "cpu/base.hh"
+#include "cpu/smt.hh"
 #include "mem/cache/base_cache.hh"
 #include "mem/cache/miss/mshr.hh"
-#include "mem/packet_impl.hh"
-#include "cpu/smt.hh"
-#include "cpu/base.hh"
 
 using namespace std;
 
index a16e590e3482dce9e176aa91e4e77efce2bf492a..8e502f2bee045ab9dacf00e5c95ce955dd8b4d80 100644 (file)
  */
 
 #include <iostream>
+
 #include "base/misc.hh"
-#include "mem/packet.hh"
 #include "base/trace.hh"
+#include "mem/packet.hh"
 
 static const std::string ReadReqString("ReadReq");
 static const std::string WriteReqString("WriteReq");
index f6197885e854a9b3d0054dc35ee281202b341d19..29b421862e6cce43b9ccc8aeb9cde7227e783865 100644 (file)
 #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. */
diff --git a/src/mem/packet_access.hh b/src/mem/packet_access.hh
new file mode 100644 (file)
index 0000000..aac0c3a
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2006 The Regents of The University of Michigan
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Authors: Ali Saidi
+ *          Nathan Binkert
+ */
+
+#include "arch/isa_traits.hh"
+#include "mem/packet.hh"
+#include "sim/byteswap.hh"
+
+#ifndef __MEM_PACKET_ACCESS_HH__
+#define __MEM_PACKET_ACCESS_HH__
+// The memory system needs to have an endianness. This is the easiest
+// way to deal with it for now. At some point, we will have to remove
+// these functions and make the users do their own byte swapping since
+// the memory system does not in fact have an endianness.
+
+/** return the value of what is pointed to in the packet. */
+template <typename T>
+inline T
+Packet::get()
+{
+    assert(staticData || dynamicData);
+    assert(sizeof(T) <= size);
+    return TheISA::gtoh(*(T*)data);
+}
+
+/** set the value in the data pointer to v. */
+template <typename T>
+inline void
+Packet::set(T v)
+{
+    assert(sizeof(T) <= size);
+    *(T*)data = TheISA::htog(v);
+}
+
+#endif //__MEM_PACKET_ACCESS_HH__
index f5a0ade15358762db8305dd756c7856044d160e6..43a7c5cb40cf667925393c5dddbc57ec70993710 100644 (file)
 #include <iostream>
 #include <string>
 
-
+#include "arch/isa_traits.hh"
 #include "base/misc.hh"
 #include "config/full_system.hh"
-#include "mem/packet_impl.hh"
 #include "mem/physical.hh"
-#include "sim/host.hh"
 #include "sim/builder.hh"
 #include "sim/eventq.hh"
-#include "arch/isa_traits.hh"
-
+#include "sim/host.hh"
 
 using namespace std;
 using namespace TheISA;
 
-
 PhysicalMemory::PhysicalMemory(Params *p)
     : MemObject(p->name), pmemAddr(NULL), port(NULL), lat(p->latency), _params(p)
 {
index 17924b7597a8c4ef0f3dfca7d3cac8fef15b4c56..bbc98c160c578e185a4c520dfed57e2cc84322bd 100644 (file)
@@ -35,7 +35,6 @@
 
 #include "base/chunk_generator.hh"
 #include "base/trace.hh"
-#include "mem/packet_impl.hh"
 #include "mem/port.hh"
 
 void