summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/SConscript1
-rw-r--r--src/base/bigint.cc47
-rw-r--r--src/base/bigint.hh19
-rw-r--r--src/cpu/exetrace.hh2
-rw-r--r--src/mem/packet_access.hh25
-rw-r--r--src/sim/byteswap.hh19
6 files changed, 87 insertions, 26 deletions
diff --git a/src/SConscript b/src/SConscript
index 9d7248213..74d9bf9a6 100644
--- a/src/SConscript
+++ b/src/SConscript
@@ -48,6 +48,7 @@ Import('env')
base_sources = Split('''
base/annotate.cc
+ base/bigint.cc
base/circlebuf.cc
base/cprintf.cc
base/fast_alloc.cc
diff --git a/src/base/bigint.cc b/src/base/bigint.cc
new file mode 100644
index 000000000..ce9942c9c
--- /dev/null
+++ b/src/base/bigint.cc
@@ -0,0 +1,47 @@
+/*
+ * 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: Gabe Black
+ */
+
+#include "base/bigint.hh"
+
+#include <iostream>
+
+using namespace std;
+
+ostream & operator << (ostream & os, const Twin64_t & t)
+{
+ os << t.a << ", " << t.b;
+ return os;
+}
+
+ostream & operator << (ostream & os, const Twin32_t & t)
+{
+ os << t.a << ", " << t.b;
+ return os;
+}
diff --git a/src/base/bigint.hh b/src/base/bigint.hh
index d533e662a..ed48c67fe 100644
--- a/src/base/bigint.hh
+++ b/src/base/bigint.hh
@@ -28,12 +28,21 @@
* Authors: Ali Saidi
*/
+#include <iostream>
+
#ifndef __BASE_BIGINT_HH__
#define __BASE_BIGINT_HH__
// Create a couple of large int types for atomic reads
struct m5_twin64_t {
uint64_t a;
uint64_t b;
+ m5_twin64_t()
+ {}
+ m5_twin64_t(const uint64_t x)
+ {
+ a = x;
+ b = x;
+ }
inline m5_twin64_t& operator=(const uint64_t x)
{
a = x;
@@ -45,6 +54,13 @@ struct m5_twin64_t {
struct m5_twin32_t {
uint32_t a;
uint32_t b;
+ m5_twin32_t()
+ {}
+ m5_twin32_t(const uint32_t x)
+ {
+ a = x;
+ b = x;
+ }
inline m5_twin32_t& operator=(const uint32_t x)
{
a = x;
@@ -59,6 +75,9 @@ struct m5_twin32_t {
typedef m5_twin64_t Twin64_t;
typedef m5_twin32_t Twin32_t;
+// Output operator overloads
+std::ostream & operator << (std::ostream & os, const Twin64_t & t);
+std::ostream & operator << (std::ostream & os, const Twin32_t & t);
#endif // __BASE_BIGINT_HH__
diff --git a/src/cpu/exetrace.hh b/src/cpu/exetrace.hh
index 0f642c08e..8c0fa22cb 100644
--- a/src/cpu/exetrace.hh
+++ b/src/cpu/exetrace.hh
@@ -116,6 +116,8 @@ class InstRecord
void setAddr(Addr a) { addr = a; addr_valid = true; }
+ void setData(Twin64_t d) { data.as_int = d.a; data_status = DataInt64; }
+ void setData(Twin32_t d) { data.as_int = d.a; data_status = DataInt32; }
void setData(uint64_t d) { data.as_int = d; data_status = DataInt64; }
void setData(uint32_t d) { data.as_int = d; data_status = DataInt32; }
void setData(uint16_t d) { data.as_int = d; data_status = DataInt16; }
diff --git a/src/mem/packet_access.hh b/src/mem/packet_access.hh
index 552b6dd27..d1edd00aa 100644
--- a/src/mem/packet_access.hh
+++ b/src/mem/packet_access.hh
@@ -41,31 +41,6 @@
// these functions and make the users do their own byte swapping since
// the memory system does not in fact have an endianness.
-template<>
-inline Twin64_t
-Packet::get()
-{
- Twin64_t d;
- assert(staticData || dynamicData);
- assert(sizeof(Twin64_t) <= size);
- d.a = TheISA::gtoh(*(uint64_t*)data);
- d.b = TheISA::gtoh(*((uint64_t*)data + 1));
- return d;
-}
-
-template<>
-inline Twin32_t
-Packet::get()
-{
- Twin32_t d;
- assert(staticData || dynamicData);
- assert(sizeof(Twin32_t) <= size);
- d.a = TheISA::gtoh(*(uint32_t*)data);
- d.b = TheISA::gtoh(*((uint32_t*)data + 1));
- return d;
-}
-
-
/** return the value of what is pointed to in the packet. */
template <typename T>
inline T
diff --git a/src/sim/byteswap.hh b/src/sim/byteswap.hh
index cbc0b5088..062fc4513 100644
--- a/src/sim/byteswap.hh
+++ b/src/sim/byteswap.hh
@@ -37,6 +37,7 @@
#ifndef __SIM_BYTE_SWAP_HH__
#define __SIM_BYTE_SWAP_HH__
+#include "base/bigint.hh"
#include "base/misc.hh"
#include "sim/host.hh"
@@ -109,7 +110,7 @@ swap_byte16(uint16_t x)
// This function lets the compiler figure out how to call the
// swap_byte functions above for different data types. Since the
-// sizeof() values are known at compiel time, it should inline to a
+// sizeof() values are known at compile time, it should inline to a
// direct call to the right swap_byteNN() function.
template <typename T>
static inline T swap_byte(T x) {
@@ -125,6 +126,22 @@ static inline T swap_byte(T x) {
panic("Can't byte-swap values larger than 64 bits");
}
+template<>
+static inline Twin64_t swap_byte<Twin64_t>(Twin64_t x)
+{
+ x.a = swap_byte(x.a);
+ x.b = swap_byte(x.b);
+ return x;
+}
+
+template<>
+static inline Twin32_t swap_byte<Twin32_t>(Twin32_t x)
+{
+ x.a = swap_byte(x.a);
+ x.b = swap_byte(x.b);
+ return x;
+}
+
//The conversion functions with fixed endianness on both ends don't need to
//be in a namespace
template <typename T> static inline T betole(T value) {return swap_byte(value);}