Mem: Reclaim some request flags used by MIPS for alignment checking.
[gem5.git] / src / arch / arm / tlb.hh
index 1bddd8497a516b0338004e06b47fe27dc303b3af..2d3661f7dce5799391fa91119557c62d4eb733fe 100644 (file)
@@ -52,7 +52,7 @@
 #include "base/statistics.hh"
 #include "mem/request.hh"
 #include "params/ArmTLB.hh"
-#include "sim/faults.hh"
+#include "sim/fault.hh"
 #include "sim/tlb.hh"
 
 class ThreadContext;
@@ -65,20 +65,22 @@ class TLB : public BaseTLB
 {
   public:
     enum ArmFlags {
-        AlignmentMask = 0x7,
+        AlignmentMask = 0x1f,
 
         AlignByte = 0x0,
         AlignHalfWord = 0x1,
         AlignWord = 0x3,
         AlignDoubleWord = 0x7,
+        AlignQuadWord = 0xf,
+        AlignOctWord = 0x1f,
 
-        AllowUnaligned = 0x8,
+        AllowUnaligned = 0x20,
         // Priv code operating as if it wasn't
-        UserMode = 0x10,
+        UserMode = 0x40,
         // Because zero otherwise looks like a valid setting and may be used
         // accidentally, this bit must be non-zero to show it was used on
         // purpose.
-        MustBeOne = 0x20
+        MustBeOne = 0x80
     };
   protected:
     typedef std::multimap<Addr, int> PageTable;
@@ -86,7 +88,6 @@ class TLB : public BaseTLB
 
     TlbEntry *table;   // the Page Table
     int size;                  // TLB Size
-    int nlu;                   // not last used entry (for replacement)
 
     uint32_t _attr;      // Memory attributes for last accessed TLB entry
 
@@ -94,8 +95,13 @@ class TLB : public BaseTLB
     TableWalker *tableWalker;
 #endif
 
-    void nextnlu() { if (++nlu >= size) nlu = 0; }
-    TlbEntry *lookup(Addr vpn, uint8_t asn);
+    /** Lookup an entry in the TLB
+     * @param vpn virtual address
+     * @param asn context id/address space id to use
+     * @param functional if the lookup should modify state
+     * @return pointer to TLB entrry if it exists
+     */
+    TlbEntry *lookup(Addr vpn, uint8_t asn, bool functional = false);
 
     // Access Stats
     mutable Stats::Scalar read_hits;
@@ -110,6 +116,7 @@ class TLB : public BaseTLB
     Stats::Formula misses;
     Stats::Formula accesses;
 
+    int rangeMRU; //On lookup, only move entries ahead when outside rangeMRU
 
   public:
     typedef ArmTLBParams Params;
@@ -152,6 +159,16 @@ class TLB : public BaseTLB
 
     static bool validVirtualAddress(Addr vaddr);
 
+    /**
+     * Do a functional lookup on the TLB (for debugging)
+     * and don't modify any internal state
+     * @param tc thread context to get the context id from
+     * @param vaddr virtual address to translate
+     * @param pa returned physical address
+     * @return if the translation was successful
+     */
+    bool translateFunctional(ThreadContext *tc, Addr vaddr, Addr &paddr);
+
     /** Accessor functions for memory attributes for last accessed TLB entry
      */
     void