summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabe Black <gblack@eecs.umich.edu>2007-08-28 14:30:50 -0700
committerGabe Black <gblack@eecs.umich.edu>2007-08-28 14:30:50 -0700
commita3367adaff66997044553cb9a746e101418afbdd (patch)
tree4a26081985724fe95e9b993e8d49994d2e65a755
parent3ab19130770e04aaede1a3582959a01bb482b96b (diff)
downloadgem5-a3367adaff66997044553cb9a746e101418afbdd.tar.xz
Address translation: De-templatize the GenericTLB class.
--HG-- extra : convert_revision : b605a90a4a1071e39f49085a839fdcd175e09fdb
-rw-r--r--src/arch/mips/tlb.cc18
-rw-r--r--src/arch/mips/tlb.hh17
-rw-r--r--src/arch/x86/tlb.hh8
-rw-r--r--src/sim/tlb.cc2
-rw-r--r--src/sim/tlb.hh48
5 files changed, 39 insertions, 54 deletions
diff --git a/src/arch/mips/tlb.cc b/src/arch/mips/tlb.cc
index 71111b843..41a26aba1 100644
--- a/src/arch/mips/tlb.cc
+++ b/src/arch/mips/tlb.cc
@@ -35,6 +35,24 @@
#include "params/MipsITB.hh"
namespace MipsISA {
+ Fault
+ TLB::translate(RequestPtr req, ThreadContext *tc, bool)
+ {
+ Fault fault = GenericTLB::translate(req, tc);
+ if (fault != NoFault)
+ return fault;
+
+ typeof(req->getSize()) size = req->getSize();
+ Addr paddr = req->getPaddr();
+
+ if (!isPowerOf2(size))
+ panic("Invalid request size!\n");
+ if ((size - 1) & paddr)
+ return new GenericAlignmentFault(paddr);
+
+ return NoFault;
+ }
+
void
TlbEntry::serialize(std::ostream &os)
{
diff --git a/src/arch/mips/tlb.hh b/src/arch/mips/tlb.hh
index 6025de4c0..682aa7654 100644
--- a/src/arch/mips/tlb.hh
+++ b/src/arch/mips/tlb.hh
@@ -45,17 +45,26 @@ namespace MipsISA
void unserialize(Checkpoint *cp, const std::string &section);
};
- class ITB : public GenericITB<>
+ class TLB : public GenericTLB
{
public:
- ITB(const std::string &name) : GenericITB<>(name)
+ TLB(const std::string &name) : GenericTLB(name)
+ {}
+
+ Fault translate(RequestPtr req, ThreadContext *tc, bool=false);
+ };
+
+ class ITB : public TLB
+ {
+ public:
+ ITB(const std::string &name) : TLB(name)
{}
};
- class DTB : public GenericDTB<>
+ class DTB : public TLB
{
public:
- DTB(const std::string &name) : GenericDTB<>(name)
+ DTB(const std::string &name) : TLB(name)
{}
};
};
diff --git a/src/arch/x86/tlb.hh b/src/arch/x86/tlb.hh
index 4cf65ac08..6622f5dc2 100644
--- a/src/arch/x86/tlb.hh
+++ b/src/arch/x86/tlb.hh
@@ -78,17 +78,17 @@ namespace X86ISA
void unserialize(Checkpoint *cp, const std::string &section);
};
- class ITB : public GenericITB<false, false>
+ class ITB : public GenericTLB
{
public:
- ITB(const std::string &name) : GenericITB<false, false>(name)
+ ITB(const std::string &name) : GenericTLB(name)
{}
};
- class DTB : public GenericDTB<false, false>
+ class DTB : public GenericTLB
{
public:
- DTB(const std::string &name) : GenericDTB<false, false>(name)
+ DTB(const std::string &name) : GenericTLB(name)
{}
};
};
diff --git a/src/sim/tlb.cc b/src/sim/tlb.cc
index 5ceec637e..de6779839 100644
--- a/src/sim/tlb.cc
+++ b/src/sim/tlb.cc
@@ -34,7 +34,7 @@
#include "sim/tlb.hh"
Fault
-GenericTLBBase::translate(RequestPtr req, ThreadContext * tc)
+GenericTLB::translate(RequestPtr req, ThreadContext * tc, bool)
{
#if FULL_SYSTEM
panic("Generic translation shouldn't be used in full system mode.\n");
diff --git a/src/sim/tlb.hh b/src/sim/tlb.hh
index c4c171015..4239b4cf3 100644
--- a/src/sim/tlb.hh
+++ b/src/sim/tlb.hh
@@ -39,56 +39,14 @@
class ThreadContext;
class Packet;
-class GenericTLBBase : public SimObject
+class GenericTLB : public SimObject
{
protected:
- GenericTLBBase(const std::string &name) : SimObject(name)
+ GenericTLB(const std::string &name) : SimObject(name)
{}
- Fault translate(RequestPtr req, ThreadContext *tc);
-};
-
-template <bool doSizeCheck=true, bool doAlignmentCheck=true>
-class GenericTLB : public GenericTLBBase
-{
- public:
- GenericTLB(const std::string &name) : GenericTLBBase(name)
- {}
-
- Fault translate(RequestPtr req, ThreadContext *tc, bool=false)
- {
- Fault fault = GenericTLBBase::translate(req, tc);
- if (fault != NoFault)
- return fault;
-
- typeof(req->getSize()) size = req->getSize();
- Addr paddr = req->getPaddr();
-
- if(doSizeCheck && !isPowerOf2(size))
- panic("Invalid request size!\n");
- if (doAlignmentCheck && ((size - 1) & paddr))
- return new GenericAlignmentFault(paddr);
-
- return NoFault;
- }
-};
-
-template <bool doSizeCheck=true, bool doAlignmentCheck=true>
-class GenericITB : public GenericTLB<doSizeCheck, doAlignmentCheck>
-{
public:
- GenericITB(const std::string &name) :
- GenericTLB<doSizeCheck, doAlignmentCheck>(name)
- {}
-};
-
-template <bool doSizeCheck=true, bool doAlignmentCheck=true>
-class GenericDTB : public GenericTLB<doSizeCheck, doAlignmentCheck>
-{
- public:
- GenericDTB(const std::string &name) :
- GenericTLB<doSizeCheck, doAlignmentCheck>(name)
- {}
+ Fault translate(RequestPtr req, ThreadContext *tc, bool=false);
};
#endif // __ARCH_SPARC_TLB_HH__