summaryrefslogtreecommitdiff
path: root/src/dev/arm/generic_timer.hh
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/dev/arm/generic_timer.hh
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/dev/arm/generic_timer.hh')
-rw-r--r--src/dev/arm/generic_timer.hh20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/dev/arm/generic_timer.hh b/src/dev/arm/generic_timer.hh
index d8f7f54e2..97823f05f 100644
--- a/src/dev/arm/generic_timer.hh
+++ b/src/dev/arm/generic_timer.hh
@@ -58,7 +58,7 @@ class GenericTimerMemParams;
/// Global system counter. It is shared by the architected timers.
/// @todo: implement memory-mapped controls
-class SystemCounter
+class SystemCounter : public Serializable
{
protected:
/// Counter frequency (as specified by CNTFRQ).
@@ -93,8 +93,8 @@ class SystemCounter
void setKernelControl(uint32_t val) { _regCntkctl = val; }
uint32_t getKernelControl() { return _regCntkctl; }
- void serialize(std::ostream &os) const;
- void unserialize(Checkpoint *cp, const std::string &section);
+ void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+ void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
private:
// Disable copying
@@ -102,7 +102,7 @@ class SystemCounter
};
/// Per-CPU architected timer.
-class ArchTimer
+class ArchTimer : public Serializable
{
public:
class Interrupt
@@ -189,8 +189,8 @@ class ArchTimer
/// Returns the value of the counter which this timer relies on.
uint64_t value() const;
- void serialize(std::ostream &os) const;
- void unserialize(Checkpoint *cp, const std::string &section);
+ void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+ void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
private:
// Disable copying
@@ -202,8 +202,8 @@ class GenericTimer : public SimObject
public:
GenericTimer(GenericTimerParams *p);
- void serialize(std::ostream &os) M5_ATTR_OVERRIDE;
- void unserialize(Checkpoint *cp, const std::string &sec) M5_ATTR_OVERRIDE;
+ void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+ void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
public:
void setMiscReg(int misc_reg, unsigned cpu, ArmISA::MiscReg val);
@@ -279,8 +279,8 @@ class GenericTimerMem : public PioDevice
public:
GenericTimerMem(GenericTimerMemParams *p);
- void serialize(std::ostream &os) M5_ATTR_OVERRIDE;
- void unserialize(Checkpoint *cp, const std::string &sec) M5_ATTR_OVERRIDE;
+ void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+ void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
public: // PioDevice
AddrRangeList getAddrRanges() const M5_ATTR_OVERRIDE { return addrRanges; }