summaryrefslogtreecommitdiff
path: root/src/cpu/kvm
diff options
context:
space:
mode:
authorAndreas Sandberg <andreas.sandberg@arm.com>2015-07-07 09:51:03 +0100
committerAndreas Sandberg <andreas.sandberg@arm.com>2015-07-07 09:51:03 +0100
commit76cd4393c08b83fa9006ee7bce1fb62457e053c1 (patch)
treef1d2d109f77a8cf31365143d6eb127b610d924f5 /src/cpu/kvm
parentd7a56ee524c976a41fa40e5382a28462de799645 (diff)
downloadgem5-76cd4393c08b83fa9006ee7bce1fb62457e053c1.tar.xz
sim: Refactor the serialization base class
Objects that are can be serialized are supposed to inherit from the Serializable class. This class is meant to provide a unified API for such objects. However, so far it has mainly been used by SimObjects due to some fundamental design limitations. This changeset redesigns to the serialization interface to make it more generic and hide the underlying checkpoint storage. Specifically: * Add a set of APIs to serialize into a subsection of the current object. Previously, objects that needed this functionality would use ad-hoc solutions using nameOut() and section name generation. In the new world, an object that implements the interface has the methods serializeSection() and unserializeSection() that serialize into a named /subsection/ of the current object. Calling serialize() serializes an object into the current section. * Move the name() method from Serializable to SimObject as it is no longer needed for serialization. The fully qualified section name is generated by the main serialization code on the fly as objects serialize sub-objects. * Add a scoped ScopedCheckpointSection helper class. Some objects need to serialize data structures, that are not deriving from Serializable, into subsections. Previously, this was done using nameOut() and manual section name generation. To simplify this, this changeset introduces a ScopedCheckpointSection() helper class. When this class is instantiated, it adds a new /subsection/ and subsequent serialization calls during the lifetime of this helper class happen inside this section (or a subsection in case of nested sections). * The serialize() call is now const which prevents accidental state manipulation during serialization. Objects that rely on modifying state can use the serializeOld() call instead. The default implementation simply calls serialize(). Note: The old-style calls need to be explicitly called using the serializeOld()/serializeSectionOld() style APIs. These are used by default when serializing SimObjects. * Both the input and output checkpoints now use their own named types. This hides underlying checkpoint implementation from objects that need checkpointing and makes it easier to change the underlying checkpoint storage code.
Diffstat (limited to 'src/cpu/kvm')
-rw-r--r--src/cpu/kvm/BaseKvmCPU.py2
-rw-r--r--src/cpu/kvm/base.cc11
-rw-r--r--src/cpu/kvm/base.hh9
-rw-r--r--src/cpu/kvm/x86_cpu.cc2
-rw-r--r--src/cpu/kvm/x86_cpu.hh2
5 files changed, 13 insertions, 13 deletions
diff --git a/src/cpu/kvm/BaseKvmCPU.py b/src/cpu/kvm/BaseKvmCPU.py
index 644ca3620..b7c964669 100644
--- a/src/cpu/kvm/BaseKvmCPU.py
+++ b/src/cpu/kvm/BaseKvmCPU.py
@@ -53,7 +53,7 @@ class BaseKvmCPU(BaseCPU):
@classmethod
def export_methods(cls, code):
code('''
- void dump();
+ void dump() const;
''')
@classmethod
diff --git a/src/cpu/kvm/base.cc b/src/cpu/kvm/base.cc
index 827cd5581..30e984366 100644
--- a/src/cpu/kvm/base.cc
+++ b/src/cpu/kvm/base.cc
@@ -259,7 +259,7 @@ BaseKvmCPU::regStats()
}
void
-BaseKvmCPU::serializeThread(std::ostream &os, ThreadID tid)
+BaseKvmCPU::serializeThread(CheckpointOut &cp, ThreadID tid) const
{
if (DTRACE(Checkpoint)) {
DPRINTF(Checkpoint, "KVM: Serializing thread %i:\n", tid);
@@ -268,18 +268,17 @@ BaseKvmCPU::serializeThread(std::ostream &os, ThreadID tid)
assert(tid == 0);
assert(_status == Idle);
- thread->serialize(os);
+ thread->serialize(cp);
}
void
-BaseKvmCPU::unserializeThread(Checkpoint *cp, const std::string &section,
- ThreadID tid)
+BaseKvmCPU::unserializeThread(CheckpointIn &cp, ThreadID tid)
{
DPRINTF(Checkpoint, "KVM: Unserialize thread %i:\n", tid);
assert(tid == 0);
assert(_status == Idle);
- thread->unserialize(cp, section);
+ thread->unserialize(cp);
threadContextDirty = true;
}
@@ -511,7 +510,7 @@ BaseKvmCPU::totalOps() const
}
void
-BaseKvmCPU::dump()
+BaseKvmCPU::dump() const
{
inform("State dumping not implemented.");
}
diff --git a/src/cpu/kvm/base.hh b/src/cpu/kvm/base.hh
index ce32cdbb1..a8e429dfa 100644
--- a/src/cpu/kvm/base.hh
+++ b/src/cpu/kvm/base.hh
@@ -84,9 +84,10 @@ class BaseKvmCPU : public BaseCPU
void startup();
void regStats();
- void serializeThread(std::ostream &os, ThreadID tid);
- void unserializeThread(Checkpoint *cp, const std::string &section,
- ThreadID tid);
+ void serializeThread(CheckpointOut &cp,
+ ThreadID tid) const M5_ATTR_OVERRIDE;
+ void unserializeThread(CheckpointIn &cp,
+ ThreadID tid) M5_ATTR_OVERRIDE;
unsigned int drain(DrainManager *dm);
void drainResume();
@@ -111,7 +112,7 @@ class BaseKvmCPU : public BaseCPU
Counter totalOps() const;
/** Dump the internal state to the terminal. */
- virtual void dump();
+ virtual void dump() const;
/**
* Force an exit from KVM.
diff --git a/src/cpu/kvm/x86_cpu.cc b/src/cpu/kvm/x86_cpu.cc
index 34b51f137..cd46370a4 100644
--- a/src/cpu/kvm/x86_cpu.cc
+++ b/src/cpu/kvm/x86_cpu.cc
@@ -562,7 +562,7 @@ X86KvmCPU::startup()
}
void
-X86KvmCPU::dump()
+X86KvmCPU::dump() const
{
dumpIntRegs();
if (useXSave)
diff --git a/src/cpu/kvm/x86_cpu.hh b/src/cpu/kvm/x86_cpu.hh
index 18471040c..2e93a5f26 100644
--- a/src/cpu/kvm/x86_cpu.hh
+++ b/src/cpu/kvm/x86_cpu.hh
@@ -47,7 +47,7 @@ class X86KvmCPU : public BaseKvmCPU
void startup();
/** @{ */
- void dump();
+ void dump() const M5_ATTR_OVERRIDE;
void dumpFpuRegs() const;
void dumpIntRegs() const;
void dumpSpecRegs() const;