I found that checkpointing in M5 for the MIPS ISA was not working.
There were two reasons for this: (1) During checkpoint restoration
MipsLiveProcess::startup() was re-initializing things (re-setting up
the initial stack state, etc.) and (2) some MIPS ISA-specific things
were not being serialized (miscRegFile, most importantly).

The attached patch fixes these issues.

-- 
Cheers,
Matt
diff --git a/src/arch/mips/isa.cc b/src/arch/mips/isa.cc
index 1cad7e4..c34aaaf 100644
--- a/src/arch/mips/isa.cc
+++ b/src/arch/mips/isa.cc
@@ -36,6 +36,9 @@
 #include "cpu/base.hh"
 #include "cpu/thread_context.hh"
 
+#include <string.h>
+#include <stdio.h>
+
 namespace MipsISA
 {
 
@@ -595,4 +598,86 @@ ISA::CP0Event::unscheduleEvent()
         squash();
 }
 
+#define NUM_STR_SIZE 8
+void
+ISA::serialize(EventManager *em, std::ostream &os)
+{
+    std::string base_str;
+    char num[NUM_STR_SIZE] = {'\0'};
+    size_t i = 0;
+
+    // Serialize the 2D array miscRegFile
+    size_t miscRegFile_size = miscRegFile.size();
+    SERIALIZE_SCALAR(miscRegFile_size);
+    base_str = "miscRegFile";
+    for (i = 0; i < miscRegFile_size; i++) {
+        std::string str = base_str;
+        int bytes_written = snprintf (num, NUM_STR_SIZE-1, "%d", i);
+        assert (bytes_written >= 0 && bytes_written < NUM_STR_SIZE-1);
+        str.append (num);
+        arrayParamOut(os, str.c_str(), miscRegFile[i]);
+    }
+
+    // Serialize the 2D array miscRegFile_WriteMask
+    size_t miscRegFile_WriteMask_size = miscRegFile_WriteMask.size();
+    SERIALIZE_SCALAR(miscRegFile_WriteMask_size);
+    base_str = "miscRegFile_WriteMask";
+    for (i = 0; i < miscRegFile_WriteMask_size; i++) {
+        std::string str = base_str;
+        int bytes_written = snprintf (num, NUM_STR_SIZE-1, "%d", i);
+        assert (bytes_written >= 0 && bytes_written < NUM_STR_SIZE-1);
+        str.append (num);
+        arrayParamOut(os, str.c_str(), miscRegFile_WriteMask[i]);
+    }
+
+    // Serialize the BankType vector
+    std::vector<int> bankType_ints;
+    bankType_ints.resize (bankType.size());
+    for (i = 0; i < bankType.size(); i++)
+        bankType_ints[i] = bankType[i];
+    arrayParamOut(os, "bankType", bankType_ints);
+}
+
+void
+ISA::unserialize(EventManager *em, Checkpoint *cp,
+                 const std::string &section)
+{
+    std::string base_str;
+    char num[NUM_STR_SIZE] = {'\0'};
+    size_t i = 0;
+
+    // Unserialize the 2D array miscRegFile
+    size_t miscRegFile_size;
+    UNSERIALIZE_SCALAR(miscRegFile_size);
+    miscRegFile.resize(miscRegFile_size);
+    base_str = "miscRegFile";
+    for (i = 0; i < miscRegFile_size; i++) {
+        std::string str = base_str;
+        int bytes_written = snprintf (num, NUM_STR_SIZE-1, "%d", i);
+        assert (bytes_written >= 0 && bytes_written < NUM_STR_SIZE-1);
+        str.append (num);
+        arrayParamIn(cp, section, str.c_str(), miscRegFile[i]);
+    }
+
+    // Unserialize the 2D array miscRegFile_WriteMask
+    size_t miscRegFile_WriteMask_size;
+    UNSERIALIZE_SCALAR(miscRegFile_WriteMask_size);
+    miscRegFile_WriteMask.resize(miscRegFile_WriteMask_size);
+    base_str = "miscRegFile_WriteMask";
+    for (i = 0; i < miscRegFile_WriteMask_size; i++) {
+        std::string str = base_str;
+        int bytes_written = snprintf (num, NUM_STR_SIZE-1, "%d", i);
+        assert (bytes_written >= 0 && bytes_written < NUM_STR_SIZE-1);
+        str.append (num);
+        arrayParamIn(cp, section, str.c_str(), miscRegFile_WriteMask[i]);
+    }
+
+    // Unserialize the BankType vector
+    std::vector<int> bankType_ints;
+    arrayParamIn(cp, section, "bankType", bankType_ints);
+    bankType.resize (bankType_ints.size());
+    for (i = 0; i < bankType_ints.size(); i++)
+        bankType[i] = (enum BankType)bankType_ints[i];
+}
+
 }
diff --git a/src/arch/mips/isa.hh b/src/arch/mips/isa.hh
index 3f7afcd..65386f1 100644
--- a/src/arch/mips/isa.hh
+++ b/src/arch/mips/isa.hh
@@ -169,11 +169,9 @@ namespace MipsISA
             return reg;
         }
 
-        void serialize(EventManager *em, std::ostream &os)
-        {}
+        void serialize(EventManager *em, std::ostream &os);
         void unserialize(EventManager *em, Checkpoint *cp,
-                const std::string &section)
-        {}
+                         const std::string &section);
     };
 }
 
diff --git a/src/arch/mips/process.cc b/src/arch/mips/process.cc
index 2fd9114..795f986 100644
--- a/src/arch/mips/process.cc
+++ b/src/arch/mips/process.cc
@@ -69,6 +69,9 @@ MipsLiveProcess::MipsLiveProcess(LiveProcessParams * params,
 void
 MipsLiveProcess::startup()
 {
+    if (checkpointRestored)
+        return;
+
     Process::startup();
 
     argsInit<uint32_t>(VMPageSize);
_______________________________________________
m5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/m5-dev

Reply via email to