add code to serialize se structures. Lisa is working on the python side of things...
authorAli Saidi <saidi@eecs.umich.edu>
Tue, 17 Oct 2006 23:38:36 +0000 (19:38 -0400)
committerAli Saidi <saidi@eecs.umich.edu>
Tue, 17 Oct 2006 23:38:36 +0000 (19:38 -0400)
src/mem/page_table.cc:
src/mem/page_table.hh:
    add code to serialize/unserialize page table
src/sim/process.cc:
src/sim/process.hh:
    add code to serialize/unserialize process

--HG--
extra : convert_revision : ee9eb5e2c38c5d317a2f381972c552d455e0db9e

src/mem/page_table.cc
src/mem/page_table.hh
src/sim/process.cc
src/sim/process.hh

index 2b460306f7e59c329a673b86ebafbba442d96165..32da4282ceda9eed57dc5d0dde89318d8b671120 100644 (file)
@@ -27,6 +27,7 @@
  *
  * Authors: Steve Reinhardt
  *          Ron Dreslinski
+ *          Ali Saidi
  */
 
 /**
@@ -97,6 +98,8 @@ PageTable::allocate(Addr vaddr, int64_t size)
     // starting address must be page aligned
     assert(pageOffset(vaddr) == 0);
 
+    DPRINTF(MMU, "Allocating Page: %#x-%#x\n", vaddr, vaddr+ size);
+
     for (; size > 0; size -= pageSize, vaddr += pageSize) {
         m5::hash_map<Addr,Addr>::iterator iter = pTable.find(vaddr);
 
@@ -159,3 +162,37 @@ PageTable::translate(RequestPtr &req)
     req->setPaddr(paddr);
     return page_check(req->getPaddr(), req->getSize());
 }
+
+void
+PageTable::serialize(std::ostream &os)
+{
+    paramOut(os, "ptable.size", pTable.size());
+    int count = 0;
+
+    m5::hash_map<Addr,Addr>::iterator iter;
+    while (iter != pTable.end()) {
+        paramOut(os, csprintf("ptable.entry%dvaddr", count),iter->first);
+        paramOut(os, csprintf("ptable.entry%dpaddr", count),iter->second);
+        ++count;
+    }
+    assert(count == pTable.size());
+}
+
+void
+PageTable::unserialize(Checkpoint *cp, const std::string &section)
+{
+    int i = 0, count;
+    paramIn(cp, section, "ptable.size", count);
+    Addr vaddr, paddr;
+
+    pTable.clear();
+
+    while(i < count) {
+        paramIn(cp, section, csprintf("ptable.entry%dvaddr", i), vaddr);
+        paramIn(cp, section, csprintf("ptable.entry%dpaddr", i), paddr);
+        pTable[vaddr] = paddr;
+        ++i;
+   }
+
+}
+
index fce063280ff98c9e9c49ba630c02ee891b3b9dd9..0e2b1f58c8695841620175a8a97dbba930aeac77 100644 (file)
@@ -95,6 +95,8 @@ class PageTable
      */
     Fault translate(RequestPtr &req);
 
+    void serialize(std::ostream &os);
+    void unserialize(Checkpoint *cp, const std::string &section);
 };
 
 #endif
index 46ccd25964c7c40027922329776f4107435d87d7..f3e289d41595874e78315b3311b6e457c704cd0c 100644 (file)
@@ -240,6 +240,41 @@ Process::sim_fd(int tgt_fd)
     return fd_map[tgt_fd];
 }
 
+void
+Process::serialize(std::ostream &os)
+{
+    SERIALIZE_SCALAR(initialContextLoaded);
+    SERIALIZE_SCALAR(brk_point);
+    SERIALIZE_SCALAR(stack_base);
+    SERIALIZE_SCALAR(stack_size);
+    SERIALIZE_SCALAR(stack_min);
+    SERIALIZE_SCALAR(next_thread_stack_base);
+    SERIALIZE_SCALAR(mmap_start);
+    SERIALIZE_SCALAR(mmap_end);
+    SERIALIZE_SCALAR(nxm_start);
+    SERIALIZE_SCALAR(nxm_end);
+    SERIALIZE_ARRAY(fd_map, MAX_FD);
+
+    pTable->serialize(os);
+}
+
+void
+Process::unserialize(Checkpoint *cp, const std::string &section)
+{
+    UNSERIALIZE_SCALAR(initialContextLoaded);
+    UNSERIALIZE_SCALAR(brk_point);
+    UNSERIALIZE_SCALAR(stack_base);
+    UNSERIALIZE_SCALAR(stack_size);
+    UNSERIALIZE_SCALAR(stack_min);
+    UNSERIALIZE_SCALAR(next_thread_stack_base);
+    UNSERIALIZE_SCALAR(mmap_start);
+    UNSERIALIZE_SCALAR(mmap_end);
+    UNSERIALIZE_SCALAR(nxm_start);
+    UNSERIALIZE_SCALAR(nxm_end);
+    UNSERIALIZE_ARRAY(fd_map, MAX_FD);
+
+    pTable->unserialize(cp, section);
+}
 
 
 //
index b2777170f820f74d9728a11023032ae350668507..5c37f725e3ae6d6fbadeb030dc96cde943171f7f 100644 (file)
@@ -162,6 +162,9 @@ class Process : public SimObject
     int sim_fd(int tgt_fd);
 
     virtual void syscall(int64_t callnum, ThreadContext *tc) = 0;
+
+    void serialize(std::ostream &os);
+    void unserialize(Checkpoint *cp, const std::string &section);
 };
 
 //