summaryrefslogtreecommitdiff
path: root/src/dev/mips
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/mips
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/mips')
-rwxr-xr-xsrc/dev/mips/malta.cc4
-rwxr-xr-xsrc/dev/mips/malta.hh14
-rwxr-xr-xsrc/dev/mips/malta_cchip.cc4
-rwxr-xr-xsrc/dev/mips/malta_cchip.hh16
-rwxr-xr-xsrc/dev/mips/malta_io.cc12
-rwxr-xr-xsrc/dev/mips/malta_io.hh14
-rwxr-xr-xsrc/dev/mips/malta_pchip.cc4
-rwxr-xr-xsrc/dev/mips/malta_pchip.hh14
8 files changed, 20 insertions, 62 deletions
diff --git a/src/dev/mips/malta.cc b/src/dev/mips/malta.cc
index 277633c6b..0c37e2713 100755
--- a/src/dev/mips/malta.cc
+++ b/src/dev/mips/malta.cc
@@ -91,13 +91,13 @@ Malta::pciToDma(Addr pciAddr) const
}
void
-Malta::serialize(std::ostream &os)
+Malta::serialize(CheckpointOut &cp) const
{
SERIALIZE_ARRAY(intr_sum_type, Malta::Max_CPUs);
}
void
-Malta::unserialize(Checkpoint *cp, const std::string &section)
+Malta::unserialize(CheckpointIn &cp)
{
UNSERIALIZE_ARRAY(intr_sum_type, Malta::Max_CPUs);
}
diff --git a/src/dev/mips/malta.hh b/src/dev/mips/malta.hh
index e612fb295..c5ee92e3d 100755
--- a/src/dev/mips/malta.hh
+++ b/src/dev/mips/malta.hh
@@ -135,18 +135,8 @@ class Malta : public Platform
M5_DUMMY_RETURN
}
- /**
- * Serialize this object to the given output stream.
- * @param os The stream to serialize to.
- */
- virtual void serialize(std::ostream &os);
-
- /**
- * Reconstruct the state of this object from a checkpoint.
- * @param cp The checkpoint use.
- * @param section The section name of this object
- */
- virtual void unserialize(Checkpoint *cp, const std::string &section);
+ void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+ void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
};
#endif // __DEV_MALTA_HH__
diff --git a/src/dev/mips/malta_cchip.cc b/src/dev/mips/malta_cchip.cc
index dc5211122..34f79b65b 100755
--- a/src/dev/mips/malta_cchip.cc
+++ b/src/dev/mips/malta_cchip.cc
@@ -501,7 +501,7 @@ MaltaCChip::clearIntr(uint32_t interrupt)
void
-MaltaCChip::serialize(std::ostream &os)
+MaltaCChip::serialize(CheckpointOut &cp) const
{
// SERIALIZE_ARRAY(dim, Malta::Max_CPUs);
//SERIALIZE_ARRAY(dir, Malta::Max_CPUs);
@@ -511,7 +511,7 @@ MaltaCChip::serialize(std::ostream &os)
}
void
-MaltaCChip::unserialize(Checkpoint *cp, const std::string &section)
+MaltaCChip::unserialize(CheckpointIn &cp)
{
//UNSERIALIZE_ARRAY(dim, Malta::Max_CPUs);
//UNSERIALIZE_ARRAY(dir, Malta::Max_CPUs);
diff --git a/src/dev/mips/malta_cchip.hh b/src/dev/mips/malta_cchip.hh
index 9a17f632f..707cd1048 100755
--- a/src/dev/mips/malta_cchip.hh
+++ b/src/dev/mips/malta_cchip.hh
@@ -133,20 +133,8 @@ class MaltaCChip : public BasicPioDevice
*/
void reqIPI(uint64_t ipreq);
-
- /**
- * Serialize this object to the given output stream.
- * @param os The stream to serialize to.
- */
- virtual void serialize(std::ostream &os);
-
- /**
- * Reconstruct the state of this object from a checkpoint.
- * @param cp The checkpoint use.
- * @param section The section name of this object
- */
- virtual void unserialize(Checkpoint *cp, const std::string &section);
-
+ void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+ void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
};
#endif // __MALTA_CCHIP_HH__
diff --git a/src/dev/mips/malta_io.cc b/src/dev/mips/malta_io.cc
index d79e43260..bd3791163 100755
--- a/src/dev/mips/malta_io.cc
+++ b/src/dev/mips/malta_io.cc
@@ -111,7 +111,7 @@ MaltaIO::clearIntr(uint8_t interrupt)
}
void
-MaltaIO::serialize(ostream &os)
+MaltaIO::serialize(CheckpointOut &cp) const
{
SERIALIZE_SCALAR(timerData);
SERIALIZE_SCALAR(mask1);
@@ -122,12 +122,12 @@ MaltaIO::serialize(ostream &os)
SERIALIZE_SCALAR(picInterrupting);
// Serialize the timers
- pitimer.serialize("pitimer", os);
- rtc.serialize("rtc", os);
+ pitimer.serialize("pitimer", cp);
+ rtc.serialize("rtc", cp);
}
void
-MaltaIO::unserialize(Checkpoint *cp, const string &section)
+MaltaIO::unserialize(CheckpointIn &cp)
{
UNSERIALIZE_SCALAR(timerData);
UNSERIALIZE_SCALAR(mask1);
@@ -138,8 +138,8 @@ MaltaIO::unserialize(Checkpoint *cp, const string &section)
UNSERIALIZE_SCALAR(picInterrupting);
// Unserialize the timers
- pitimer.unserialize("pitimer", cp, section);
- rtc.unserialize("rtc", cp, section);
+ pitimer.unserialize("pitimer", cp);
+ rtc.unserialize("rtc", cp);
}
void
diff --git a/src/dev/mips/malta_io.hh b/src/dev/mips/malta_io.hh
index dd035aea2..bea6733fc 100755
--- a/src/dev/mips/malta_io.hh
+++ b/src/dev/mips/malta_io.hh
@@ -130,18 +130,8 @@ class MaltaIO : public BasicPioDevice
/** Clear an Interrupt to the CPU */
void clearIntr(uint8_t interrupt);
- /**
- * Serialize this object to the given output stream.
- * @param os The stream to serialize to.
- */
- virtual void serialize(std::ostream &os);
-
- /**
- * Reconstruct the state of this object from a checkpoint.
- * @param cp The checkpoint use.
- * @param section The section name of this object
- */
- virtual void unserialize(Checkpoint *cp, const std::string &section);
+ void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+ void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
/**
* Start running.
diff --git a/src/dev/mips/malta_pchip.cc b/src/dev/mips/malta_pchip.cc
index bee61fddd..d0ae3daaa 100755
--- a/src/dev/mips/malta_pchip.cc
+++ b/src/dev/mips/malta_pchip.cc
@@ -312,7 +312,7 @@ MaltaPChip::calcConfigAddr(int bus, int dev, int func)
void
-MaltaPChip::serialize(std::ostream &os)
+MaltaPChip::serialize(CheckpointOut &cp) const
{
SERIALIZE_SCALAR(pctl);
SERIALIZE_ARRAY(wsba, 4);
@@ -321,7 +321,7 @@ MaltaPChip::serialize(std::ostream &os)
}
void
-MaltaPChip::unserialize(Checkpoint *cp, const std::string &section)
+MaltaPChip::unserialize(CheckpointIn &cp)
{
UNSERIALIZE_SCALAR(pctl);
UNSERIALIZE_ARRAY(wsba, 4);
diff --git a/src/dev/mips/malta_pchip.hh b/src/dev/mips/malta_pchip.hh
index a6145515a..368faf9c5 100755
--- a/src/dev/mips/malta_pchip.hh
+++ b/src/dev/mips/malta_pchip.hh
@@ -88,18 +88,8 @@ class MaltaPChip : public BasicPioDevice
virtual Tick read(PacketPtr pkt);
virtual Tick write(PacketPtr pkt);
- /**
- * Serialize this object to the given output stream.
- * @param os The stream to serialize to.
- */
- virtual void serialize(std::ostream &os);
-
- /**
- * Reconstruct the state of this object from a checkpoint.
- * @param cp The checkpoint use.
- * @param section The section name of this object
- */
- virtual void unserialize(Checkpoint *cp, const std::string &section);
+ void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+ void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
};
#endif // __TSUNAMI_PCHIP_HH__