ruby: handle llsc accesses through CacheEntry, not CacheMemory
[gem5.git] / src / mem / page_table.cc
index d3af09e1e5ede68010f53889b0bd6614c7fc07e5..6875d6f9b5a22ee52db3869a98cd9bff2be15787 100644 (file)
@@ -37,6 +37,7 @@
  */
 #include <fstream>
 #include <map>
+#include <memory>
 #include <string>
 
 #include "base/bitfield.hh"
@@ -196,44 +197,37 @@ PageTableBase::translate(RequestPtr req)
 }
 
 void
-FuncPageTable::serialize(std::ostream &os)
+FuncPageTable::serialize(CheckpointOut &cp) const
 {
-    paramOut(os, "ptable.size", pTable.size());
+    paramOut(cp, "ptable.size", pTable.size());
 
     PTable::size_type count = 0;
+    for (auto &pte : pTable) {
+        ScopedCheckpointSection sec(cp, csprintf("Entry%d", count++));
 
-    PTableItr iter = pTable.begin();
-    PTableItr end = pTable.end();
-    while (iter != end) {
-        os << "\n[" << csprintf("%s.Entry%d", name(), count) << "]\n";
-
-        paramOut(os, "vaddr", iter->first);
-        iter->second.serialize(os);
-
-        ++iter;
-        ++count;
+        paramOut(cp, "vaddr", pte.first);
+        pte.second.serialize(cp);
     }
     assert(count == pTable.size());
 }
 
 void
-FuncPageTable::unserialize(Checkpoint *cp, const std::string &section)
+FuncPageTable::unserialize(CheckpointIn &cp)
 {
-    int i = 0, count;
-    paramIn(cp, section, "ptable.size", count);
+    int count;
+    paramIn(cp, "ptable.size", count);
 
-    pTable.clear();
+    for (int i = 0; i < count; ++i) {
+        ScopedCheckpointSection sec(cp, csprintf("Entry%d", i));
 
-    while (i < count) {
-        TheISA::TlbEntry *entry;
+        std::unique_ptr<TheISA::TlbEntry> entry;
         Addr vaddr;
 
-        paramIn(cp, csprintf("%s.Entry%d", name(), i), "vaddr", vaddr);
-        entry = new TheISA::TlbEntry();
-        entry->unserialize(cp, csprintf("%s.Entry%d", name(), i));
+        paramIn(cp, "vaddr", vaddr);
+        entry.reset(new TheISA::TlbEntry());
+        entry->unserialize(cp);
+
         pTable[vaddr] = *entry;
-        delete entry;
-        ++i;
     }
 }