summaryrefslogtreecommitdiff
path: root/src/cpu/base.hh
diff options
context:
space:
mode:
authorAndreas Sandberg <Andreas.Sandberg@ARM.com>2013-01-07 13:05:52 -0500
committerAndreas Sandberg <Andreas.Sandberg@ARM.com>2013-01-07 13:05:52 -0500
commit009970f59b86eac6c9a35eeb175dd9e3a3079d13 (patch)
tree03119f68fd1e03ff753954b63722b916b39f6737 /src/cpu/base.hh
parent5fb00e1df6b2b7d9db472d0c25765263ed1b839f (diff)
downloadgem5-009970f59b86eac6c9a35eeb175dd9e3a3079d13.tar.xz
cpu: Unify the serialization code for all of the CPU models
Cleanup the serialization code for the simple CPUs and the O3 CPU. The CPU-specific code has been replaced with a (un)serializeThread that serializes the thread state / context of a specific thread. Assuming that the thread state class uses the CPU-specific thread state uses the base thread state serialization code, this allows us to restore a checkpoint with any of the CPU models.
Diffstat (limited to 'src/cpu/base.hh')
-rw-r--r--src/cpu/base.hh32
1 files changed, 31 insertions, 1 deletions
diff --git a/src/cpu/base.hh b/src/cpu/base.hh
index cd30d29bc..34b23cea0 100644
--- a/src/cpu/base.hh
+++ b/src/cpu/base.hh
@@ -365,18 +365,48 @@ class BaseCPU : public MemObject
/**
* Serialize this object to the given output stream.
+ *
+ * @note CPU models should normally overload the serializeThread()
+ * method instead of the serialize() method as this provides a
+ * uniform data format for all CPU models and promotes better code
+ * reuse.
+ *
* @param os The stream to serialize to.
*/
virtual void serialize(std::ostream &os);
/**
* Reconstruct the state of this object from a checkpoint.
+ *
+ * @note CPU models should normally overload the
+ * unserializeThread() method instead of the unserialize() method
+ * as this provides a uniform data format for all CPU models and
+ * promotes better code reuse.
+
* @param cp The checkpoint use.
- * @param section The section name of this object
+ * @param section The section name of this object.
*/
virtual void unserialize(Checkpoint *cp, const std::string &section);
/**
+ * Serialize a single thread.
+ *
+ * @param os The stream to serialize to.
+ * @param tid ID of the current thread.
+ */
+ virtual void serializeThread(std::ostream &os, ThreadID tid) {};
+
+ /**
+ * Unserialize one thread.
+ *
+ * @param cp The checkpoint use.
+ * @param section The section name of this thread.
+ * @param tid ID of the current thread.
+ */
+ virtual void unserializeThread(Checkpoint *cp, const std::string &section,
+ ThreadID tid) {};
+
+ /**
* Return pointer to CPU's branch predictor (NULL if none).
* @return Branch predictor pointer.
*/