ARM: Make VMSR, RFE PC/LR etc non speculative, and serializing
[gem5.git] / src / sim / serialize.cc
index 27831ef3229d96aec025c241df13dac0568c6dd9..aa343d0e9c2ed7569574ad866f0fbef44d414754 100644 (file)
@@ -85,6 +85,14 @@ showParam(ostream &os, const T &value)
 //
 
 // Treat 8-bit ints (chars) as ints on output, not as chars
+template <>
+void
+showParam(ostream &os, const char &value)
+{
+    os << (int)value;
+}
+
+
 template <>
 void
 showParam(ostream &os, const signed char &value)
@@ -261,7 +269,7 @@ arrayParamIn(Checkpoint *cp, const string &section, const string &name,
         // for which operator[] returns a special reference class
         // that's not the same as 'bool&', (since it's a packed
         // vector)
-        T scalar_value;
+        T scalar_value = 0;
         if (!parseParam(tokens[i], scalar_value)) {
             string err("could not parse \"");
 
@@ -303,7 +311,7 @@ arrayParamIn(Checkpoint *cp, const string &section,
         // for which operator[] returns a special reference class
         // that's not the same as 'bool&', (since it's a packed
         // vector)
-        T scalar_value;
+        T scalar_value = 0;
         if (!parseParam(tokens[i], scalar_value)) {
             string err("could not parse \"");
 
@@ -350,6 +358,7 @@ template void                                                           \
 arrayParamIn(Checkpoint *cp, const string &section,                     \
              const string &name, vector<type> &param);
 
+INSTANTIATE_PARAM_TEMPLATES(char)
 INSTANTIATE_PARAM_TEMPLATES(signed char)
 INSTANTIATE_PARAM_TEMPLATES(unsigned char)
 INSTANTIATE_PARAM_TEMPLATES(signed short)
@@ -427,8 +436,7 @@ Serializable::unserialize(Checkpoint *cp, const string &section)
 void
 Serializable::serializeAll(const string &cpt_dir)
 {
-    setCheckpointDir(cpt_dir);
-    string dir = Checkpoint::dir();
+    string dir = Checkpoint::setDir(cpt_dir);
     if (mkdir(dir.c_str(), 0775) == -1 && errno != EEXIST)
             fatal("couldn't mkdir %s\n", dir);
 
@@ -443,48 +451,12 @@ Serializable::serializeAll(const string &cpt_dir)
     SimObject::serializeAll(outstream);
 }
 
-void
-Serializable::unserializeAll(const string &cpt_dir)
-{
-    setCheckpointDir(cpt_dir);
-    string dir = Checkpoint::dir();
-    string cpt_file = dir + Checkpoint::baseFilename;
-    string section = "";
-
-    DPRINTFR(Config, "Loading checkpoint dir '%s'\n",
-             dir);
-    Checkpoint *cp = new Checkpoint(dir, section);
-    unserializeGlobals(cp);
-    SimObject::unserializeAll(cp);
-}
-
 void
 Serializable::unserializeGlobals(Checkpoint *cp)
 {
     globals.unserialize(cp);
 }
 
-const char *Checkpoint::baseFilename = "m5.cpt";
-
-static string checkpointDirBase;
-
-void
-setCheckpointDir(const string &name)
-{
-    checkpointDirBase = name;
-    if (checkpointDirBase[checkpointDirBase.size() - 1] != '/')
-        checkpointDirBase += "/";
-}
-
-string
-Checkpoint::dir()
-{
-    // use csprintf to insert curTick into directory name if it
-    // appears to have a format placeholder in it.
-    return (checkpointDirBase.find("%") != string::npos) ?
-        csprintf(checkpointDirBase, curTick) : checkpointDirBase;
-}
-
 void
 debug_serialize(const string &cpt_dir)
 {
@@ -554,10 +526,33 @@ Serializable::create(Checkpoint *cp, const string &section)
 }
 
 
-Checkpoint::Checkpoint(const string &cpt_dir, const string &path)
-    : db(new IniFile), basePath(path), cptDir(cpt_dir)
+const char *Checkpoint::baseFilename = "m5.cpt";
+
+string Checkpoint::currentDirectory;
+
+string
+Checkpoint::setDir(const string &name)
+{
+    // use csprintf to insert curTick into directory name if it
+    // appears to have a format placeholder in it.
+    currentDirectory = (name.find("%") != string::npos) ?
+        csprintf(name, curTick) : name;
+    if (currentDirectory[currentDirectory.size() - 1] != '/')
+        currentDirectory += "/";
+    return currentDirectory;
+}
+
+string
+Checkpoint::dir()
+{
+    return currentDirectory;
+}
+
+
+Checkpoint::Checkpoint(const string &cpt_dir)
+    : db(new IniFile), cptDir(setDir(cpt_dir))
 {
-    string filename = cpt_dir + "/" + Checkpoint::baseFilename;
+    string filename = cptDir + "/" + Checkpoint::baseFilename;
     if (!db->load(filename)) {
         fatal("Can't load checkpoint file '%s'\n", filename);
     }