summaryrefslogtreecommitdiff
path: root/src/sim/tlb.hh
diff options
context:
space:
mode:
authorGabe Black <gblack@eecs.umich.edu>2007-08-26 20:33:57 -0700
committerGabe Black <gblack@eecs.umich.edu>2007-08-26 20:33:57 -0700
commit9b49a78cfdc0bd6f8afdb0d066ea39778095d7ac (patch)
treeb4a977c8d7379ac552d245847825a73b61bf8c5b /src/sim/tlb.hh
parent80d51650c8bce1503e5ce3877f3bfe21d3e57d45 (diff)
downloadgem5-9b49a78cfdc0bd6f8afdb0d066ea39778095d7ac.tar.xz
Address translation: Make the page table more flexible.
The page table now stores actual page table entries. It is still a templated class here, but this will be corrected in the near future. --HG-- extra : convert_revision : 804dcc6320414c2b3ab76a74a15295bd24e1d13d
Diffstat (limited to 'src/sim/tlb.hh')
-rw-r--r--src/sim/tlb.hh48
1 files changed, 38 insertions, 10 deletions
diff --git a/src/sim/tlb.hh b/src/sim/tlb.hh
index 8e291ecc9..b54eb501f 100644
--- a/src/sim/tlb.hh
+++ b/src/sim/tlb.hh
@@ -31,36 +31,64 @@
#ifndef __SIM_TLB_HH__
#define __SIM_TLB_HH__
+#include "base/misc.hh"
#include "mem/request.hh"
-#include "sim/sim_object.hh"
#include "sim/faults.hh"
+#include "sim/sim_object.hh"
class ThreadContext;
class Packet;
-class GenericTLB : public SimObject
+class GenericTLBBase : public SimObject
{
- public:
- GenericTLB(const std::string &name) : SimObject(name)
+ protected:
+ GenericTLBBase(const std::string &name) : SimObject(name)
{}
+
+ Fault translate(RequestPtr req, ThreadContext *tc);
};
-class GenericITB : public GenericTLB
+template <bool doSizeCheck=true, bool doAlignmentCheck=true>
+class GenericTLB : public GenericTLBBase
{
public:
- GenericITB(const std::string &name) : GenericTLB(name)
+ GenericTLB(const std::string &name) : GenericTLBBase(name)
{}
- Fault translate(RequestPtr &req, ThreadContext *tc);
+ 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 Fault(new GenericAlignmentFault(paddr));
+
+ return NoFault;
+ }
};
-class GenericDTB : public GenericTLB
+template <bool doSizeCheck=true, bool doAlignmentCheck=true>
+class GenericITB : public GenericTLB<doSizeCheck, doAlignmentCheck>
{
public:
- GenericDTB(const std::string &name) : GenericTLB(name)
+ GenericITB(const std::string &name) :
+ GenericTLB<doSizeCheck, doAlignmentCheck>(name)
{}
+};
- Fault translate(RequestPtr &req, ThreadContext *tc, bool write);
+template <bool doSizeCheck=true, bool doAlignmentCheck=true>
+class GenericDTB : public GenericTLB<doSizeCheck, doAlignmentCheck>
+{
+ public:
+ GenericDTB(const std::string &name) :
+ GenericTLB<doSizeCheck, doAlignmentCheck>(name)
+ {}
};
#endif // __ARCH_SPARC_TLB_HH__