mem-cache: Add multiple eviction stats
[gem5.git] / src / arch / arm / pagetable.hh
index c1956cf095e017f7965f0eb046ceaf09a0ac16ba..240a1cad8a290272fb8e5f4a6a1cb43a0efd841b 100644 (file)
@@ -61,12 +61,12 @@ struct VAddr
 // ITB/DTB page table entry
 struct PTE
 {
-    void serialize(std::ostream &os)
+    void serialize(CheckpointOut &cp) const
     {
         panic("Need to implement PTE serialization\n");
     }
 
-    void unserialize(Checkpoint *cp, const std::string &section)
+    void unserialize(CheckpointIn &cp)
     {
         panic("Need to implement PTE serialization\n");
     }
@@ -83,7 +83,7 @@ enum LookupLevel {
 };
 
 // ITB/DTB table entry
-struct TlbEntry
+struct TlbEntry : public Serializable
 {
   public:
     enum class MemoryType : std::uint8_t {
@@ -133,7 +133,7 @@ struct TlbEntry
     // True if the entry was brought in from a non-secure page table
     bool nstid;
     // Exception level on insert, AARCH64 EL0&1, AARCH32 -> el=1
-    uint8_t el;
+    ExceptionLevel el;
 
     // Type of memory
     bool nonCacheable;     // Can we wrap this in mtype?
@@ -154,7 +154,7 @@ struct TlbEntry
          innerAttrs(0), outerAttrs(0), ap(read_only ? 0x3 : 0), hap(0x3),
          domain(DomainType::Client),  mtype(MemoryType::StronglyOrdered),
          longDescFormat(false), isHyp(false), global(false), valid(true),
-         ns(true), nstid(true), el(0), nonCacheable(uncacheable),
+         ns(true), nstid(true), el(EL0), nonCacheable(uncacheable),
          shareable(false), outerShareable(false), xn(0), pxn(0)
     {
         // no restrictions by default, hap = 0x3
@@ -168,8 +168,8 @@ struct TlbEntry
          pfn(0), size(0), vpn(0), attributes(0), lookupLevel(L1), asid(0),
          vmid(0), N(0), innerAttrs(0), outerAttrs(0), ap(0), hap(0x3),
          domain(DomainType::Client), mtype(MemoryType::StronglyOrdered),
-         longDescFormat(false), isHyp(false), global(false), valid(true),
-         ns(true), nstid(true), el(0), nonCacheable(false),
+         longDescFormat(false), isHyp(false), global(false), valid(false),
+         ns(true), nstid(true), el(EL0), nonCacheable(false),
          shareable(false), outerShareable(false), xn(0), pxn(0)
     {
         // no restrictions by default, hap = 0x3
@@ -191,14 +191,14 @@ struct TlbEntry
 
     bool
     match(Addr va, uint8_t _vmid, bool hypLookUp, bool secure_lookup,
-          uint8_t target_el) const
+          ExceptionLevel target_el) const
     {
         return match(va, 0, _vmid, hypLookUp, secure_lookup, true, target_el);
     }
 
     bool
     match(Addr va, uint16_t asn, uint8_t _vmid, bool hypLookUp,
-          bool secure_lookup, bool ignore_asn, uint8_t target_el) const
+          bool secure_lookup, bool ignore_asn, ExceptionLevel target_el) const
     {
         bool match = false;
         Addr v = vpn << N;
@@ -206,10 +206,8 @@ struct TlbEntry
         if (valid && va >= v && va <= v + size && (secure_lookup == !nstid) &&
             (hypLookUp == isHyp))
         {
-            if (target_el == 2 || target_el == 3)
-                match = (el == target_el);
-            else
-                match = (el == 0) || (el == 1);
+            match = checkELMatch(target_el);
+
             if (match && !ignore_asn) {
                 match = global || (asn == asid);
             }
@@ -220,6 +218,16 @@ struct TlbEntry
         return match;
     }
 
+    bool
+    checkELMatch(ExceptionLevel target_el) const
+    {
+        if (target_el == EL2 || target_el == EL3) {
+            return (el  == target_el);
+        } else {
+            return (el == EL0) || (el == EL1);
+        }
+    }
+
     Addr
     pAddr(Addr va) const
     {
@@ -284,7 +292,7 @@ struct TlbEntry
     }
 
     void
-    serialize(std::ostream &os)
+    serialize(CheckpointOut &cp) const override
     {
         SERIALIZE_SCALAR(longDescFormat);
         SERIALIZE_SCALAR(pfn);
@@ -311,10 +319,10 @@ struct TlbEntry
         SERIALIZE_SCALAR(ap);
         SERIALIZE_SCALAR(hap);
         uint8_t domain_ = static_cast<uint8_t>(domain);
-        paramOut(os, "domain", domain_);
+        paramOut(cp, "domain", domain_);
     }
     void
-    unserialize(Checkpoint *cp, const std::string &section)
+    unserialize(CheckpointIn &cp) override
     {
         UNSERIALIZE_SCALAR(longDescFormat);
         UNSERIALIZE_SCALAR(pfn);
@@ -341,7 +349,7 @@ struct TlbEntry
         UNSERIALIZE_SCALAR(ap);
         UNSERIALIZE_SCALAR(hap);
         uint8_t domain_;
-        paramIn(cp, section, "domain", domain_);
+        paramIn(cp, "domain", domain_);
         domain = static_cast<DomainType>(domain_);
     }