sim: Refactor the serialization base class
authorAndreas Sandberg <andreas.sandberg@arm.com>
Tue, 7 Jul 2015 08:51:03 +0000 (09:51 +0100)
committerAndreas Sandberg <andreas.sandberg@arm.com>
Tue, 7 Jul 2015 08:51:03 +0000 (09:51 +0100)
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.

231 files changed:
src/arch/alpha/interrupts.hh
src/arch/alpha/isa.cc
src/arch/alpha/isa.hh
src/arch/alpha/kernel_stats.cc
src/arch/alpha/kernel_stats.hh
src/arch/alpha/pagetable.cc
src/arch/alpha/pagetable.hh
src/arch/alpha/process.cc
src/arch/alpha/process.hh
src/arch/alpha/system.cc
src/arch/alpha/system.hh
src/arch/alpha/tlb.cc
src/arch/alpha/tlb.hh
src/arch/arm/interrupts.hh
src/arch/arm/isa.hh
src/arch/arm/kvm/gic.cc
src/arch/arm/kvm/gic.hh
src/arch/arm/pagetable.hh
src/arch/arm/pmu.cc
src/arch/arm/pmu.hh
src/arch/arm/tlb.cc
src/arch/arm/tlb.hh
src/arch/arm/types.hh
src/arch/generic/types.hh
src/arch/mips/interrupts.hh
src/arch/mips/pagetable.cc
src/arch/mips/pagetable.hh
src/arch/mips/tlb.cc
src/arch/mips/tlb.hh
src/arch/power/pagetable.cc
src/arch/power/pagetable.hh
src/arch/power/tlb.cc
src/arch/power/tlb.hh
src/arch/sparc/interrupts.hh
src/arch/sparc/isa.cc
src/arch/sparc/isa.hh
src/arch/sparc/pagetable.cc
src/arch/sparc/pagetable.hh
src/arch/sparc/system.cc
src/arch/sparc/system.hh
src/arch/sparc/tlb.cc
src/arch/sparc/tlb.hh
src/arch/x86/interrupts.cc
src/arch/x86/interrupts.hh
src/arch/x86/isa.cc
src/arch/x86/isa.hh
src/arch/x86/pagetable.cc
src/arch/x86/pagetable.hh
src/arch/x86/tlb.cc
src/arch/x86/tlb.hh
src/arch/x86/types.cc
src/arch/x86/types.hh
src/base/cp_annotate.cc
src/base/cp_annotate.hh
src/base/loader/symtab.cc
src/base/loader/symtab.hh
src/base/pollevent.cc
src/base/pollevent.hh
src/base/random.cc
src/base/random.hh
src/base/time.cc
src/base/time.hh
src/cpu/base.cc
src/cpu/base.hh
src/cpu/checker/cpu.cc
src/cpu/checker/cpu.hh
src/cpu/checker/thread_context.hh
src/cpu/kvm/BaseKvmCPU.py
src/cpu/kvm/base.cc
src/cpu/kvm/base.hh
src/cpu/kvm/x86_cpu.cc
src/cpu/kvm/x86_cpu.hh
src/cpu/minor/cpu.cc
src/cpu/minor/cpu.hh
src/cpu/o3/cpu.cc
src/cpu/o3/cpu.hh
src/cpu/o3/thread_state.hh
src/cpu/simple/base.cc
src/cpu/simple/base.hh
src/cpu/simple_thread.cc
src/cpu/simple_thread.hh
src/cpu/testers/traffic_gen/traffic_gen.cc
src/cpu/testers/traffic_gen/traffic_gen.hh
src/cpu/thread_context.cc
src/cpu/thread_context.hh
src/cpu/thread_state.cc
src/cpu/thread_state.hh
src/dev/alpha/backdoor.cc
src/dev/alpha/backdoor.hh
src/dev/alpha/tsunami.cc
src/dev/alpha/tsunami.hh
src/dev/alpha/tsunami_cchip.cc
src/dev/alpha/tsunami_cchip.hh
src/dev/alpha/tsunami_io.cc
src/dev/alpha/tsunami_io.hh
src/dev/alpha/tsunami_pchip.cc
src/dev/alpha/tsunami_pchip.hh
src/dev/arm/energy_ctrl.cc
src/dev/arm/energy_ctrl.hh
src/dev/arm/flash_device.cc
src/dev/arm/flash_device.hh
src/dev/arm/generic_timer.cc
src/dev/arm/generic_timer.hh
src/dev/arm/gic_pl390.cc
src/dev/arm/gic_pl390.hh
src/dev/arm/hdlcd.cc
src/dev/arm/hdlcd.hh
src/dev/arm/kmi.cc
src/dev/arm/kmi.hh
src/dev/arm/pl011.cc
src/dev/arm/pl011.hh
src/dev/arm/pl111.cc
src/dev/arm/pl111.hh
src/dev/arm/rtc_pl031.cc
src/dev/arm/rtc_pl031.hh
src/dev/arm/rv_ctrl.cc
src/dev/arm/rv_ctrl.hh
src/dev/arm/timer_cpulocal.cc
src/dev/arm/timer_cpulocal.hh
src/dev/arm/timer_sp804.cc
src/dev/arm/timer_sp804.hh
src/dev/arm/ufs_device.cc
src/dev/arm/ufs_device.hh
src/dev/arm/vgic.cc
src/dev/arm/vgic.hh
src/dev/copy_engine.cc
src/dev/copy_engine.hh
src/dev/copy_engine_defs.hh
src/dev/disk_image.cc
src/dev/disk_image.hh
src/dev/etherlink.cc
src/dev/etherlink.hh
src/dev/etherpkt.cc
src/dev/etherpkt.hh
src/dev/ethertap.cc
src/dev/ethertap.hh
src/dev/i2cbus.cc
src/dev/i2cbus.hh
src/dev/i8254xGBe.cc
src/dev/i8254xGBe.hh
src/dev/i8254xGBe_defs.hh
src/dev/ide_ctrl.cc
src/dev/ide_ctrl.hh
src/dev/ide_disk.cc
src/dev/ide_disk.hh
src/dev/intel_8254_timer.cc
src/dev/intel_8254_timer.hh
src/dev/mc146818.cc
src/dev/mc146818.hh
src/dev/mips/malta.cc
src/dev/mips/malta.hh
src/dev/mips/malta_cchip.cc
src/dev/mips/malta_cchip.hh
src/dev/mips/malta_io.cc
src/dev/mips/malta_io.hh
src/dev/mips/malta_pchip.cc
src/dev/mips/malta_pchip.hh
src/dev/ns_gige.cc
src/dev/ns_gige.hh
src/dev/pcidev.cc
src/dev/pcidev.hh
src/dev/pktfifo.cc
src/dev/pktfifo.hh
src/dev/sinic.cc
src/dev/sinic.hh
src/dev/sparc/dtod.cc
src/dev/sparc/dtod.hh
src/dev/sparc/iob.cc
src/dev/sparc/iob.hh
src/dev/sparc/mm_disk.cc
src/dev/sparc/mm_disk.hh
src/dev/uart8250.cc
src/dev/uart8250.hh
src/dev/virtio/base.cc
src/dev/virtio/base.hh
src/dev/virtio/fs9p.cc
src/dev/virtio/fs9p.hh
src/dev/x86/cmos.cc
src/dev/x86/cmos.hh
src/dev/x86/i8042.cc
src/dev/x86/i8042.hh
src/dev/x86/i82094aa.cc
src/dev/x86/i82094aa.hh
src/dev/x86/i8237.cc
src/dev/x86/i8237.hh
src/dev/x86/i8254.cc
src/dev/x86/i8254.hh
src/dev/x86/i8259.cc
src/dev/x86/i8259.hh
src/dev/x86/speaker.cc
src/dev/x86/speaker.hh
src/kern/kernel_stats.cc
src/kern/kernel_stats.hh
src/mem/cache/cache.hh
src/mem/cache/cache_impl.hh
src/mem/multi_level_page_table.hh
src/mem/multi_level_page_table_impl.hh
src/mem/page_table.cc
src/mem/page_table.hh
src/mem/physical.cc
src/mem/physical.hh
src/mem/ruby/system/System.cc
src/mem/ruby/system/System.hh
src/python/m5/SimObject.py
src/python/swig/core.i
src/python/swig/pyobject.cc
src/python/swig/pyobject.hh
src/sim/clock_domain.cc
src/sim/clock_domain.hh
src/sim/cxx_manager.cc
src/sim/cxx_manager.hh
src/sim/dvfs_handler.cc
src/sim/dvfs_handler.hh
src/sim/eventq.cc
src/sim/eventq.hh
src/sim/process.cc
src/sim/process.hh
src/sim/root.cc
src/sim/root.hh
src/sim/serialize.cc
src/sim/serialize.hh
src/sim/sim_events.cc
src/sim/sim_events.hh
src/sim/sim_object.cc
src/sim/sim_object.hh
src/sim/system.cc
src/sim/system.hh
src/sim/ticked_object.cc
src/sim/ticked_object.hh
src/sim/voltage_domain.cc
src/sim/voltage_domain.hh

index 3e9c9038127b423e219fb86468d7333bb895568a..1e67f54b5567c6f774e25b678a6d1c92f3821d24 100644 (file)
@@ -121,14 +121,14 @@ class Interrupts : public SimObject
     }
 
     void
-    serialize(std::ostream &os)
+    serialize(CheckpointOut &cp) const
     {
         SERIALIZE_ARRAY(interrupts, NumInterruptLevels);
         SERIALIZE_SCALAR(intstatus);
     }
 
     void
-    unserialize(Checkpoint *cp, const std::string &section)
+    unserialize(CheckpointIn &cp)
     {
         UNSERIALIZE_ARRAY(interrupts, NumInterruptLevels);
         UNSERIALIZE_SCALAR(intstatus);
index 20f03916628161830a6dc8a18a6135402a8359f6..8240037ccf900b64192d7abec2c6e7b31052c507 100644 (file)
@@ -53,7 +53,7 @@ ISA::params() const
 }
 
 void
-ISA::serialize(std::ostream &os)
+ISA::serialize(CheckpointOut &cp) const
 {
     SERIALIZE_SCALAR(fpcr);
     SERIALIZE_SCALAR(uniq);
@@ -63,7 +63,7 @@ ISA::serialize(std::ostream &os)
 }
 
 void
-ISA::unserialize(Checkpoint *cp, const std::string &section)
+ISA::unserialize(CheckpointIn &cp)
 {
     UNSERIALIZE_SCALAR(fpcr);
     UNSERIALIZE_SCALAR(uniq);
index 52e4e98beb7cac67efddbe305c5287d3058917c9..6a88ee40bb0e793c57936a667ddd47e58fefd17b 100644 (file)
@@ -92,8 +92,8 @@ namespace AlphaISA
             memset(ipr, 0, sizeof(ipr));
         }
 
-        void serialize(std::ostream &os);
-        void unserialize(Checkpoint *cp, const std::string &section);
+        void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+        void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 
         int
         flattenIntIndex(int reg) const
index bac5d26cd66d85e1429fdffa75699a5fa3c704d4..94142a0314544ef8aa0d5388a96f670bda23eb51 100644 (file)
@@ -194,9 +194,9 @@ Statistics::callpal(int code, ThreadContext *tc)
 }
 
 void
-Statistics::serialize(ostream &os)
+Statistics::serialize(CheckpointOut &cp) const
 {
-    ::Kernel::Statistics::serialize(os);
+    ::Kernel::Statistics::serialize(cp);
     int exemode = themode;
     SERIALIZE_SCALAR(exemode);
     SERIALIZE_SCALAR(idleProcess);
@@ -204,9 +204,9 @@ Statistics::serialize(ostream &os)
 }
 
 void
-Statistics::unserialize(Checkpoint *cp, const string &section)
+Statistics::unserialize(CheckpointIn &cp)
 {
-    ::Kernel::Statistics::unserialize(cp, section);
+    ::Kernel::Statistics::unserialize(cp);
     int exemode;
     UNSERIALIZE_SCALAR(exemode);
     UNSERIALIZE_SCALAR(idleProcess);
index 8372693098ecc53bc860b7e32142a6c9aec848d3..188d3ec4b9a9dd061d6857c871299f3b4a5c576d 100644 (file)
@@ -86,8 +86,8 @@ class Statistics : public ::Kernel::Statistics
     void setIdleProcess(Addr idle, ThreadContext *tc);
 
   public:
-    void serialize(std::ostream &os);
-    void unserialize(Checkpoint *cp, const std::string &section);
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 };
 
 } // namespace Kernel
index 4dff04777e4b99bc033a81c1cac5e8fd660b3a68..f2b1147f7ad4393a101cc0af362796f37f9eca32 100644 (file)
@@ -34,7 +34,7 @@
 namespace AlphaISA {
 
 void
-TlbEntry::serialize(std::ostream &os)
+TlbEntry::serialize(CheckpointOut &cp) const
 {
     SERIALIZE_SCALAR(tag);
     SERIALIZE_SCALAR(ppn);
@@ -48,7 +48,7 @@ TlbEntry::serialize(std::ostream &os)
 }
 
 void
-TlbEntry::unserialize(Checkpoint *cp, const std::string &section)
+TlbEntry::unserialize(CheckpointIn &cp)
 {
     UNSERIALIZE_SCALAR(tag);
     UNSERIALIZE_SCALAR(ppn);
index ca44de7fad44a5e2080ff5951627c6926cc21cac..0b652404308ab47eb4b2f03e3024ecd85a9dcdcd 100644 (file)
@@ -90,7 +90,7 @@ struct PageTableEntry
 };
 
 // ITB/DTB table entry
-struct TlbEntry
+struct TlbEntry : public Serializable
 {
     Addr tag;               // virtual page number tag
     Addr ppn;               // physical page number
@@ -124,7 +124,10 @@ struct TlbEntry
     }
 
     TlbEntry()
-    {}
+        : tag(0), ppn(0), xre(0), xwe(0), asn(0),
+          asma(false), fonr(0), fonw(0), valid(0)
+    {
+    }
 
     void
     updateVaddr(Addr new_vaddr)
@@ -139,8 +142,8 @@ struct TlbEntry
         return ppn << PageShift;
     }
 
-    void serialize(std::ostream &os);
-    void unserialize(Checkpoint *cp, const std::string &section);
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 };
 
 } // namespace AlphaISA
index f50131be07b6534f8c181eae7203e59f9b3b7d2d..e214c88740e1280317e4e00e4831e9c98001cddb 100644 (file)
@@ -175,7 +175,7 @@ AlphaLiveProcess::setupASNReg()
 
 
 void
-AlphaLiveProcess::loadState(Checkpoint *cp)
+AlphaLiveProcess::loadState(CheckpointIn &cp)
 {
     LiveProcess::loadState(cp);
     // need to set up ASN after unserialization since M5_pid value may
index d3f9fdfc39ee2197c6683ab179bd082e2bb4ca2d..6701017e0406a2ca7097e2ce505375918123c066 100644 (file)
@@ -42,7 +42,7 @@ class AlphaLiveProcess : public LiveProcess
   protected:
     AlphaLiveProcess(LiveProcessParams *params, ObjectFile *objFile);
 
-    void loadState(Checkpoint *cp);
+    void loadState(CheckpointIn &cp) M5_ATTR_OVERRIDE;
     void initState();
 
     void argsInit(int intSize, int pageSize);
index 3ebc02b64b333e6046f76946a76407761e423af1..d2be5492f071fd68a55f3b7cdde76be70e500eab 100644 (file)
@@ -218,17 +218,17 @@ AlphaSystem::setAlphaAccess(Addr access)
 }
 
 void
-AlphaSystem::serializeSymtab(std::ostream &os)
+AlphaSystem::serializeSymtab(CheckpointOut &cp) const
 {
-    consoleSymtab->serialize("console_symtab", os);
-    palSymtab->serialize("pal_symtab", os);
+    consoleSymtab->serialize("console_symtab", cp);
+    palSymtab->serialize("pal_symtab", cp);
 }
 
 void
-AlphaSystem::unserializeSymtab(Checkpoint *cp, const std::string &section)
+AlphaSystem::unserializeSymtab(CheckpointIn &cp)
 {
-    consoleSymtab->unserialize("console_symtab", cp, section);
-    palSymtab->unserialize("pal_symtab", cp, section);
+    consoleSymtab->unserialize("console_symtab", cp);
+    palSymtab->unserialize("pal_symtab", cp);
 }
 
 AlphaSystem *
index 11a5e90a4c57450d19ef772ae507079a2fbc6bc4..3f4a2367ec7b97c926b1cbff9eeb17bfdc8e1ebc 100644 (file)
@@ -60,8 +60,8 @@ class AlphaSystem : public System
     /**
      * Serialization stuff
      */
-    virtual void serializeSymtab(std::ostream &os);
-    virtual void unserializeSymtab(Checkpoint *cp, const std::string &section);
+    void serializeSymtab(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+    void unserializeSymtab(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 
     /** Override startup() to provide a path to call setupFuncEvents()
      */
index a740da388201bca868fa02b0b92600a023a9967b..5f0ed85dbcec91f4363c60e564455721fc2ffc56 100644 (file)
  *          Andrew Schultz
  */
 
+#include "arch/alpha/tlb.hh"
+
+#include <algorithm>
 #include <memory>
 #include <string>
 #include <vector>
 
 #include "arch/alpha/faults.hh"
 #include "arch/alpha/pagetable.hh"
-#include "arch/alpha/tlb.hh"
 #include "arch/generic/debugfaults.hh"
 #include "base/inifile.hh"
 #include "base/str.hh"
@@ -62,17 +64,13 @@ bool uncacheBit40 = false;
 #define MODE2MASK(X) (1 << (X))
 
 TLB::TLB(const Params *p)
-    : BaseTLB(p), size(p->size), nlu(0)
+    : BaseTLB(p), table(p->size), nlu(0)
 {
-    table = new TlbEntry[size];
-    memset(table, 0, sizeof(TlbEntry) * size);
     flushCache();
 }
 
 TLB::~TLB()
 {
-    if (table)
-        delete [] table;
 }
 
 void
@@ -283,7 +281,7 @@ void
 TLB::flushAll()
 {
     DPRINTF(TLB, "flushAll\n");
-    memset(table, 0, sizeof(TlbEntry) * size);
+    std::fill(table.begin(), table.end(), TlbEntry());
     flushCache();
     lookupTable.clear();
     nlu = 0;
@@ -345,25 +343,26 @@ TLB::flushAddr(Addr addr, uint8_t asn)
 
 
 void
-TLB::serialize(ostream &os)
+TLB::serialize(CheckpointOut &cp) const
 {
+    const unsigned size(table.size());
     SERIALIZE_SCALAR(size);
     SERIALIZE_SCALAR(nlu);
 
-    for (int i = 0; i < size; i++) {
-        nameOut(os, csprintf("%s.Entry%d", name(), i));
-        table[i].serialize(os);
-    }
+    for (int i = 0; i < size; i++)
+        table[i].serializeSection(cp, csprintf("Entry%d", i));
 }
 
 void
-TLB::unserialize(Checkpoint *cp, const string &section)
+TLB::unserialize(CheckpointIn &cp)
 {
+    unsigned size(0);
     UNSERIALIZE_SCALAR(size);
     UNSERIALIZE_SCALAR(nlu);
 
+    table.resize(size);
     for (int i = 0; i < size; i++) {
-        table[i].unserialize(cp, csprintf("%s.Entry%d", section, i));
+        table[i].unserializeSection(cp, csprintf("Entry%d", i));
         if (table[i].valid) {
             lookupTable.insert(make_pair(table[i].tag, i));
         }
index ccd4362d387a3ce94e6d54570a3cb9835147f491..73ffda1f61237602678a8da15ce52d303f79e0f1 100644 (file)
@@ -74,11 +74,10 @@ class TLB : public BaseTLB
     typedef std::multimap<Addr, int> PageTable;
     PageTable lookupTable;  // Quick lookup into page table
 
-    TlbEntry *table;        // the Page Table
-    int size;               // TLB Size
+    std::vector<TlbEntry> table; // the Page Table
     int nlu;                // not last used entry (for replacement)
 
-    void nextnlu() { if (++nlu >= size) nlu = 0; }
+    void nextnlu() { if (++nlu >= table.size()) nlu = 0; }
     TlbEntry *lookup(Addr vpn, uint8_t asn);
 
   public:
@@ -90,7 +89,7 @@ class TLB : public BaseTLB
 
     virtual void regStats();
 
-    int getsize() const { return size; }
+    int getsize() const { return table.size(); }
 
     TlbEntry &index(bool advance = true);
     void insert(Addr vaddr, TlbEntry &entry);
@@ -118,8 +117,8 @@ class TLB : public BaseTLB
     static Fault checkCacheability(RequestPtr &req, bool itb = false);
 
     // Checkpointing
-    virtual void serialize(std::ostream &os);
-    virtual void unserialize(Checkpoint *cp, const std::string &section);
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 
     // Most recently used page table entries
     TlbEntry *EntryCache[3];
index f93ea5c8f4a17dd3d17e94afef79c4eaf40a069f..d5d2dac348c275904fa6493d4cf674fdc8d5790a 100644 (file)
@@ -272,14 +272,14 @@ class Interrupts : public SimObject
     }
 
     void
-    serialize(std::ostream &os)
+    serialize(CheckpointOut &cp) const
     {
         SERIALIZE_ARRAY(interrupts, NumInterruptTypes);
         SERIALIZE_SCALAR(intStatus);
     }
 
     void
-    unserialize(Checkpoint *cp, const std::string &section)
+    unserialize(CheckpointIn &cp)
     {
         UNSERIALIZE_ARRAY(interrupts, NumInterruptTypes);
         UNSERIALIZE_SCALAR(intStatus);
index 11f25de6d62fa12620a3f2ab81c2c05ba2c619c1..a07017c17dadbf8a1a6cd4e16250fb54ee7f290a 100644 (file)
@@ -402,7 +402,7 @@ namespace ArmISA
             return flat_idx;
         }
 
-        void serialize(std::ostream &os)
+        void serialize(CheckpointOut &cp) const
         {
             DPRINTF(Checkpoint, "Serializing Arm Misc Registers\n");
             SERIALIZE_ARRAY(miscRegs, NumMiscRegs);
@@ -413,7 +413,7 @@ namespace ArmISA
             SERIALIZE_SCALAR(haveLargeAsid64);
             SERIALIZE_SCALAR(physAddrRange64);
         }
-        void unserialize(Checkpoint *cp, const std::string &section)
+        void unserialize(CheckpointIn &cp)
         {
             DPRINTF(Checkpoint, "Unserializing Arm Misc Registers\n");
             UNSERIALIZE_ARRAY(miscRegs, NumMiscRegs);
index 9010d8df8b8ecbd2fedd0df493b243a4224543e2..a0e0e789973730cc7042f8f3381cd6c273304954 100644 (file)
@@ -66,13 +66,13 @@ KvmGic::~KvmGic()
 }
 
 void
-KvmGic::serialize(std::ostream &os)
+KvmGic::serialize(CheckpointOut &cp) const
 {
     panic("Checkpointing unsupported\n");
 }
 
 void
-KvmGic::unserialize(Checkpoint *cp, const std::string &sec)
+KvmGic::unserialize(CheckpointIn &cp)
 {
     panic("Checkpointing unsupported\n");
 }
index 3b196d1087faf8968fbafe91bcb8a5c43416dc8e..4a115c87c3bc746c7335e05b4d70183d0261bc60 100644 (file)
@@ -79,7 +79,7 @@ class KvmGic : public BaseGic
     void startup() M5_ATTR_OVERRIDE { verifyMemoryMode(); }
     void drainResume() M5_ATTR_OVERRIDE { verifyMemoryMode(); }
 
-    void serialize(std::ostream &os) M5_ATTR_OVERRIDE;
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
     void unserialize(Checkpoint *cp, const std::string &sec)  M5_ATTR_OVERRIDE;
 
   public: // PioDevice
index c1956cf095e017f7965f0eb046ceaf09a0ac16ba..3de993d27c696a9d7f091f28d7ffd45222822d84 100644 (file)
@@ -61,12 +61,12 @@ struct VAddr
 // ITB/DTB page table entry
 struct PTE
 {
-    void serialize(std::ostream &os)
+    void serialize(CheckpointOut &cp) const
     {
         panic("Need to implement PTE serialization\n");
     }
 
-    void unserialize(Checkpoint *cp, const std::string &section)
+    void unserialize(CheckpointIn &cp)
     {
         panic("Need to implement PTE serialization\n");
     }
@@ -83,7 +83,7 @@ enum LookupLevel {
 };
 
 // ITB/DTB table entry
-struct TlbEntry
+struct TlbEntry : public Serializable
 {
   public:
     enum class MemoryType : std::uint8_t {
@@ -284,7 +284,7 @@ struct TlbEntry
     }
 
     void
-    serialize(std::ostream &os)
+    serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE
     {
         SERIALIZE_SCALAR(longDescFormat);
         SERIALIZE_SCALAR(pfn);
@@ -311,10 +311,10 @@ struct TlbEntry
         SERIALIZE_SCALAR(ap);
         SERIALIZE_SCALAR(hap);
         uint8_t domain_ = static_cast<uint8_t>(domain);
-        paramOut(os, "domain", domain_);
+        paramOut(cp, "domain", domain_);
     }
     void
-    unserialize(Checkpoint *cp, const std::string &section)
+    unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE
     {
         UNSERIALIZE_SCALAR(longDescFormat);
         UNSERIALIZE_SCALAR(pfn);
@@ -341,7 +341,7 @@ struct TlbEntry
         UNSERIALIZE_SCALAR(ap);
         UNSERIALIZE_SCALAR(hap);
         uint8_t domain_;
-        paramIn(cp, section, "domain", domain_);
+        paramIn(cp, "domain", domain_);
         domain = static_cast<DomainType>(domain_);
     }
 
index d20f4e27d68de561aa514a58af055b2778c73391..6ea053e552de62b697eeee9c497dbd7f97e67b3a 100644 (file)
@@ -513,7 +513,7 @@ PMU::raiseInterrupt()
 }
 
 void
-PMU::serialize(std::ostream &os)
+PMU::serialize(CheckpointOut &cp) const
 {
     DPRINTF(Checkpoint, "Serializing Arm PMU\n");
 
@@ -525,17 +525,14 @@ PMU::serialize(std::ostream &os)
     SERIALIZE_SCALAR(reg_pmceid);
     SERIALIZE_SCALAR(clock_remainder);
 
-    for (size_t i = 0; i < counters.size(); ++i) {
-        nameOut(os, csprintf("%s.counters.%i", name(), i));
-        counters[i].serialize(os);
-    }
+    for (size_t i = 0; i < counters.size(); ++i)
+        counters[i].serializeSection(cp, csprintf("counters.%i", i));
 
-    nameOut(os, csprintf("%s.cycleCounter", name()));
-    cycleCounter.serialize(os);
+    cycleCounter.serializeSection(cp, "cycleCounter");
 }
 
 void
-PMU::unserialize(Checkpoint *cp, const std::string &section)
+PMU::unserialize(CheckpointIn &cp)
 {
     DPRINTF(Checkpoint, "Unserializing Arm PMU\n");
 
@@ -548,13 +545,13 @@ PMU::unserialize(Checkpoint *cp, const std::string &section)
     UNSERIALIZE_SCALAR(clock_remainder);
 
     for (size_t i = 0; i < counters.size(); ++i)
-        counters[i].unserialize(cp, csprintf("%s.counters.%i", section, i));
+        counters[i].unserializeSection(cp, csprintf("counters.%i", i));
 
-    cycleCounter.unserialize(cp, csprintf("%s.cycleCounter", section));
+    cycleCounter.unserializeSection(cp, "cycleCounter");
 }
 
 void
-PMU::CounterState::serialize(std::ostream &os)
+PMU::CounterState::serialize(CheckpointOut &cp) const
 {
     SERIALIZE_SCALAR(eventId);
     SERIALIZE_SCALAR(value);
@@ -563,7 +560,7 @@ PMU::CounterState::serialize(std::ostream &os)
 }
 
 void
-PMU::CounterState::unserialize(Checkpoint *cp, const std::string &section)
+PMU::CounterState::unserialize(CheckpointIn &cp)
 {
     UNSERIALIZE_SCALAR(eventId);
     UNSERIALIZE_SCALAR(value);
index 94f8c239748b4a91235fe4f441becac99993c96a..80be965a4fff8c3a68044416d4b22ca3eedaa84e 100644 (file)
@@ -96,8 +96,8 @@ class PMU : public SimObject, public ArmISA::BaseISADevice {
     void addEventProbe(unsigned int id, SimObject *obj, const char *name);
 
   public: // SimObject and related interfaces
-    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;
 
     void drainResume() M5_ATTR_OVERRIDE;
 
@@ -321,7 +321,7 @@ class PMU : public SimObject, public ArmISA::BaseISADevice {
     };
 
     /** State of a counter within the PMU. */
-    struct CounterState {
+    struct CounterState : public Serializable {
         CounterState()
             : eventId(0), filter(0), value(0), enabled(false),
               overflow64(false) {
@@ -329,8 +329,8 @@ class PMU : public SimObject, public ArmISA::BaseISADevice {
             listeners.reserve(4);
         }
 
-        void serialize(std::ostream &os);
-        void unserialize(Checkpoint *cp, const std::string &section);
+        void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+        void unserialize(CheckpointIn &cp)  M5_ATTR_OVERRIDE;
 
         /**
          * Add an event count to the counter and check for overflow.
index 9a706a16624bfe2c20d10cb3574d06a57dc9c16a..11075f02cf48a8211034c3227012324e65681f9c 100644 (file)
@@ -383,7 +383,7 @@ TLB::takeOverFrom(BaseTLB *_otlb)
 }
 
 void
-TLB::serialize(ostream &os)
+TLB::serialize(CheckpointOut &cp) const
 {
     DPRINTF(Checkpoint, "Serializing Arm TLB\n");
 
@@ -394,14 +394,12 @@ TLB::serialize(ostream &os)
 
     int num_entries = size;
     SERIALIZE_SCALAR(num_entries);
-    for(int i = 0; i < size; i++){
-        nameOut(os, csprintf("%s.TlbEntry%d", name(), i));
-        table[i].serialize(os);
-    }
+    for(int i = 0; i < size; i++)
+        table[i].serializeSection(cp, csprintf("TlbEntry%d", i));
 }
 
 void
-TLB::unserialize(Checkpoint *cp, const string &section)
+TLB::unserialize(CheckpointIn &cp)
 {
     DPRINTF(Checkpoint, "Unserializing Arm TLB\n");
 
@@ -412,9 +410,8 @@ TLB::unserialize(Checkpoint *cp, const string &section)
 
     int num_entries;
     UNSERIALIZE_SCALAR(num_entries);
-    for(int i = 0; i < min(size, num_entries); i++){
-        table[i].unserialize(cp, csprintf("%s.TlbEntry%d", section, i));
-    }
+    for(int i = 0; i < min(size, num_entries); i++)
+        table[i].unserializeSection(cp, csprintf("TlbEntry%d", i));
 }
 
 void
index 5d418ef176b1c7bb7d9fd6b847bdab7b76b2c0cf..28b99a8e05bb7245eec1acc9344f4636f1dfedbf 100644 (file)
@@ -287,8 +287,8 @@ class TLB : public BaseTLB
     void drainResume();
 
     // Checkpointing
-    void serialize(std::ostream &os);
-    void unserialize(Checkpoint *cp, const std::string &section);
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 
     void regStats();
 
index eff8f13fbc2308841169cfa9beb18b3cd6eda210..c54bfb5f4252a34d27546ea36c9b8cce5571c4e9 100644 (file)
@@ -483,9 +483,9 @@ namespace ArmISA
         }
 
         void
-        serialize(std::ostream &os)
+        serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE
         {
-            Base::serialize(os);
+            Base::serialize(cp);
             SERIALIZE_SCALAR(flags);
             SERIALIZE_SCALAR(_size);
             SERIALIZE_SCALAR(nextFlags);
@@ -494,9 +494,9 @@ namespace ArmISA
         }
 
         void
-        unserialize(Checkpoint *cp, const std::string &section)
+        unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE
         {
-            Base::unserialize(cp, section);
+            Base::unserialize(cp);
             UNSERIALIZE_SCALAR(flags);
             UNSERIALIZE_SCALAR(_size);
             UNSERIALIZE_SCALAR(nextFlags);
index 0381e9953c6958b28accf295e8bfcb6680adf43d..8e35b5b2fbebda6a4fb7996e852cdd6fa1f9e440 100644 (file)
@@ -41,7 +41,7 @@ namespace GenericISA
 {
 
 // The guaranteed interface.
-class PCStateBase
+class PCStateBase : public Serializable
 {
   protected:
     Addr _pc;
@@ -105,14 +105,14 @@ class PCStateBase
     }
 
     void
-    serialize(std::ostream &os)
+    serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE
     {
         SERIALIZE_SCALAR(_pc);
         SERIALIZE_SCALAR(_npc);
     }
 
     void
-    unserialize(Checkpoint *cp, const std::string &section)
+    unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE
     {
         UNSERIALIZE_SCALAR(_pc);
         UNSERIALIZE_SCALAR(_npc);
@@ -248,17 +248,17 @@ class UPCState : public SimplePCState<MachInst>
     }
 
     void
-    serialize(std::ostream &os)
+    serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE
     {
-        Base::serialize(os);
+        Base::serialize(cp);
         SERIALIZE_SCALAR(_upc);
         SERIALIZE_SCALAR(_nupc);
     }
 
     void
-    unserialize(Checkpoint *cp, const std::string &section)
+    unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE
     {
-        Base::unserialize(cp, section);
+        Base::unserialize(cp);
         UNSERIALIZE_SCALAR(_upc);
         UNSERIALIZE_SCALAR(_nupc);
     }
@@ -329,16 +329,16 @@ class DelaySlotPCState : public SimplePCState<MachInst>
     }
 
     void
-    serialize(std::ostream &os)
+    serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE
     {
-        Base::serialize(os);
+        Base::serialize(cp);
         SERIALIZE_SCALAR(_nnpc);
     }
 
     void
-    unserialize(Checkpoint *cp, const std::string &section)
+    unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE
     {
-        Base::unserialize(cp, section);
+        Base::unserialize(cp);
         UNSERIALIZE_SCALAR(_nnpc);
     }
 };
@@ -426,17 +426,17 @@ class DelaySlotUPCState : public DelaySlotPCState<MachInst>
     }
 
     void
-    serialize(std::ostream &os)
+    serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE
     {
-        Base::serialize(os);
+        Base::serialize(cp);
         SERIALIZE_SCALAR(_upc);
         SERIALIZE_SCALAR(_nupc);
     }
 
     void
-    unserialize(Checkpoint *cp, const std::string &section)
+    unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE
     {
-        Base::unserialize(cp, section);
+        Base::unserialize(cp);
         UNSERIALIZE_SCALAR(_upc);
         UNSERIALIZE_SCALAR(_nupc);
     }
index 8367bf91c8617fd42a2c1d119b5ff8ab86489e0d..3c9165bfa35bfc50045054893fdfb70ecf532056 100755 (executable)
@@ -116,13 +116,13 @@ class Interrupts : public SimObject
 
 
     void
-    serialize(std::ostream &os)
+    serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE
     {
         fatal("Serialization of Interrupts Unimplemented for MIPS");
     }
 
     void
-    unserialize(Checkpoint *cp, const std::string &section)
+    unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE
     {
         fatal("Unserialization of Interrupts Unimplemented for MIPS");
     }
index b4304060cb90ffabc73d04ae905034ee52c6ab59..26d9bf40874e30830eccc28d4df9d0c2297d95b0 100644 (file)
@@ -38,7 +38,7 @@ namespace MipsISA
 {
 
 void
-PTE::serialize(std::ostream &os)
+PTE::serialize(CheckpointOut &cp) const
 {
     SERIALIZE_SCALAR(Mask);
     SERIALIZE_SCALAR(VPN);
@@ -57,7 +57,7 @@ PTE::serialize(std::ostream &os)
 }
 
 void
-PTE::unserialize(Checkpoint *cp, const std::string &section)
+PTE::unserialize(CheckpointIn &cp)
 {
     UNSERIALIZE_SCALAR(Mask);
     UNSERIALIZE_SCALAR(VPN);
index 992d6649ba54927dcd6631784cd55a272258db07..cc4e4a859bdbec094ac02357ba344d7a59f4bff2 100755 (executable)
@@ -74,8 +74,8 @@ struct PTE
     int OffsetMask;
 
     bool Valid() { return (V0 | V1); };
-    void serialize(std::ostream &os);
-    void unserialize(Checkpoint *cp, const std::string &section);
+    void serialize(CheckpointOut &cp) const;
+    void unserialize(CheckpointIn &cp);
 };
 
 // WARN: This particular TLB entry is not necessarily conformed to MIPS ISA
@@ -100,12 +100,12 @@ struct TlbEntry
     void
     updateVaddr(Addr new_vaddr) {}
 
-    void serialize(std::ostream &os)
+    void serialize(CheckpointOut &cp) const
     {
         SERIALIZE_SCALAR(_pageStart);
     }
 
-    void unserialize(Checkpoint *cp, const std::string &section)
+    void unserialize(CheckpointIn &cp)
     {
         UNSERIALIZE_SCALAR(_pageStart);
     }
index 6c46cacc652972935d7e7d4d3c6950bc606323bf..d2aa5ad709fb9900c002ea3cac037dd6cd2c6958 100644 (file)
@@ -197,25 +197,26 @@ TLB::flushAll()
 }
 
 void
-TLB::serialize(ostream &os)
+TLB::serialize(CheckpointOut &cp) const
 {
     SERIALIZE_SCALAR(size);
     SERIALIZE_SCALAR(nlu);
 
     for (int i = 0; i < size; i++) {
-        nameOut(os, csprintf("%s.PTE%d", name(), i));
-        table[i].serialize(os);
+        ScopedCheckpointSection sec(cp, csprintf("PTE%d", i));
+        table[i].serialize(cp);
     }
 }
 
 void
-TLB::unserialize(Checkpoint *cp, const string &section)
+TLB::unserialize(CheckpointIn &cp)
 {
     UNSERIALIZE_SCALAR(size);
     UNSERIALIZE_SCALAR(nlu);
 
     for (int i = 0; i < size; i++) {
-        table[i].unserialize(cp, csprintf("%s.PTE%d", section, i));
+        ScopedCheckpointSection sec(cp, csprintf("PTE%d", i));
+        table[i].unserialize(cp);
         if (table[i].V0 || table[i].V1) {
             lookupTable.insert(make_pair(table[i].VPN, i));
         }
index c7cd5e63189c8eacd64682c9c8e5f30d69791779..5a9069e4ca70843ed23420259a9ad977cbe9bbb3 100644 (file)
@@ -107,8 +107,8 @@ class TLB : public BaseTLB
     static Fault checkCacheability(RequestPtr &req);
 
     // Checkpointing
-    void serialize(std::ostream &os);
-    void unserialize(Checkpoint *cp, const std::string &section);
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 
     void regStats();
 
index 091fb8bc875f57e7368742236e23f1facb7dfd72..4af0b7919ec5a3b0ce77b37b348076d5bc74d7a2 100644 (file)
@@ -42,7 +42,7 @@ namespace PowerISA
 {
 
 void
-PTE::serialize(std::ostream &os)
+PTE::serialize(CheckpointOut &cp) const
 {
     SERIALIZE_SCALAR(Mask);
     SERIALIZE_SCALAR(VPN);
@@ -61,7 +61,7 @@ PTE::serialize(std::ostream &os)
 }
 
 void
-PTE::unserialize(Checkpoint *cp, const std::string &section)
+PTE::unserialize(CheckpointIn &cp)
 {
     UNSERIALIZE_SCALAR(Mask);
     UNSERIALIZE_SCALAR(VPN);
index 3097aa5263dea67e8e49fdcbefb0340d0f30bf54..d835a531601f2e58620d7362a6f90d0ec3ba3406 100644 (file)
@@ -146,9 +146,8 @@ struct PTE
         return (V0 | V1);
     };
 
-    void serialize(std::ostream &os);
-
-    void unserialize(Checkpoint *cp, const std::string &section);
+    void serialize(CheckpointOut &cp) const;
+    void unserialize(CheckpointIn &cp);
 };
 
 } // namespace PowerISA
index 458ed29bfc6e8c2cb14bce6b3a876c019e4c065f..edfb4f453dd4983c5ef94d2c87f1b0a3c00d4ab2 100644 (file)
@@ -195,25 +195,25 @@ TLB::flushAll()
 }
 
 void
-TLB::serialize(ostream &os)
+TLB::serialize(CheckpointOut &cp) const
 {
     SERIALIZE_SCALAR(size);
     SERIALIZE_SCALAR(nlu);
 
     for (int i = 0; i < size; i++) {
-        nameOut(os, csprintf("%s.PTE%d", name(), i));
-        table[i].serialize(os);
+        ScopedCheckpointSection sec(cp, csprintf("PTE%d", i));
+        table[i].serialize(cp);
     }
 }
 
 void
-TLB::unserialize(Checkpoint *cp, const string &section)
+TLB::unserialize(CheckpointIn &cp)
 {
     UNSERIALIZE_SCALAR(size);
     UNSERIALIZE_SCALAR(nlu);
 
     for (int i = 0; i < size; i++) {
-        table[i].unserialize(cp, csprintf("%s.PTE%d", section, i));
+        ScopedCheckpointSection sec(cp, csprintf("PTE%d", i));
         if (table[i].V0 || table[i].V1) {
             lookupTable.insert(make_pair(table[i].VPN, i));
         }
index 9818774d8e35a604f1903c3a17f2e981e6b34b9b..a07dad9543954305aed54b5d04347d18212eafa1 100644 (file)
@@ -84,13 +84,13 @@ struct TlbEntry
     }
 
     void
-    serialize(std::ostream &os)
+    serialize(CheckpointOut &cp) const
     {
         SERIALIZE_SCALAR(_pageStart);
     }
 
     void
-    unserialize(Checkpoint *cp, const std::string &section)
+    unserialize(CheckpointIn &cp)
     {
         UNSERIALIZE_SCALAR(_pageStart);
     }
@@ -172,8 +172,9 @@ class TLB : public BaseTLB
     Fault finalizePhysical(RequestPtr req, ThreadContext *tc, Mode mode) const;
 
     // Checkpointing
-    void serialize(std::ostream &os);
-    void unserialize(Checkpoint *cp, const std::string &section);
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
+
     void regStats();
 };
 
index 56cbbf0eb59d382eb8145e26cf3193d6f5a3bc94..432132f66ca9dc84d56dc8225e5986bea59a80ff 100644 (file)
@@ -191,14 +191,14 @@ class Interrupts : public SimObject
     }
 
     void
-    serialize(std::ostream &os)
+    serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE
     {
         SERIALIZE_ARRAY(interrupts,NumInterruptTypes);
         SERIALIZE_SCALAR(intStatus);
     }
 
     void
-    unserialize(Checkpoint *cp, const std::string &section)
+    unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE
     {
         UNSERIALIZE_ARRAY(interrupts,NumInterruptTypes);
         UNSERIALIZE_SCALAR(intStatus);
index c9a3a33b4cc2e0d90e4607f69a850447cb7d0b20..a588eaf666402c4c56671966d2628e0121f263b2 100644 (file)
@@ -638,7 +638,7 @@ ISA::setMiscReg(int miscReg, MiscReg val, ThreadContext * tc)
 }
 
 void
-ISA::serialize(std::ostream &os)
+ISA::serialize(CheckpointOut &cp) const
 {
     SERIALIZE_SCALAR(asi);
     SERIALIZE_SCALAR(tick);
@@ -714,7 +714,7 @@ ISA::serialize(std::ostream &os)
 }
 
 void
-ISA::unserialize(Checkpoint *cp, const std::string &section)
+ISA::unserialize(CheckpointIn &cp)
 {
     UNSERIALIZE_SCALAR(asi);
     UNSERIALIZE_SCALAR(tick);
index 4551cf3c151fae5470f0d00f2d4473604b1a2645..1d2a457d20d00130f62029f6bc2e0349f56b1db9 100644 (file)
@@ -167,9 +167,8 @@ class ISA : public SimObject
 
     void clear();
 
-    void serialize(std::ostream & os);
-
-    void unserialize(Checkpoint *cp, const std::string & section);
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 
     void startup(ThreadContext *tc) {}
 
index bdd3e97fe4920c4a8aa88315e74382e47226b1b5..f0d2c10cf96c3718e23d05d31fb0c085542fb196 100644 (file)
@@ -35,7 +35,7 @@ namespace SparcISA
 {
 
 void
-TlbEntry::serialize(std::ostream &os)
+TlbEntry::serialize(CheckpointOut &cp) const
 {
     SERIALIZE_SCALAR(range.va);
     SERIALIZE_SCALAR(range.size);
@@ -52,7 +52,7 @@ TlbEntry::serialize(std::ostream &os)
 
 
 void
-TlbEntry::unserialize(Checkpoint *cp, const std::string &section)
+TlbEntry::unserialize(CheckpointIn &cp)
 {
     UNSERIALIZE_SCALAR(range.va);
     UNSERIALIZE_SCALAR(range.size);
index 727727f951765a53f741177c21b7d65c805e235c..79b4d3cc5aa3b7a09027c57662bc3a8a2c9f3b4b 100644 (file)
@@ -277,8 +277,8 @@ struct TlbEntry
         range.va = new_vaddr;
     }
 
-    void serialize(std::ostream &os);
-    void unserialize(Checkpoint *cp, const std::string &section);
+    void serialize(CheckpointOut &cp) const;
+    void unserialize(CheckpointIn &cp);
 };
 
 } // namespace SparcISA
index 0b36df9cabe8366f329081c1208e0176b8240dfc..b6fa645cec8cc9585e4cb14131f8f38ddcae4ece 100644 (file)
@@ -177,26 +177,26 @@ SparcSystem::~SparcSystem()
 }
 
 void
-SparcSystem::serializeSymtab(std::ostream &os)
+SparcSystem::serializeSymtab(CheckpointOut &cp) const
 {
-    resetSymtab->serialize("reset_symtab", os);
-    hypervisorSymtab->serialize("hypervisor_symtab", os);
-    openbootSymtab->serialize("openboot_symtab", os);
-    nvramSymtab->serialize("nvram_symtab", os);
-    hypervisorDescSymtab->serialize("hypervisor_desc_symtab", os);
-    partitionDescSymtab->serialize("partition_desc_symtab", os);
+    resetSymtab->serialize("reset_symtab", cp);
+    hypervisorSymtab->serialize("hypervisor_symtab", cp);
+    openbootSymtab->serialize("openboot_symtab", cp);
+    nvramSymtab->serialize("nvram_symtab", cp);
+    hypervisorDescSymtab->serialize("hypervisor_desc_symtab", cp);
+    partitionDescSymtab->serialize("partition_desc_symtab", cp);
 }
 
 
 void
-SparcSystem::unserializeSymtab(Checkpoint *cp, const std::string &section)
+SparcSystem::unserializeSymtab(CheckpointIn &cp)
 {
-    resetSymtab->unserialize("reset_symtab", cp, section);
-    hypervisorSymtab->unserialize("hypervisor_symtab", cp, section);
-    openbootSymtab->unserialize("openboot_symtab", cp, section);
-    nvramSymtab->unserialize("nvram_symtab", cp, section);
-    hypervisorDescSymtab->unserialize("hypervisor_desc_symtab", cp, section);
-    partitionDescSymtab->unserialize("partition_desc_symtab", cp, section);
+    resetSymtab->unserialize("reset_symtab", cp);
+    hypervisorSymtab->unserialize("hypervisor_symtab", cp);
+    openbootSymtab->unserialize("openboot_symtab", cp);
+    nvramSymtab->unserialize("nvram_symtab", cp);
+    hypervisorDescSymtab->unserialize("hypervisor_desc_symtab", cp);
+    partitionDescSymtab->unserialize("partition_desc_symtab", cp);
 }
 
 SparcSystem *
index a4bd64aa56c81f3e3250a48f74a7a734f8989cd6..68688cc1fa6ddf070299d9d587892f1907d05b83 100644 (file)
@@ -54,8 +54,8 @@ class SparcSystem : public System
  * Serialization stuff
  */
   public:
-    virtual void serializeSymtab(std::ostream &os);
-    virtual void unserializeSymtab(Checkpoint *cp, const std::string &section);
+    void serializeSymtab(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+    void unserializeSymtab(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 
     /** reset binary symbol table */
     SymbolTable *resetSymtab;
index 84d748dd376157997f49adf054920868a7987e5c..c0c28f95261e6111b54fc3eeaeb7417924677e37 100644 (file)
@@ -1353,23 +1353,18 @@ TLB::MakeTsbPtr(TsbPageSize ps, uint64_t tag_access, uint64_t c0_tsb,
 }
 
 void
-TLB::serialize(std::ostream &os)
+TLB::serialize(CheckpointOut &cp) const
 {
     SERIALIZE_SCALAR(size);
     SERIALIZE_SCALAR(usedEntries);
     SERIALIZE_SCALAR(lastReplaced);
 
     // convert the pointer based free list into an index based one
-    int *free_list = (int*)malloc(sizeof(int) * size);
-    int cntr = 0;
-    std::list<TlbEntry*>::iterator i;
-    i = freeList.begin();
-    while (i != freeList.end()) {
-        free_list[cntr++] = ((size_t)*i - (size_t)tlb)/ sizeof(TlbEntry);
-        i++;
-    }
-    SERIALIZE_SCALAR(cntr);
-    SERIALIZE_ARRAY(free_list,  cntr);
+    std::vector<int> free_list;
+    for (const TlbEntry *entry : freeList)
+        free_list.push_back(entry - tlb);
+
+    SERIALIZE_CONTAINER(free_list);
 
     SERIALIZE_SCALAR(c0_tsb_ps0);
     SERIALIZE_SCALAR(c0_tsb_ps1);
@@ -1381,31 +1376,28 @@ TLB::serialize(std::ostream &os)
     SERIALIZE_SCALAR(tag_access);
 
     for (int x = 0; x < size; x++) {
-        nameOut(os, csprintf("%s.PTE%d", name(), x));
-        tlb[x].serialize(os);
+        ScopedCheckpointSection sec(cp, csprintf("PTE%d", x));
+        tlb[x].serialize(cp);
     }
     SERIALIZE_SCALAR(sfar);
 }
 
 void
-TLB::unserialize(Checkpoint *cp, const std::string &section)
+TLB::unserialize(CheckpointIn &cp)
 {
     int oldSize;
 
-    paramIn(cp, section, "size", oldSize);
+    paramIn(cp, "size", oldSize);
     if (oldSize != size)
         panic("Don't support unserializing different sized TLBs\n");
     UNSERIALIZE_SCALAR(usedEntries);
     UNSERIALIZE_SCALAR(lastReplaced);
 
-    int cntr;
-    UNSERIALIZE_SCALAR(cntr);
-
-    int *free_list = (int*)malloc(sizeof(int) * cntr);
+    std::vector<int> free_list;
+    UNSERIALIZE_CONTAINER(free_list);
     freeList.clear();
-    UNSERIALIZE_ARRAY(free_list,  cntr);
-    for (int x = 0; x < cntr; x++)
-        freeList.push_back(&tlb[free_list[x]]);
+    for (int idx : free_list)
+        freeList.push_back(&tlb[idx]);
 
     UNSERIALIZE_SCALAR(c0_tsb_ps0);
     UNSERIALIZE_SCALAR(c0_tsb_ps1);
@@ -1418,7 +1410,8 @@ TLB::unserialize(Checkpoint *cp, const std::string &section)
 
     lookupTable.clear();
     for (int x = 0; x < size; x++) {
-        tlb[x].unserialize(cp, csprintf("%s.PTE%d", section, x));
+        ScopedCheckpointSection sec(cp, csprintf("PTE%d", x));
+        tlb[x].unserialize(cp);
         if (tlb[x].valid)
             lookupTable.insert(tlb[x].range, &tlb[x]);
 
index 1d229fba7d4d5a35f75e0d23a43a5f21bb41cb27..e64d3f1b4709dc366d4d6b5c656ef248b4bbf4e2 100644 (file)
@@ -176,8 +176,8 @@ class TLB : public BaseTLB
     void GetTsbPtr(ThreadContext *tc, Addr addr, int ctx, Addr *ptrs);
 
     // Checkpointing
-    virtual void serialize(std::ostream &os);
-    virtual void unserialize(Checkpoint *cp, const std::string &section);
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 
     /** Give an entry id, read that tlb entries' tte */
     uint64_t TteRead(int entry);
index 171e8a1c59948c78aa5b008e1dc8da209f3ea0cf..556cdda3769a94b2f2e3d2ecc8cf20e5410aa9be 100644 (file)
@@ -729,7 +729,7 @@ X86ISA::Interrupts::updateIntrInfo(ThreadContext *tc)
 }
 
 void
-X86ISA::Interrupts::serialize(std::ostream &os)
+X86ISA::Interrupts::serialize(CheckpointOut &cp) const
 {
     SERIALIZE_ARRAY(regs, NUM_APIC_REGS);
     SERIALIZE_SCALAR(pendingSmi);
@@ -754,7 +754,7 @@ X86ISA::Interrupts::serialize(std::ostream &os)
 }
 
 void
-X86ISA::Interrupts::unserialize(Checkpoint *cp, const std::string &section)
+X86ISA::Interrupts::unserialize(CheckpointIn &cp)
 {
     UNSERIALIZE_ARRAY(regs, NUM_APIC_REGS);
     UNSERIALIZE_SCALAR(pendingSmi);
index b584c234b74ff694dbf138c542f51004b1561cc6..272cfea44e7e72b48cefe109682d1bcc57329bcb 100644 (file)
@@ -293,9 +293,8 @@ class Interrupts : public BasicPioDevice, IntDevice
     /*
      * Serialization.
      */
-
-    virtual void serialize(std::ostream &os);
-    virtual void unserialize(Checkpoint *cp, const std::string &section);
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 
     /*
      * Old functions needed for compatability but which will be phased out
index f9b99db0f5f198ea630a659284e7869c435472d5..213a9e2e3fc25a6313ddd517aa1982ad32bac5a7 100644 (file)
@@ -409,13 +409,13 @@ ISA::setMiscReg(int miscReg, MiscReg val, ThreadContext * tc)
 }
 
 void
-ISA::serialize(std::ostream & os)
+ISA::serialize(CheckpointOut &cp) const
 {
     SERIALIZE_ARRAY(regVal, NumMiscRegs);
 }
 
 void
-ISA::unserialize(Checkpoint * cp, const std::string & section)
+ISA::unserialize(CheckpointIn &cp)
 {
     UNSERIALIZE_ARRAY(regVal, NumMiscRegs);
     updateHandyM5Reg(regVal[MISCREG_EFER],
index a82b4ae2f4ccb2c286c808b676cffe11b9b3abf9..88f4980aeee5e09c0edec6806d3bda97e0c3ef49 100644 (file)
@@ -97,8 +97,9 @@ namespace X86ISA
             return reg;
         }
 
-        void serialize(std::ostream &os);
-        void unserialize(Checkpoint *cp, const std::string &section);
+        void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+        void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
+
         void startup(ThreadContext *tc);
 
         /// Explicitly import the otherwise hidden startup
index cd4df42e7934356dba2503cd3066ff58f16be354..4e8c39eb960aeefba27265ef9fde71510f82fcce 100644 (file)
 namespace X86ISA
 {
 
+TlbEntry::TlbEntry()
+    : paddr(0), vaddr(0), logBytes(0), writable(0),
+      user(true), uncacheable(0), global(false), patBit(0),
+      noExec(false), lruSeq(0)
+{
+}
+
 TlbEntry::TlbEntry(Addr asn, Addr _vaddr, Addr _paddr,
                    bool uncacheable, bool read_only) :
     paddr(_paddr), vaddr(_vaddr), logBytes(PageShift), writable(!read_only),
     user(true), uncacheable(uncacheable), global(false), patBit(0),
-    noExec(false)
+    noExec(false), lruSeq(0)
 {}
 
 void
-TlbEntry::serialize(std::ostream &os)
+TlbEntry::serialize(CheckpointOut &cp) const
 {
     SERIALIZE_SCALAR(paddr);
     SERIALIZE_SCALAR(vaddr);
@@ -68,7 +75,7 @@ TlbEntry::serialize(std::ostream &os)
 }
 
 void
-TlbEntry::unserialize(Checkpoint *cp, const std::string &section)
+TlbEntry::unserialize(CheckpointIn &cp)
 {
     UNSERIALIZE_SCALAR(paddr);
     UNSERIALIZE_SCALAR(vaddr);
index 639815893e06fff94f254c1e14e311c89f38aa0a..3345366d087a64b3dcca5a0f22bf662bfa4da57b 100644 (file)
@@ -97,7 +97,7 @@ namespace X86ISA
     EndBitUnion(PageTableEntry)
 
 
-    struct TlbEntry
+    struct TlbEntry : public Serializable
     {
         // The base of the physical page.
         Addr paddr;
@@ -130,7 +130,7 @@ namespace X86ISA
 
         TlbEntry(Addr asn, Addr _vaddr, Addr _paddr,
                  bool uncacheable, bool read_only);
-        TlbEntry() {}
+        TlbEntry();
 
         void
         updateVaddr(Addr new_vaddr)
@@ -149,8 +149,8 @@ namespace X86ISA
             return (1 << logBytes);
         }
 
-        void serialize(std::ostream &os);
-        void unserialize(Checkpoint *cp, const std::string &section);
+        void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+        void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
     };
 
     /** The size of each level of the page table expressed in base 2
index 86e051debea35074c4289358cbdeb58def599883..d0e77bc9b49ba1e14ca030ea741e58151961d26e 100644 (file)
 
 namespace X86ISA {
 
-TLB::TLB(const Params *p) : BaseTLB(p), configAddress(0), size(p->size),
-    lruSeq(0)
+TLB::TLB(const Params *p)
+    : BaseTLB(p), configAddress(0), size(p->size),
+      tlb(size), lruSeq(0)
 {
     if (!size)
         fatal("TLBs must have a non-zero size.\n");
-    tlb = new TlbEntry[size];
-    std::memset(tlb, 0, sizeof(TlbEntry) * size);
 
     for (int x = 0; x < size; x++) {
         tlb[x].trieHandle = NULL;
@@ -451,7 +450,7 @@ TLB::getWalker()
 }
 
 void
-TLB::serialize(std::ostream &os)
+TLB::serialize(CheckpointOut &cp) const
 {
     // Only store the entries in use.
     uint32_t _size = size - freeList.size();
@@ -459,18 +458,14 @@ TLB::serialize(std::ostream &os)
     SERIALIZE_SCALAR(lruSeq);
 
     uint32_t _count = 0;
-
     for (uint32_t x = 0; x < size; x++) {
-        if (tlb[x].trieHandle != NULL) {
-            os << "\n[" << csprintf("%s.Entry%d", name(), _count) << "]\n";
-            tlb[x].serialize(os);
-            _count++;
-        }
+        if (tlb[x].trieHandle != NULL)
+            tlb[x].serializeSection(cp, csprintf("Entry%d", _count++));
     }
 }
 
 void
-TLB::unserialize(Checkpoint *cp, const std::string &section)
+TLB::unserialize(CheckpointIn &cp)
 {
     // Do not allow to restore with a smaller tlb.
     uint32_t _size;
@@ -485,7 +480,7 @@ TLB::unserialize(Checkpoint *cp, const std::string &section)
         TlbEntry *newEntry = freeList.front();
         freeList.pop_front();
 
-        newEntry->unserialize(cp, csprintf("%s.Entry%d", name(), x));
+        newEntry->unserializeSection(cp, csprintf("Entry%d", x));
         newEntry->trieHandle = trie.insert(newEntry->vaddr,
             TlbEntryTrie::MaxBits - newEntry->logBytes, newEntry);
     }
index 77f9fc49d03ed0664e0ad402a16b9b2d23acf690..83ec7cc591db66b6f31db56a35861d53cbee2be8 100644 (file)
@@ -98,7 +98,7 @@ namespace X86ISA
       protected:
         uint32_t size;
 
-        TlbEntry * tlb;
+        std::vector<TlbEntry> tlb;
 
         EntryList freeList;
 
@@ -148,8 +148,8 @@ namespace X86ISA
         TlbEntry * insert(Addr vpn, TlbEntry &entry);
 
         // Checkpointing
-        virtual void serialize(std::ostream &os);
-        virtual void unserialize(Checkpoint *cp, const std::string &section);
+        void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+        void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 
         /**
          * Get the table walker master port. This is used for
index 830a131e50cae10e20fb64e5da31916c91f50051..a960205b58fffaf64149cdc589d02883749ce964 100644 (file)
@@ -36,69 +36,68 @@ using namespace std;
 
 template <>
 void
-paramOut(ostream &os, const string &name, ExtMachInst const &machInst)
+paramOut(CheckpointOut &cp, const string &name, ExtMachInst const &machInst)
 {
     // Prefixes
-    paramOut(os, name + ".legacy", (uint8_t)machInst.legacy);
-    paramOut(os, name + ".rex", (uint8_t)machInst.rex);
+    paramOut(cp, name + ".legacy", (uint8_t)machInst.legacy);
+    paramOut(cp, name + ".rex", (uint8_t)machInst.rex);
 
     // Opcode
-    paramOut(os, name + ".opcode.type", (uint8_t)machInst.opcode.type);
-    paramOut(os, name + ".opcode.op", (uint8_t)machInst.opcode.op);
+    paramOut(cp, name + ".opcode.type", (uint8_t)machInst.opcode.type);
+    paramOut(cp, name + ".opcode.op", (uint8_t)machInst.opcode.op);
 
     // Modifier bytes
-    paramOut(os, name + ".modRM", (uint8_t)machInst.modRM);
-    paramOut(os, name + ".sib", (uint8_t)machInst.sib);
+    paramOut(cp, name + ".modRM", (uint8_t)machInst.modRM);
+    paramOut(cp, name + ".sib", (uint8_t)machInst.sib);
 
     // Immediate fields
-    paramOut(os, name + ".immediate", machInst.immediate);
-    paramOut(os, name + ".displacement", machInst.displacement);
+    paramOut(cp, name + ".immediate", machInst.immediate);
+    paramOut(cp, name + ".displacement", machInst.displacement);
 
     // Sizes
-    paramOut(os, name + ".opSize", machInst.opSize);
-    paramOut(os, name + ".addrSize", machInst.addrSize);
-    paramOut(os, name + ".stackSize", machInst.stackSize);
-    paramOut(os, name + ".dispSize", machInst.dispSize);
+    paramOut(cp, name + ".opSize", machInst.opSize);
+    paramOut(cp, name + ".addrSize", machInst.addrSize);
+    paramOut(cp, name + ".stackSize", machInst.stackSize);
+    paramOut(cp, name + ".dispSize", machInst.dispSize);
 
     // Mode
-    paramOut(os, name + ".mode", (uint8_t)machInst.mode);
+    paramOut(cp, name + ".mode", (uint8_t)machInst.mode);
 }
 
 template <>
 void
-paramIn(Checkpoint *cp, const string &section,
-        const string &name, ExtMachInst &machInst)
+paramIn(CheckpointIn &cp, const string &name, ExtMachInst &machInst)
 {
     uint8_t temp8;
     // Prefixes
-    paramIn(cp, section, name + ".legacy", temp8);
+    paramIn(cp, name + ".legacy", temp8);
     machInst.legacy = temp8;
-    paramIn(cp, section, name + ".rex", temp8);
+    paramIn(cp, name + ".rex", temp8);
     machInst.rex = temp8;
 
     // Opcode
-    paramIn(cp, section, name + ".opcode.type", temp8);
+    paramIn(cp, name + ".opcode.type", temp8);
     machInst.opcode.type = (OpcodeType)temp8;
-    paramIn(cp, section, name + ".opcode.op", temp8);
+    paramIn(cp, name + ".opcode.op", temp8);
     machInst.opcode.op = temp8;
 
     // Modifier bytes
-    paramIn(cp, section, name + ".modRM", temp8);
+    paramIn(cp, name + ".modRM", temp8);
     machInst.modRM = temp8;
-    paramIn(cp, section, name + ".sib", temp8);
+    paramIn(cp, name + ".sib", temp8);
     machInst.sib = temp8;;
 
     // Immediate fields
-    paramIn(cp, section, name + ".immediate", machInst.immediate);
-    paramIn(cp, section, name + ".displacement", machInst.displacement);
+    paramIn(cp, name + ".immediate", machInst.immediate);
+    paramIn(cp, name + ".displacement", machInst.displacement);
 
     // Sizes
-    paramIn(cp, section, name + ".opSize", machInst.opSize);
-    paramIn(cp, section, name + ".addrSize", machInst.addrSize);
-    paramIn(cp, section, name + ".stackSize", machInst.stackSize);
-    paramIn(cp, section, name + ".dispSize", machInst.dispSize);
+    paramIn(cp, name + ".opSize", machInst.opSize);
+    paramIn(cp, name + ".addrSize", machInst.addrSize);
+    paramIn(cp, name + ".stackSize", machInst.stackSize);
+    paramIn(cp, name + ".dispSize", machInst.dispSize);
 
     // Mode
-    paramIn(cp, section, name + ".mode", temp8);
+    paramIn(cp, name + ".mode", temp8);
     machInst.mode = temp8;
 }
index dd60c0aecaae0a2e35f23db7cd997fa2f59a08dc..23d60020b9544e4088b1f45e82c0bdf08f233532 100644 (file)
@@ -276,16 +276,16 @@ namespace X86ISA
         }
 
         void
-        serialize(std::ostream &os)
+        serialize(CheckpointOut &cp) const
         {
-            Base::serialize(os);
+            Base::serialize(cp);
             SERIALIZE_SCALAR(_size);
         }
 
         void
-        unserialize(Checkpoint *cp, const std::string &section)
+        unserialize(CheckpointIn &cp)
         {
-            Base::unserialize(cp, section);
+            Base::unserialize(cp);
             UNSERIALIZE_SCALAR(_size);
         }
     };
@@ -314,11 +314,11 @@ __hash_namespace_end
 // and UNSERIALIZE_SCALAR.
 template <>
 void
-paramOut(std::ostream &os, const std::string &name,
+paramOut(CheckpointOut &cp, const std::string &name,
          const X86ISA::ExtMachInst &machInst);
 template <>
 void
-paramIn(Checkpoint *cp, const std::string &section,
-        const std::string &name, X86ISA::ExtMachInst &machInst);
+paramIn(CheckpointIn &cp, const std::string &name,
+        X86ISA::ExtMachInst &machInst);
 
 #endif // __ARCH_X86_TYPES_HH__
index 4904949b4d4fb5f81416b1abb128f8b6352962e2..5c421a5cf1956bb4b60554a038be8638b991dc89 100644 (file)
@@ -1063,7 +1063,7 @@ CPA::doDq(System *sys, int flags, int cpuid, int sm,
 
 
 void
-CPA::serialize(std::ostream &os)
+CPA::serialize(CheckpointOut &cp) const
 {
 
     SERIALIZE_SCALAR(numSm);
@@ -1077,8 +1077,6 @@ CPA::serialize(std::ostream &os)
     arrayParamOut(os, "qSize", qSize);
     arrayParamOut(os, "qBytes", qBytes);
 
-    std::list<AnnDataPtr>::iterator ai;
-
     SCache::iterator i;
     int x = 0, y = 0;
 
@@ -1211,36 +1209,33 @@ CPA::serialize(std::ostream &os)
         if (!qData[x].size())
             continue;
         y = 0;
-        ai = qData[x].begin();
-        while (ai != qData[x].end()) {
-            nameOut(os, csprintf("%s.Q%d_%d", name(), x, y));
-            (*ai)->serialize(os);
-            ai++;
+        for (auto &ann : qData[x]) {
+            ann->serializeSection(os, csprintf("Q%d_%d", x, y));
             y++;
         }
     }
 }
 
 void
-CPA::unserialize(Checkpoint *cp, const std::string &section)
+CPA::unserialize(CheckpointIn &cp)
 {
     UNSERIALIZE_SCALAR(numSm);
     UNSERIALIZE_SCALAR(numSmt);
-    arrayParamIn(cp, section, "numSt", numSt);
-    arrayParamIn(cp, section, "numQ", numQ);
+    UNSERIALIZE_CONTAINER(numSt);
+    UNSERIALIZE_CONTAINER(numQ);
     UNSERIALIZE_SCALAR(numSys);
     UNSERIALIZE_SCALAR(numQs);
     UNSERIALIZE_SCALAR(conId);
-    arrayParamIn(cp, section, "qSize", qSize);
-    arrayParamIn(cp, section, "qBytes", qBytes);
+    UNSERIALIZE_CONTAINER(qSize);
+    UNSERIALIZE_CONTAINER(qBytes);
 
 
     // smtCache (SCache
     string str;
     int smi;
     for (int x = 0;  x < numSmt; x++) {
-        paramIn(cp, section, csprintf("smtCache%d.str", x), str);
-        paramIn(cp, section, csprintf("smtCache%d.int", x), smi);
+        paramIn(cp, csprintf("smtCache%d.str", x), str);
+        paramIn(cp, csprintf("smtCache%d.int", x), smi);
         smtCache[str] = smi;
     }
 
@@ -1248,8 +1243,8 @@ CPA::unserialize(Checkpoint *cp, const std::string &section)
     stCache.resize(numSmt);
     for (int x = 0;  x < numSmt; x++) {
         for (int y = 0; y < numSt[x]; y++) {
-            paramIn(cp, section, csprintf("stCache%d_%d.str", x,y), str);
-            paramIn(cp, section, csprintf("stCache%d_%d.int", x,y), smi);
+            paramIn(cp, csprintf("stCache%d_%d.str", x,y), str);
+            paramIn(cp, csprintf("stCache%d_%d.int", x,y), smi);
             stCache[x][str] = smi;
         }
     }
@@ -1259,9 +1254,9 @@ CPA::unserialize(Checkpoint *cp, const std::string &section)
     qCache.resize(numSys);
     for (int x = 0;  x < numSys; x++) {
         for (int y = 0; y < numQ[x]; y++) {
-            paramIn(cp, section, csprintf("qCache%d_%d.str", x,y), str);
-            paramIn(cp, section, csprintf("qCache%d_%d.id", x,y), id);
-            paramIn(cp, section, csprintf("qCache%d_%d.int", x,y), smi);
+            paramIn(cp, csprintf("qCache%d_%d.str", x,y), str);
+            paramIn(cp, csprintf("qCache%d_%d.id", x,y), id);
+            paramIn(cp, csprintf("qCache%d_%d.int", x,y), smi);
             qCache[x][Id(str,id)] = smi;
         }
     }
@@ -1270,11 +1265,11 @@ CPA::unserialize(Checkpoint *cp, const std::string &section)
     smCache.resize(numSys);
     for (int x = 0;  x < numSys; x++) {
         int size;
-        paramIn(cp, section, csprintf("smCache%d", x), size);
+        paramIn(cp, csprintf("smCache%d", x), size);
         for (int y = 0; y < size; y++) {
-            paramIn(cp, section, csprintf("smCache%d_%d.str", x,y), str);
-            paramIn(cp, section, csprintf("smCache%d_%d.id", x,y), id);
-            paramIn(cp, section, csprintf("smCache%d_%d.int", x,y), smi);
+            paramIn(cp, csprintf("smCache%d_%d.str", x,y), str);
+            paramIn(cp, csprintf("smCache%d_%d.id", x,y), id);
+            paramIn(cp, csprintf("smCache%d_%d.int", x,y), smi);
             smCache[x][Id(str,id)] = smi;
         }
     }
@@ -1290,27 +1285,27 @@ CPA::unserialize(Checkpoint *cp, const std::string &section)
         string str;
         int sysi;
 
-        objParamIn(cp, section, csprintf("nameCache%d.name", x), sptr);
+        objParamIn(cp, csprintf("nameCache%d.name", x), sptr);
         sys = dynamic_cast<System*>(sptr);
 
-        paramIn(cp, section, csprintf("nameCache%d.str", x), str);
-        paramIn(cp, section, csprintf("nameCache%d.int", x), sysi);
+        paramIn(cp, csprintf("nameCache%d.str", x), str);
+        paramIn(cp, csprintf("nameCache%d.int", x), sysi);
         nameCache[sys] = std::make_pair(str, sysi);
     }
 
     //smStack (SmStack)
     int smStack_size;
-    paramIn(cp, section, "smStackIdCount", smStack_size);
+    paramIn(cp, "smStackIdCount", smStack_size);
     for (int x = 0; x < smStack_size; x++) {
         int sysi;
         uint64_t frame;
         int count;
-        paramIn(cp, section, csprintf("smStackId%d.sys", x), sysi);
-        paramIn(cp, section, csprintf("smStackId%d.frame", x), frame);
-        paramIn(cp, section, csprintf("smStackId%d.count", x), count);
+        paramIn(cp, csprintf("smStackId%d.sys", x), sysi);
+        paramIn(cp, csprintf("smStackId%d.frame", x), frame);
+        paramIn(cp, csprintf("smStackId%d.count", x), count);
         StackId sid = StackId(sysi, frame);
         for (int y = 0; y < count; y++) {
-            paramIn(cp, section, csprintf("smStackId%d_%d", x, y), smi);
+            paramIn(cp, csprintf("smStackId%d_%d", x, y), smi);
             smStack[sid].push_back(smi);
         }
     }
@@ -1318,23 +1313,23 @@ CPA::unserialize(Checkpoint *cp, const std::string &section)
     // lnMap (LinkMap)
     int lsmi;
     int lnMap_size;
-    paramIn(cp, section, "lnMapSize", lnMap_size);
+    paramIn(cp, "lnMapSize", lnMap_size);
     for (int x = 0;  x < lnMap_size; x++) {
-        paramIn(cp, section, csprintf("lnMap%d.smi", x), smi);
-        paramIn(cp, section, csprintf("lnMap%d.lsmi", x), lsmi);
+        paramIn(cp, csprintf("lnMap%d.smi", x), smi);
+        paramIn(cp, csprintf("lnMap%d.lsmi", x), lsmi);
         lnMap[smi] = lsmi;
     }
 
     // swExpl (vector)
     int swExpl_size;
-    paramIn(cp, section, "swExplCount", swExpl_size);
+    paramIn(cp, "swExplCount", swExpl_size);
     for (int x = 0; x < swExpl_size; x++) {
         int sysi;
         uint64_t frame;
         bool b;
-        paramIn(cp, section, csprintf("swExpl%d.sys", x), sysi);
-        paramIn(cp, section, csprintf("swExpl%d.frame", x), frame);
-        paramIn(cp, section, csprintf("swExpl%d.swexpl", x), b);
+        paramIn(cp, csprintf("swExpl%d.sys", x), sysi);
+        paramIn(cp, csprintf("swExpl%d.frame", x), frame);
+        paramIn(cp, csprintf("swExpl%d.swexpl", x), b);
         StackId sid = StackId(sysi, frame);
         swExpl[sid] = b;
     }
@@ -1342,10 +1337,10 @@ CPA::unserialize(Checkpoint *cp, const std::string &section)
     // lastState (IMap)
     int sti;
     int lastState_size;
-    paramIn(cp, section, "lastStateSize", lastState_size);
+    paramIn(cp, "lastStateSize", lastState_size);
     for (int x = 0;  x < lastState_size; x++) {
-        paramIn(cp, section, csprintf("lastState%d.smi", x), smi);
-        paramIn(cp, section, csprintf("lastState%d.sti", x), sti);
+        paramIn(cp, csprintf("lastState%d.smi", x), smi);
+        paramIn(cp, csprintf("lastState%d.sti", x), sti);
         lastState[smi] = sti;
     }
 
@@ -1353,17 +1348,17 @@ CPA::unserialize(Checkpoint *cp, const std::string &section)
     //smMap (IdMap)
     smMap.resize(numSm);
     for (int x = 0; x < smMap.size(); x++) {
-        paramIn(cp, section, csprintf("smMap%d.sys", x), smMap[x].first);
-        paramIn(cp, section, csprintf("smMap%d.smname", x), smMap[x].second.first);
-        paramIn(cp, section, csprintf("smMap%d.id", x), smMap[x].second.second);
+        paramIn(cp, csprintf("smMap%d.sys", x), smMap[x].first);
+        paramIn(cp, csprintf("smMap%d.smname", x), smMap[x].second.first);
+        paramIn(cp, csprintf("smMap%d.id", x), smMap[x].second.second);
     }
 
     //qMap (IdMap)
     qMap.resize(numQs);
     for (int x = 0; x < qMap.size(); x++) {
-        paramIn(cp, section, csprintf("qMap%d.sys", x), qMap[x].first);
-        paramIn(cp, section, csprintf("qMap%d.qname", x), qMap[x].second.first);
-        paramIn(cp, section, csprintf("qMap%d.id", x), qMap[x].second.second);
+        paramIn(cp, csprintf("qMap%d.sys", x), qMap[x].first);
+        paramIn(cp, csprintf("qMap%d.qname", x), qMap[x].second.first);
+        paramIn(cp, csprintf("qMap%d.id", x), qMap[x].second.second);
     }
 
 
@@ -1374,7 +1369,7 @@ CPA::unserialize(Checkpoint *cp, const std::string &section)
             continue;
         for (int y = 0; y < qSize[x]; y++) {
             AnnDataPtr a = std::make_shared<AnnotateData>();
-            a->unserialize(cp, csprintf("%s.Q%d_%d", section, x, y));
+            a->unserializeSection(cp, csprintf("Q%d_%d", x, y));
             data.push_back(a);
             qData[x].push_back(a);
         }
@@ -1382,7 +1377,7 @@ CPA::unserialize(Checkpoint *cp, const std::string &section)
 }
 
 void
-CPA::AnnotateData::serialize(std::ostream &os)
+CPA::AnnotateData::serialize(CheckpointOut &cp) const
 {
     SERIALIZE_SCALAR(time);
     SERIALIZE_SCALAR(data);
@@ -1394,7 +1389,7 @@ CPA::AnnotateData::serialize(std::ostream &os)
 }
 
 void
-CPA::AnnotateData::unserialize(Checkpoint *cp, const std::string &section)
+CPA::AnnotateData::unserialize(CheckpointIn &cp)
 {
     UNSERIALIZE_SCALAR(time);
     UNSERIALIZE_SCALAR(data);
index 5d554aa73bc3493842bcfc46666fccee19244ef8..a57d9bc79d8d32697a8e29d052d97d7515a6c3a6 100644 (file)
@@ -190,7 +190,7 @@ class CPA : SimObject
         }
 
     /* struct that is written to the annotation output file */
-    struct AnnotateData {
+    struct AnnotateData : public Serializable {
 
         Tick time;
         uint32_t data;
@@ -202,9 +202,8 @@ class CPA : SimObject
         uint8_t  cpu;
         bool dump;
 
-        void serialize(std::ostream &os);
-        void unserialize(Checkpoint *cp, const std::string &section);
-
+        void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+        void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
     };
 
     typedef std::shared_ptr<AnnotateData> AnnDataPtr;
@@ -541,9 +540,8 @@ class CPA : SimObject
     void dump(bool all);
     void dumpKey();
 
-    void serialize(std::ostream &os);
-    void unserialize(Checkpoint *cp, const std::string &section);
-
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 };
 #endif // !CP_ANNOTATE
 
index 2c868a9b1e08e91aeec1c28a5ab7d4cde6c46e17..439394852daaa405ed40bd032755b9efabe9d197 100644 (file)
@@ -108,32 +108,31 @@ SymbolTable::load(const string &filename)
 }
 
 void
-SymbolTable::serialize(const string &base, ostream &os)
+SymbolTable::serialize(const string &base, CheckpointOut &cp) const
 {
-    paramOut(os, base + ".size", addrTable.size());
+    paramOut(cp, base + ".size", addrTable.size());
 
     int i = 0;
     ATable::const_iterator p, end = addrTable.end();
     for (p = addrTable.begin(); p != end; ++p) {
-        paramOut(os, csprintf("%s.addr_%d", base, i), p->first);
-        paramOut(os, csprintf("%s.symbol_%d", base, i), p->second);
+        paramOut(cp, csprintf("%s.addr_%d", base, i), p->first);
+        paramOut(cp, csprintf("%s.symbol_%d", base, i), p->second);
         ++i;
     }
 }
 
 void
-SymbolTable::unserialize(const string &base, Checkpoint *cp,
-                         const string &section)
+SymbolTable::unserialize(const string &base, CheckpointIn &cp)
 {
     clear();
     int size;
-    paramIn(cp, section, base + ".size", size);
+    paramIn(cp, base + ".size", size);
     for (int i = 0; i < size; ++i) {
         Addr addr;
         std::string symbol;
 
-        paramIn(cp, section, csprintf("%s.addr_%d", base, i), addr);
-        paramIn(cp, section, csprintf("%s.symbol_%d", base, i), symbol);
+        paramIn(cp, csprintf("%s.addr_%d", base, i), addr);
+        paramIn(cp, csprintf("%s.symbol_%d", base, i), symbol);
         insert(addr, symbol);
     }
 }
index 2a2fd068ed610211776bd1aea99585c9c4584a96..403cb13ac0237185a8650bef52fc1bde7a2be608 100644 (file)
@@ -37,8 +37,8 @@
 #include <string>
 
 #include "base/types.hh"
+#include "sim/serialize.hh"
 
-class Checkpoint;
 class SymbolTable
 {
   public:
@@ -76,9 +76,8 @@ class SymbolTable
     const STable &getSymbolTable() const { return symbolTable; }
 
   public:
-    void serialize(const std::string &base, std::ostream &os);
-    void unserialize(const std::string &base, Checkpoint *cp,
-                     const std::string &section);
+    void serialize(const std::string &base, CheckpointOut &cp) const;
+    void unserialize(const std::string &base, CheckpointIn &cp);
 
   public:
     bool
index ea4d632d06a1c5bf59b01f20c6dcb2378c60fec5..a6c93c1f3828fb64a722ac0f93aeecac21595d2f 100644 (file)
@@ -88,7 +88,7 @@ PollEvent::enable()
 }
 
 void
-PollEvent::serialize(ostream &os)
+PollEvent::serialize(CheckpointOut &cp) const
 {
     SERIALIZE_SCALAR(pfd.fd);
     SERIALIZE_SCALAR(pfd.events);
@@ -96,7 +96,7 @@ PollEvent::serialize(ostream &os)
 }
 
 void
-PollEvent::unserialize(Checkpoint *cp, const std::string &section)
+PollEvent::unserialize(CheckpointIn &cp)
 {
     UNSERIALIZE_SCALAR(pfd.fd);
     UNSERIALIZE_SCALAR(pfd.events);
index 5e0faa7299427085b8fb1e0a27ac06d3b32cfddf..632239e08dc2806167a2b4e157057e198aa337e0 100644 (file)
@@ -40,7 +40,7 @@
 class Checkpoint;
 class PollQueue;
 
-class PollEvent
+class PollEvent : public Serializable
 {
   private:
     friend class PollQueue;
@@ -60,8 +60,8 @@ class PollEvent
 
     bool queued() { return queue != 0; }
 
-    virtual void serialize(std::ostream &os);
-    virtual void unserialize(Checkpoint *cp, const std::string &section);
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 };
 
 class PollQueue
index ced9a8f45b54ab25324562d1cc0f5adf36afb13b..2eb60c6e5dc387bc07e3d8717c350d8a77718bf4 100644 (file)
@@ -70,7 +70,7 @@ Random::init(uint32_t s)
 }
 
 void
-Random::serialize(std::ostream &os)
+Random::serialize(CheckpointOut &cp) const
 {
     panic("Currently not used anywhere.\n");
 
@@ -78,11 +78,11 @@ Random::serialize(std::ostream &os)
     std::ostringstream oss;
     oss << gen;
     std::string state = oss.str();
-    paramOut(os, "mt_state", state);
+    paramOut(cp, "mt_state", state);
 }
 
 void
-Random::unserialize(Checkpoint *cp, const std::string &section)
+Random::unserialize(CheckpointIn &cp)
 {
     panic("Currently not used anywhere.\n");
 
@@ -90,7 +90,7 @@ Random::unserialize(Checkpoint *cp, const std::string &section)
     // checkpoint state, so be forgiving in the unserialization and
     // keep on going if the parameter is not there
     std::string state;
-    if (optParamIn(cp, section, "mt_state", state)) {
+    if (optParamIn(cp, "mt_state", state)) {
         std::istringstream iss(state);
         iss >> gen;
     }
index cedbd6bd44bcd8d581e78243020c28d6bdb162f1..dca956306924cfe731fc33b1e8488ba131027a62 100644 (file)
 #include <string>
 #include <type_traits>
 
+#include "base/compiler.hh"
 #include "base/types.hh"
+#include "sim/serialize.hh"
 
 class Checkpoint;
 
-class Random
+class Random : public Serializable
 {
 
   private:
@@ -102,8 +104,8 @@ class Random
         return dist(gen);
     }
 
-    void serialize(std::ostream &os);
-    void unserialize(Checkpoint *cp, const std::string &section);
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 };
 
 extern Random random_mt;
index a0ae9bb8252795da2454b2104de2e115715925d1..86a31156c8d1706f47171c1e5a7c79101f06179e 100644 (file)
@@ -117,20 +117,19 @@ Time::time() const
 }
 
 void
-Time::serialize(const std::string &base, ostream &os)
+Time::serialize(const std::string &base, CheckpointOut &cp) const
 {
-    paramOut(os, base + ".sec", sec());
-    paramOut(os, base + ".nsec", nsec());
+    paramOut(cp, base + ".sec", sec());
+    paramOut(cp, base + ".nsec", nsec());
 }
 
 void
-Time::unserialize(const std::string &base, Checkpoint *cp,
-                  const string &section)
+Time::unserialize(const std::string &base, CheckpointIn &cp)
 {
     time_t secs;
     time_t nsecs;
-    paramIn(cp, section, base + ".sec", secs);
-    paramIn(cp, section, base + ".nsec", nsecs);
+    paramIn(cp, base + ".sec", secs);
+    paramIn(cp, base + ".nsec", nsecs);
     sec(secs);
     nsec(nsecs);
 }
index 734a86fa91f9238e3dad27d230d65f14fb74d01c..41d454a65b266a753fa22bc5a51776ca6d0735c3 100644 (file)
@@ -43,8 +43,7 @@
 #include <string>
 
 #include "base/types.hh"
-
-class Checkpoint;
+#include "sim/serialize.hh"
 
 class Time
 {
@@ -198,9 +197,8 @@ class Time
     std::string date(const std::string &format = "") const;
     std::string time() const;
 
-    void serialize(const std::string &base, std::ostream &os);
-    void unserialize(const std::string &base, Checkpoint *cp,
-                     const std::string &section);
+    void serialize(const std::string &base, CheckpointOut &cp) const;
+    void unserialize(const std::string &base, CheckpointIn &cp);
 };
 
 void sleep(const Time &time);
index 4d8b09ed2572a57e58217a8f4fda86dfe12fe729..0b704c48bff5e927a80a5a8f18398336f4df9afe 100644 (file)
@@ -640,7 +640,7 @@ BaseCPU::ProfileEvent::process()
 }
 
 void
-BaseCPU::serialize(std::ostream &os)
+BaseCPU::serialize(CheckpointOut &cp) const
 {
     SERIALIZE_SCALAR(instCnt);
 
@@ -651,28 +651,30 @@ BaseCPU::serialize(std::ostream &os)
          * system. */
         SERIALIZE_SCALAR(_pid);
 
-        interrupts->serialize(os);
+        interrupts->serialize(cp);
 
         // Serialize the threads, this is done by the CPU implementation.
         for (ThreadID i = 0; i < numThreads; ++i) {
-            nameOut(os, csprintf("%s.xc.%i", name(), i));
-            serializeThread(os, i);
+            ScopedCheckpointSection sec(cp, csprintf("xc.%i", i));
+            serializeThread(cp, i);
         }
     }
 }
 
 void
-BaseCPU::unserialize(Checkpoint *cp, const std::string &section)
+BaseCPU::unserialize(CheckpointIn &cp)
 {
     UNSERIALIZE_SCALAR(instCnt);
 
     if (!_switchedOut) {
         UNSERIALIZE_SCALAR(_pid);
-        interrupts->unserialize(cp, section);
+        interrupts->unserialize(cp);
 
         // Unserialize the threads, this is done by the CPU implementation.
-        for (ThreadID i = 0; i < numThreads; ++i)
-            unserializeThread(cp, csprintf("%s.xc.%i", section, i), i);
+        for (ThreadID i = 0; i < numThreads; ++i) {
+            ScopedCheckpointSection sec(cp, csprintf("xc.%i", i));
+            unserializeThread(cp, i);
+        }
     }
 }
 
index 662b24a99a6bda756037ddfb9d4a69a13ee99af5..660f0278e952dad7ba0837733cc97e128d3cef4c 100644 (file)
@@ -390,7 +390,7 @@ class BaseCPU : public MemObject
      *
      * @param os The stream to serialize to.
      */
-    virtual void serialize(std::ostream &os);
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
 
     /**
      * Reconstruct the state of this object from a checkpoint.
@@ -403,7 +403,7 @@ class BaseCPU : public MemObject
      * @param cp The checkpoint use.
      * @param section The section name of this object.
      */
-    virtual void unserialize(Checkpoint *cp, const std::string &section);
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 
     /**
      * Serialize a single thread.
@@ -411,7 +411,7 @@ class BaseCPU : public MemObject
      * @param os The stream to serialize to.
      * @param tid ID of the current thread.
      */
-    virtual void serializeThread(std::ostream &os, ThreadID tid) {};
+    virtual void serializeThread(CheckpointOut &cp, ThreadID tid) const {};
 
     /**
      * Unserialize one thread.
@@ -420,8 +420,7 @@ class BaseCPU : public MemObject
      * @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) {};
+    virtual void unserializeThread(CheckpointIn &cp, ThreadID tid) {};
 
     virtual Counter totalInsts() const = 0;
 
index 229066fcc9b3be190e38260a26f12649dbce6164..ac476e5f460f28f9735b503f7d090b792e158247 100644 (file)
@@ -129,12 +129,12 @@ CheckerCPU::setDcachePort(MasterPort *dcache_port)
 }
 
 void
-CheckerCPU::serialize(ostream &os)
+CheckerCPU::serialize(ostream &os) const
 {
 }
 
 void
-CheckerCPU::unserialize(Checkpoint *cp, const string &section)
+CheckerCPU::unserialize(CheckpointIn &cp)
 {
 }
 
index bed3b9e3239a42bf44d36e930b38af674c26e241..a363b6d0f6694c21716b166ce4988fcd9d3adb6d 100644 (file)
@@ -189,8 +189,8 @@ class CheckerCPU : public BaseCPU, public ExecContext
     Counter numLoad;
     Counter startNumLoad;
 
-    virtual void serialize(std::ostream &os);
-    virtual void unserialize(Checkpoint *cp, const std::string &section);
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 
     // These functions are only used in CPU models that split
     // effective address computation from the actual memory access.
index 26d0dfa8b5d0cd1a20e8bac7ca169659adbadb84..71c231ba0e5ebe053f058e52c2c13b5937aab3a7 100644 (file)
@@ -180,10 +180,6 @@ class CheckerThreadContext : public ThreadContext
         checkerTC->regStats(name);
     }
 
-    void serialize(std::ostream &os) { actualTC->serialize(os); }
-    void unserialize(Checkpoint *cp, const std::string &section)
-    { actualTC->unserialize(cp, section); }
-
     EndQuiesceEvent *getQuiesceEvent() { return actualTC->getQuiesceEvent(); }
 
     Tick readLastActivate() { return actualTC->readLastActivate(); }
index 644ca3620a8042cbb63b8d0b9a801b68a5ce9bd9..b7c964669d9569c459eb3768896023ffee2caf0a 100644 (file)
@@ -53,7 +53,7 @@ class BaseKvmCPU(BaseCPU):
     @classmethod
     def export_methods(cls, code):
         code('''
-      void dump();
+      void dump() const;
 ''')
 
     @classmethod
index 827cd55814cc6bcad913437bd58de66cbe00953a..30e984366647eaa54b9e29f04de0567cc69a8785 100644 (file)
@@ -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.");
 }
index ce32cdbb1f9640677c1022d25a255d7cf01e01bf..a8e429dfaafe79d7e6da98e74cf1df89a4f37aaf 100644 (file)
@@ -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.
index 34b51f1376dd68b94c282553f54b8503bf4df87e..cd46370a4f99bba83a0aa4ff28b0d9d73f7fdde5 100644 (file)
@@ -562,7 +562,7 @@ X86KvmCPU::startup()
 }
 
 void
-X86KvmCPU::dump()
+X86KvmCPU::dump() const
 {
     dumpIntRegs();
     if (useXSave)
index 18471040cdfcd26436e30b4d46a520e5f501ddcd..2e93a5f2638f4c791e4df93fb6d5c489f49304c7 100644 (file)
@@ -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;
index 45817c3a8174b0d052b3b42e6d08a0aef461b909..d21bf7042d356fa64f302238618fde04ba1c41e2 100644 (file)
@@ -130,33 +130,32 @@ MinorCPU::regStats()
 }
 
 void
-MinorCPU::serializeThread(std::ostream &os, ThreadID thread_id)
+MinorCPU::serializeThread(CheckpointOut &cp, ThreadID thread_id) const
 {
-    threads[thread_id]->serialize(os);
+    threads[thread_id]->serialize(cp);
 }
 
 void
-MinorCPU::unserializeThread(Checkpoint *cp, const std::string &section,
-    ThreadID thread_id)
+MinorCPU::unserializeThread(CheckpointIn &cp, ThreadID thread_id)
 {
     if (thread_id != 0)
         fatal("Trying to load more than one thread into a MinorCPU\n");
 
-    threads[thread_id]->unserialize(cp, section);
+    threads[thread_id]->unserialize(cp);
 }
 
 void
-MinorCPU::serialize(std::ostream &os)
+MinorCPU::serialize(CheckpointOut &cp) const
 {
-    pipeline->serialize(os);
-    BaseCPU::serialize(os);
+    pipeline->serialize(cp);
+    BaseCPU::serialize(cp);
 }
 
 void
-MinorCPU::unserialize(Checkpoint *cp, const std::string &section)
+MinorCPU::unserialize(CheckpointIn &cp)
 {
-    pipeline->unserialize(cp, section);
-    BaseCPU::unserialize(cp, section);
+    pipeline->unserialize(cp);
+    BaseCPU::unserialize(cp);
 }
 
 Addr
index 507261fbd4b259b4e0114357294af25764cd79e4..fba54b5155b976528f5ef19f9ccd493b45456640 100644 (file)
@@ -146,13 +146,13 @@ class MinorCPU : public BaseCPU
     Counter totalInsts() const;
     Counter totalOps() const;
 
-    void serializeThread(std::ostream &os, ThreadID thread_id);
-    void unserializeThread(Checkpoint *cp, const std::string &section,
-        ThreadID thread_id);
+    void serializeThread(CheckpointOut &cp,
+                         ThreadID tid) const M5_ATTR_OVERRIDE;
+    void unserializeThread(CheckpointIn &cp, ThreadID tid) M5_ATTR_OVERRIDE;
 
     /** Serialize pipeline data */
-    void serialize(std::ostream &os);
-    void unserialize(Checkpoint *cp, const std::string &section);
+    void serialize(CheckpointOut &cp) const;
+    void unserialize(CheckpointIn &cp);
 
     /** Drain interface */
     unsigned int drain(DrainManager *drain_manager);
index 34ef275a77a7e5c606e43f54c17627f768a598ac..18e9582784e48e8b6c277981392f166000da73d4 100644 (file)
@@ -986,17 +986,16 @@ FullO3CPU<Impl>::syscall(int64_t callnum, ThreadID tid)
 
 template <class Impl>
 void
-FullO3CPU<Impl>::serializeThread(std::ostream &os, ThreadID tid)
+FullO3CPU<Impl>::serializeThread(CheckpointOut &cp, ThreadID tid) const
 {
-    thread[tid]->serialize(os);
+    thread[tid]->serialize(cp);
 }
 
 template <class Impl>
 void
-FullO3CPU<Impl>::unserializeThread(Checkpoint *cp, const std::string &section,
-                                   ThreadID tid)
+FullO3CPU<Impl>::unserializeThread(CheckpointIn &cp, ThreadID tid)
 {
-    thread[tid]->unserialize(cp, section);
+    thread[tid]->unserialize(cp);
 }
 
 template <class Impl>
index c4ccd562bc1a4291487a6148c9c9250bdd76cbb0..bbc9fde8e3011d1830e95e27379a0b7014b53e9c 100644 (file)
@@ -338,10 +338,9 @@ class FullO3CPU : public BaseO3CPU
     /** Is the CPU draining? */
     bool isDraining() const { return getDrainState() == Drainable::Draining; }
 
-    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;
 
   public:
     /** Executes a syscall.
index eea7a3d160a748b9f6a88a4456350b69cad81024..cf9403e4837561cc0256291a549dbe739b242777 100644 (file)
@@ -112,24 +112,24 @@ struct O3ThreadState : public ThreadState {
         profilePC = 3;
     }
 
-    void serialize(std::ostream &os)
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE
     {
-        ThreadState::serialize(os);
+        ThreadState::serialize(cp);
         // Use the ThreadContext serialization helper to serialize the
         // TC.
-        ::serialize(*tc, os);
+        ::serialize(*tc, cp);
     }
 
-    void unserialize(Checkpoint *cp, const std::string &section)
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE
     {
         // Prevent squashing - we don't have any instructions in
         // flight that we need to squash since we just instantiated a
         // clean system.
         noSquashFromTC = true;
-        ThreadState::unserialize(cp, section);
+        ThreadState::unserialize(cp);
         // Use the ThreadContext serialization helper to unserialize
         // the TC.
-        ::unserialize(*tc, cp, section);
+        ::unserialize(*tc, cp);
         noSquashFromTC = false;
     }
 
index 9cfbd5f93cebc000db4af19720cdfd478472d89b..2751a346cb4c4a18452109249afcb3f8645f7d9e 100644 (file)
@@ -305,21 +305,20 @@ BaseSimpleCPU::resetStats()
 }
 
 void
-BaseSimpleCPU::serializeThread(ostream &os, ThreadID tid)
+BaseSimpleCPU::serializeThread(CheckpointOut &cp, ThreadID tid) const
 {
     assert(_status == Idle || _status == Running);
     assert(tid == 0);
 
-    thread->serialize(os);
+    thread->serialize(cp);
 }
 
 void
-BaseSimpleCPU::unserializeThread(Checkpoint *cp, const string &section,
-                                 ThreadID tid)
+BaseSimpleCPU::unserializeThread(CheckpointIn &cp, ThreadID tid)
 {
     if (tid != 0)
         fatal("Trying to load more than one thread into a SimpleCPU\n");
-    thread->unserialize(cp, section);
+    thread->unserialize(cp);
 }
 
 void
index 6e8b4a8c8876faeffee8cc72e55d853165c00a6d..2f72470109e07a4b723dbb2fe118f365431b4fbf 100644 (file)
@@ -278,9 +278,9 @@ class BaseSimpleCPU : public BaseCPU, public ExecContext
     // instruction mix histogram by OpClass
     Stats::Vector statExecutedInstType;
 
-    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;
 
     // These functions are only used in CPU models that split
     // effective address computation from the actual memory access.
index 36603a1c167cd10f908e8ef1578d916d1384f5d8..5e457f692859972cfc69cd3ba5e3341164fac610 100644 (file)
@@ -131,18 +131,18 @@ SimpleThread::copyState(ThreadContext *oldContext)
 }
 
 void
-SimpleThread::serialize(ostream &os)
+SimpleThread::serialize(CheckpointOut &cp) const
 {
-    ThreadState::serialize(os);
-    ::serialize(*tc, os);
+    ThreadState::serialize(cp);
+    ::serialize(*tc, cp);
 }
 
 
 void
-SimpleThread::unserialize(Checkpoint *cp, const std::string &section)
+SimpleThread::unserialize(CheckpointIn &cp)
 {
-    ThreadState::unserialize(cp, section);
-    ::unserialize(*tc, cp, section);
+    ThreadState::unserialize(cp);
+    ::unserialize(*tc, cp);
 }
 
 void
index e862385c57833cefe29dc993dcf0d3709061b490..20acff6ee27891fd3c4857b44e73efc0d804d413 100644 (file)
@@ -154,8 +154,8 @@ class SimpleThread : public ThreadState
 
     void copyState(ThreadContext *oldContext);
 
-    void serialize(std::ostream &os);
-    void unserialize(Checkpoint *cp, const std::string &section);
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
     void startup();
 
     /***************************************************************
index 9f31926561616ba0f57c6ebfa26509c24ce9e47b..0fc8848fb796c0d61b8e6b73baf996127a5c3d7d 100644 (file)
@@ -139,7 +139,7 @@ TrafficGen::drain(DrainManager *dm)
 }
 
 void
-TrafficGen::serialize(ostream &os)
+TrafficGen::serialize(CheckpointOut &cp) const
 {
     DPRINTF(Checkpoint, "Serializing TrafficGen\n");
 
@@ -158,7 +158,7 @@ TrafficGen::serialize(ostream &os)
 }
 
 void
-TrafficGen::unserialize(Checkpoint* cp, const string& section)
+TrafficGen::unserialize(CheckpointIn &cp)
 {
     // restore scheduled events
     Tick nextEvent;
index eb9f6541d4a481204c3ab45194c45de0361653ec..ba7fda7dd1257f1017fd28d2706401f2a70a087e 100644 (file)
@@ -203,9 +203,8 @@ class TrafficGen : public MemObject
 
     unsigned int drain(DrainManager *dm);
 
-    void serialize(std::ostream &os);
-
-    void unserialize(Checkpoint* cp, const std::string& section);
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 
     /** Register statistics */
     void regStats();
index 09f91746af042d19845adafd4f5b9c754dfb14c5..fe1ae69dd43ff1de945f31fd7bab909a16b493fb 100644 (file)
@@ -104,7 +104,7 @@ ThreadContext::compare(ThreadContext *one, ThreadContext *two)
 }
 
 void
-serialize(ThreadContext &tc, std::ostream &os)
+serialize(ThreadContext &tc, CheckpointOut &cp)
 {
     using namespace TheISA;
 
@@ -113,7 +113,7 @@ serialize(ThreadContext &tc, std::ostream &os)
         floatRegs[i] = tc.readFloatRegBitsFlat(i);
     // This is a bit ugly, but needed to maintain backwards
     // compatibility.
-    arrayParamOut(os, "floatRegs.i", floatRegs, NumFloatRegs);
+    arrayParamOut(cp, "floatRegs.i", floatRegs, NumFloatRegs);
 
     IntReg intRegs[NumIntRegs];
     for (int i = 0; i < NumIntRegs; ++i)
@@ -127,20 +127,20 @@ serialize(ThreadContext &tc, std::ostream &os)
     SERIALIZE_ARRAY(ccRegs, NumCCRegs);
 #endif
 
-    tc.pcState().serialize(os);
+    tc.pcState().serialize(cp);
 
     // thread_num and cpu_id are deterministic from the config
 }
 
 void
-unserialize(ThreadContext &tc, Checkpoint *cp, const std::string &section)
+unserialize(ThreadContext &tc, CheckpointIn &cp)
 {
     using namespace TheISA;
 
     FloatRegBits floatRegs[NumFloatRegs];
     // This is a bit ugly, but needed to maintain backwards
     // compatibility.
-    arrayParamIn(cp, section, "floatRegs.i", floatRegs, NumFloatRegs);
+    arrayParamIn(cp, "floatRegs.i", floatRegs, NumFloatRegs);
     for (int i = 0; i < NumFloatRegs; ++i)
         tc.setFloatRegBitsFlat(i, floatRegs[i]);
 
@@ -157,7 +157,7 @@ unserialize(ThreadContext &tc, Checkpoint *cp, const std::string &section)
 #endif
 
     PCState pcState;
-    pcState.unserialize(cp, section);
+    pcState.unserialize(cp);
     tc.pcState(pcState);
 
     // thread_num and cpu_id are deterministic from the config
index 966924c50f23389defbf9895648599e4b3461ec8..2544b19c66d0031dd4b6661eba446dcd197d34dd 100644 (file)
@@ -499,8 +499,8 @@ class ProxyThreadContext : public ThreadContext
  * be confusing when the ThreadContext is exported via a proxy.
  */
 
-void serialize(ThreadContext &tc, std::ostream &os);
-void unserialize(ThreadContext &tc, Checkpoint *cp, const std::string &section);
+void serialize(ThreadContext &tc, CheckpointOut &cp);
+void unserialize(ThreadContext &tc, CheckpointIn &cp);
 
 /** @} */
 
index 0e1e6c57e3b5c4a29032fd991c973fb0bb918252..42418761315b6890b32d428303b45d5eb9bd265e 100644 (file)
@@ -63,7 +63,7 @@ ThreadState::~ThreadState()
 }
 
 void
-ThreadState::serialize(std::ostream &os)
+ThreadState::serialize(CheckpointOut &cp) const
 {
     SERIALIZE_ENUM(_status);
     // thread_num and cpu_id are deterministic from the config
@@ -77,11 +77,11 @@ ThreadState::serialize(std::ostream &os)
         quiesceEndTick = quiesceEvent->when();
     SERIALIZE_SCALAR(quiesceEndTick);
     if (kernelStats)
-        kernelStats->serialize(os);
+        kernelStats->serialize(cp);
 }
 
 void
-ThreadState::unserialize(Checkpoint *cp, const std::string &section)
+ThreadState::unserialize(CheckpointIn &cp)
 {
 
     UNSERIALIZE_ENUM(_status);
@@ -96,7 +96,7 @@ ThreadState::unserialize(Checkpoint *cp, const std::string &section)
     if (quiesceEndTick)
         baseCpu->schedule(quiesceEvent, quiesceEndTick);
     if (kernelStats)
-        kernelStats->unserialize(cp, section);
+        kernelStats->unserialize(cp);
 }
 
 void
index f937964ffa3b052d9fa9e81d0823b9e30b066185..485c9306fef15138259a3d59aadf652a78f0e49e 100644 (file)
@@ -56,16 +56,16 @@ class Checkpoint;
  *  memory, quiesce events, and certain stats.  This can be expanded
  *  to hold more thread-specific stats within it.
  */
-struct ThreadState {
+struct ThreadState : public Serializable {
     typedef ThreadContext::Status Status;
 
     ThreadState(BaseCPU *cpu, ThreadID _tid, Process *_process);
 
     virtual ~ThreadState();
 
-    void serialize(std::ostream &os);
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
 
-    void unserialize(Checkpoint *cp, const std::string &section);
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 
     int cpuId() const { return baseCpu->cpuId(); }
 
index 59862089359dedfc72f4c96b511e74dbb2f0a908..ec5765673a943d9ea42b6c41792bdfddc63c7aef 100644 (file)
@@ -252,7 +252,7 @@ AlphaBackdoor::write(PacketPtr pkt)
 }
 
 void
-AlphaBackdoor::Access::serialize(ostream &os)
+AlphaBackdoor::Access::serialize(CheckpointOut &cp) const
 {
     SERIALIZE_SCALAR(last_offset);
     SERIALIZE_SCALAR(version);
@@ -274,7 +274,7 @@ AlphaBackdoor::Access::serialize(ostream &os)
 }
 
 void
-AlphaBackdoor::Access::unserialize(Checkpoint *cp, const std::string &section)
+AlphaBackdoor::Access::unserialize(CheckpointIn &cp)
 {
     UNSERIALIZE_SCALAR(last_offset);
     UNSERIALIZE_SCALAR(version);
@@ -296,15 +296,15 @@ AlphaBackdoor::Access::unserialize(Checkpoint *cp, const std::string &section)
 }
 
 void
-AlphaBackdoor::serialize(ostream &os)
+AlphaBackdoor::serialize(CheckpointOut &cp) const
 {
-    alphaAccess->serialize(os);
+    alphaAccess->serialize(cp);
 }
 
 void
-AlphaBackdoor::unserialize(Checkpoint *cp, const std::string &section)
+AlphaBackdoor::unserialize(CheckpointIn &cp)
 {
-    alphaAccess->unserialize(cp, section);
+    alphaAccess->unserialize(cp);
 }
 
 AlphaBackdoor *
index b9d04c7c0874e6144f9c56f2db33b7c8d8c749ef..da62010592fc86bcaf9910957abd70103ef2a75e 100644 (file)
@@ -74,10 +74,10 @@ class SimpleDisk;
 class AlphaBackdoor : public BasicPioDevice
 {
   protected:
-    struct Access : public AlphaAccess
+    struct Access : public AlphaAccess, public Serializable
     {
-        void serialize(std::ostream &os);
-        void unserialize(Checkpoint *cp, const std::string &section);
+        void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+        void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
     };
 
     union {
@@ -118,8 +118,8 @@ class AlphaBackdoor : public BasicPioDevice
     /**
      * standard serialization routines for checkpointing
      */
-    virtual void serialize(std::ostream &os);
-    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_ALPHA_BACKDOOR_HH__
index 41a2fef0c1d3f16694fc8f7fa59f323e23c016f3..36b1a9ded839381064f6e1d26f5f838bc155c18d 100644 (file)
@@ -114,13 +114,13 @@ Tsunami::calcPciMemAddr(Addr addr)
 }
 
 void
-Tsunami::serialize(std::ostream &os)
+Tsunami::serialize(CheckpointOut &cp) const
 {
     SERIALIZE_ARRAY(intr_sum_type, Tsunami::Max_CPUs);
 }
 
 void
-Tsunami::unserialize(Checkpoint *cp, const std::string &section)
+Tsunami::unserialize(CheckpointIn &cp)
 {
     UNSERIALIZE_ARRAY(intr_sum_type, Tsunami::Max_CPUs);
 }
index 9380864b04e3a15d366d18bcdd71a986c7712c50..19df8093e9da1ea94f7cb5249fe955f02e928ea9 100644 (file)
@@ -124,18 +124,8 @@ class Tsunami : public Platform
      */
     virtual Addr calcPciMemAddr(Addr addr);
 
-    /**
-     * 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_TSUNAMI_HH__
index 7416de403036481c42599cc396ca19be01714b1a..d67f4e3fb4f1297a1f9a8f1f8517c76f413b8da2 100644 (file)
@@ -507,7 +507,7 @@ TsunamiCChip::clearDRIR(uint32_t interrupt)
 
 
 void
-TsunamiCChip::serialize(std::ostream &os)
+TsunamiCChip::serialize(CheckpointOut &cp) const
 {
     SERIALIZE_ARRAY(dim, Tsunami::Max_CPUs);
     SERIALIZE_ARRAY(dir, Tsunami::Max_CPUs);
@@ -517,7 +517,7 @@ TsunamiCChip::serialize(std::ostream &os)
 }
 
 void
-TsunamiCChip::unserialize(Checkpoint *cp, const std::string &section)
+TsunamiCChip::unserialize(CheckpointIn &cp)
 {
     UNSERIALIZE_ARRAY(dim, Tsunami::Max_CPUs);
     UNSERIALIZE_ARRAY(dir, Tsunami::Max_CPUs);
index e9aca5d5ceaa7980023fd43d91ee491797edafbf..fdbe64ef1a2af8d8e48f381905782c368a48ae78 100644 (file)
@@ -131,20 +131,8 @@ class TsunamiCChip : 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 // __TSUNAMI_CCHIP_HH__
index 2236546fc8aa18dd876768fd3a12c97d19a13368..8015ec2fe298b895f9d071df48bbefed7ab83d7f 100644 (file)
@@ -251,7 +251,7 @@ TsunamiIO::clearPIC(uint8_t bitvector)
 }
 
 void
-TsunamiIO::serialize(ostream &os)
+TsunamiIO::serialize(CheckpointOut &cp) const
 {
     SERIALIZE_SCALAR(rtcAddr);
     SERIALIZE_SCALAR(timerData);
@@ -263,12 +263,12 @@ TsunamiIO::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
-TsunamiIO::unserialize(Checkpoint *cp, const string &section)
+TsunamiIO::unserialize(CheckpointIn &cp)
 {
     UNSERIALIZE_SCALAR(rtcAddr);
     UNSERIALIZE_SCALAR(timerData);
@@ -280,8 +280,8 @@ TsunamiIO::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
index f242c9e2ac21cc974e75165e3bf9ce5cad91bb9a..2b7f5484e524a2351654724b39264fc9f229ea2a 100644 (file)
@@ -138,18 +138,8 @@ class TsunamiIO : public BasicPioDevice
      */
     void clearPIC(uint8_t bitvector);
 
-    /**
-     * 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.
index 328699f9fcdedad09516c01bd15add656a389291..cfd1e69e40408a0c97359dc8b743887445edf99d 100644 (file)
@@ -324,7 +324,7 @@ TsunamiPChip::calcMemAddr(Addr addr)
 }
 
 void
-TsunamiPChip::serialize(std::ostream &os)
+TsunamiPChip::serialize(CheckpointOut &cp) const
 {
     SERIALIZE_SCALAR(pctl);
     SERIALIZE_ARRAY(wsba, 4);
@@ -333,7 +333,7 @@ TsunamiPChip::serialize(std::ostream &os)
 }
 
 void
-TsunamiPChip::unserialize(Checkpoint *cp, const std::string &section)
+TsunamiPChip::unserialize(CheckpointIn &cp)
 {
     UNSERIALIZE_SCALAR(pctl);
     UNSERIALIZE_ARRAY(wsba, 4);
index 3e32db989b41f53076f395f2a2fd9318ae8aeff9..0eb9921317d8729ac3a9a24cd498c8ce2a65c933 100644 (file)
@@ -89,18 +89,8 @@ class TsunamiPChip : 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__
index b77eaba3bff3c76a57dd445a7d1e18ceda4e387a..0e6925852faa017511abbce1def4fb578d0ca503 100644 (file)
@@ -216,7 +216,7 @@ EnergyCtrl::write(PacketPtr pkt)
 }
 
 void
-EnergyCtrl::serialize(std::ostream &os)
+EnergyCtrl::serialize(CheckpointOut &cp) const
 {
     SERIALIZE_SCALAR(domainID);
     SERIALIZE_SCALAR(domainIDIndexToRead);
@@ -228,7 +228,7 @@ EnergyCtrl::serialize(std::ostream &os)
 }
 
 void
-EnergyCtrl::unserialize(Checkpoint *cp, const std::string &section)
+EnergyCtrl::unserialize(CheckpointIn &cp)
 {
     UNSERIALIZE_SCALAR(domainID);
     UNSERIALIZE_SCALAR(domainIDIndexToRead);
index 54a6906796e33cd5eac0a6f1c5e07f0de5b598e3..a1a36287982157920d7a3b2dc6e668215067734f 100644 (file)
@@ -132,8 +132,8 @@ class EnergyCtrl : public BasicPioDevice
      */
     virtual Tick write(PacketPtr pkt);
 
-    void serialize(std::ostream &os);
-    void unserialize(Checkpoint *cp, const std::string &section);
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 
     void startup();
     void init();
index eaa8391783d21a5777ecb454b15d53e81c2db77e..96f8f05668d94c84685c5e43d8bd4aa0dbf87df8 100644 (file)
@@ -518,7 +518,7 @@ FlashDevice::regStats()
  */
 
 void
-FlashDevice::serialize(std::ostream &os)
+FlashDevice::serialize(CheckpointOut &cp) const
 {
     SERIALIZE_SCALAR(planeMask);
 
@@ -551,7 +551,7 @@ FlashDevice::serialize(std::ostream &os)
  */
 
 void
-FlashDevice::unserialize(Checkpoint *cp, const std::string &section)
+FlashDevice::unserialize(CheckpointIn &cp)
 {
     UNSERIALIZE_SCALAR(planeMask);
 
index 8dc4ba04a7259ec0e0eda6f7af843177afdb4a39..330299451b10734404878e80d551e5e0392b9877 100644 (file)
@@ -64,8 +64,9 @@ class FlashDevice : public AbstractNVM
     /** Checkpoint functions*/
     unsigned int drain(DrainManager *dm);
     void checkDrain();
-    void serialize(std::ostream &os);
-    void unserialize(Checkpoint *cp, const std::string &section);
+
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 
   private:
     /** Defines the possible actions to the flash*/
index 41cb4badaa07027fc4fc5a7f30a0d75e4c9524c8..173855b88fae8bf2ff14613aadd2910c288a4c5f 100644 (file)
@@ -66,7 +66,7 @@ SystemCounter::setFreq(uint32_t freq)
 }
 
 void
-SystemCounter::serialize(std::ostream &os) const
+SystemCounter::serialize(CheckpointOut &cp) const
 {
     SERIALIZE_SCALAR(_regCntkctl);
     SERIALIZE_SCALAR(_freq);
@@ -75,8 +75,7 @@ SystemCounter::serialize(std::ostream &os) const
 }
 
 void
-SystemCounter::unserialize(Checkpoint *cp,
-                           const std::string &section)
+SystemCounter::unserialize(CheckpointIn &cp)
 {
     // We didn't handle CNTKCTL in this class before, assume it's zero
     // if it isn't present.
@@ -175,9 +174,9 @@ ArchTimer::value() const
 }
 
 void
-ArchTimer::serialize(std::ostream &os) const
+ArchTimer::serialize(CheckpointOut &cp) const
 {
-    paramOut(os, "control_serial", _control);
+    paramOut(cp, "control_serial", _control);
     SERIALIZE_SCALAR(_counterLimit);
     SERIALIZE_SCALAR(_offset);
 
@@ -190,10 +189,9 @@ ArchTimer::serialize(std::ostream &os) const
 }
 
 void
-ArchTimer::unserialize(Checkpoint *cp,
-                                         const std::string &section)
+ArchTimer::unserialize(CheckpointIn &cp)
 {
-    paramIn(cp, section, "control_serial", _control);
+    paramIn(cp, "control_serial", _control);
     // We didn't serialize an offset before we added support for the
     // virtual timer. Consider it optional to maintain backwards
     // compatibility.
@@ -240,28 +238,26 @@ GenericTimer::GenericTimer(GenericTimerParams *p)
 }
 
 void
-GenericTimer::serialize(std::ostream &os)
+GenericTimer::serialize(CheckpointOut &cp) const
 {
-    paramOut(os, "cpu_count", timers.size());
+    paramOut(cp, "cpu_count", timers.size());
 
-    nameOut(os, csprintf("%s.sys_counter", name()));
-    systemCounter.serialize(os);
+    systemCounter.serializeSection(cp, "sys_counter");
 
     for (int i = 0; i < timers.size(); ++i) {
-        CoreTimers &core(getTimers(i));
-
-        nameOut(os, core.phys.name());
-        core.phys.serialize(os);
+        const CoreTimers &core(*timers[i]);
 
-        nameOut(os, core.virt.name());
-        core.virt.serialize(os);
+        // This should really be phys_timerN, but we are stuck with
+        // arch_timer for backwards compatibility.
+        core.phys.serializeSection(cp, csprintf("arch_timer%d", i));
+        core.virt.serializeSection(cp, csprintf("virt_timer%d", i));
     }
 }
 
 void
-GenericTimer::unserialize(Checkpoint *cp, const std::string &section)
+GenericTimer::unserialize(CheckpointIn &cp)
 {
-    systemCounter.unserialize(cp, csprintf("%s.sys_counter", section));
+    systemCounter.unserializeSection(cp, "sys_counter");
 
     // Try to unserialize the CPU count. Old versions of the timer
     // model assumed a 8 CPUs, so we fall back to that if the field
@@ -278,8 +274,8 @@ GenericTimer::unserialize(Checkpoint *cp, const std::string &section)
         CoreTimers &core(getTimers(i));
         // This should really be phys_timerN, but we are stuck with
         // arch_timer for backwards compatibility.
-        core.phys.unserialize(cp, csprintf("%s.arch_timer%d", section, i));
-        core.virt.unserialize(cp, csprintf("%s.virt_timer%d", section, i));
+        core.phys.unserializeSection(cp, csprintf("arch_timer%d", i));
+        core.virt.unserializeSection(cp, csprintf("virt_timer%d", i));
     }
 }
 
@@ -498,24 +494,20 @@ GenericTimerMem::GenericTimerMem(GenericTimerMemParams *p)
 }
 
 void
-GenericTimerMem::serialize(std::ostream &os)
+GenericTimerMem::serialize(CheckpointOut &cp) const
 {
-    paramOut(os, "timer_count", 1);
-
-    nameOut(os, csprintf("%s.sys_counter", name()));
-    systemCounter.serialize(os);
+    paramOut(cp, "timer_count", 1);
 
-    nameOut(os, physTimer.name());
-    physTimer.serialize(os);
+    systemCounter.serializeSection(cp, "sys_counter");
 
-    nameOut(os, virtTimer.name());
-    virtTimer.serialize(os);
+    physTimer.serializeSection(cp, "phys_timer0");
+    virtTimer.serializeSection(cp, "virt_timer0");
 }
 
 void
-GenericTimerMem::unserialize(Checkpoint *cp, const std::string &section)
+GenericTimerMem::unserialize(CheckpointIn &cp)
 {
-    systemCounter.unserialize(cp, csprintf("%s.sys_counter", section));
+    systemCounter.unserializeSection(cp, "sys_counter");
 
     unsigned timer_count;
     UNSERIALIZE_SCALAR(timer_count);
@@ -524,8 +516,8 @@ GenericTimerMem::unserialize(Checkpoint *cp, const std::string &section)
     if (timer_count != 1)
         panic("Incompatible checkpoint: Only one set of timers supported");
 
-    physTimer.unserialize(cp, csprintf("%s.phys_timer0", section));
-    virtTimer.unserialize(cp, csprintf("%s.virt_timer0", section));
+    physTimer.unserializeSection(cp, "phys_timer0");
+    virtTimer.unserializeSection(cp, "virt_timer0");
 }
 
 Tick
index d8f7f54e2886ca7113ea7a22bf2b7faa38239237..97823f05f2103dc0a83c69669e375fa588693beb 100644 (file)
@@ -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; }
index b4dc37682fb9ce5b29f099420f91ea2cc9f76494..5a21f6cecf586d845460e6a174448b0b16ae1a97 100644 (file)
@@ -741,7 +741,7 @@ Pl390::getAddrRanges() const
 
 
 void
-Pl390::serialize(std::ostream &os)
+Pl390::serialize(CheckpointOut &cp) const
 {
     DPRINTF(Checkpoint, "Serializing Arm GIC\n");
 
@@ -781,7 +781,7 @@ Pl390::serialize(std::ostream &os)
 }
 
 void
-Pl390::unserialize(Checkpoint *cp, const std::string &section)
+Pl390::unserialize(CheckpointIn &cp)
 {
     DPRINTF(Checkpoint, "Unserializing Arm GIC\n");
 
index 2621e1a2790a19c199c0a4f4b5068d97e50175c8..1adad6c9aaa708464ce24aa635cdfac6fa0e493b 100644 (file)
@@ -300,8 +300,8 @@ class Pl390 : public BaseGic
     void driveIrqEn(bool state);
     /** @} */
 
-    virtual void serialize(std::ostream &os);
-    virtual void unserialize(Checkpoint *cp, const std::string &section);
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 
   protected:
     /** Handle a read to the distributor poriton of the GIC
index 3fc30f16d8048d96f488b68d39aa38df50dfff4e..afeef7637b13e6ee7330a1f92df7d1b54d419a5c 100644 (file)
@@ -580,7 +580,7 @@ HDLcd::dmaDone(DmaDoneEvent *event)
 }
 
 void
-HDLcd::serialize(std::ostream &os)
+HDLcd::serialize(CheckpointOut &cp) const
 {
     DPRINTF(HDLcd, "Serializing ARM HDLCD\n");
 
@@ -641,7 +641,7 @@ HDLcd::serialize(std::ostream &os)
     SERIALIZE_SCALAR(dmaPendingNum);
     SERIALIZE_SCALAR(frameUnderrun);
 
-    arrayParamOut(os, "virtualDisplayBuffer", virtualDisplayBuffer);
+    arrayParamOut(cp, "virtualDisplayBuffer", virtualDisplayBuffer);
 
     SERIALIZE_SCALAR(pixelBufferSize);
     SERIALIZE_SCALAR(pixelIndex);
@@ -678,12 +678,12 @@ HDLcd::serialize(std::ostream &os)
         dma_done_event_burst_len[x] = dmaDoneEventAll[x].scheduled() ?
             dmaDoneEventAll[x].getTransactionSize() : 0;
     }
-    arrayParamOut(os, "dma_done_event_tick", dma_done_event_tick);
-    arrayParamOut(os, "dma_done_event_burst_length", dma_done_event_burst_len);
+    arrayParamOut(cp, "dma_done_event_tick", dma_done_event_tick);
+    arrayParamOut(cp, "dma_done_event_burst_length", dma_done_event_burst_len);
 }
 
 void
-HDLcd::unserialize(Checkpoint *cp, const std::string &section)
+HDLcd::unserialize(CheckpointIn &cp)
 {
     uint32_t version_serial, int_rawstat_serial, int_clear_serial,
             int_mask_serial, int_status_serial, fb_line_count_serial,
@@ -753,7 +753,7 @@ HDLcd::unserialize(Checkpoint *cp, const std::string &section)
     UNSERIALIZE_SCALAR(frameUnderrun);
     UNSERIALIZE_SCALAR(dmaBytesInFlight);
 
-    arrayParamIn(cp, section, "virtualDisplayBuffer", virtualDisplayBuffer);
+    arrayParamIn(cp, "virtualDisplayBuffer", virtualDisplayBuffer);
 
     UNSERIALIZE_SCALAR(pixelBufferSize);
     UNSERIALIZE_SCALAR(pixelIndex);
@@ -783,8 +783,8 @@ HDLcd::unserialize(Checkpoint *cp, const std::string &section)
 
     vector<Tick> dma_done_event_tick(MAX_OUTSTANDING_DMA_REQ_CAPACITY);
     vector<Tick> dma_done_event_burst_len(MAX_OUTSTANDING_DMA_REQ_CAPACITY);
-    arrayParamIn(cp, section, "dma_done_event_tick", dma_done_event_tick);
-    arrayParamIn(cp, section, "dma_done_event_burst_length", dma_done_event_burst_len);
+    arrayParamIn(cp, "dma_done_event_tick", dma_done_event_tick);
+    arrayParamIn(cp, "dma_done_event_burst_length", dma_done_event_burst_len);
     dmaDoneEventFree.clear();
     for (int x = 0; x < MAX_OUTSTANDING_DMA_REQ_CAPACITY; ++x) {
         if (dma_done_event_tick[x]) {
index 519afeba69f84128a12d5b8dd69955f3d0ce0589..1396c9a8b6d51e7fa4857b0f79fa927720d23ed4 100644 (file)
@@ -502,8 +502,8 @@ class HDLcd: public AmbaDmaDevice
     virtual Tick read(PacketPtr pkt);
     virtual Tick write(PacketPtr pkt);
 
-    virtual void serialize(std::ostream &os);
-    virtual void unserialize(Checkpoint *cp, const std::string &section);
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 
     /**
      * Determine the address ranges that this device responds to.
index 2344b4cb566b3aa093f370fb126a29439c9bceb3..d96810351715126a954158cfb71abca52f9cb0a4 100644 (file)
@@ -308,7 +308,7 @@ Pl050::keyPress(uint32_t key, bool down)
 }
 
 void
-Pl050::serialize(std::ostream &os)
+Pl050::serialize(CheckpointOut &cp) const
 {
     uint8_t ctrlreg = control;
     SERIALIZE_SCALAR(ctrlreg);
@@ -327,11 +327,11 @@ Pl050::serialize(std::ostream &os)
     SERIALIZE_SCALAR(shiftDown);
     SERIALIZE_SCALAR(driverInitialized);
 
-    arrayParamOut(os, "rxQueue", rxQueue);
+    SERIALIZE_CONTAINER(rxQueue);
 }
 
 void
-Pl050::unserialize(Checkpoint *cp, const std::string &section)
+Pl050::unserialize(CheckpointIn &cp)
 {
     uint8_t ctrlreg;
     UNSERIALIZE_SCALAR(ctrlreg);
@@ -355,7 +355,7 @@ Pl050::unserialize(Checkpoint *cp, const std::string &section)
     UNSERIALIZE_SCALAR(shiftDown);
     UNSERIALIZE_SCALAR(driverInitialized);
 
-    arrayParamIn(cp, section, "rxQueue", rxQueue);
+    UNSERIALIZE_CONTAINER(rxQueue);
 }
 
 
index f9dbfcf762d4f6da3b8b370e50ab0bd238c60123..9b30b3c152ad923611dc7bb1fda2051b7230f066 100644 (file)
@@ -157,8 +157,8 @@ class Pl050 : public AmbaIntDevice, public VncKeyboard, public VncMouse
     virtual void mouseAt(uint16_t x, uint16_t y, uint8_t buttons);
     virtual void keyPress(uint32_t key, bool down);
 
-    virtual void serialize(std::ostream &os);
-    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_ARM_PL050_HH__
index 2abd82e9662670c4b9dc4dea111d6b8b8d3f6531..f0c3d2d9871628ed595ebbe9a94dadbbf896586e 100644 (file)
@@ -272,7 +272,7 @@ Pl011::setInterrupts(uint16_t ints, uint16_t mask)
 
 
 void
-Pl011::serialize(std::ostream &os)
+Pl011::serialize(CheckpointOut &cp) const
 {
     DPRINTF(Checkpoint, "Serializing Arm PL011\n");
     SERIALIZE_SCALAR(control);
@@ -282,12 +282,12 @@ Pl011::serialize(std::ostream &os)
     SERIALIZE_SCALAR(ifls);
 
     // Preserve backwards compatibility by giving these silly names.
-    paramOut(os, "imsc_serial", imsc);
-    paramOut(os, "rawInt_serial", rawInt);
+    paramOut(cp, "imsc_serial", imsc);
+    paramOut(cp, "rawInt_serial", rawInt);
 }
 
 void
-Pl011::unserialize(Checkpoint *cp, const std::string &section)
+Pl011::unserialize(CheckpointIn &cp)
 {
     DPRINTF(Checkpoint, "Unserializing Arm PL011\n");
 
@@ -298,8 +298,8 @@ Pl011::unserialize(Checkpoint *cp, const std::string &section)
     UNSERIALIZE_SCALAR(ifls);
 
     // Preserve backwards compatibility by giving these silly names.
-    paramIn(cp, section, "imsc_serial", imsc);
-    paramIn(cp, section, "rawInt_serial", rawInt);
+    paramIn(cp, "imsc_serial", imsc);
+    paramIn(cp, "rawInt_serial", rawInt);
 }
 
 Pl011 *
index f2587c08d84fc2a44d612fac99a5241b1e462680..b0f7d576d054f095dfa7a2a242a3647ae7bd539d 100644 (file)
@@ -60,8 +60,8 @@ class Pl011 : public Uart, public AmbaDevice
   public:
     Pl011(const Pl011Params *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
     Tick read(PacketPtr pkt) M5_ATTR_OVERRIDE;
index fcce09f50b6357344893af8f134471cb3a8f8662..179f1bf2dac0c66669514eb3eeb9d08558b14ad8 100644 (file)
@@ -547,7 +547,7 @@ Pl111::dmaDone()
 }
 
 void
-Pl111::serialize(std::ostream &os)
+Pl111::serialize(CheckpointOut &cp) const
 {
     DPRINTF(PL111, "Serializing ARM PL111\n");
 
@@ -633,11 +633,11 @@ Pl111::serialize(std::ostream &os)
         dma_done_event_tick[x] = dmaDoneEventAll[x].scheduled() ?
             dmaDoneEventAll[x].when() : 0;
     }
-    arrayParamOut(os, "dma_done_event_tick", dma_done_event_tick);
+    SERIALIZE_CONTAINER(dma_done_event_tick);
 }
 
 void
-Pl111::unserialize(Checkpoint *cp, const std::string &section)
+Pl111::unserialize(CheckpointIn &cp)
 {
     DPRINTF(PL111, "Unserializing ARM PL111\n");
 
@@ -731,7 +731,7 @@ Pl111::unserialize(Checkpoint *cp, const std::string &section)
 
     vector<Tick> dma_done_event_tick;
     dma_done_event_tick.resize(maxOutstandingDma);
-    arrayParamIn(cp, section, "dma_done_event_tick", dma_done_event_tick);
+    UNSERIALIZE_CONTAINER(dma_done_event_tick);
     dmaDoneEventFree.clear();
     for (int x = 0; x < maxOutstandingDma; x++) {
         if (dma_done_event_tick[x])
index 85973bbc7374c65352fb8a123df286ddbe10be46..08d9147a4341a0cf0fb6dced02db63b4fc18de50 100644 (file)
@@ -371,8 +371,8 @@ class Pl111: public AmbaDmaDevice
     virtual Tick read(PacketPtr pkt);
     virtual Tick write(PacketPtr pkt);
 
-    virtual void serialize(std::ostream &os);
-    virtual void unserialize(Checkpoint *cp, const std::string &section);
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 
     /**
      * Determine the address ranges that this device responds to.
index e619045c2aff4bbc43aca9e8e9f5cc9c07f82222..d5661877c10e144a0b11be39c76ce06a819e59b5 100644 (file)
@@ -192,7 +192,7 @@ PL031::counterMatch()
 }
 
 void
-PL031::serialize(std::ostream &os)
+PL031::serialize(CheckpointOut &cp) const
 {
     DPRINTF(Checkpoint, "Serializing Arm PL031\n");
     SERIALIZE_SCALAR(timeVal);
@@ -214,7 +214,7 @@ PL031::serialize(std::ostream &os)
 }
 
 void
-PL031::unserialize(Checkpoint *cp, const std::string &section)
+PL031::unserialize(CheckpointIn &cp)
 {
     DPRINTF(Checkpoint, "Unserializing Arm PL031\n");
 
index 0f1929d29ca3e229948c7d31c050e2ae2bd5a665..406857e70d3ae188535e1274d54ca05599265b71 100644 (file)
@@ -125,9 +125,8 @@ class PL031 : public AmbaIntDevice
      */
     virtual Tick write(PacketPtr pkt);
 
-
-    virtual void serialize(std::ostream &os);
-    virtual void unserialize(Checkpoint *cp, const std::string &section);
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 };
 
 
index f2b85d513fa816fee1178fde559374c62af42795..27ba2e8a6886b4372a075a755d6ac120eb7fa1d4 100644 (file)
@@ -248,13 +248,13 @@ RealViewCtrl::write(PacketPtr pkt)
 }
 
 void
-RealViewCtrl::serialize(std::ostream &os)
+RealViewCtrl::serialize(CheckpointOut &cp) const
 {
     SERIALIZE_SCALAR(flags);
 }
 
 void
-RealViewCtrl::unserialize(Checkpoint *cp, const std::string &section)
+RealViewCtrl::unserialize(CheckpointIn &cp)
 {
     UNSERIALIZE_SCALAR(flags);
 }
index adf06563178e60474bbd869b66a2852e457aa797..cae5e2e2c905a205828608a19fd9f0fcf3932e76 100644 (file)
@@ -136,9 +136,8 @@ class RealViewCtrl : public BasicPioDevice
      */
     virtual Tick write(PacketPtr pkt);
 
-
-    virtual void serialize(std::ostream &os);
-    virtual void unserialize(Checkpoint *cp, const std::string &section);
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 };
 
 
index de2f99f0aa549be1d71454579a93aadb9e99e2c7..ac02d099f9f18c487344a2a61039c9fe6a0d400f 100644 (file)
@@ -335,7 +335,7 @@ CpuLocalTimer::Timer::watchdogAtZero()
 }
 
 void
-CpuLocalTimer::Timer::serialize(std::ostream &os)
+CpuLocalTimer::Timer::serialize(CheckpointOut &cp) const
 {
     DPRINTF(Checkpoint, "Serializing Arm CpuLocalTimer\n");
     SERIALIZE_SCALAR(intNumTimer);
@@ -373,7 +373,7 @@ CpuLocalTimer::Timer::serialize(std::ostream &os)
 }
 
 void
-CpuLocalTimer::Timer::unserialize(Checkpoint *cp, const std::string &section)
+CpuLocalTimer::Timer::unserialize(CheckpointIn &cp)
 {
     DPRINTF(Checkpoint, "Unserializing Arm CpuLocalTimer\n");
 
@@ -416,20 +416,17 @@ CpuLocalTimer::Timer::unserialize(Checkpoint *cp, const std::string &section)
 
 
 void
-CpuLocalTimer::serialize(std::ostream &os)
+CpuLocalTimer::serialize(CheckpointOut &cp) const
 {
-    for (int i = 0; i < CPU_MAX; i++) {
-        nameOut(os, csprintf("%s.timer%d", name(), i));
-        localTimer[i].serialize(os);
-    }
+    for (int i = 0; i < CPU_MAX; i++)
+        localTimer[i].serializeSection(cp, csprintf("timer%d", i));
 }
 
 void
-CpuLocalTimer::unserialize(Checkpoint *cp, const std::string &section)
+CpuLocalTimer::unserialize(CheckpointIn &cp)
 {
-    for (int i = 0; i < CPU_MAX; i++) {
-        localTimer[i].unserialize(cp, csprintf("%s.timer%d", section, i));
-    }
+    for (int i = 0; i < CPU_MAX; i++)
+        localTimer[i].unserializeSection(cp, csprintf("timer%d", i));
 }
 
 CpuLocalTimer *
index f53f5bc25910ac35007a1394ac3db9aa3c6d2dc1..73a2d449347bdcb5cd880326bf5e187db7b72fcf 100644 (file)
@@ -55,7 +55,7 @@ class BaseGic;
 class CpuLocalTimer : public BasicPioDevice
 {
   protected:
-    class Timer
+    class Timer : public Serializable
     {
 
       public:
@@ -145,8 +145,8 @@ class CpuLocalTimer : public BasicPioDevice
         /** Handle write for a single timer */
         void write(PacketPtr pkt, Addr daddr);
 
-        void serialize(std::ostream &os);
-        void unserialize(Checkpoint *cp, const std::string &section);
+        void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+        void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 
         friend class CpuLocalTimer;
     };
@@ -186,9 +186,8 @@ class CpuLocalTimer : public BasicPioDevice
      */
     virtual Tick write(PacketPtr pkt);
 
-
-    virtual void serialize(std::ostream &os);
-    virtual void unserialize(Checkpoint *cp, const std::string &section);
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 };
 
 
index 9f7867107c423cb8a51704ddd4f58b1413290c8b..54a5a25165a1df1d11db6ab08242b100b976cb8b 100644 (file)
@@ -217,7 +217,7 @@ Sp804::Timer::counterAtZero()
 }
 
 void
-Sp804::Timer::serialize(std::ostream &os)
+Sp804::Timer::serialize(CheckpointOut &cp) const
 {
     DPRINTF(Checkpoint, "Serializing Arm Sp804\n");
 
@@ -239,7 +239,7 @@ Sp804::Timer::serialize(std::ostream &os)
 }
 
 void
-Sp804::Timer::unserialize(Checkpoint *cp, const std::string &section)
+Sp804::Timer::unserialize(CheckpointIn &cp)
 {
     DPRINTF(Checkpoint, "Unserializing Arm Sp804\n");
 
@@ -264,19 +264,17 @@ Sp804::Timer::unserialize(Checkpoint *cp, const std::string &section)
 
 
 void
-Sp804::serialize(std::ostream &os)
+Sp804::serialize(CheckpointOut &cp) const
 {
-    nameOut(os, csprintf("%s.timer0", name()));
-    timer0.serialize(os);
-    nameOut(os, csprintf("%s.timer1", name()));
-    timer1.serialize(os);
+    timer0.serializeSection(cp, "timer0");
+    timer1.serializeSection(cp, "timer1");
 }
 
 void
-Sp804::unserialize(Checkpoint *cp, const std::string &section)
+Sp804::unserialize(CheckpointIn &cp)
 {
-    timer0.unserialize(cp, csprintf("%s.timer0", section));
-    timer1.unserialize(cp, csprintf("%s.timer1", section));
+    timer0.unserializeSection(cp, "timer0");
+    timer1.unserializeSection(cp, "timer1");
 }
 
 Sp804 *
index 03dc20ec14b441f802953211fc6d6711f4546684..c5b3bb6332834813b091c5e038987ce7c8d2c7c6 100644 (file)
@@ -52,7 +52,7 @@ class BaseGic;
 class Sp804 : public AmbaPioDevice
 {
   protected:
-    class Timer
+    class Timer : public Serializable
     {
 
       public:
@@ -121,9 +121,8 @@ class Sp804 : public AmbaPioDevice
         /** Handle write for a single timer */
         void write(PacketPtr pkt, Addr daddr);
 
-        void serialize(std::ostream &os);
-        void unserialize(Checkpoint *cp, const std::string &section);
-
+        void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+        void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
     };
 
     /** Pointer to the GIC for causing an interrupt */
@@ -161,8 +160,8 @@ class Sp804 : public AmbaPioDevice
     virtual Tick write(PacketPtr pkt);
 
 
-    virtual void serialize(std::ostream &os);
-    virtual void unserialize(Checkpoint *cp, const std::string &section);
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 };
 
 
index d271656cd224646adcf8b6c5e121796fa47946ea..02df00e351a8757238b34b4e17cf709e3cbe151c 100644 (file)
@@ -2283,11 +2283,11 @@ UFSHostDevice::readGarbage()
  */
 
 void
-UFSHostDevice::serialize(std::ostream &os)
+UFSHostDevice::serialize(CheckpointOut &cp) const
 {
-    DmaDevice::serialize(os);
+    DmaDevice::serialize(cp);
 
-    uint8_t* temp_HCI_mem = reinterpret_cast<uint8_t*>(&UFSHCIMem);
+    const uint8_t* temp_HCI_mem = reinterpret_cast<const uint8_t*>(&UFSHCIMem);
     SERIALIZE_ARRAY(temp_HCI_mem, sizeof(HCIMem));
 
     uint32_t lun_avail = lunAvail;
@@ -2300,9 +2300,9 @@ UFSHostDevice::serialize(std::ostream &os)
  */
 
 void
-UFSHostDevice::unserialize(Checkpoint *cp, const std::string &section)
+UFSHostDevice::unserialize(CheckpointIn &cp)
 {
-    DmaDevice::unserialize(cp, section);
+    DmaDevice::unserialize(cp);
     uint8_t* temp_HCI_mem = reinterpret_cast<uint8_t*>(&UFSHCIMem);
     UNSERIALIZE_ARRAY(temp_HCI_mem, sizeof(HCIMem));
 
index 07f038175482a359a61c5c3518725be70eeb0169..15e983ad8ae1a1d4e84588de47071bd22e07915d 100644 (file)
@@ -175,8 +175,8 @@ class UFSHostDevice : public DmaDevice
 
     unsigned int drain(DrainManager *dm);
     void checkDrain();
-    void serialize(std::ostream &os);
-    void unserialize(Checkpoint *cp, const std::string &section);
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 
   private:
     /**
index 4a63c796a9fbffd3af08c7f3a3f5ff7d15a79ff6..f4a3e8c3f8e73bd1e5a067faf74c7a2852035596 100644 (file)
@@ -56,9 +56,6 @@ VGic::VGic(const Params *p)
         maintIntPosted[x] = false;
         vIntPosted[x] = false;
     }
-    for (int c = 0; c < VGIC_CPU_MAX; c++) {
-        memset(&vcpuData[c], 0, sizeof(struct vcpuIntData));
-    }
     assert(sys->numRunningContexts() <= VGIC_CPU_MAX);
 }
 
@@ -437,7 +434,7 @@ VGic::getAddrRanges() const
 }
 
 void
-VGic::serialize(std::ostream &os)
+VGic::serialize(CheckpointOut &cp) const
 {
     Tick interrupt_time[VGIC_CPU_MAX];
     for (uint32_t cpu = 0; cpu < VGIC_CPU_MAX; cpu++) {
@@ -457,42 +454,45 @@ VGic::serialize(std::ostream &os)
     SERIALIZE_SCALAR(pioDelay);
     SERIALIZE_SCALAR(maintInt);
 
-    for (uint32_t cpu = 0; cpu < VGIC_CPU_MAX; cpu++) {
-        nameOut(os, csprintf("%s.vcpuData%d", name(), cpu));
-        uint32_t vctrl_val = vcpuData[cpu].vctrl;
-        SERIALIZE_SCALAR(vctrl_val);
-        uint32_t hcr_val = vcpuData[cpu].hcr;
-        SERIALIZE_SCALAR(hcr_val);
-        uint64_t eisr_val = vcpuData[cpu].eisr;
-        SERIALIZE_SCALAR(eisr_val);
-        uint8_t VMGrp0En_val = vcpuData[cpu].VMGrp0En;
-        SERIALIZE_SCALAR(VMGrp0En_val);
-        uint8_t VMGrp1En_val = vcpuData[cpu].VMGrp1En;
-        SERIALIZE_SCALAR(VMGrp1En_val);
-        uint8_t VMAckCtl_val = vcpuData[cpu].VMAckCtl;
-        SERIALIZE_SCALAR(VMAckCtl_val);
-        uint8_t VMFiqEn_val = vcpuData[cpu].VMFiqEn;
-        SERIALIZE_SCALAR(VMFiqEn_val);
-        uint8_t VMCBPR_val = vcpuData[cpu].VMCBPR;
-        SERIALIZE_SCALAR(VMCBPR_val);
-        uint8_t VEM_val = vcpuData[cpu].VEM;
-        SERIALIZE_SCALAR(VEM_val);
-        uint8_t VMABP_val = vcpuData[cpu].VMABP;
-        SERIALIZE_SCALAR(VMABP_val);
-        uint8_t VMBP_val = vcpuData[cpu].VMBP;
-        SERIALIZE_SCALAR(VMBP_val);
-        uint8_t VMPriMask_val = vcpuData[cpu].VMPriMask;
-        SERIALIZE_SCALAR(VMPriMask_val);
-
-        for (int i = 0; i < NUM_LR; i++) {
-            uint32_t lr = vcpuData[cpu].LR[i];
-            nameOut(os, csprintf("%s.vcpuData%d.LR%d", name(), cpu, i));
-            SERIALIZE_SCALAR(lr);
-        }
+    for (uint32_t cpu = 0; cpu < VGIC_CPU_MAX; cpu++)
+        vcpuData[cpu].serializeSection(cp, csprintf("vcpuData%d", cpu));
+}
+
+void
+VGic::vcpuIntData::serialize(CheckpointOut &cp) const
+{
+    uint32_t vctrl_val = vctrl;
+    SERIALIZE_SCALAR(vctrl_val);
+    uint32_t hcr_val = hcr;
+    SERIALIZE_SCALAR(hcr_val);
+    uint64_t eisr_val = eisr;
+    SERIALIZE_SCALAR(eisr_val);
+    uint8_t VMGrp0En_val = VMGrp0En;
+    SERIALIZE_SCALAR(VMGrp0En_val);
+    uint8_t VMGrp1En_val = VMGrp1En;
+    SERIALIZE_SCALAR(VMGrp1En_val);
+    uint8_t VMAckCtl_val = VMAckCtl;
+    SERIALIZE_SCALAR(VMAckCtl_val);
+    uint8_t VMFiqEn_val = VMFiqEn;
+    SERIALIZE_SCALAR(VMFiqEn_val);
+    uint8_t VMCBPR_val = VMCBPR;
+    SERIALIZE_SCALAR(VMCBPR_val);
+    uint8_t VEM_val = VEM;
+    SERIALIZE_SCALAR(VEM_val);
+    uint8_t VMABP_val = VMABP;
+    SERIALIZE_SCALAR(VMABP_val);
+    uint8_t VMBP_val = VMBP;
+    SERIALIZE_SCALAR(VMBP_val);
+    uint8_t VMPriMask_val = VMPriMask;
+    SERIALIZE_SCALAR(VMPriMask_val);
+
+    for (int i = 0; i < NUM_LR; i++) {
+        ScopedCheckpointSection sec_lr(cp, csprintf("LR%d", i));
+        paramOut(cp, "lr", LR[i]);
     }
 }
 
-void VGic::unserialize(Checkpoint *cp, const std::string &section)
+void VGic::unserialize(CheckpointIn &cp)
 {
     DPRINTF(Checkpoint, "Unserializing Arm GIC\n");
 
@@ -502,37 +502,7 @@ void VGic::unserialize(Checkpoint *cp, const std::string &section)
         if (interrupt_time[cpu])
             schedule(postVIntEvent[cpu], interrupt_time[cpu]);
 
-        uint32_t tmp;
-        paramIn(cp, csprintf("%s.vcpuData%d", section, cpu),
-                "vctrl_val", tmp);
-        vcpuData[cpu].vctrl = tmp;
-        paramIn(cp, csprintf("%s.vcpuData%d", section, cpu),
-                "hcr_val", tmp);
-        vcpuData[cpu].hcr = tmp;
-        paramIn(cp, csprintf("%s.vcpuData%d", section, cpu),
-                "eisr_val", vcpuData[cpu].eisr);
-        paramIn(cp, csprintf("%s.vcpuData%d", section, cpu),
-                "VMGrp0En_val", vcpuData[cpu].VMGrp0En);
-        paramIn(cp, csprintf("%s.vcpuData%d", section, cpu),
-                "VMGrp1En_val", vcpuData[cpu].VMGrp1En);
-        paramIn(cp, csprintf("%s.vcpuData%d", section, cpu),
-                "VMAckCtl_val", vcpuData[cpu].VMAckCtl);
-        paramIn(cp, csprintf("%s.vcpuData%d", section, cpu),
-                "VMFiqEn_val", vcpuData[cpu].VMFiqEn);
-        paramIn(cp, csprintf("%s.vcpuData%d", section, cpu),
-                "VMCBPR_val", vcpuData[cpu].VMCBPR);
-        paramIn(cp, csprintf("%s.vcpuData%d", section, cpu),
-                "VEM_val", vcpuData[cpu].VEM);
-        paramIn(cp, csprintf("%s.vcpuData%d", section, cpu),
-                "VMABP_val", vcpuData[cpu].VMABP);
-        paramIn(cp, csprintf("%s.vcpuData%d", section, cpu),
-                "VMPriMask_val", vcpuData[cpu].VMPriMask);
-
-        for (int i = 0; i < NUM_LR; i++) {
-            paramIn(cp, csprintf("%s.vcpuData%d.LR%d", section, cpu, i),
-                    "lr", tmp);
-            vcpuData[cpu].LR[i] = tmp;
-        }
+        vcpuData[cpu].unserializeSection(cp, csprintf("vcpuData%d", cpu));
     }
     UNSERIALIZE_ARRAY(maintIntPosted, VGIC_CPU_MAX);
     UNSERIALIZE_ARRAY(vIntPosted, VGIC_CPU_MAX);
@@ -542,6 +512,27 @@ void VGic::unserialize(Checkpoint *cp, const std::string &section)
     UNSERIALIZE_SCALAR(maintInt);
 }
 
+void
+VGic::vcpuIntData::unserialize(CheckpointIn &cp)
+{
+    paramIn(cp, "vctrl_val", vctrl);
+    paramIn(cp, "hcr_val", hcr);
+    paramIn(cp, "eisr_val", eisr);
+    paramIn(cp, "VMGrp0En_val", VMGrp0En);
+    paramIn(cp, "VMGrp1En_val", VMGrp1En);
+    paramIn(cp, "VMAckCtl_val", VMAckCtl);
+    paramIn(cp, "VMFiqEn_val", VMFiqEn);
+    paramIn(cp, "VMCBPR_val", VMCBPR);
+    paramIn(cp, "VEM_val", VEM);
+    paramIn(cp, "VMABP_val", VMABP);
+    paramIn(cp, "VMPriMask_val", VMPriMask);
+
+    for (int i = 0; i < NUM_LR; i++) {
+        ScopedCheckpointSection sec_lr(cp, csprintf("LR%d", i));
+        paramIn(cp, "lr", LR[i]);
+    }
+}
+
 VGic *
 VGicParams::create()
 {
index e1c4960e9d38186352903be5ad3b6bccd653181c..ac88f842f9e196d68157cc9337b4f20bc3e4600f 100644 (file)
@@ -52,6 +52,9 @@
 #ifndef __DEV_ARM_VGIC_H__
 #define __DEV_ARM_VGIC_H__
 
+#include <algorithm>
+#include <array>
+
 #include "base/addr_range.hh"
 #include "base/bitunion.hh"
 #include "cpu/intr_control.hh"
@@ -162,8 +165,17 @@ class VGic : public PioDevice
     /* State per CPU.  EVERYTHING should be in this struct and simply replicated
      * N times.
      */
-    struct vcpuIntData {
-        ListReg LR[NUM_LR];
+    struct vcpuIntData : public Serializable {
+        vcpuIntData()
+            : vctrl(0), hcr(0), eisr(0), VMGrp0En(0), VMGrp1En(0),
+              VMAckCtl(0), VMFiqEn(0), VMCBPR(0), VEM(0), VMABP(0), VMBP(0),
+              VMPriMask(0)
+        {
+            std::fill(LR.begin(), LR.end(), 0);
+        }
+        virtual ~vcpuIntData() {}
+
+        std::array<ListReg, NUM_LR> LR;
         VCTLR vctrl;
 
         HCR hcr;
@@ -179,9 +191,12 @@ class VGic : public PioDevice
         uint8_t VMABP;
         uint8_t VMBP;
         uint8_t VMPriMask;
+
+        void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+        void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
     };
 
-    struct vcpuIntData vcpuData[VGIC_CPU_MAX];
+    struct std::array<vcpuIntData, VGIC_CPU_MAX>  vcpuData;
 
   public:
    typedef VGicParams Params;
@@ -197,8 +212,8 @@ class VGic : public PioDevice
     virtual Tick read(PacketPtr pkt);
     virtual Tick write(PacketPtr pkt);
 
-    virtual void serialize(std::ostream &os);
-    virtual void unserialize(Checkpoint *cp, const std::string &section);
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 
   private:
     Tick readVCpu(PacketPtr pkt);
index a3d73b634a71226a8adecbb96f70c6288e388824..5506103b1a5969c6f9f610c77a75c5584522b977 100644 (file)
@@ -676,27 +676,25 @@ CopyEngine::drain(DrainManager *dm)
 }
 
 void
-CopyEngine::serialize(std::ostream &os)
+CopyEngine::serialize(CheckpointOut &cp) const
 {
-    PciDevice::serialize(os);
-    regs.serialize(os);
-    for (int x =0; x < chan.size(); x++) {
-        nameOut(os, csprintf("%s.channel%d", name(), x));
-        chan[x]->serialize(os);
-    }
+    PciDevice::serialize(cp);
+    regs.serialize(cp);
+    for (int x =0; x < chan.size(); x++)
+        chan[x]->serializeSection(cp, csprintf("channel%d", x));
 }
 
 void
-CopyEngine::unserialize(Checkpoint *cp, const std::string &section)
+CopyEngine::unserialize(CheckpointIn &cp)
 {
-    PciDevice::unserialize(cp, section);
-    regs.unserialize(cp, section);
+    PciDevice::unserialize(cp);
+    regs.unserialize(cp);
     for (int x = 0; x < chan.size(); x++)
-        chan[x]->unserialize(cp, csprintf("%s.channel%d", section, x));
+        chan[x]->unserializeSection(cp, csprintf("channel%d", x));
 }
 
 void
-CopyEngine::CopyEngineChannel::serialize(std::ostream &os)
+CopyEngine::CopyEngineChannel::serialize(CheckpointOut &cp) const
 {
     SERIALIZE_SCALAR(channelId);
     SERIALIZE_SCALAR(busy);
@@ -707,13 +705,13 @@ CopyEngine::CopyEngineChannel::serialize(std::ostream &os)
     SERIALIZE_SCALAR(fetchAddress);
     int nextState = this->nextState;
     SERIALIZE_SCALAR(nextState);
-    arrayParamOut(os, "curDmaDesc", (uint8_t*)curDmaDesc, sizeof(DmaDesc));
+    arrayParamOut(cp, "curDmaDesc", (uint8_t*)curDmaDesc, sizeof(DmaDesc));
     SERIALIZE_ARRAY(copyBuffer, ce->params()->XferCap);
-    cr.serialize(os);
+    cr.serialize(cp);
 
 }
 void
-CopyEngine::CopyEngineChannel::unserialize(Checkpoint *cp, const std::string &section)
+CopyEngine::CopyEngineChannel::unserialize(CheckpointIn &cp)
 {
     UNSERIALIZE_SCALAR(channelId);
     UNSERIALIZE_SCALAR(busy);
@@ -725,9 +723,9 @@ CopyEngine::CopyEngineChannel::unserialize(Checkpoint *cp, const std::string &se
     int nextState;
     UNSERIALIZE_SCALAR(nextState);
     this->nextState = (ChannelState)nextState;
-    arrayParamIn(cp, section, "curDmaDesc", (uint8_t*)curDmaDesc, sizeof(DmaDesc));
+    arrayParamIn(cp, "curDmaDesc", (uint8_t*)curDmaDesc, sizeof(DmaDesc));
     UNSERIALIZE_ARRAY(copyBuffer, ce->params()->XferCap);
-    cr.unserialize(cp, section);
+    cr.unserialize(cp);
 
 }
 
index 1186d0b1dd67dd48f8fe375019fe1eb281980e14..80c9798ee0f870d1bf538212ddd39d425a27aca7 100644 (file)
@@ -60,7 +60,7 @@
 
 class CopyEngine : public PciDevice
 {
-    class CopyEngineChannel : public Drainable
+    class CopyEngineChannel : public Drainable, public Serializable
     {
       private:
         DmaPort cePort;
@@ -110,8 +110,8 @@ class CopyEngine : public PciDevice
         unsigned int drain(DrainManager *drainManger);
         void drainResume();
 
-        void serialize(std::ostream &os);
-        void unserialize(Checkpoint *cp, const std::string &section);
+        void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+        void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 
       private:
         void fetchDescriptor(Addr address);
@@ -205,8 +205,8 @@ class CopyEngine : public PciDevice
     virtual Tick read(PacketPtr pkt);
     virtual Tick write(PacketPtr pkt);
 
-    virtual void serialize(std::ostream &os);
-    virtual void unserialize(Checkpoint *cp, const std::string &section);
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 
     unsigned int drain(DrainManager *drainManger);
     void drainResume();
index 98216e64c56270334a6d6f36a2319d4cc61b845f..afefac2b51e0a5c8a77d104ef27d2056f5cf17b8 100644 (file)
@@ -100,18 +100,18 @@ struct Reg {
     bool operator==(T d) { return d == _data; }
     void operator()(T d) { _data = d; }
     Reg() { _data = 0; }
-    void serialize(std::ostream &os)
+    void serialize(CheckpointOut &cp) const
     {
         SERIALIZE_SCALAR(_data);
     }
-    void unserialize(Checkpoint *cp, const std::string &section)
+    void unserialize(CheckpointIn &cp)
     {
         UNSERIALIZE_SCALAR(_data);
     }
 };
 
 
-struct Regs {
+struct Regs : public Serializable {
     uint8_t chanCount;
     uint8_t xferCap;
 
@@ -125,25 +125,25 @@ struct Regs {
 
     uint32_t attnStatus; // Read clears
 
-    void serialize(std::ostream &os)
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE
     {
         SERIALIZE_SCALAR(chanCount);
         SERIALIZE_SCALAR(xferCap);
-        paramOut(os, "intrctrl", intrctrl._data);
+        paramOut(cp, "intrctrl", intrctrl._data);
         SERIALIZE_SCALAR(attnStatus);
     }
 
-    void unserialize(Checkpoint *cp, const std::string &section)
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE
     {
         UNSERIALIZE_SCALAR(chanCount);
         UNSERIALIZE_SCALAR(xferCap);
-        paramIn(cp, section, "intrctrl", intrctrl._data);
+        paramIn(cp, "intrctrl", intrctrl._data);
         UNSERIALIZE_SCALAR(attnStatus);
     }
 
 };
 
-struct ChanRegs {
+struct ChanRegs : public Serializable {
     struct CHANCTRL : public Reg<uint16_t> { // channelX + 0x00
         using Reg<uint16_t>::operator =;
         ADD_FIELD16(interrupt_disable,0,1);
@@ -197,24 +197,24 @@ struct ChanRegs {
     };
     CHANERR error;
 
-    void serialize(std::ostream &os)
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE
     {
-        paramOut(os, "ctrl", ctrl._data);
-        paramOut(os, "status", status._data);
+        paramOut(cp, "ctrl", ctrl._data);
+        paramOut(cp, "status", status._data);
         SERIALIZE_SCALAR(descChainAddr);
-        paramOut(os, "command", command._data);
+        paramOut(cp, "command", command._data);
         SERIALIZE_SCALAR(completionAddr);
-        paramOut(os, "error", error._data);
+        paramOut(cp, "error", error._data);
     }
 
-    void unserialize(Checkpoint *cp, const std::string &section)
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE
     {
-        paramIn(cp, section, "ctrl", ctrl._data);
-        paramIn(cp, section, "status", status._data);
+        paramIn(cp, "ctrl", ctrl._data);
+        paramIn(cp, "status", status._data);
         UNSERIALIZE_SCALAR(descChainAddr);
-        paramIn(cp, section, "command", command._data);
+        paramIn(cp, "command", command._data);
         UNSERIALIZE_SCALAR(completionAddr);
-        paramIn(cp, section, "error", error._data);
+        paramIn(cp, "error", error._data);
     }
 
 
index 8194eb507bc948832c41d3381713457aac147735..e4907853fd26fcf7bc44ba0527083b05f49c957a 100644 (file)
@@ -308,13 +308,13 @@ SafeWriteSwap(ofstream &stream, const T &data)
     SafeWrite(stream, &swappeddata, sizeof(data));
 }
 void
-CowDiskImage::save()
+CowDiskImage::save() const
 {
     save(filename);
 }
 
 void
-CowDiskImage::save(const string &file)
+CowDiskImage::save(const string &file) const
 {
     if (!initialized)
         panic("RawDiskImage not initialized");
@@ -408,19 +408,19 @@ CowDiskImage::write(const uint8_t *data, std::streampos offset)
 }
 
 void
-CowDiskImage::serialize(ostream &os)
+CowDiskImage::serialize(CheckpointOut &cp) const
 {
     string cowFilename = name() + ".cow";
     SERIALIZE_SCALAR(cowFilename);
-    save(Checkpoint::dir() + "/" + cowFilename);
+    save(CheckpointIn::dir() + "/" + cowFilename);
 }
 
 void
-CowDiskImage::unserialize(Checkpoint *cp, const string &section)
+CowDiskImage::unserialize(CheckpointIn &cp)
 {
     string cowFilename;
     UNSERIALIZE_SCALAR(cowFilename);
-    cowFilename = cp->cptDir + "/" + cowFilename;
+    cowFilename = cp.cptDir + "/" + cowFilename;
     open(cowFilename);
 }
 
index da96082cb0919a5db390c9152e200433faff70e4..25483eed509c32d5cdd4827fc94a5de4757e4fbc 100644 (file)
@@ -125,11 +125,12 @@ class CowDiskImage : public DiskImage
 
     void initSectorTable(int hash_size);
     bool open(const std::string &file);
-    void save();
-    void save(const std::string &file);
+    void save() const;
+    void save(const std::string &file) const;
     void writeback();
-    void serialize(std::ostream &os);
-    void unserialize(Checkpoint *cp, const std::string &section);
+
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 
     virtual std::streampos size() const;
 
index c5ef66d998a6617f096b54755ca8f453ac093f87..27179d508a0afe1a00e723b090a343b053873154 100644 (file)
@@ -107,17 +107,17 @@ EtherLink::Link::Link(const string &name, EtherLink *p, int num,
 { }
 
 void
-EtherLink::serialize(ostream &os)
+EtherLink::serialize(CheckpointOut &cp) const
 {
-    link[0]->serialize("link0", os);
-    link[1]->serialize("link1", os);
+    link[0]->serialize("link0", cp);
+    link[1]->serialize("link1", cp);
 }
 
 void
-EtherLink::unserialize(Checkpoint *cp, const string &section)
+EtherLink::unserialize(CheckpointIn &cp)
 {
-    link[0]->unserialize("link0", cp, section);
-    link[1]->unserialize("link1", cp, section);
+    link[0]->unserialize("link0", cp);
+    link[1]->unserialize("link1", cp);
 }
 
 void
@@ -141,11 +141,11 @@ class LinkDelayEvent : public Event
 
     void process();
 
-    virtual void serialize(ostream &os);
-    void unserialize(Checkpoint *cp, const string &section) {}
-    void unserialize(Checkpoint *cp, const string &section,
-                     EventQueue *eventq);
-    static Serializable *createForUnserialize(Checkpoint *cp,
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE {}
+    void unserializeEvent(CheckpointIn &cp,
+                          EventQueue *eventq) M5_ATTR_OVERRIDE;
+    static Serializable *createForUnserialize(CheckpointIn &cp,
                                               const string &section);
 };
 
@@ -193,38 +193,37 @@ EtherLink::Link::transmit(EthPacketPtr pkt)
 }
 
 void
-EtherLink::Link::serialize(const string &base, ostream &os)
+EtherLink::Link::serialize(const string &base, CheckpointOut &cp) const
 {
     bool packet_exists = packet != nullptr;
-    paramOut(os, base + ".packet_exists", packet_exists);
+    paramOut(cp, base + ".packet_exists", packet_exists);
     if (packet_exists)
-        packet->serialize(base + ".packet", os);
+        packet->serialize(base + ".packet", cp);
 
     bool event_scheduled = doneEvent.scheduled();
-    paramOut(os, base + ".event_scheduled", event_scheduled);
+    paramOut(cp, base + ".event_scheduled", event_scheduled);
     if (event_scheduled) {
         Tick event_time = doneEvent.when();
-        paramOut(os, base + ".event_time", event_time);
+        paramOut(cp, base + ".event_time", event_time);
     }
 
 }
 
 void
-EtherLink::Link::unserialize(const string &base, Checkpoint *cp,
-                             const string &section)
+EtherLink::Link::unserialize(const string &base, CheckpointIn &cp)
 {
     bool packet_exists;
-    paramIn(cp, section, base + ".packet_exists", packet_exists);
+    paramIn(cp, base + ".packet_exists", packet_exists);
     if (packet_exists) {
         packet = make_shared<EthPacketData>(16384);
-        packet->unserialize(base + ".packet", cp, section);
+        packet->unserialize(base + ".packet", cp);
     }
 
     bool event_scheduled;
-    paramIn(cp, section, base + ".event_scheduled", event_scheduled);
+    paramIn(cp, base + ".event_scheduled", event_scheduled);
     if (event_scheduled) {
         Tick event_time;
-        paramIn(cp, section, base + ".event_time", event_time);
+        paramIn(cp, base + ".event_time", event_time);
         parent->schedule(doneEvent, event_time);
     }
 }
@@ -246,25 +245,24 @@ LinkDelayEvent::process()
 }
 
 void
-LinkDelayEvent::serialize(ostream &os)
+LinkDelayEvent::serialize(CheckpointOut &cp) const
 {
-    paramOut(os, "type", string("LinkDelayEvent"));
-    Event::serialize(os);
+    paramOut(cp, "type", string("LinkDelayEvent"));
+    Event::serialize(cp);
 
     EtherLink *parent = link->parent;
     bool number = link->number;
     SERIALIZE_OBJPTR(parent);
     SERIALIZE_SCALAR(number);
 
-    packet->serialize("packet", os);
+    packet->serialize("packet", cp);
 }
 
 
 void
-LinkDelayEvent::unserialize(Checkpoint *cp, const string &section,
-                            EventQueue *eventq)
+LinkDelayEvent::unserializeEvent(CheckpointIn &cp, EventQueue *eventq)
 {
-    Event::unserialize(cp, section, eventq);
+    Event::unserializeEvent(cp, eventq);
 
     EtherLink *parent;
     bool number;
@@ -274,12 +272,12 @@ LinkDelayEvent::unserialize(Checkpoint *cp, const string &section,
     link = parent->link[number];
 
     packet = make_shared<EthPacketData>(16384);
-    packet->unserialize("packet", cp, section);
+    packet->unserialize("packet", cp);
 }
 
 
 Serializable *
-LinkDelayEvent::createForUnserialize(Checkpoint *cp, const string &section)
+LinkDelayEvent::createForUnserialize(CheckpointIn &cp, const string &section)
 {
     return new LinkDelayEvent();
 }
index ca17b837da708b48c60ad7d94295f420ee163c61..525e8250d53e10017ad61afd32f6642960844ba5 100644 (file)
@@ -99,9 +99,8 @@ class EtherLink : public EtherObject
         void setTxInt(Interface *i) { assert(!txint); txint = i; }
         void setRxInt(Interface *i) { assert(!rxint); rxint = i; }
 
-        void serialize(const std::string &base, std::ostream &os);
-        void unserialize(const std::string &base, Checkpoint *cp,
-                                 const std::string &section);
+        void serialize(const std::string &base, CheckpointOut &cp) const;
+        void unserialize(const std::string &base, CheckpointIn &cp);
     };
 
     /*
@@ -135,8 +134,8 @@ class EtherLink : public EtherObject
 
     virtual EtherInt *getEthPort(const std::string &if_name, int idx);
 
-    virtual void serialize(std::ostream &os);
-    virtual void unserialize(Checkpoint *cp, const std::string &section);
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 
 };
 
index 2c8343eb05ba242fb42043aedd3df023d117d2b0..548a1f179090b68a98e1563dc7dde66387d53fbe 100644 (file)
 using namespace std;
 
 void
-EthPacketData::serialize(const string &base, ostream &os)
+EthPacketData::serialize(const string &base, CheckpointOut &cp) const
 {
-    paramOut(os, base + ".length", length);
-    arrayParamOut(os, base + ".data", data, length);
+    paramOut(cp, base + ".length", length);
+    arrayParamOut(cp, base + ".data", data, length);
 }
 
 void
-EthPacketData::unserialize(const string &base, Checkpoint *cp,
-                        const string &section)
+EthPacketData::unserialize(const string &base, CheckpointIn &cp)
 {
-    paramIn(cp, section, base + ".length", length);
+    paramIn(cp, base + ".length", length);
     if (length)
-        arrayParamIn(cp, section, base + ".data", data, length);
+        arrayParamIn(cp, base + ".data", data, length);
 }
index febd303a183b1927621eb46c1f98db78014caa1e..acda9fb477fa4d53e002d45f73ed55dda63d2195 100644 (file)
 #include <memory>
 
 #include "base/types.hh"
+#include "sim/serialize.hh"
 
 /*
  * Reference counted class containing ethernet packet data
  */
-class Checkpoint;
 class EthPacketData
 {
   public:
@@ -71,9 +71,8 @@ class EthPacketData
     ~EthPacketData() { if (data) delete [] data; }
 
   public:
-    void serialize(const std::string &base, std::ostream &os);
-    void unserialize(const std::string &base, Checkpoint *cp,
-                     const std::string &section);
+    void serialize(const std::string &base, CheckpointOut &cp) const;
+    void unserialize(const std::string &base, CheckpointIn &cp);
 };
 
 typedef std::shared_ptr<EthPacketData> EthPacketPtr;
index 38ce4a2b343457c7fda88670c78d83f1d73291ce..d062b5d8a078691b54c2d10f5676f1fae7bc5c32 100644 (file)
@@ -294,7 +294,7 @@ EtherTap::getEthPort(const std::string &if_name, int idx)
 //=====================================================================
 
 void
-EtherTap::serialize(ostream &os)
+EtherTap::serialize(CheckpointOut &cp) const
 {
     SERIALIZE_SCALAR(socket);
     SERIALIZE_SCALAR(buflen);
@@ -307,7 +307,7 @@ EtherTap::serialize(ostream &os)
     if (event) {
         tapevent_present = true;
         SERIALIZE_SCALAR(tapevent_present);
-        event->serialize(os);
+        event->serialize(cp);
     }
     else {
         SERIALIZE_SCALAR(tapevent_present);
@@ -315,7 +315,7 @@ EtherTap::serialize(ostream &os)
 }
 
 void
-EtherTap::unserialize(Checkpoint *cp, const std::string &section)
+EtherTap::unserialize(CheckpointIn &cp)
 {
     UNSERIALIZE_SCALAR(socket);
     UNSERIALIZE_SCALAR(buflen);
@@ -329,7 +329,7 @@ EtherTap::unserialize(Checkpoint *cp, const std::string &section)
     if (tapevent_present) {
         event = new TapEvent(this, socket, POLLIN|POLLERR);
 
-        event->unserialize(cp,section);
+        event->unserialize(cp);
 
         if (event->queued()) {
             pollQueue.schedule(event);
index 2f38d57b49ad2f13305ed3557e1b5e3c7c314ea7..9c21dfc033fdb114be3d71f60a40a656bb3c8f41 100644 (file)
@@ -115,8 +115,8 @@ class EtherTap : public EtherObject
     virtual bool recvPacket(EthPacketPtr packet);
     virtual void sendDone();
 
-    virtual void serialize(std::ostream &os);
-    virtual void unserialize(Checkpoint *cp, const std::string &section);
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 };
 
 class EtherTapInt : public EtherInt
index 9d7da44d0a2d555f5b20e8ec805791869c7ad94d..03ca6769c109a69f9d9118021da3fa33f458a46f 100644 (file)
@@ -212,7 +212,7 @@ I2CBus::isEnd(PacketPtr pkt) const
     return scl && (msg & 2) && daddr == SB_CONTROLS;
 }
 void
-I2CBus::serialize(std::ostream &os)
+I2CBus::serialize(CheckpointOut &cp) const
 {
     DPRINTF(Checkpoint, "Serializing I2C bus.\n");
     SERIALIZE_SCALAR(scl);
@@ -224,7 +224,7 @@ I2CBus::serialize(std::ostream &os)
 }
 
 void
-I2CBus::unserialize(Checkpoint *cp, const std::string &section)
+I2CBus::unserialize(CheckpointIn &cp)
 {
     DPRINTF(Checkpoint, "Unserializing I2C bus.\n");
     UNSERIALIZE_SCALAR(scl);
index 318950b39c867c2baeb9be81e3d8b76b1371450f..3ebfa308b44bd8a4d3895e4629214ed2b078eeb7 100644 (file)
@@ -146,8 +146,8 @@ class I2CBus : public BasicPioDevice
     virtual Tick read(PacketPtr pkt);
     virtual Tick write(PacketPtr pkt);
 
-    virtual void serialize(std::ostream& os);
-    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_I2CBUS
index 213ad580aca12cac00d1bde5008a01a6f8b4fdad..0ff52bda064e8065248d3ade46778611dce9bebc 100644 (file)
@@ -1117,7 +1117,7 @@ IGbE::DescCache<T>::reset()
 
 template<class T>
 void
-IGbE::DescCache<T>::serialize(std::ostream &os)
+IGbE::DescCache<T>::serialize(CheckpointOut &cp) const
 {
     SERIALIZE_SCALAR(cachePnt);
     SERIALIZE_SCALAR(curFetching);
@@ -1128,14 +1128,14 @@ IGbE::DescCache<T>::serialize(std::ostream &os)
     typename CacheType::size_type usedCacheSize = usedCache.size();
     SERIALIZE_SCALAR(usedCacheSize);
     for (typename CacheType::size_type x = 0; x < usedCacheSize; x++) {
-        arrayParamOut(os, csprintf("usedCache_%d", x),
+        arrayParamOut(cp, csprintf("usedCache_%d", x),
                       (uint8_t*)usedCache[x],sizeof(T));
     }
 
     typename CacheType::size_type unusedCacheSize = unusedCache.size();
     SERIALIZE_SCALAR(unusedCacheSize);
     for (typename CacheType::size_type x = 0; x < unusedCacheSize; x++) {
-        arrayParamOut(os, csprintf("unusedCache_%d", x),
+        arrayParamOut(cp, csprintf("unusedCache_%d", x),
                       (uint8_t*)unusedCache[x],sizeof(T));
     }
 
@@ -1152,7 +1152,7 @@ IGbE::DescCache<T>::serialize(std::ostream &os)
 
 template<class T>
 void
-IGbE::DescCache<T>::unserialize(Checkpoint *cp, const std::string &section)
+IGbE::DescCache<T>::unserialize(CheckpointIn &cp)
 {
     UNSERIALIZE_SCALAR(cachePnt);
     UNSERIALIZE_SCALAR(curFetching);
@@ -1165,7 +1165,7 @@ IGbE::DescCache<T>::unserialize(Checkpoint *cp, const std::string &section)
     T *temp;
     for (typename CacheType::size_type x = 0; x < usedCacheSize; x++) {
         temp = new T;
-        arrayParamIn(cp, section, csprintf("usedCache_%d", x),
+        arrayParamIn(cp, csprintf("usedCache_%d", x),
                      (uint8_t*)temp,sizeof(T));
         usedCache.push_back(temp);
     }
@@ -1174,7 +1174,7 @@ IGbE::DescCache<T>::unserialize(Checkpoint *cp, const std::string &section)
     UNSERIALIZE_SCALAR(unusedCacheSize);
     for (typename CacheType::size_type x = 0; x < unusedCacheSize; x++) {
         temp = new T;
-        arrayParamIn(cp, section, csprintf("unusedCache_%d", x),
+        arrayParamIn(cp, csprintf("unusedCache_%d", x),
                      (uint8_t*)temp,sizeof(T));
         unusedCache.push_back(temp);
     }
@@ -1518,18 +1518,18 @@ IGbE::RxDescCache::hasOutstandingEvents()
 }
 
 void
-IGbE::RxDescCache::serialize(std::ostream &os)
+IGbE::RxDescCache::serialize(CheckpointOut &cp) const
 {
-    DescCache<RxDesc>::serialize(os);
+    DescCache<RxDesc>::serialize(cp);
     SERIALIZE_SCALAR(pktDone);
     SERIALIZE_SCALAR(splitCount);
     SERIALIZE_SCALAR(bytesCopied);
 }
 
 void
-IGbE::RxDescCache::unserialize(Checkpoint *cp, const std::string &section)
+IGbE::RxDescCache::unserialize(CheckpointIn &cp)
 {
-    DescCache<RxDesc>::unserialize(cp, section);
+    DescCache<RxDesc>::unserialize(cp);
     UNSERIALIZE_SCALAR(pktDone);
     UNSERIALIZE_SCALAR(splitCount);
     UNSERIALIZE_SCALAR(bytesCopied);
@@ -1961,9 +1961,10 @@ IGbE::TxDescCache::actionAfterWb()
 }
 
 void
-IGbE::TxDescCache::serialize(std::ostream &os)
+IGbE::TxDescCache::serialize(CheckpointOut &cp) const
 {
-    DescCache<TxDesc>::serialize(os);
+    DescCache<TxDesc>::serialize(cp);
+
     SERIALIZE_SCALAR(pktDone);
     SERIALIZE_SCALAR(isTcp);
     SERIALIZE_SCALAR(pktWaiting);
@@ -1989,9 +1990,10 @@ IGbE::TxDescCache::serialize(std::ostream &os)
 }
 
 void
-IGbE::TxDescCache::unserialize(Checkpoint *cp, const std::string &section)
+IGbE::TxDescCache::unserialize(CheckpointIn &cp)
 {
-    DescCache<TxDesc>::unserialize(cp, section);
+    DescCache<TxDesc>::unserialize(cp);
+
     UNSERIALIZE_SCALAR(pktDone);
     UNSERIALIZE_SCALAR(isTcp);
     UNSERIALIZE_SCALAR(pktWaiting);
@@ -2452,11 +2454,11 @@ IGbE::ethTxDone()
 }
 
 void
-IGbE::serialize(std::ostream &os)
+IGbE::serialize(CheckpointOut &cp) const
 {
-    PciDevice::serialize(os);
+    PciDevice::serialize(cp);
 
-    regs.serialize(os);
+    regs.serialize(cp);
     SERIALIZE_SCALAR(eeOpBits);
     SERIALIZE_SCALAR(eeAddrBits);
     SERIALIZE_SCALAR(eeDataBits);
@@ -2465,13 +2467,13 @@ IGbE::serialize(std::ostream &os)
     SERIALIZE_SCALAR(lastInterrupt);
     SERIALIZE_ARRAY(flash,iGbReg::EEPROM_SIZE);
 
-    rxFifo.serialize("rxfifo", os);
-    txFifo.serialize("txfifo", os);
+    rxFifo.serialize("rxfifo", cp);
+    txFifo.serialize("txfifo", cp);
 
     bool txPktExists = txPacket != nullptr;
     SERIALIZE_SCALAR(txPktExists);
     if (txPktExists)
-        txPacket->serialize("txpacket", os);
+        txPacket->serialize("txpacket", cp);
 
     Tick rdtr_time = 0, radv_time = 0, tidv_time = 0, tadv_time = 0,
         inter_time = 0;
@@ -2498,19 +2500,16 @@ IGbE::serialize(std::ostream &os)
 
     SERIALIZE_SCALAR(pktOffset);
 
-    nameOut(os, csprintf("%s.TxDescCache", name()));
-    txDescCache.serialize(os);
-
-    nameOut(os, csprintf("%s.RxDescCache", name()));
-    rxDescCache.serialize(os);
+    txDescCache.serializeSection(cp, "TxDescCache");
+    rxDescCache.serializeSection(cp, "RxDescCache");
 }
 
 void
-IGbE::unserialize(Checkpoint *cp, const std::string &section)
+IGbE::unserialize(CheckpointIn &cp)
 {
-    PciDevice::unserialize(cp, section);
+    PciDevice::unserialize(cp);
 
-    regs.unserialize(cp, section);
+    regs.unserialize(cp);
     UNSERIALIZE_SCALAR(eeOpBits);
     UNSERIALIZE_SCALAR(eeAddrBits);
     UNSERIALIZE_SCALAR(eeDataBits);
@@ -2519,14 +2518,14 @@ IGbE::unserialize(Checkpoint *cp, const std::string &section)
     UNSERIALIZE_SCALAR(lastInterrupt);
     UNSERIALIZE_ARRAY(flash,iGbReg::EEPROM_SIZE);
 
-    rxFifo.unserialize("rxfifo", cp, section);
-    txFifo.unserialize("txfifo", cp, section);
+    rxFifo.unserialize("rxfifo", cp);
+    txFifo.unserialize("txfifo", cp);
 
     bool txPktExists;
     UNSERIALIZE_SCALAR(txPktExists);
     if (txPktExists) {
         txPacket = std::make_shared<EthPacketData>(16384);
-        txPacket->unserialize("txpacket", cp, section);
+        txPacket->unserialize("txpacket", cp);
     }
 
     rxTick = true;
@@ -2557,9 +2556,8 @@ IGbE::unserialize(Checkpoint *cp, const std::string &section)
 
     UNSERIALIZE_SCALAR(pktOffset);
 
-    txDescCache.unserialize(cp, csprintf("%s.TxDescCache", section));
-
-    rxDescCache.unserialize(cp, csprintf("%s.RxDescCache", section));
+    txDescCache.unserializeSection(cp, "TxDescCache");
+    rxDescCache.unserializeSection(cp, "RxDescCache");
 }
 
 IGbE *
index 27439740dda427535a3dbdfdb8d83e4f6b48eb99..d353c1d8349fb0e264556aaa7bdb8f2639572345 100644 (file)
@@ -218,7 +218,7 @@ class IGbE : public EtherDevice
 
 
     template<class T>
-    class DescCache
+    class DescCache : public Serializable
     {
       protected:
         virtual Addr descBase() const = 0;
@@ -331,8 +331,9 @@ class IGbE : public EtherDevice
          * changed */
         void reset();
 
-        virtual void serialize(std::ostream &os);
-        virtual void unserialize(Checkpoint *cp, const std::string &section);
+
+        void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+        void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 
         virtual bool hasOutstandingEvents() {
             return wbEvent.scheduled() || fetchEvent.scheduled();
@@ -395,8 +396,8 @@ class IGbE : public EtherDevice
 
         virtual bool hasOutstandingEvents();
 
-        virtual void serialize(std::ostream &os);
-        virtual void unserialize(Checkpoint *cp, const std::string &section);
+        void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+        void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
     };
     friend class RxDescCache;
 
@@ -506,10 +507,10 @@ class IGbE : public EtherDevice
         }
         EventWrapper<TxDescCache, &TxDescCache::nullCallback> nullEvent;
 
-        virtual void serialize(std::ostream &os);
-        virtual void unserialize(Checkpoint *cp, const std::string &section);
-
+        void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+        void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
     };
+
     friend class TxDescCache;
 
     TxDescCache txDescCache;
@@ -537,8 +538,8 @@ class IGbE : public EtherDevice
     bool ethRxPkt(EthPacketPtr packet);
     void ethTxDone();
 
-    virtual void serialize(std::ostream &os);
-    virtual void unserialize(Checkpoint *cp, const std::string &section);
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 
     unsigned int drain(DrainManager *dm);
     void drainResume();
index 3b45f6498ac6e4ca67f16982872f3ad2d0b95a15..92257aea7751b97eaaefb7b61a41db2da5bb1606 100644 (file)
@@ -294,7 +294,7 @@ inline int utcmd(TxDesc *d) { assert(isContext(d)); return bits(d->d2,24,31); }
     inline uint64_t NAME() { return bits(_data, OFFSET+BITS-1, OFFSET); } \
     inline void NAME(uint64_t d) { replaceBits(_data, OFFSET+BITS-1, OFFSET,d); }
 
-struct Regs {
+struct Regs : public Serializable {
     template<class T>
     struct Reg {
         T _data;
@@ -303,11 +303,11 @@ struct Regs {
         bool operator==(T d) { return d == _data; }
         void operator()(T d) { _data = d; }
         Reg() { _data = 0; }
-        void serialize(std::ostream &os)
+        void serialize(CheckpointOut &cp) const
         {
             SERIALIZE_SCALAR(_data);
         }
-        void unserialize(Checkpoint *cp, const std::string &section)
+        void unserialize(CheckpointIn &cp)
         {
             UNSERIALIZE_SCALAR(_data);
         }
@@ -759,95 +759,95 @@ struct Regs {
 
     uint32_t sw_fw_sync;
 
-    void serialize(std::ostream &os)
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE
     {
-        paramOut(os, "ctrl", ctrl._data);
-        paramOut(os, "sts", sts._data);
-        paramOut(os, "eecd", eecd._data);
-        paramOut(os, "eerd", eerd._data);
-        paramOut(os, "ctrl_ext", ctrl_ext._data);
-        paramOut(os, "mdic", mdic._data);
-        paramOut(os, "icr", icr._data);
+        paramOut(cp, "ctrl", ctrl._data);
+        paramOut(cp, "sts", sts._data);
+        paramOut(cp, "eecd", eecd._data);
+        paramOut(cp, "eerd", eerd._data);
+        paramOut(cp, "ctrl_ext", ctrl_ext._data);
+        paramOut(cp, "mdic", mdic._data);
+        paramOut(cp, "icr", icr._data);
         SERIALIZE_SCALAR(imr);
-        paramOut(os, "itr", itr._data);
+        paramOut(cp, "itr", itr._data);
         SERIALIZE_SCALAR(iam);
-        paramOut(os, "rctl", rctl._data);
-        paramOut(os, "fcttv", fcttv._data);
-        paramOut(os, "tctl", tctl._data);
-        paramOut(os, "pba", pba._data);
-        paramOut(os, "fcrtl", fcrtl._data);
-        paramOut(os, "fcrth", fcrth._data);
-        paramOut(os, "rdba", rdba._data);
-        paramOut(os, "rdlen", rdlen._data);
-        paramOut(os, "srrctl", srrctl._data);
-        paramOut(os, "rdh", rdh._data);
-        paramOut(os, "rdt", rdt._data);
-        paramOut(os, "rdtr", rdtr._data);
-        paramOut(os, "rxdctl", rxdctl._data);
-        paramOut(os, "radv", radv._data);
-        paramOut(os, "rsrpd", rsrpd._data);
-        paramOut(os, "tdba", tdba._data);
-        paramOut(os, "tdlen", tdlen._data);
-        paramOut(os, "tdh", tdh._data);
-        paramOut(os, "txdca_ctl", txdca_ctl._data);
-        paramOut(os, "tdt", tdt._data);
-        paramOut(os, "tidv", tidv._data);
-        paramOut(os, "txdctl", txdctl._data);
-        paramOut(os, "tadv", tadv._data);
-        //paramOut(os, "tdwba", tdwba._data);
+        paramOut(cp, "rctl", rctl._data);
+        paramOut(cp, "fcttv", fcttv._data);
+        paramOut(cp, "tctl", tctl._data);
+        paramOut(cp, "pba", pba._data);
+        paramOut(cp, "fcrtl", fcrtl._data);
+        paramOut(cp, "fcrth", fcrth._data);
+        paramOut(cp, "rdba", rdba._data);
+        paramOut(cp, "rdlen", rdlen._data);
+        paramOut(cp, "srrctl", srrctl._data);
+        paramOut(cp, "rdh", rdh._data);
+        paramOut(cp, "rdt", rdt._data);
+        paramOut(cp, "rdtr", rdtr._data);
+        paramOut(cp, "rxdctl", rxdctl._data);
+        paramOut(cp, "radv", radv._data);
+        paramOut(cp, "rsrpd", rsrpd._data);
+        paramOut(cp, "tdba", tdba._data);
+        paramOut(cp, "tdlen", tdlen._data);
+        paramOut(cp, "tdh", tdh._data);
+        paramOut(cp, "txdca_ctl", txdca_ctl._data);
+        paramOut(cp, "tdt", tdt._data);
+        paramOut(cp, "tidv", tidv._data);
+        paramOut(cp, "txdctl", txdctl._data);
+        paramOut(cp, "tadv", tadv._data);
+        //paramOut(cp, "tdwba", tdwba._data);
         SERIALIZE_SCALAR(tdwba);
-        paramOut(os, "rxcsum", rxcsum._data);
+        paramOut(cp, "rxcsum", rxcsum._data);
         SERIALIZE_SCALAR(rlpml);
-        paramOut(os, "rfctl", rfctl._data);
-        paramOut(os, "manc", manc._data);
-        paramOut(os, "swsm", swsm._data);
-        paramOut(os, "fwsm", fwsm._data);
+        paramOut(cp, "rfctl", rfctl._data);
+        paramOut(cp, "manc", manc._data);
+        paramOut(cp, "swsm", swsm._data);
+        paramOut(cp, "fwsm", fwsm._data);
         SERIALIZE_SCALAR(sw_fw_sync);
     }
 
-    void unserialize(Checkpoint *cp, const std::string &section)
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE
     {
-        paramIn(cp, section, "ctrl", ctrl._data);
-        paramIn(cp, section, "sts", sts._data);
-        paramIn(cp, section, "eecd", eecd._data);
-        paramIn(cp, section, "eerd", eerd._data);
-        paramIn(cp, section, "ctrl_ext", ctrl_ext._data);
-        paramIn(cp, section, "mdic", mdic._data);
-        paramIn(cp, section, "icr", icr._data);
+        paramIn(cp, "ctrl", ctrl._data);
+        paramIn(cp, "sts", sts._data);
+        paramIn(cp, "eecd", eecd._data);
+        paramIn(cp, "eerd", eerd._data);
+        paramIn(cp, "ctrl_ext", ctrl_ext._data);
+        paramIn(cp, "mdic", mdic._data);
+        paramIn(cp, "icr", icr._data);
         UNSERIALIZE_SCALAR(imr);
-        paramIn(cp, section, "itr", itr._data);
+        paramIn(cp, "itr", itr._data);
         UNSERIALIZE_SCALAR(iam);
-        paramIn(cp, section, "rctl", rctl._data);
-        paramIn(cp, section, "fcttv", fcttv._data);
-        paramIn(cp, section, "tctl", tctl._data);
-        paramIn(cp, section, "pba", pba._data);
-        paramIn(cp, section, "fcrtl", fcrtl._data);
-        paramIn(cp, section, "fcrth", fcrth._data);
-        paramIn(cp, section, "rdba", rdba._data);
-        paramIn(cp, section, "rdlen", rdlen._data);
-        paramIn(cp, section, "srrctl", srrctl._data);
-        paramIn(cp, section, "rdh", rdh._data);
-        paramIn(cp, section, "rdt", rdt._data);
-        paramIn(cp, section, "rdtr", rdtr._data);
-        paramIn(cp, section, "rxdctl", rxdctl._data);
-        paramIn(cp, section, "radv", radv._data);
-        paramIn(cp, section, "rsrpd", rsrpd._data);
-        paramIn(cp, section, "tdba", tdba._data);
-        paramIn(cp, section, "tdlen", tdlen._data);
-        paramIn(cp, section, "tdh", tdh._data);
-        paramIn(cp, section, "txdca_ctl", txdca_ctl._data);
-        paramIn(cp, section, "tdt", tdt._data);
-        paramIn(cp, section, "tidv", tidv._data);
-        paramIn(cp, section, "txdctl", txdctl._data);
-        paramIn(cp, section, "tadv", tadv._data);
+        paramIn(cp, "rctl", rctl._data);
+        paramIn(cp, "fcttv", fcttv._data);
+        paramIn(cp, "tctl", tctl._data);
+        paramIn(cp, "pba", pba._data);
+        paramIn(cp, "fcrtl", fcrtl._data);
+        paramIn(cp, "fcrth", fcrth._data);
+        paramIn(cp, "rdba", rdba._data);
+        paramIn(cp, "rdlen", rdlen._data);
+        paramIn(cp, "srrctl", srrctl._data);
+        paramIn(cp, "rdh", rdh._data);
+        paramIn(cp, "rdt", rdt._data);
+        paramIn(cp, "rdtr", rdtr._data);
+        paramIn(cp, "rxdctl", rxdctl._data);
+        paramIn(cp, "radv", radv._data);
+        paramIn(cp, "rsrpd", rsrpd._data);
+        paramIn(cp, "tdba", tdba._data);
+        paramIn(cp, "tdlen", tdlen._data);
+        paramIn(cp, "tdh", tdh._data);
+        paramIn(cp, "txdca_ctl", txdca_ctl._data);
+        paramIn(cp, "tdt", tdt._data);
+        paramIn(cp, "tidv", tidv._data);
+        paramIn(cp, "txdctl", txdctl._data);
+        paramIn(cp, "tadv", tadv._data);
         UNSERIALIZE_SCALAR(tdwba);
-        //paramIn(cp, section, "tdwba", tdwba._data);
-        paramIn(cp, section, "rxcsum", rxcsum._data);
+        //paramIn(cp, "tdwba", tdwba._data);
+        paramIn(cp, "rxcsum", rxcsum._data);
         UNSERIALIZE_SCALAR(rlpml);
-        paramIn(cp, section, "rfctl", rfctl._data);
-        paramIn(cp, section, "manc", manc._data);
-        paramIn(cp, section, "swsm", swsm._data);
-        paramIn(cp, section, "fwsm", fwsm._data);
+        paramIn(cp, "rfctl", rfctl._data);
+        paramIn(cp, "manc", manc._data);
+        paramIn(cp, "swsm", swsm._data);
+        paramIn(cp, "fwsm", fwsm._data);
         UNSERIALIZE_SCALAR(sw_fw_sync);
     }
 };
index d931fab2bdc6b926892065d945b6bab8aba35da3..3e608626575abb2c5082ecf960ffcc4fb88920f1 100644 (file)
@@ -555,14 +555,14 @@ IdeController::write(PacketPtr pkt)
 }
 
 void
-IdeController::serialize(std::ostream &os)
+IdeController::serialize(CheckpointOut &cp) const
 {
     // Serialize the PciDevice base class
-    PciDevice::serialize(os);
+    PciDevice::serialize(cp);
 
     // Serialize channels
-    primary.serialize("primary", os);
-    secondary.serialize("secondary", os);
+    primary.serialize("primary", cp);
+    secondary.serialize("secondary", cp);
 
     // Serialize config registers
     SERIALIZE_SCALAR(primaryTiming);
@@ -580,31 +580,32 @@ IdeController::serialize(std::ostream &os)
 }
 
 void
-IdeController::Channel::serialize(const std::string &base, std::ostream &os)
+IdeController::Channel::serialize(const std::string &base,
+                                  CheckpointOut &cp) const
 {
-    paramOut(os, base + ".cmdAddr", cmdAddr);
-    paramOut(os, base + ".cmdSize", cmdSize);
-    paramOut(os, base + ".ctrlAddr", ctrlAddr);
-    paramOut(os, base + ".ctrlSize", ctrlSize);
+    paramOut(cp, base + ".cmdAddr", cmdAddr);
+    paramOut(cp, base + ".cmdSize", cmdSize);
+    paramOut(cp, base + ".ctrlAddr", ctrlAddr);
+    paramOut(cp, base + ".ctrlSize", ctrlSize);
     uint8_t command = bmiRegs.command;
-    paramOut(os, base + ".bmiRegs.command", command);
-    paramOut(os, base + ".bmiRegs.reserved0", bmiRegs.reserved0);
+    paramOut(cp, base + ".bmiRegs.command", command);
+    paramOut(cp, base + ".bmiRegs.reserved0", bmiRegs.reserved0);
     uint8_t status = bmiRegs.status;
-    paramOut(os, base + ".bmiRegs.status", status);
-    paramOut(os, base + ".bmiRegs.reserved1", bmiRegs.reserved1);
-    paramOut(os, base + ".bmiRegs.bmidtp", bmiRegs.bmidtp);
-    paramOut(os, base + ".selectBit", selectBit);
+    paramOut(cp, base + ".bmiRegs.status", status);
+    paramOut(cp, base + ".bmiRegs.reserved1", bmiRegs.reserved1);
+    paramOut(cp, base + ".bmiRegs.bmidtp", bmiRegs.bmidtp);
+    paramOut(cp, base + ".selectBit", selectBit);
 }
 
 void
-IdeController::unserialize(Checkpoint *cp, const std::string &section)
+IdeController::unserialize(CheckpointIn &cp)
 {
     // Unserialize the PciDevice base class
-    PciDevice::unserialize(cp, section);
+    PciDevice::unserialize(cp);
 
     // Unserialize channels
-    primary.unserialize("primary", cp, section);
-    secondary.unserialize("secondary", cp, section);
+    primary.unserialize("primary", cp);
+    secondary.unserialize("secondary", cp);
 
     // Unserialize config registers
     UNSERIALIZE_SCALAR(primaryTiming);
@@ -622,23 +623,22 @@ IdeController::unserialize(Checkpoint *cp, const std::string &section)
 }
 
 void
-IdeController::Channel::unserialize(const std::string &base, Checkpoint *cp,
-    const std::string &section)
+IdeController::Channel::unserialize(const std::string &base, CheckpointIn &cp)
 {
-    paramIn(cp, section, base + ".cmdAddr", cmdAddr);
-    paramIn(cp, section, base + ".cmdSize", cmdSize);
-    paramIn(cp, section, base + ".ctrlAddr", ctrlAddr);
-    paramIn(cp, section, base + ".ctrlSize", ctrlSize);
+    paramIn(cp, base + ".cmdAddr", cmdAddr);
+    paramIn(cp, base + ".cmdSize", cmdSize);
+    paramIn(cp, base + ".ctrlAddr", ctrlAddr);
+    paramIn(cp, base + ".ctrlSize", ctrlSize);
     uint8_t command;
-    paramIn(cp, section, base +".bmiRegs.command", command);
+    paramIn(cp, base +".bmiRegs.command", command);
     bmiRegs.command = command;
-    paramIn(cp, section, base + ".bmiRegs.reserved0", bmiRegs.reserved0);
+    paramIn(cp, base + ".bmiRegs.reserved0", bmiRegs.reserved0);
     uint8_t status;
-    paramIn(cp, section, base + ".bmiRegs.status", status);
+    paramIn(cp, base + ".bmiRegs.status", status);
     bmiRegs.status = status;
-    paramIn(cp, section, base + ".bmiRegs.reserved1", bmiRegs.reserved1);
-    paramIn(cp, section, base + ".bmiRegs.bmidtp", bmiRegs.bmidtp);
-    paramIn(cp, section, base + ".selectBit", selectBit);
+    paramIn(cp, base + ".bmiRegs.reserved1", bmiRegs.reserved1);
+    paramIn(cp, base + ".bmiRegs.bmidtp", bmiRegs.bmidtp);
+    paramIn(cp, base + ".selectBit", selectBit);
     select(selectBit);
 }
 
index 414e310873e812e43b89a852b5ad38439a0c15c3..7917432e457f78ccb5e2e69d167b31afb7a9d633 100644 (file)
@@ -111,9 +111,8 @@ class IdeController : public PciDevice
         Channel(std::string newName, Addr _cmdSize, Addr _ctrlSize);
         ~Channel();
 
-        void serialize(const std::string &base, std::ostream &os);
-        void unserialize(const std::string &base, Checkpoint *cp,
-            const std::string &section);
+        void serialize(const std::string &base, std::ostream &os) const;
+        void unserialize(const std::string &base, CheckpointIn &cp);
     };
 
     Channel primary;
@@ -155,7 +154,7 @@ class IdeController : public PciDevice
     Tick read(PacketPtr pkt);
     Tick write(PacketPtr pkt);
 
-    void serialize(std::ostream &os);
-    void unserialize(Checkpoint *cp, const std::string &section);
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 };
 #endif // __IDE_CTRL_HH_
index 4bf1a13c89cdb0cb8f4dd449a9f0bffce71255bb..bbdee8e512c1f5ee233c5cb20e6bf877357df2eb 100644 (file)
@@ -1063,7 +1063,7 @@ IdeDisk::updateState(DevAction_t action)
 }
 
 void
-IdeDisk::serialize(ostream &os)
+IdeDisk::serialize(CheckpointOut &cp) const
 {
     // Check all outstanding events to see if they are scheduled
     // these are all mutually exclusive
@@ -1141,7 +1141,7 @@ IdeDisk::serialize(ostream &os)
 }
 
 void
-IdeDisk::unserialize(Checkpoint *cp, const string &section)
+IdeDisk::unserialize(CheckpointIn &cp)
 {
     // Reschedule events that were outstanding
     // these are all mutually exclusive
index 6ccca985eba3c50b43dcc5467dc2dad47000dbef..79e931a29bfbdbcb84228b5af410c4e2b8652273 100644 (file)
@@ -365,18 +365,8 @@ class IdeDisk : public SimObject
 
     inline Addr pciToDma(Addr pciAddr);
 
-    /**
-     * Serialize this object to the given output stream.
-     * @param os The stream to serialize to.
-     */
-    void serialize(std::ostream &os);
-
-    /**
-     * Reconstruct the state of this object from a checkpoint.
-     * @param cp The checkpoint to use.
-     * @param section The section name describing this object.
-     */
-    void unserialize(Checkpoint *cp, const std::string &section);
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 };
 
 
index 63bb6e8afeb901f99e5c11edc40250f1b59eabdd..75600fb72d8401e04879d866bcb802eb68a8cf5f 100644 (file)
@@ -71,22 +71,21 @@ Intel8254Timer::writeControl(const CtrlReg data)
 }
 
 void
-Intel8254Timer::serialize(const string &base, ostream &os)
+Intel8254Timer::serialize(const string &base, CheckpointOut &cp) const
 {
     // serialize the counters
-    counter[0]->serialize(base + ".counter0", os);
-    counter[1]->serialize(base + ".counter1", os);
-    counter[2]->serialize(base + ".counter2", os);
+    counter[0]->serialize(base + ".counter0", cp);
+    counter[1]->serialize(base + ".counter1", cp);
+    counter[2]->serialize(base + ".counter2", cp);
 }
 
 void
-Intel8254Timer::unserialize(const string &base, Checkpoint *cp,
-        const string &section)
+Intel8254Timer::unserialize(const string &base, CheckpointIn &cp)
 {
     // unserialze the counters
-    counter[0]->unserialize(base + ".counter0", cp, section);
-    counter[1]->unserialize(base + ".counter1", cp, section);
-    counter[2]->unserialize(base + ".counter2", cp, section);
+    counter[0]->unserialize(base + ".counter0", cp);
+    counter[1]->unserialize(base + ".counter1", cp);
+    counter[2]->unserialize(base + ".counter2", cp);
 }
 
 void
@@ -229,39 +228,38 @@ Intel8254Timer::Counter::outputHigh()
 }
 
 void
-Intel8254Timer::Counter::serialize(const string &base, ostream &os)
+Intel8254Timer::Counter::serialize(const string &base, CheckpointOut &cp) const
 {
-    paramOut(os, base + ".initial_count", initial_count);
-    paramOut(os, base + ".latched_count", latched_count);
-    paramOut(os, base + ".period", period);
-    paramOut(os, base + ".mode", mode);
-    paramOut(os, base + ".output_high", output_high);
-    paramOut(os, base + ".latch_on", latch_on);
-    paramOut(os, base + ".read_byte", read_byte);
-    paramOut(os, base + ".write_byte", write_byte);
+    paramOut(cp, base + ".initial_count", initial_count);
+    paramOut(cp, base + ".latched_count", latched_count);
+    paramOut(cp, base + ".period", period);
+    paramOut(cp, base + ".mode", mode);
+    paramOut(cp, base + ".output_high", output_high);
+    paramOut(cp, base + ".latch_on", latch_on);
+    paramOut(cp, base + ".read_byte", read_byte);
+    paramOut(cp, base + ".write_byte", write_byte);
 
     Tick event_tick_offset = 0;
     if (event.scheduled())
         event_tick_offset = event.when() - curTick();
-    paramOut(os, base + ".event_tick_offset", event_tick_offset);
+    paramOut(cp, base + ".event_tick_offset", event_tick_offset);
 }
 
 void
-Intel8254Timer::Counter::unserialize(const string &base, Checkpoint *cp,
-                                         const string &section)
+Intel8254Timer::Counter::unserialize(const string &base, CheckpointIn &cp)
 {
-    paramIn(cp, section, base + ".initial_count", initial_count);
-    paramIn(cp, section, base + ".latched_count", latched_count);
-    paramIn(cp, section, base + ".period", period);
-    paramIn(cp, section, base + ".mode", mode);
-    paramIn(cp, section, base + ".output_high", output_high);
-    paramIn(cp, section, base + ".latch_on", latch_on);
-    paramIn(cp, section, base + ".read_byte", read_byte);
-    paramIn(cp, section, base + ".write_byte", write_byte);
+    paramIn(cp, base + ".initial_count", initial_count);
+    paramIn(cp, base + ".latched_count", latched_count);
+    paramIn(cp, base + ".period", period);
+    paramIn(cp, base + ".mode", mode);
+    paramIn(cp, base + ".output_high", output_high);
+    paramIn(cp, base + ".latch_on", latch_on);
+    paramIn(cp, base + ".read_byte", read_byte);
+    paramIn(cp, base + ".write_byte", write_byte);
 
     Tick event_tick_offset = 0;
     assert(!event.scheduled());
-    paramIn(cp, section, base + ".event_tick_offset", event_tick_offset);
+    paramIn(cp, base + ".event_tick_offset", event_tick_offset);
     offset = event_tick_offset;
 }
 
index b2fd949f2abea48841e6623df1b6ada271ea0a43..86b91620db674eb129409dc90ccd0decaf599b98 100644 (file)
@@ -179,7 +179,7 @@ class Intel8254Timer : public EventManager
          * @param base The base name of the counter object.
          * @param os   The stream to serialize to.
          */
-        void serialize(const std::string &base, std::ostream &os);
+        void serialize(const std::string &base, CheckpointOut &cp) const;
 
         /**
          * Reconstruct the state of this object from a checkpoint.
@@ -187,8 +187,7 @@ class Intel8254Timer : public EventManager
          * @param cp The checkpoint use.
          * @param section The section name of this object
          */
-        void unserialize(const std::string &base, Checkpoint *cp,
-                         const std::string &section);
+        void unserialize(const std::string &base, CheckpointIn &cp);
 
         /** Start ticking */
         void startup();
@@ -247,7 +246,7 @@ class Intel8254Timer : public EventManager
      * @param base The base name of the counter object.
      * @param os The stream to serialize to.
      */
-    void serialize(const std::string &base, std::ostream &os);
+    void serialize(const std::string &base, CheckpointOut &cp) const;
 
     /**
      * Reconstruct the state of this object from a checkpoint.
@@ -255,8 +254,7 @@ class Intel8254Timer : public EventManager
      * @param cp The checkpoint use.
      * @param section The section name of this object
      */
-    void unserialize(const std::string &base, Checkpoint *cp,
-                     const std::string &section);
+    void unserialize(const std::string &base, CheckpointIn &cp);
 
     /** Start ticking */
     void startup();
index b5467f8cced1052411241e23e7d74883cd5ab3fa..02c302bae574b32dfa7b896b8c448891fed8bd3b 100644 (file)
@@ -265,14 +265,14 @@ MC146818::tickClock()
 }
 
 void
-MC146818::serialize(const string &base, ostream &os)
+MC146818::serialize(const string &base, CheckpointOut &cp) const
 {
     uint8_t regA_serial(stat_regA);
     uint8_t regB_serial(stat_regB);
 
-    arrayParamOut(os, base + ".clock_data", clock_data, sizeof(clock_data));
-    paramOut(os, base + ".stat_regA", (uint8_t)regA_serial);
-    paramOut(os, base + ".stat_regB", (uint8_t)regB_serial);
+    arrayParamOut(cp, base + ".clock_data", clock_data, sizeof(clock_data));
+    paramOut(cp, base + ".stat_regA", (uint8_t)regA_serial);
+    paramOut(cp, base + ".stat_regB", (uint8_t)regB_serial);
 
     //
     // save the timer tick and rtc clock tick values to correctly reschedule 
@@ -285,17 +285,16 @@ MC146818::serialize(const string &base, ostream &os)
 }
 
 void
-MC146818::unserialize(const string &base, Checkpoint *cp,
-                      const string &section)
+MC146818::unserialize(const string &base, CheckpointIn &cp)
 {
     uint8_t tmp8;
 
-    arrayParamIn(cp, section, base + ".clock_data", clock_data,
+    arrayParamIn(cp, base + ".clock_data", clock_data,
                  sizeof(clock_data));
 
-    paramIn(cp, section, base + ".stat_regA", tmp8);
+    paramIn(cp, base + ".stat_regA", tmp8);
     stat_regA = tmp8;
-    paramIn(cp, section, base + ".stat_regB", tmp8);
+    paramIn(cp, base + ".stat_regB", tmp8);
     stat_regB = tmp8;
 
     //
index 936f597d04272669a7b4656086dc53c198907243..e19040ec32ca0947f61f9da04f3cbc5cd02dc530 100644 (file)
@@ -170,7 +170,7 @@ class MC146818 : public EventManager
       * @param base The base name of the counter object.
       * @param os The stream to serialize to.
       */
-    void serialize(const std::string &base, std::ostream &os);
+    void serialize(const std::string &base, CheckpointOut &cp) const;
 
     /**
      * Reconstruct the state of this object from a checkpoint.
@@ -178,8 +178,7 @@ class MC146818 : public EventManager
      * @param cp The checkpoint use.
      * @param section The section name of this object
      */
-    void unserialize(const std::string &base, Checkpoint *cp,
-                     const std::string &section);
+    void unserialize(const std::string &base, CheckpointIn &cp);
 };
 
 #endif // __DEV_MC146818_HH__
index 277633c6b8aaea7491e7c6ae8657922ad355a0a6..0c37e2713e0958f1f8e4bf5da0f8297854204cb4 100755 (executable)
@@ -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);
 }
index e612fb295c295e5cfe8c7c430a909cabf32934fd..c5ee92e3d34d030b67f94dc8d3b1fa5406cad85e 100755 (executable)
@@ -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__
index dc521112298cc04573f8742e606e784cb8bc8eff..34f79b65b14faf8c29db6c91756f45d694c2638e 100755 (executable)
@@ -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);
index 9a17f632f54433ac075864b1428ec752a0fc3a1f..707cd104860b90703cb15c10a8dad966d6562121 100755 (executable)
@@ -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__
index d79e43260ff528008fdc9ad5362b25695f1be375..bd37911631932f1ad0495a80f483f22e1b12021e 100755 (executable)
@@ -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
index dd035aea2652fd9018bf9b245f9a1c43f0fe129e..bea6733fc7607c6d97553d20eecbd36156a9df9a 100755 (executable)
@@ -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.
index bee61fddd5744bdc6103e838c576c390bce24999..d0ae3daaa9563cf484356f13c7c6fdb9766437eb 100755 (executable)
@@ -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);
index a6145515a9b42f6b6bd01d496bd257b2c9a35d9f..368faf9c57585c1cd7b090155f02f973a11d9c97 100755 (executable)
@@ -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__
index d87975759f9b526ac5e48b98dc236949898b070f..c525f6359e0186504531ab6cb69c773bcce02531 100644 (file)
@@ -2123,10 +2123,10 @@ NSGigE::drainResume()
 //
 //
 void
-NSGigE::serialize(ostream &os)
+NSGigE::serialize(CheckpointOut &cp) const
 {
     // Serialize the PciDevice base class
-    PciDevice::serialize(os);
+    PciDevice::serialize(cp);
 
     /*
      * Finalize any DMA events now.
@@ -2179,8 +2179,8 @@ NSGigE::serialize(ostream &os)
     /*
      * Serialize the data Fifos
      */
-    rxFifo.serialize("rxFifo", os);
-    txFifo.serialize("txFifo", os);
+    rxFifo.serialize("rxFifo", cp);
+    txFifo.serialize("txFifo", cp);
 
     /*
      * Serialize the various helper variables
@@ -2189,7 +2189,7 @@ NSGigE::serialize(ostream &os)
     SERIALIZE_SCALAR(txPacketExists);
     if (txPacketExists) {
         txPacket->length = txPacketBufPtr - txPacket->data;
-        txPacket->serialize("txPacket", os);
+        txPacket->serialize("txPacket", cp);
         uint32_t txPktBufPtr = (uint32_t) (txPacketBufPtr - txPacket->data);
         SERIALIZE_SCALAR(txPktBufPtr);
     }
@@ -2197,7 +2197,7 @@ NSGigE::serialize(ostream &os)
     bool rxPacketExists = rxPacket != nullptr;
     SERIALIZE_SCALAR(rxPacketExists);
     if (rxPacketExists) {
-        rxPacket->serialize("rxPacket", os);
+        rxPacket->serialize("rxPacket", cp);
         uint32_t rxPktBufPtr = (uint32_t) (rxPacketBufPtr - rxPacket->data);
         SERIALIZE_SCALAR(rxPktBufPtr);
     }
@@ -2295,10 +2295,10 @@ NSGigE::serialize(ostream &os)
 }
 
 void
-NSGigE::unserialize(Checkpoint *cp, const std::string &section)
+NSGigE::unserialize(CheckpointIn &cp)
 {
     // Unserialize the PciDevice base class
-    PciDevice::unserialize(cp, section);
+    PciDevice::unserialize(cp);
 
     UNSERIALIZE_SCALAR(regs.command);
     UNSERIALIZE_SCALAR(regs.config);
@@ -2343,8 +2343,8 @@ NSGigE::unserialize(Checkpoint *cp, const std::string &section)
     /*
      * unserialize the data fifos
      */
-    rxFifo.unserialize("rxFifo", cp, section);
-    txFifo.unserialize("txFifo", cp, section);
+    rxFifo.unserialize("rxFifo", cp);
+    txFifo.unserialize("txFifo", cp);
 
     /*
      * unserialize the various helper variables
@@ -2353,7 +2353,7 @@ NSGigE::unserialize(Checkpoint *cp, const std::string &section)
     UNSERIALIZE_SCALAR(txPacketExists);
     if (txPacketExists) {
         txPacket = make_shared<EthPacketData>(16384);
-        txPacket->unserialize("txPacket", cp, section);
+        txPacket->unserialize("txPacket", cp);
         uint32_t txPktBufPtr;
         UNSERIALIZE_SCALAR(txPktBufPtr);
         txPacketBufPtr = (uint8_t *) txPacket->data + txPktBufPtr;
@@ -2365,7 +2365,7 @@ NSGigE::unserialize(Checkpoint *cp, const std::string &section)
     rxPacket = 0;
     if (rxPacketExists) {
         rxPacket = make_shared<EthPacketData>(16384);
-        rxPacket->unserialize("rxPacket", cp, section);
+        rxPacket->unserialize("rxPacket", cp);
         uint32_t rxPktBufPtr;
         UNSERIALIZE_SCALAR(rxPktBufPtr);
         rxPacketBufPtr = (uint8_t *) rxPacket->data + rxPktBufPtr;
index 6d5068a2b8a3f93d2d04c27213c897559cb02bea..f8e9be853bf1019975409cbe4e7e361df8b0c40d 100644 (file)
@@ -366,8 +366,8 @@ class NSGigE : public EtherDevBase
     bool recvPacket(EthPacketPtr packet);
     void transferDone();
 
-    virtual void serialize(std::ostream &os);
-    virtual void unserialize(Checkpoint *cp, const std::string &section);
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 
     void drainResume();
 };
index 40be9716d277ef5a02fe10e6c9a220bde979e2a1..581ae2ebd7dd680b078f0b87a7e867f17d3ce382 100644 (file)
@@ -473,29 +473,29 @@ PciDevice::writeConfig(PacketPtr pkt)
 }
 
 void
-PciDevice::serialize(std::ostream &os)
+PciDevice::serialize(CheckpointOut &cp) const
 {
     SERIALIZE_ARRAY(BARSize, sizeof(BARSize) / sizeof(BARSize[0]));
     SERIALIZE_ARRAY(BARAddrs, sizeof(BARAddrs) / sizeof(BARAddrs[0]));
     SERIALIZE_ARRAY(config.data, sizeof(config.data) / sizeof(config.data[0]));
 
     // serialize the capability list registers
-    paramOut(os, csprintf("pmcap.pid"), uint16_t(pmcap.pid));
-    paramOut(os, csprintf("pmcap.pc"), uint16_t(pmcap.pc));
-    paramOut(os, csprintf("pmcap.pmcs"), uint16_t(pmcap.pmcs));
+    paramOut(cp, csprintf("pmcap.pid"), uint16_t(pmcap.pid));
+    paramOut(cp, csprintf("pmcap.pc"), uint16_t(pmcap.pc));
+    paramOut(cp, csprintf("pmcap.pmcs"), uint16_t(pmcap.pmcs));
 
-    paramOut(os, csprintf("msicap.mid"), uint16_t(msicap.mid));
-    paramOut(os, csprintf("msicap.mc"), uint16_t(msicap.mc));
-    paramOut(os, csprintf("msicap.ma"), uint32_t(msicap.ma));
+    paramOut(cp, csprintf("msicap.mid"), uint16_t(msicap.mid));
+    paramOut(cp, csprintf("msicap.mc"), uint16_t(msicap.mc));
+    paramOut(cp, csprintf("msicap.ma"), uint32_t(msicap.ma));
     SERIALIZE_SCALAR(msicap.mua);
-    paramOut(os, csprintf("msicap.md"), uint16_t(msicap.md));
+    paramOut(cp, csprintf("msicap.md"), uint16_t(msicap.md));
     SERIALIZE_SCALAR(msicap.mmask);
     SERIALIZE_SCALAR(msicap.mpend);
 
-    paramOut(os, csprintf("msixcap.mxid"), uint16_t(msixcap.mxid));
-    paramOut(os, csprintf("msixcap.mxc"), uint16_t(msixcap.mxc));
-    paramOut(os, csprintf("msixcap.mtab"), uint32_t(msixcap.mtab));
-    paramOut(os, csprintf("msixcap.mpba"), uint32_t(msixcap.mpba));
+    paramOut(cp, csprintf("msixcap.mxid"), uint16_t(msixcap.mxid));
+    paramOut(cp, csprintf("msixcap.mxc"), uint16_t(msixcap.mxc));
+    paramOut(cp, csprintf("msixcap.mtab"), uint32_t(msixcap.mtab));
+    paramOut(cp, csprintf("msixcap.mpba"), uint32_t(msixcap.mpba));
 
     // Only serialize if we have a non-zero base address
     if (MSIXCAP_BASE != 0x0) {
@@ -510,35 +510,35 @@ PciDevice::serialize(std::ostream &os)
         SERIALIZE_SCALAR(pba_array_size);
 
         for (int i = 0; i < msix_array_size; i++) {
-            paramOut(os, csprintf("msix_table[%d].addr_lo", i),
+            paramOut(cp, csprintf("msix_table[%d].addr_lo", i),
                      msix_table[i].fields.addr_lo);
-            paramOut(os, csprintf("msix_table[%d].addr_hi", i),
+            paramOut(cp, csprintf("msix_table[%d].addr_hi", i),
                      msix_table[i].fields.addr_hi);
-            paramOut(os, csprintf("msix_table[%d].msg_data", i),
+            paramOut(cp, csprintf("msix_table[%d].msg_data", i),
                      msix_table[i].fields.msg_data);
-            paramOut(os, csprintf("msix_table[%d].vec_ctrl", i),
+            paramOut(cp, csprintf("msix_table[%d].vec_ctrl", i),
                      msix_table[i].fields.vec_ctrl);
         }
         for (int i = 0; i < pba_array_size; i++) {
-            paramOut(os, csprintf("msix_pba[%d].bits", i),
+            paramOut(cp, csprintf("msix_pba[%d].bits", i),
                      msix_pba[i].bits);
         }
     }
 
-    paramOut(os, csprintf("pxcap.pxid"), uint16_t(pxcap.pxid));
-    paramOut(os, csprintf("pxcap.pxcap"), uint16_t(pxcap.pxcap));
-    paramOut(os, csprintf("pxcap.pxdcap"), uint32_t(pxcap.pxdcap));
-    paramOut(os, csprintf("pxcap.pxdc"), uint16_t(pxcap.pxdc));
-    paramOut(os, csprintf("pxcap.pxds"), uint16_t(pxcap.pxds));
-    paramOut(os, csprintf("pxcap.pxlcap"), uint32_t(pxcap.pxlcap));
-    paramOut(os, csprintf("pxcap.pxlc"), uint16_t(pxcap.pxlc));
-    paramOut(os, csprintf("pxcap.pxls"), uint16_t(pxcap.pxls));
-    paramOut(os, csprintf("pxcap.pxdcap2"), uint32_t(pxcap.pxdcap2));
-    paramOut(os, csprintf("pxcap.pxdc2"), uint32_t(pxcap.pxdc2));
+    paramOut(cp, csprintf("pxcap.pxid"), uint16_t(pxcap.pxid));
+    paramOut(cp, csprintf("pxcap.pxcap"), uint16_t(pxcap.pxcap));
+    paramOut(cp, csprintf("pxcap.pxdcap"), uint32_t(pxcap.pxdcap));
+    paramOut(cp, csprintf("pxcap.pxdc"), uint16_t(pxcap.pxdc));
+    paramOut(cp, csprintf("pxcap.pxds"), uint16_t(pxcap.pxds));
+    paramOut(cp, csprintf("pxcap.pxlcap"), uint32_t(pxcap.pxlcap));
+    paramOut(cp, csprintf("pxcap.pxlc"), uint16_t(pxcap.pxlc));
+    paramOut(cp, csprintf("pxcap.pxls"), uint16_t(pxcap.pxls));
+    paramOut(cp, csprintf("pxcap.pxdcap2"), uint32_t(pxcap.pxdcap2));
+    paramOut(cp, csprintf("pxcap.pxdc2"), uint32_t(pxcap.pxdc2));
 }
 
 void
-PciDevice::unserialize(Checkpoint *cp, const std::string &section)
+PciDevice::unserialize(CheckpointIn &cp)
 {
     UNSERIALIZE_ARRAY(BARSize, sizeof(BARSize) / sizeof(BARSize[0]));
     UNSERIALIZE_ARRAY(BARAddrs, sizeof(BARAddrs) / sizeof(BARAddrs[0]));
@@ -548,32 +548,32 @@ PciDevice::unserialize(Checkpoint *cp, const std::string &section)
     // unserialize the capability list registers
     uint16_t tmp16;
     uint32_t tmp32;
-    paramIn(cp, section, csprintf("pmcap.pid"), tmp16);
+    paramIn(cp, csprintf("pmcap.pid"), tmp16);
     pmcap.pid = tmp16;
-    paramIn(cp, section, csprintf("pmcap.pc"), tmp16);
+    paramIn(cp, csprintf("pmcap.pc"), tmp16);
     pmcap.pc = tmp16;
-    paramIn(cp, section, csprintf("pmcap.pmcs"), tmp16);
+    paramIn(cp, csprintf("pmcap.pmcs"), tmp16);
     pmcap.pmcs = tmp16;
 
-    paramIn(cp, section, csprintf("msicap.mid"), tmp16);
+    paramIn(cp, csprintf("msicap.mid"), tmp16);
     msicap.mid = tmp16;
-    paramIn(cp, section, csprintf("msicap.mc"), tmp16);
+    paramIn(cp, csprintf("msicap.mc"), tmp16);
     msicap.mc = tmp16;
-    paramIn(cp, section, csprintf("msicap.ma"), tmp32);
+    paramIn(cp, csprintf("msicap.ma"), tmp32);
     msicap.ma = tmp32;
     UNSERIALIZE_SCALAR(msicap.mua);
-    paramIn(cp, section, csprintf("msicap.md"), tmp16);;
+    paramIn(cp, csprintf("msicap.md"), tmp16);;
     msicap.md = tmp16;
     UNSERIALIZE_SCALAR(msicap.mmask);
     UNSERIALIZE_SCALAR(msicap.mpend);
 
-    paramIn(cp, section, csprintf("msixcap.mxid"), tmp16);
+    paramIn(cp, csprintf("msixcap.mxid"), tmp16);
     msixcap.mxid = tmp16;
-    paramIn(cp, section, csprintf("msixcap.mxc"), tmp16);
+    paramIn(cp, csprintf("msixcap.mxc"), tmp16);
     msixcap.mxc = tmp16;
-    paramIn(cp, section, csprintf("msixcap.mtab"), tmp32);
+    paramIn(cp, csprintf("msixcap.mtab"), tmp32);
     msixcap.mtab = tmp32;
-    paramIn(cp, section, csprintf("msixcap.mpba"), tmp32);
+    paramIn(cp, csprintf("msixcap.mpba"), tmp32);
     msixcap.mpba = tmp32;
 
     // Only allocate if MSIXCAP_BASE is not 0x0
@@ -591,40 +591,40 @@ PciDevice::unserialize(Checkpoint *cp, const std::string &section)
         msix_pba.resize(pba_array_size, tmp2);
 
         for (int i = 0; i < msix_array_size; i++) {
-            paramIn(cp, section, csprintf("msix_table[%d].addr_lo", i),
+            paramIn(cp, csprintf("msix_table[%d].addr_lo", i),
                     msix_table[i].fields.addr_lo);
-            paramIn(cp, section, csprintf("msix_table[%d].addr_hi", i),
+            paramIn(cp, csprintf("msix_table[%d].addr_hi", i),
                     msix_table[i].fields.addr_hi);
-            paramIn(cp, section, csprintf("msix_table[%d].msg_data", i),
+            paramIn(cp, csprintf("msix_table[%d].msg_data", i),
                     msix_table[i].fields.msg_data);
-            paramIn(cp, section, csprintf("msix_table[%d].vec_ctrl", i),
+            paramIn(cp, csprintf("msix_table[%d].vec_ctrl", i),
                     msix_table[i].fields.vec_ctrl);
         }
         for (int i = 0; i < pba_array_size; i++) {
-            paramIn(cp, section, csprintf("msix_pba[%d].bits", i),
+            paramIn(cp, csprintf("msix_pba[%d].bits", i),
                     msix_pba[i].bits);
         }
     }
 
-    paramIn(cp, section, csprintf("pxcap.pxid"), tmp16);
+    paramIn(cp, csprintf("pxcap.pxid"), tmp16);
     pxcap.pxid = tmp16;
-    paramIn(cp, section, csprintf("pxcap.pxcap"), tmp16);
+    paramIn(cp, csprintf("pxcap.pxcap"), tmp16);
     pxcap.pxcap = tmp16;
-    paramIn(cp, section, csprintf("pxcap.pxdcap"), tmp32);
+    paramIn(cp, csprintf("pxcap.pxdcap"), tmp32);
     pxcap.pxdcap = tmp32;
-    paramIn(cp, section, csprintf("pxcap.pxdc"), tmp16);
+    paramIn(cp, csprintf("pxcap.pxdc"), tmp16);
     pxcap.pxdc = tmp16;
-    paramIn(cp, section, csprintf("pxcap.pxds"), tmp16);
+    paramIn(cp, csprintf("pxcap.pxds"), tmp16);
     pxcap.pxds = tmp16;
-    paramIn(cp, section, csprintf("pxcap.pxlcap"), tmp32);
+    paramIn(cp, csprintf("pxcap.pxlcap"), tmp32);
     pxcap.pxlcap = tmp32;
-    paramIn(cp, section, csprintf("pxcap.pxlc"), tmp16);
+    paramIn(cp, csprintf("pxcap.pxlc"), tmp16);
     pxcap.pxlc = tmp16;
-    paramIn(cp, section, csprintf("pxcap.pxls"), tmp16);
+    paramIn(cp, csprintf("pxcap.pxls"), tmp16);
     pxcap.pxls = tmp16;
-    paramIn(cp, section, csprintf("pxcap.pxdcap2"), tmp32);
+    paramIn(cp, csprintf("pxcap.pxdcap2"), tmp32);
     pxcap.pxdcap2 = tmp32;
-    paramIn(cp, section, csprintf("pxcap.pxdc2"), tmp32);
+    paramIn(cp, csprintf("pxcap.pxdc2"), tmp32);
     pxcap.pxdc2 = tmp32;
     pioPort.sendRangeChange();
 }
index 1c29293a6ae2aca6a0b77bc635214e146c59b3cf..4f997932b46ede338968ba1b0a8c135b958df0aa 100644 (file)
@@ -249,14 +249,14 @@ class PciDevice : public DmaDevice
      * Serialize this object to the given output stream.
      * @param os The stream to serialize to.
      */
-    virtual void serialize(std::ostream &os);
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
 
     /**
      * 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 unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 
 
     virtual unsigned int drain(DrainManager *dm);
index efd8b083da857552ee5b1848a5acf5b7516ac29b..fb2564b716cda67c4f2a2fc48791f1c771a38c62 100644 (file)
@@ -65,58 +65,51 @@ PacketFifo::copyout(void *dest, unsigned offset, unsigned len)
 
 
 void
-PacketFifoEntry::serialize(const string &base, ostream &os)
+PacketFifoEntry::serialize(const string &base, CheckpointOut &cp) const
 {
-    packet->serialize(base + ".packet", os);
-    paramOut(os, base + ".slack", slack);
-    paramOut(os, base + ".number", number);
-    paramOut(os, base + ".priv", priv);
+    packet->serialize(base + ".packet", cp);
+    paramOut(cp, base + ".slack", slack);
+    paramOut(cp, base + ".number", number);
+    paramOut(cp, base + ".priv", priv);
 }
 
 void
-PacketFifoEntry::unserialize(const string &base, Checkpoint *cp,
-                             const string &section)
+PacketFifoEntry::unserialize(const string &base, CheckpointIn &cp)
 {
     packet = make_shared<EthPacketData>(16384);
-    packet->unserialize(base + ".packet", cp, section);
-    paramIn(cp, section, base + ".slack", slack);
-    paramIn(cp, section, base + ".number", number);
-    paramIn(cp, section, base + ".priv", priv);
+    packet->unserialize(base + ".packet", cp);
+    paramIn(cp, base + ".slack", slack);
+    paramIn(cp, base + ".number", number);
+    paramIn(cp, base + ".priv", priv);
 }
 
 void
-PacketFifo::serialize(const string &base, ostream &os)
+PacketFifo::serialize(const string &base, CheckpointOut &cp) const
 {
-    paramOut(os, base + ".size", _size);
-    paramOut(os, base + ".maxsize", _maxsize);
-    paramOut(os, base + ".reserved", _reserved);
-    paramOut(os, base + ".packets", fifo.size());
+    paramOut(cp, base + ".size", _size);
+    paramOut(cp, base + ".maxsize", _maxsize);
+    paramOut(cp, base + ".reserved", _reserved);
+    paramOut(cp, base + ".packets", fifo.size());
 
     int i = 0;
-    iterator entry = fifo.begin();
-    iterator end = fifo.end();
-    while (entry != end) {
-        entry->serialize(csprintf("%s.entry%d", base, i), os);
-        ++entry;
-        ++i;
-    }
+    for (const auto &entry : fifo)
+        entry.serialize(csprintf("%s.entry%d", base, i++), cp);
 }
 
 void
-PacketFifo::unserialize(const string &base, Checkpoint *cp,
-                        const string &section)
+PacketFifo::unserialize(const string &base, CheckpointIn &cp)
 {
-    paramIn(cp, section, base + ".size", _size);
-//  paramIn(cp, section, base + ".maxsize", _maxsize);
-    paramIn(cp, section, base + ".reserved", _reserved);
+    paramIn(cp, base + ".size", _size);
+//  paramIn(cp, base + ".maxsize", _maxsize);
+    paramIn(cp, base + ".reserved", _reserved);
     int fifosize;
-    paramIn(cp, section, base + ".packets", fifosize);
+    paramIn(cp, base + ".packets", fifosize);
 
     fifo.clear();
 
     for (int i = 0; i < fifosize; ++i) {
         PacketFifoEntry entry;
-        entry.unserialize(csprintf("%s.entry%d", base, i), cp, section);
+        entry.unserialize(csprintf("%s.entry%d", base, i), cp);
         fifo.push_back(entry);
     }
 }
index b548627e0294990963cd6070c41eb72db1838b91..95d46fc76c60969dfd2ed4c4fd115e5cd4c4bdec 100644 (file)
@@ -70,9 +70,8 @@ struct PacketFifoEntry
         priv = -1;
     }
 
-    void serialize(const std::string &base, std::ostream &os);
-    void unserialize(const std::string &base, Checkpoint *cp,
-                     const std::string &section);
+    void serialize(const std::string &base, CheckpointOut &cp) const;
+    void unserialize(const std::string &base, CheckpointIn &cp);
 };
 
 class PacketFifo
@@ -201,9 +200,8 @@ class PacketFifo
  * Serialization stuff
  */
   public:
-    void serialize(const std::string &base, std::ostream &os);
-    void unserialize(const std::string &base,
-                     Checkpoint *cp, const std::string &section);
+    void serialize(const std::string &base, CheckpointOut &cp) const;
+    void unserialize(const std::string &base, CheckpointIn &cp);
 };
 
 #endif // __DEV_PKTFIFO_HH__
index a5608fb36384eaed90b86dbd131f196c759c97c0..d5a05b3198137101e663544b7bffb66cc8fa2559 100644 (file)
@@ -1259,10 +1259,10 @@ Device::drainResume()
 //
 //
 void
-Base::serialize(std::ostream &os)
+Base::serialize(CheckpointOut &cp) const
 {
     // Serialize the PciDevice base class
-    PciDevice::serialize(os);
+    PciDevice::serialize(cp);
 
     SERIALIZE_SCALAR(rxEnable);
     SERIALIZE_SCALAR(txEnable);
@@ -1280,10 +1280,10 @@ Base::serialize(std::ostream &os)
 }
 
 void
-Base::unserialize(Checkpoint *cp, const std::string &section)
+Base::unserialize(CheckpointIn &cp)
 {
     // Unserialize the PciDevice base class
-    PciDevice::unserialize(cp, section);
+    PciDevice::unserialize(cp);
 
     UNSERIALIZE_SCALAR(rxEnable);
     UNSERIALIZE_SCALAR(txEnable);
@@ -1303,12 +1303,12 @@ Base::unserialize(Checkpoint *cp, const std::string &section)
 }
 
 void
-Device::serialize(std::ostream &os)
+Device::serializeOld(CheckpointOut &cp)
 {
     int count;
 
     // Serialize the PciDevice base class
-    Base::serialize(os);
+    Base::serialize(cp);
 
     if (rxState == rxCopy)
         panic("can't serialize with an in flight dma request rxState=%s",
@@ -1333,16 +1333,16 @@ Device::serialize(std::ostream &os)
     int virtualRegsSize = virtualRegs.size();
     SERIALIZE_SCALAR(virtualRegsSize);
     for (int i = 0; i < virtualRegsSize; ++i) {
-        VirtualReg *vnic = &virtualRegs[i];
+        const VirtualReg *vnic = &virtualRegs[i];
 
         std::string reg = csprintf("vnic%d", i);
-        paramOut(os, reg + ".RxData", vnic->RxData);
-        paramOut(os, reg + ".RxDone", vnic->RxDone);
-        paramOut(os, reg + ".TxData", vnic->TxData);
-        paramOut(os, reg + ".TxDone", vnic->TxDone);
+        paramOut(cp, reg + ".RxData", vnic->RxData);
+        paramOut(cp, reg + ".RxDone", vnic->RxDone);
+        paramOut(cp, reg + ".TxData", vnic->TxData);
+        paramOut(cp, reg + ".TxDone", vnic->TxDone);
 
         bool rxPacketExists = vnic->rxIndex != rxFifo.end();
-        paramOut(os, reg + ".rxPacketExists", rxPacketExists);
+        paramOut(cp, reg + ".rxPacketExists", rxPacketExists);
         if (rxPacketExists) {
             int rxPacket = 0;
             PacketFifo::iterator i = rxFifo.begin();
@@ -1352,11 +1352,11 @@ Device::serialize(std::ostream &os)
                 ++rxPacket;
             }
 
-            paramOut(os, reg + ".rxPacket", rxPacket);
-            paramOut(os, reg + ".rxPacketOffset", vnic->rxPacketOffset);
-            paramOut(os, reg + ".rxPacketBytes", vnic->rxPacketBytes);
+            paramOut(cp, reg + ".rxPacket", rxPacket);
+            paramOut(cp, reg + ".rxPacketOffset", vnic->rxPacketOffset);
+            paramOut(cp, reg + ".rxPacketBytes", vnic->rxPacketBytes);
         }
-        paramOut(os, reg + ".rxDoneData", vnic->rxDoneData);
+        paramOut(cp, reg + ".rxDoneData", vnic->rxDoneData);
     }
 
     int rxFifoPtr = -1;
@@ -1371,17 +1371,17 @@ Device::serialize(std::ostream &os)
 
     VirtualList::iterator i, end;
     for (count = 0, i = rxList.begin(), end = rxList.end(); i != end; ++i)
-        paramOut(os, csprintf("rxList%d", count++), *i);
+        paramOut(cp, csprintf("rxList%d", count++), *i);
     int rxListSize = count;
     SERIALIZE_SCALAR(rxListSize);
 
     for (count = 0, i = rxBusy.begin(), end = rxBusy.end(); i != end; ++i)
-        paramOut(os, csprintf("rxBusy%d", count++), *i);
+        paramOut(cp, csprintf("rxBusy%d", count++), *i);
     int rxBusySize = count;
     SERIALIZE_SCALAR(rxBusySize);
 
     for (count = 0, i = txList.begin(), end = txList.end(); i != end; ++i)
-        paramOut(os, csprintf("txList%d", count++), *i);
+        paramOut(cp, csprintf("txList%d", count++), *i);
     int txListSize = count;
     SERIALIZE_SCALAR(txListSize);
 
@@ -1392,7 +1392,7 @@ Device::serialize(std::ostream &os)
     SERIALIZE_SCALAR(rxState);
     SERIALIZE_SCALAR(rxEmpty);
     SERIALIZE_SCALAR(rxLow);
-    rxFifo.serialize("rxFifo", os);
+    rxFifo.serialize("rxFifo", cp);
 
     /*
      * Serialize tx state machine
@@ -1400,11 +1400,11 @@ Device::serialize(std::ostream &os)
     int txState = this->txState;
     SERIALIZE_SCALAR(txState);
     SERIALIZE_SCALAR(txFull);
-    txFifo.serialize("txFifo", os);
+    txFifo.serialize("txFifo", cp);
     bool txPacketExists = txPacket != nullptr;
     SERIALIZE_SCALAR(txPacketExists);
     if (txPacketExists) {
-        txPacket->serialize("txPacket", os);
+        txPacket->serialize("txPacket", cp);
         SERIALIZE_SCALAR(txPacketOffset);
         SERIALIZE_SCALAR(txPacketBytes);
     }
@@ -1418,10 +1418,10 @@ Device::serialize(std::ostream &os)
 }
 
 void
-Device::unserialize(Checkpoint *cp, const std::string &section)
+Device::unserialize(CheckpointIn &cp)
 {
     // Unserialize the PciDevice base class
-    Base::unserialize(cp, section);
+    Base::unserialize(cp);
 
     /*
      * Unserialize the device registers that may have been written by the OS.
@@ -1442,7 +1442,7 @@ Device::unserialize(Checkpoint *cp, const std::string &section)
     rxList.clear();
     for (int i = 0; i < rxListSize; ++i) {
         int value;
-        paramIn(cp, section, csprintf("rxList%d", i), value);
+        paramIn(cp, csprintf("rxList%d", i), value);
         rxList.push_back(value);
     }
 
@@ -1451,7 +1451,7 @@ Device::unserialize(Checkpoint *cp, const std::string &section)
     rxBusy.clear();
     for (int i = 0; i < rxBusySize; ++i) {
         int value;
-        paramIn(cp, section, csprintf("rxBusy%d", i), value);
+        paramIn(cp, csprintf("rxBusy%d", i), value);
         rxBusy.push_back(value);
     }
 
@@ -1460,7 +1460,7 @@ Device::unserialize(Checkpoint *cp, const std::string &section)
     txList.clear();
     for (int i = 0; i < txListSize; ++i) {
         int value;
-        paramIn(cp, section, csprintf("txList%d", i), value);
+        paramIn(cp, csprintf("txList%d", i), value);
         txList.push_back(value);
     }
 
@@ -1472,7 +1472,7 @@ Device::unserialize(Checkpoint *cp, const std::string &section)
     UNSERIALIZE_SCALAR(rxEmpty);
     UNSERIALIZE_SCALAR(rxLow);
     this->rxState = (RxState) rxState;
-    rxFifo.unserialize("rxFifo", cp, section);
+    rxFifo.unserialize("rxFifo", cp);
 
     int rxFifoPtr;
     UNSERIALIZE_SCALAR(rxFifoPtr);
@@ -1491,13 +1491,13 @@ Device::unserialize(Checkpoint *cp, const std::string &section)
     UNSERIALIZE_SCALAR(txState);
     UNSERIALIZE_SCALAR(txFull);
     this->txState = (TxState) txState;
-    txFifo.unserialize("txFifo", cp, section);
+    txFifo.unserialize("txFifo", cp);
     bool txPacketExists;
     UNSERIALIZE_SCALAR(txPacketExists);
     txPacket = 0;
     if (txPacketExists) {
         txPacket = make_shared<EthPacketData>(16384);
-        txPacket->unserialize("txPacket", cp, section);
+        txPacket->unserialize("txPacket", cp);
         UNSERIALIZE_SCALAR(txPacketOffset);
         UNSERIALIZE_SCALAR(txPacketBytes);
     }
@@ -1516,30 +1516,30 @@ Device::unserialize(Checkpoint *cp, const std::string &section)
         VirtualReg *vnic = &virtualRegs[i];
         std::string reg = csprintf("vnic%d", i);
 
-        paramIn(cp, section, reg + ".RxData", vnic->RxData);
-        paramIn(cp, section, reg + ".RxDone", vnic->RxDone);
-        paramIn(cp, section, reg + ".TxData", vnic->TxData);
-        paramIn(cp, section, reg + ".TxDone", vnic->TxDone);
+        paramIn(cp, reg + ".RxData", vnic->RxData);
+        paramIn(cp, reg + ".RxDone", vnic->RxDone);
+        paramIn(cp, reg + ".TxData", vnic->TxData);
+        paramIn(cp, reg + ".TxDone", vnic->TxDone);
 
         vnic->rxUnique = rxUnique++;
         vnic->txUnique = txUnique++;
 
         bool rxPacketExists;
-        paramIn(cp, section, reg + ".rxPacketExists", rxPacketExists);
+        paramIn(cp, reg + ".rxPacketExists", rxPacketExists);
         if (rxPacketExists) {
             int rxPacket;
-            paramIn(cp, section, reg + ".rxPacket", rxPacket);
+            paramIn(cp, reg + ".rxPacket", rxPacket);
             vnic->rxIndex = rxFifo.begin();
             while (rxPacket--)
                 ++vnic->rxIndex;
 
-            paramIn(cp, section, reg + ".rxPacketOffset",
+            paramIn(cp, reg + ".rxPacketOffset",
                     vnic->rxPacketOffset);
-            paramIn(cp, section, reg + ".rxPacketBytes", vnic->rxPacketBytes);
+            paramIn(cp, reg + ".rxPacketBytes", vnic->rxPacketBytes);
         } else {
             vnic->rxIndex = rxFifo.end();
         }
-        paramIn(cp, section, reg + ".rxDoneData", vnic->rxDoneData);
+        paramIn(cp, reg + ".rxDoneData", vnic->rxDoneData);
     }
 
     /*
index 58f9e7253ab4fbe005a7a71f57cfc5609af68bd2..ac7af34afb09232421d0779dcf04961fc7726b28 100644 (file)
@@ -73,8 +73,8 @@ class Base : public EtherDevBase
  * Serialization stuff
  */
   public:
-    virtual void serialize(std::ostream &os);
-    virtual void unserialize(Checkpoint *cp, const std::string &section);
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 
 /**
  * Construction/Destruction/Parameters
@@ -297,8 +297,8 @@ class Device : public Base
  * Serialization stuff
  */
   public:
-    virtual void serialize(std::ostream &os);
-    virtual void unserialize(Checkpoint *cp, const std::string &section);
+    void serializeOld(CheckpointOut &cp) M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 
   public:
     Device(const Params *p);
index 3853abb16b7dbd61845a4d0b7dcb3c04b2822a53..5b74bbcb70b5c8b66ae62c8dd452867b44f80331 100644 (file)
@@ -79,13 +79,13 @@ DumbTOD::write(PacketPtr pkt)
 }
 
 void
-DumbTOD::serialize(std::ostream &os)
+DumbTOD::serialize(CheckpointOut &cp) const
 {
     SERIALIZE_SCALAR(todTime);
 }
 
 void
-DumbTOD::unserialize(Checkpoint *cp, const std::string &section)
+DumbTOD::unserialize(CheckpointIn &cp)
 {
     UNSERIALIZE_SCALAR(todTime);
 }
index a5b2dfaffe24a6ff0357614ff2a5be28c2512c34..a7b45136453ade4b864aa1908efe1c0bed6e2955 100644 (file)
@@ -63,20 +63,8 @@ class DumbTOD : 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 // __DEV_BADDEV_HH__
index c71edd9f0b6541b3d35a718d62974039f086dbda..bee0323c86ab902076fc4dd140ddf520cb5508a0 100644 (file)
@@ -334,41 +334,43 @@ Iob::getAddrRanges() const
 
 
 void
-Iob::serialize(std::ostream &os)
+Iob::serialize(CheckpointOut &cp) const
 {
 
     SERIALIZE_SCALAR(jIntVec);
     SERIALIZE_ARRAY(jBusData0, MaxNiagaraProcs);
     SERIALIZE_ARRAY(jBusData1, MaxNiagaraProcs);
     for (int x = 0; x < NumDeviceIds; x++) {
-        nameOut(os, csprintf("%s.Int%d", name(), x));
-        paramOut(os, "cpu", intMan[x].cpu);
-        paramOut(os, "vector", intMan[x].vector);
-        paramOut(os, "mask", intCtl[x].mask);
-        paramOut(os, "pend", intCtl[x].pend);
+        ScopedCheckpointSection sec(cp, csprintf("Int%d", x));
+        paramOut(cp, "cpu", intMan[x].cpu);
+        paramOut(cp, "vector", intMan[x].vector);
+        paramOut(cp, "mask", intCtl[x].mask);
+        paramOut(cp, "pend", intCtl[x].pend);
     };
     for (int x = 0; x < MaxNiagaraProcs; x++) {
-        nameOut(os, csprintf("%s.jIntBusy%d", name(), x));
-        paramOut(os, "busy", jIntBusy[x].busy);
-        paramOut(os, "source", jIntBusy[x].source);
+        ScopedCheckpointSection sec(cp, csprintf("jIntBusy%d", x));
+        paramOut(cp, "busy", jIntBusy[x].busy);
+        paramOut(cp, "source", jIntBusy[x].source);
     };
 }
 
 void
-Iob::unserialize(Checkpoint *cp, const std::string &section)
+Iob::unserialize(CheckpointIn &cp)
 {
     UNSERIALIZE_SCALAR(jIntVec);
     UNSERIALIZE_ARRAY(jBusData0, MaxNiagaraProcs);
     UNSERIALIZE_ARRAY(jBusData1, MaxNiagaraProcs);
     for (int x = 0; x < NumDeviceIds; x++) {
-        paramIn(cp, csprintf("%s.Int%d", name(), x), "cpu", intMan[x].cpu);
-        paramIn(cp, csprintf("%s.Int%d", name(), x), "vector", intMan[x].vector);
-        paramIn(cp, csprintf("%s.Int%d", name(), x), "mask", intCtl[x].mask);
-        paramIn(cp, csprintf("%s.Int%d", name(), x), "pend", intCtl[x].pend);
+        ScopedCheckpointSection sec(cp, csprintf("Int%d", x));
+        paramIn(cp, "cpu", intMan[x].cpu);
+        paramIn(cp, "vector", intMan[x].vector);
+        paramIn(cp, "mask", intCtl[x].mask);
+        paramIn(cp, "pend", intCtl[x].pend);
     };
     for (int x = 0; x < MaxNiagaraProcs; x++) {
-        paramIn(cp, csprintf("%s.jIntBusy%d", name(), x), "busy", jIntBusy[x].busy);
-        paramIn(cp, csprintf("%s.jIntBusy%d", name(), x), "source", jIntBusy[x].source);
+        ScopedCheckpointSection sec(cp, csprintf("jIntBusy%d", x));
+        paramIn(cp, "busy", jIntBusy[x].busy);
+        paramIn(cp, "source", jIntBusy[x].source);
     };
 }
 
index fc5e610925dfd3e904eca97de02a6214b23eb8da..033ee386719dab3751a9fc22bfa8c77e263ef167 100644 (file)
@@ -142,9 +142,8 @@ class Iob : public PioDevice
 
     AddrRangeList getAddrRanges() const;
 
-    virtual void serialize(std::ostream &os);
-    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_SPARC_IOB_HH__
index 0a6d144450f83cb2d4d081586d0e4a031ab7fa00..5fe9157bcbc4bdbea245e3db91e01f112eb67369 100644 (file)
@@ -170,7 +170,7 @@ MmDisk::write(PacketPtr pkt)
 }
 
 void
-MmDisk::serialize(std::ostream &os)
+MmDisk::serialize(CheckpointOut &cp) const
 {
     // just write any dirty changes to the cow layer it will take care of
     // serialization
index d14e1d4a4c7a07049cdd25d1de1a6418819a1186..2de3cac7de886b41a0b7c712aebd17e7a751a4cd 100644 (file)
@@ -61,7 +61,7 @@ class MmDisk : public BasicPioDevice
     virtual Tick read(PacketPtr pkt);
     virtual Tick write(PacketPtr pkt);
 
-    virtual void serialize(std::ostream &os);
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
 };
 
 #endif //__DEV_SPARC_MM_DISK_HH__
index e840d2a56a52cbb0e633abb49b5fcf870ec9cd69..a9446e6d536ae0b805c5758cadbde56bb6bc2c73 100644 (file)
@@ -292,7 +292,7 @@ Uart8250::getAddrRanges() const
 }
 
 void
-Uart8250::serialize(ostream &os)
+Uart8250::serialize(CheckpointOut &cp) const
 {
     SERIALIZE_SCALAR(status);
     SERIALIZE_SCALAR(IER);
@@ -314,7 +314,7 @@ Uart8250::serialize(ostream &os)
 }
 
 void
-Uart8250::unserialize(Checkpoint *cp, const std::string &section)
+Uart8250::unserialize(CheckpointIn &cp)
 {
     UNSERIALIZE_SCALAR(status);
     UNSERIALIZE_SCALAR(IER);
index 7d577954cf6c3b1157e185cc327afe911242400f..6b255594a5121568b589dccfede5d397dfbbc214 100644 (file)
@@ -113,9 +113,8 @@ class Uart8250 : public Uart
      */
     virtual bool intStatus() { return status ? true : false; }
 
-    virtual void serialize(std::ostream &os);
-    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_UART_HH__
index a65fe7fa488f16d0194137ff0a12db012014f4fb..ad97de99c4c959dde9ae3fccb6fc0e9391c4e87b 100644 (file)
@@ -233,18 +233,18 @@ VirtQueue::VirtQueue(PortProxy &proxy, uint16_t size)
 }
 
 void
-VirtQueue::serialize(std::ostream &os)
+VirtQueue::serialize(CheckpointOut &cp) const
 {
     SERIALIZE_SCALAR(_address);
     SERIALIZE_SCALAR(_last_avail);
 }
 
 void
-VirtQueue::unserialize(Checkpoint *cp, const std::string &section)
+VirtQueue::unserialize(CheckpointIn &cp)
 {
     Addr addr_in;
 
-    paramIn(cp, section, "_address", addr_in);
+    paramIn(cp, "_address", addr_in);
     UNSERIALIZE_SCALAR(_last_avail);
 
     // Use the address setter to ensure that the ring buffer addresses
@@ -336,27 +336,23 @@ VirtIODeviceBase::~VirtIODeviceBase()
 }
 
 void
-VirtIODeviceBase::serialize(std::ostream &os)
+VirtIODeviceBase::serialize(CheckpointOut &cp) const
 {
     SERIALIZE_SCALAR(guestFeatures);
-    paramOut(os, "_deviceStatus", (uint8_t)_deviceStatus);
+    SERIALIZE_SCALAR(_deviceStatus);
     SERIALIZE_SCALAR(_queueSelect);
-    for (QueueID i = 0; i < _queues.size(); ++i) {
-        nameOut(os, csprintf("%s._queues.%i", name(), i));
-        _queues[i]->serialize(os);
-    }
+    for (QueueID i = 0; i < _queues.size(); ++i)
+        _queues[i]->serializeSection(cp, csprintf("_queues.%i", i));
 }
 
 void
-VirtIODeviceBase::unserialize(Checkpoint *cp, const std::string &section)
+VirtIODeviceBase::unserialize(CheckpointIn &cp)
 {
     UNSERIALIZE_SCALAR(guestFeatures);
-    uint8_t status;
-    paramIn(cp, section, "_deviceStatus", status);
-    _deviceStatus = status;
+    UNSERIALIZE_SCALAR(_deviceStatus);
     UNSERIALIZE_SCALAR(_queueSelect);
     for (QueueID i = 0; i < _queues.size(); ++i)
-        _queues[i]->unserialize(cp, csprintf("%s._queues.%i", section, i));
+        _queues[i]->unserializeSection(cp, csprintf("_queues.%i", i));
 }
 
 void
index fe1685767cbbaf1203e3952d81362f122993768d..de68f92e1abf0c0990c7267a63272ffdac1fbc1f 100644 (file)
@@ -312,16 +312,15 @@ class VirtDescriptor
  * @note Queues must be registered with
  * VirtIODeviceBase::registerQueue() to be active.
  */
-class VirtQueue {
+class VirtQueue : public Serializable {
 public:
     virtual ~VirtQueue() {};
 
     /** @{
      * @name Checkpointing Interface
      */
-    virtual void serialize(std::ostream &os);
-    virtual void unserialize(Checkpoint *cp, const std::string &section);
-    /** @} */
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 
     /** @{
      * @name Low-level Device Interface
@@ -596,10 +595,8 @@ class VirtIODeviceBase : public SimObject
     /** @{
      * @name SimObject Interfaces
      */
-
-    void serialize(std::ostream &os);
-    void unserialize(Checkpoint *cp, const std::string &section);
-
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
     /** @} */
 
 
index 4861821d70fa4f51b0432b29ac68ab9bfc6e35cc..336757bb93f3ddc3e59101494954c2e7c7e8c187 100644 (file)
@@ -214,13 +214,13 @@ VirtIO9PProxy::~VirtIO9PProxy()
 
 
 void
-VirtIO9PProxy::VirtIO9PProxy::serialize(std::ostream &os)
+VirtIO9PProxy::VirtIO9PProxy::serialize(CheckpointOut &cp) const
 {
     fatal("Can't checkpoint a system with a VirtIO 9p proxy!\n");
 }
 
 void
-VirtIO9PProxy::unserialize(Checkpoint *cp, const std::string &section)
+VirtIO9PProxy::unserialize(CheckpointIn &cp)
 {
     fatal("Can't checkpoint a system with a VirtIO 9p proxy!\n");
 }
index 2cbdbc9ebdeb7bb787d2212a6dc46a6cd61fcb08..a7fb780aa2e3bcd2ecfa0dd1748b51c282a0f468 100644 (file)
@@ -216,8 +216,8 @@ class VirtIO9PProxy : public VirtIO9PBase
     VirtIO9PProxy(Params *params);
     virtual ~VirtIO9PProxy();
 
-    void serialize(std::ostream &os);
-    void unserialize(Checkpoint *cp, const std::string &section);
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 
   protected:
     void recvTMsg(const P9MsgHeader &header, const uint8_t *data, size_t size);
index 6a778b7589493fe1aeae62d52344712f4fc9f4c9..73cfe853e3319144f4b4119ec0db5eeb62fd9e93 100644 (file)
@@ -119,23 +119,23 @@ X86ISA::Cmos::startup()
 }
 
 void
-X86ISA::Cmos::serialize(std::ostream &os)
+X86ISA::Cmos::serialize(CheckpointOut &cp) const
 {
     SERIALIZE_SCALAR(address);
     SERIALIZE_ARRAY(regs, numRegs);
 
     // Serialize the timer
-    rtc.serialize("rtc", os);
+    rtc.serialize("rtc", cp);
 }
 
 void
-X86ISA::Cmos::unserialize(Checkpoint *cp, const std::string &section)
+X86ISA::Cmos::unserialize(CheckpointIn &cp)
 {
     UNSERIALIZE_SCALAR(address);
     UNSERIALIZE_ARRAY(regs, numRegs);
 
     // Serialize the timer
-    rtc.unserialize("rtc", cp, section);
+    rtc.unserialize("rtc", cp);
 }
 
 X86ISA::Cmos *
index fa5865c0a17fce7ca30d9c131607dcb5865d8273..f0234da54037c9876d4524a637daebbce9e10899 100644 (file)
@@ -83,9 +83,9 @@ class Cmos : public BasicPioDevice
     Tick write(PacketPtr pkt);
 
     virtual void startup();
-    virtual void serialize(std::ostream &os);
-    virtual void unserialize(Checkpoint *cp, const std::string &section);
 
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 };
 
 } // namespace X86ISA
index a0a7c35ec0218fcbba2725b702c193d3442f5e3e..03b12dc14629fa5070370fdd645e9b0a3d7a9626 100644 (file)
@@ -463,7 +463,7 @@ X86ISA::I8042::write(PacketPtr pkt)
 }
 
 void
-X86ISA::I8042::serialize(std::ostream &os)
+X86ISA::I8042::serializeOld(CheckpointOut &cp)
 {
     uint8_t statusRegData = statusReg.__data;
     uint8_t commandByteData = commandByte.__data;
@@ -474,12 +474,12 @@ X86ISA::I8042::serialize(std::ostream &os)
     SERIALIZE_SCALAR(commandByteData);
     SERIALIZE_SCALAR(dataReg);
     SERIALIZE_SCALAR(lastCommand);
-    mouse.serialize("mouse", os);
-    keyboard.serialize("keyboard", os);
+    mouse.serialize("mouse", cp);
+    keyboard.serialize("keyboard", cp);
 }
 
 void
-X86ISA::I8042::unserialize(Checkpoint *cp, const std::string &section)
+X86ISA::I8042::unserialize(CheckpointIn &cp)
 {
     uint8_t statusRegData;
     uint8_t commandByteData;
@@ -490,38 +490,37 @@ X86ISA::I8042::unserialize(Checkpoint *cp, const std::string &section)
     UNSERIALIZE_SCALAR(commandByteData);
     UNSERIALIZE_SCALAR(dataReg);
     UNSERIALIZE_SCALAR(lastCommand);
-    mouse.unserialize("mouse", cp, section);
-    keyboard.unserialize("keyboard", cp, section);
+    mouse.unserialize("mouse", cp);
+    keyboard.unserialize("keyboard", cp);
 
     statusReg.__data = statusRegData;
     commandByte.__data = commandByteData;
 }
 
 void
-X86ISA::PS2Keyboard::serialize(const std::string &base, std::ostream &os)
+X86ISA::PS2Keyboard::serialize(const std::string &base, CheckpointOut &cp)
 {
-    paramOut(os, base + ".lastCommand", lastCommand);
+    paramOut(cp, base + ".lastCommand", lastCommand);
     int bufferSize = outBuffer.size();
-    paramOut(os, base + ".outBuffer.size", bufferSize);
+    paramOut(cp, base + ".outBuffer.size", bufferSize);
     uint8_t *buffer = new uint8_t[bufferSize];
     for (int i = 0; i < bufferSize; ++i) {
         buffer[i] = outBuffer.front();
         outBuffer.pop();
     }
-    arrayParamOut(os, base + ".outBuffer.elts", buffer,
+    arrayParamOut(cp, base + ".outBuffer.elts", buffer,
             bufferSize*sizeof(uint8_t));
     delete[] buffer;
 }
 
 void
-X86ISA::PS2Keyboard::unserialize(const std::string &base, Checkpoint *cp,
-        const std::string &section)
+X86ISA::PS2Keyboard::unserialize(const std::string &base, CheckpointIn &cp)
 {
-    paramIn(cp, section, base + ".lastCommand", lastCommand);
+    paramIn(cp, base + ".lastCommand", lastCommand);
     int bufferSize;
-    paramIn(cp, section, base + ".outBuffer.size", bufferSize);
+    paramIn(cp, base + ".outBuffer.size", bufferSize);
     uint8_t *buffer = new uint8_t[bufferSize];
-    arrayParamIn(cp, section, base + ".outBuffer.elts", buffer,
+    arrayParamIn(cp, base + ".outBuffer.elts", buffer,
             bufferSize*sizeof(uint8_t));
     for (int i = 0; i < bufferSize; ++i) {
         outBuffer.push(buffer[i]);
@@ -530,43 +529,42 @@ X86ISA::PS2Keyboard::unserialize(const std::string &base, Checkpoint *cp,
 }
 
 void
-X86ISA::PS2Mouse::serialize(const std::string &base, std::ostream &os)
+X86ISA::PS2Mouse::serialize(const std::string &base, CheckpointOut &cp)
 {
     uint8_t statusData = status.__data;
-    paramOut(os, base + ".lastCommand", lastCommand);
+    paramOut(cp, base + ".lastCommand", lastCommand);
     int bufferSize = outBuffer.size();
-    paramOut(os, base + ".outBuffer.size", bufferSize);
+    paramOut(cp, base + ".outBuffer.size", bufferSize);
     uint8_t *buffer = new uint8_t[bufferSize];
     for (int i = 0; i < bufferSize; ++i) {
         buffer[i] = outBuffer.front();
         outBuffer.pop();
     }
-    arrayParamOut(os, base + ".outBuffer.elts", buffer,
+    arrayParamOut(cp, base + ".outBuffer.elts", buffer,
             bufferSize*sizeof(uint8_t));
     delete[] buffer;
-    paramOut(os, base + ".status", statusData);
-    paramOut(os, base + ".resolution", resolution);
-    paramOut(os, base + ".sampleRate", sampleRate);
+    paramOut(cp, base + ".status", statusData);
+    paramOut(cp, base + ".resolution", resolution);
+    paramOut(cp, base + ".sampleRate", sampleRate);
 }
 
 void
-X86ISA::PS2Mouse::unserialize(const std::string &base, Checkpoint *cp,
-        const std::string &section)
+X86ISA::PS2Mouse::unserialize(const std::string &base, CheckpointIn &cp)
 {
     uint8_t statusData;
-    paramIn(cp, section, base + ".lastCommand", lastCommand);
+    paramIn(cp, base + ".lastCommand", lastCommand);
     int bufferSize;
-    paramIn(cp, section, base + ".outBuffer.size", bufferSize);
+    paramIn(cp, base + ".outBuffer.size", bufferSize);
     uint8_t *buffer = new uint8_t[bufferSize];
-    arrayParamIn(cp, section, base + ".outBuffer.elts", buffer,
+    arrayParamIn(cp, base + ".outBuffer.elts", buffer,
             bufferSize*sizeof(uint8_t));
     for (int i = 0; i < bufferSize; ++i) {
         outBuffer.push(buffer[i]);
     }
     delete[] buffer;
-    paramIn(cp, section, base + ".status", statusData);
-    paramIn(cp, section, base + ".resolution", resolution);
-    paramIn(cp, section, base + ".sampleRate", sampleRate);
+    paramIn(cp, base + ".status", statusData);
+    paramIn(cp, base + ".resolution", resolution);
+    paramIn(cp, base + ".sampleRate", sampleRate);
 
     status.__data = statusData;
 }
index 7919221422965a61aae439e84fe35b11cf3b3eac..9d2548857f4506557ab71931719e20536bbaf371 100644 (file)
@@ -117,9 +117,8 @@ class PS2Mouse : public PS2Device
 
     bool processData(uint8_t data);
 
-    void serialize(const std::string &base, std::ostream &os);
-    void unserialize(const std::string &base, Checkpoint *cp,
-            const std::string &section);
+    void serialize(const std::string &base, CheckpointOut &cp);
+    void unserialize(const std::string &base, CheckpointIn &cp);
 };
 
 class PS2Keyboard : public PS2Device
@@ -151,9 +150,8 @@ class PS2Keyboard : public PS2Device
   public:
     bool processData(uint8_t data);
 
-    void serialize(const std::string &base, std::ostream &os);
-    void unserialize(const std::string &base, Checkpoint *cp,
-            const std::string &section);
+    void serialize(const std::string &base, CheckpointOut &cp);
+    void unserialize(const std::string &base, CheckpointIn &cp);
 };
 
 class I8042 : public BasicPioDevice
@@ -249,8 +247,8 @@ class I8042 : public BasicPioDevice
 
     Tick write(PacketPtr pkt);
 
-    virtual void serialize(std::ostream &os);
-    virtual void unserialize(Checkpoint *cp, const std::string &section);
+    void serializeOld(CheckpointOut &cp) M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 };
 
 } // namespace X86ISA
index 12697ce62e451fe02fedb8210a6a708ce4215d0d..44fa291549b8b052eff851bd32effdfe5905c620 100644 (file)
@@ -260,7 +260,7 @@ X86ISA::I82094AA::lowerInterruptPin(int number)
 }
 
 void
-X86ISA::I82094AA::serialize(std::ostream &os)
+X86ISA::I82094AA::serialize(CheckpointOut &cp) const
 {
     uint64_t* redirTableArray = (uint64_t*)redirTable;
     SERIALIZE_SCALAR(regSel);
@@ -273,7 +273,7 @@ X86ISA::I82094AA::serialize(std::ostream &os)
 }
 
 void
-X86ISA::I82094AA::unserialize(Checkpoint *cp, const std::string &section)
+X86ISA::I82094AA::unserialize(CheckpointIn &cp)
 {
     uint64_t redirTableArray[TableSize];
     UNSERIALIZE_SCALAR(regSel);
index 4fe927ae4157aae434ac34b84629567a5342c582..afa597e659dbc6d5b5a30a766f8c5db8f36b7e34 100644 (file)
@@ -109,8 +109,8 @@ class I82094AA : public BasicPioDevice, public IntDevice
     void raiseInterruptPin(int number);
     void lowerInterruptPin(int number);
 
-    virtual void serialize(std::ostream &os);
-    virtual void unserialize(Checkpoint *cp, const std::string &section);
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 };
 
 } // namespace X86ISA
index a43c1ec91ab856ecd053ab4b1a3d5e0aa2ac021a..b16f78883c6dda1dd4a0773b07d4df51ad1f9408 100644 (file)
@@ -126,13 +126,13 @@ X86ISA::I8237::write(PacketPtr pkt)
 }
 
 void
-X86ISA::I8237::serialize(std::ostream &os)
+X86ISA::I8237::serialize(CheckpointOut &cp) const
 {
     SERIALIZE_SCALAR(maskReg);
 }
 
 void
-X86ISA::I8237::unserialize(Checkpoint *cp, const std::string &section)
+X86ISA::I8237::unserialize(CheckpointIn &cp)
 {
     UNSERIALIZE_SCALAR(maskReg);
 }
index b1b11091bb878396c73a636c7860a9fb6470754f..481983b8e571b6dd0265771dc3fe30e697e87819 100644 (file)
@@ -59,8 +59,8 @@ class I8237 : public BasicPioDevice
 
     Tick write(PacketPtr pkt);
 
-    virtual void serialize(std::ostream &os);
-    virtual void unserialize(Checkpoint *cp, const std::string &section);
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 };
 
 } // namespace X86ISA
index b80952237492d208114afbc666a8d8b041b98c8e..f784a0107264dbbed31d8bd6b2805c2a20c72afa 100644 (file)
@@ -78,15 +78,15 @@ X86ISA::I8254::write(PacketPtr pkt)
 }
 
 void
-X86ISA::I8254::serialize(std::ostream &os)
+X86ISA::I8254::serialize(CheckpointOut &cp) const
 {
-    pit.serialize("pit", os);
+    pit.serialize("pit", cp);
 }
 
 void
-X86ISA::I8254::unserialize(Checkpoint *cp, const std::string &section)
+X86ISA::I8254::unserialize(CheckpointIn &cp)
 {
-    pit.unserialize("pit", cp, section);
+    pit.unserialize("pit", cp);
 }
 
 void
index 76521e73ed6b6abd248fa41c4ab2752614e45a1a..c4f04bd4222d8ba1a87596daf84237283e19490a 100644 (file)
@@ -109,8 +109,9 @@ class I8254 : public BasicPioDevice
         pit.writeControl(val);
     }
 
-    virtual void serialize(std::ostream &os);
-    virtual void unserialize(Checkpoint *cp, const std::string &section);
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
+
     virtual void startup();
 
 };
index d599ecef3534661320d338ecc2fa60531ec1ba6f..84f2d1321c4679e4257c976f54cbf44f7a85f6a6 100644 (file)
@@ -305,7 +305,7 @@ X86ISA::I8259::getVector()
 }
 
 void
-X86ISA::I8259::serialize(std::ostream &os)
+X86ISA::I8259::serialize(CheckpointOut &cp) const
 {
     SERIALIZE_ARRAY(pinStates, NumLines);
     SERIALIZE_ENUM(mode);
@@ -323,7 +323,7 @@ X86ISA::I8259::serialize(std::ostream &os)
 }
 
 void
-X86ISA::I8259::unserialize(Checkpoint *cp, const std::string &section)
+X86ISA::I8259::unserialize(CheckpointIn &cp)
 {
     UNSERIALIZE_ARRAY(pinStates, NumLines);
     UNSERIALIZE_ENUM(mode);
index 2d6080cc3ae91a56e0f573a4da137d5d1fe601bd..567ad7a32b217686ea6eb9f4a746cd4634146801 100644 (file)
@@ -109,8 +109,8 @@ class I8259 : public BasicPioDevice, public IntDevice
     void lowerInterruptPin(int number);
     int getVector();
 
-    virtual void serialize(std::ostream &os);
-    virtual void unserialize(Checkpoint *cp, const std::string &section);
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 };
 
 } // namespace X86ISA
index 70f52dd1ab0e487eb8fab6ab8738125cb728a937..2358608150e118173e3e1956046883dcfe4bbb8b 100644 (file)
@@ -74,14 +74,14 @@ X86ISA::Speaker::write(PacketPtr pkt)
 }
 
 void
-X86ISA::Speaker::serialize(std::ostream &os)
+X86ISA::Speaker::serialize(CheckpointOut &cp) const
 {
     uint8_t controlValData = controlVal.__data;
     SERIALIZE_SCALAR(controlValData);
 }
 
 void
-X86ISA::Speaker::unserialize(Checkpoint *cp, const std::string &section)
+X86ISA::Speaker::unserialize(CheckpointIn &cp)
 {
     uint8_t controlValData;
     UNSERIALIZE_SCALAR(controlValData);
index 22fc03e1c1ef460eb10957eec3c1f0cec943c01d..3c879060f24222b82ac6ee32c613c807f2893b7f 100644 (file)
@@ -73,9 +73,8 @@ class Speaker : public BasicPioDevice
 
     Tick write(PacketPtr pkt);
 
-    virtual void serialize(std::ostream &os);
-    virtual void unserialize(Checkpoint *cp, const std::string &section);
-
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 };
 
 } // namespace X86ISA
index 96e219bd47d9d4e3d1f41d86824d96131987130b..f0f01074822e506e8234224d8a0af1d98e500040 100644 (file)
@@ -129,14 +129,14 @@ Statistics::swpipl(int ipl)
 }
 
 void
-Statistics::serialize(ostream &os)
+Statistics::serialize(CheckpointOut &cp) const
 {
     SERIALIZE_SCALAR(iplLast);
     SERIALIZE_SCALAR(iplLastTick);
 }
 
 void
-Statistics::unserialize(Checkpoint *cp, const string &section)
+Statistics::unserialize(CheckpointIn &cp)
 {
     UNSERIALIZE_SCALAR(iplLast);
     UNSERIALIZE_SCALAR(iplLastTick);
index 0c8ed248aebda703da7e125486a59a4a51574932..8cc1ca84efab9c17a4d2eb5d0733eb0bbfe57caf 100644 (file)
@@ -80,8 +80,8 @@ class Statistics : public Serializable
     void swpipl(int ipl);
 
   public:
-    virtual void serialize(std::ostream &os);
-    virtual void unserialize(Checkpoint *cp, const std::string &section);
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 };
 
 } // namespace Kernel
index 4c70d3a4040436812c05af586b602663249d0e87..27d4b9ee1cd0653ab327f01b4ea41144b6682456 100644 (file)
@@ -429,8 +429,8 @@ class Cache : public BaseCache
     /** serialize the state of the caches
      * We currently don't support checkpointing cache state, so this panics.
      */
-    virtual void serialize(std::ostream &os);
-    void unserialize(Checkpoint *cp, const std::string &section);
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 };
 
 /**
index 94a3ad4ee16845fe682e54ac7450eb5eb4891f57..03593554a53100a73962d09925c956289bb82b1d 100644 (file)
@@ -2292,7 +2292,7 @@ Cache::nextMSHRReadyTime() const
 }
 
 void
-Cache::serialize(std::ostream &os)
+Cache::serialize(CheckpointOut &cp) const
 {
     bool dirty(isDirty());
 
@@ -2312,7 +2312,7 @@ Cache::serialize(std::ostream &os)
 }
 
 void
-Cache::unserialize(Checkpoint *cp, const std::string &section)
+Cache::unserialize(CheckpointIn &cp)
 {
     bool bad_checkpoint;
     UNSERIALIZE_SCALAR(bad_checkpoint);
index 232121c21141f835ea0951e6ccac8ce59e75bc82..f622bbbed07a70d722b8210128613c9630a72e51 100644 (file)
@@ -153,7 +153,7 @@ public:
     void unmap(Addr vaddr, int64_t size);
     bool isUnmapped(Addr vaddr, int64_t size);
     bool lookup(Addr vaddr, TheISA::TlbEntry &entry);
-    void serialize(std::ostream &os);
-    void unserialize(Checkpoint *cp, const std::string &section);
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 };
 #endif // __MEM_MULTI_LEVEL_PAGE_TABLE_HH__
index 6714a170e4c404183f8ba3bd09a67558f264eac2..6102405629a86ad00b56c323a6c71928e2a562d3 100644 (file)
@@ -314,19 +314,18 @@ MultiLevelPageTable<ISAOps>::lookup(Addr vaddr, TlbEntry &entry)
 
 template <class ISAOps>
 void
-MultiLevelPageTable<ISAOps>::serialize(std::ostream &os)
+MultiLevelPageTable<ISAOps>::serialize(CheckpointOut &cp) const
 {
     /** Since, the page table is stored in system memory
      * which is serialized separately, we will serialize
      * just the base pointer
      */
-    paramOut(os, "ptable.pointer", basePtr);
+    paramOut(cp, "ptable.pointer", basePtr);
 }
 
 template <class ISAOps>
 void
-MultiLevelPageTable<ISAOps>::unserialize(Checkpoint *cp,
-                                         const std::string &section)
+MultiLevelPageTable<ISAOps>::unserialize(CheckpointIn &cp)
 {
-    paramIn(cp, section, "ptable.pointer", basePtr);
+    paramIn(cp, "ptable.pointer", basePtr);
 }
index d3af09e1e5ede68010f53889b0bd6614c7fc07e5..6875d6f9b5a22ee52db3869a98cd9bff2be15787 100644 (file)
@@ -37,6 +37,7 @@
  */
 #include <fstream>
 #include <map>
+#include <memory>
 #include <string>
 
 #include "base/bitfield.hh"
@@ -196,44 +197,37 @@ PageTableBase::translate(RequestPtr req)
 }
 
 void
-FuncPageTable::serialize(std::ostream &os)
+FuncPageTable::serialize(CheckpointOut &cp) const
 {
-    paramOut(os, "ptable.size", pTable.size());
+    paramOut(cp, "ptable.size", pTable.size());
 
     PTable::size_type count = 0;
+    for (auto &pte : pTable) {
+        ScopedCheckpointSection sec(cp, csprintf("Entry%d", count++));
 
-    PTableItr iter = pTable.begin();
-    PTableItr end = pTable.end();
-    while (iter != end) {
-        os << "\n[" << csprintf("%s.Entry%d", name(), count) << "]\n";
-
-        paramOut(os, "vaddr", iter->first);
-        iter->second.serialize(os);
-
-        ++iter;
-        ++count;
+        paramOut(cp, "vaddr", pte.first);
+        pte.second.serialize(cp);
     }
     assert(count == pTable.size());
 }
 
 void
-FuncPageTable::unserialize(Checkpoint *cp, const std::string &section)
+FuncPageTable::unserialize(CheckpointIn &cp)
 {
-    int i = 0, count;
-    paramIn(cp, section, "ptable.size", count);
+    int count;
+    paramIn(cp, "ptable.size", count);
 
-    pTable.clear();
+    for (int i = 0; i < count; ++i) {
+        ScopedCheckpointSection sec(cp, csprintf("Entry%d", i));
 
-    while (i < count) {
-        TheISA::TlbEntry *entry;
+        std::unique_ptr<TheISA::TlbEntry> entry;
         Addr vaddr;
 
-        paramIn(cp, csprintf("%s.Entry%d", name(), i), "vaddr", vaddr);
-        entry = new TheISA::TlbEntry();
-        entry->unserialize(cp, csprintf("%s.Entry%d", name(), i));
+        paramIn(cp, "vaddr", vaddr);
+        entry.reset(new TheISA::TlbEntry());
+        entry->unserialize(cp);
+
         pTable[vaddr] = *entry;
-        delete entry;
-        ++i;
     }
 }
 
index 22b5c61eb3dd079385985d2a8ae4bf65060e766e..ddec104a773f97b1573ce091fb49b8c3a0798c02 100644 (file)
@@ -53,7 +53,7 @@ class ThreadContext;
 /**
  * Declaration of base class for page table
  */
-class PageTableBase
+class PageTableBase : public Serializable
 {
   protected:
     struct cacheElement {
@@ -192,10 +192,6 @@ class PageTableBase
             pTableCache[2].valid = false;
         }
     }
-
-    virtual void serialize(std::ostream &os) = 0;
-
-    virtual void unserialize(Checkpoint *cp, const std::string &section) = 0;
 };
 
 /**
@@ -239,9 +235,8 @@ class FuncPageTable : public PageTableBase
      */
     bool lookup(Addr vaddr, TheISA::TlbEntry &entry);
 
-    void serialize(std::ostream &os);
-
-    void unserialize(Checkpoint *cp, const std::string &section);
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 };
 
 /**
index e6d68262498e45c66b4210a32c1489fd06bc7bde..d757b8c5d2b820595eea78131d719986cee8ec63 100644 (file)
@@ -289,7 +289,7 @@ PhysicalMemory::functionalAccess(PacketPtr pkt)
 }
 
 void
-PhysicalMemory::serialize(ostream& os)
+PhysicalMemory::serialize(CheckpointOut &cp) const
 {
     // serialize all the locked addresses and their context ids
     vector<Addr> lal_addr;
@@ -303,8 +303,8 @@ PhysicalMemory::serialize(ostream& os)
         }
     }
 
-    arrayParamOut(os, "lal_addr", lal_addr);
-    arrayParamOut(os, "lal_cid", lal_cid);
+    SERIALIZE_CONTAINER(lal_addr);
+    SERIALIZE_CONTAINER(lal_cid);
 
     // serialize the backing stores
     unsigned int nbr_of_stores = backingStore.size();
@@ -313,14 +313,14 @@ PhysicalMemory::serialize(ostream& os)
     unsigned int store_id = 0;
     // store each backing store memory segment in a file
     for (auto& s : backingStore) {
-        nameOut(os, csprintf("%s.store%d", name(), store_id));
-        serializeStore(os, store_id++, s.first, s.second);
+        ScopedCheckpointSection sec(cp, csprintf("store%d", store_id));
+        serializeStore(cp, store_id++, s.first, s.second);
     }
 }
 
 void
-PhysicalMemory::serializeStore(ostream& os, unsigned int store_id,
-                               AddrRange range, uint8_t* pmem)
+PhysicalMemory::serializeStore(CheckpointOut &cp, unsigned int store_id,
+                               AddrRange range, uint8_t* pmem) const
 {
     // we cannot use the address range for the name as the
     // memories that are not part of the address map can overlap
@@ -335,7 +335,7 @@ PhysicalMemory::serializeStore(ostream& os, unsigned int store_id,
     SERIALIZE_SCALAR(range_size);
 
     // write memory file
-    string filepath = Checkpoint::dir() + "/" + filename.c_str();
+    string filepath = CheckpointIn::dir() + "/" + filename.c_str();
     gzFile compressed_mem = gzopen(filepath.c_str(), "wb");
     if (compressed_mem == NULL)
         fatal("Can't open physical memory checkpoint file '%s'\n",
@@ -365,14 +365,14 @@ PhysicalMemory::serializeStore(ostream& os, unsigned int store_id,
 }
 
 void
-PhysicalMemory::unserialize(Checkpoint* cp, const string& section)
+PhysicalMemory::unserialize(CheckpointIn &cp)
 {
     // unserialize the locked addresses and map them to the
     // appropriate memory controller
     vector<Addr> lal_addr;
     vector<int> lal_cid;
-    arrayParamIn(cp, section, "lal_addr", lal_addr);
-    arrayParamIn(cp, section, "lal_cid", lal_cid);
+    UNSERIALIZE_CONTAINER(lal_addr);
+    UNSERIALIZE_CONTAINER(lal_cid);
     for(size_t i = 0; i < lal_addr.size(); ++i) {
         const auto& m = addrMap.find(lal_addr[i]);
         m->second->addLockedAddr(LockedAddr(lal_addr[i], lal_cid[i]));
@@ -383,13 +383,14 @@ PhysicalMemory::unserialize(Checkpoint* cp, const string& section)
     UNSERIALIZE_SCALAR(nbr_of_stores);
 
     for (unsigned int i = 0; i < nbr_of_stores; ++i) {
-        unserializeStore(cp, csprintf("%s.store%d", section, i));
+        ScopedCheckpointSection sec(cp, csprintf("store%d", i));
+        unserializeStore(cp);
     }
 
 }
 
 void
-PhysicalMemory::unserializeStore(Checkpoint* cp, const string& section)
+PhysicalMemory::unserializeStore(CheckpointIn &cp)
 {
     const uint32_t chunk_size = 16384;
 
@@ -398,7 +399,7 @@ PhysicalMemory::unserializeStore(Checkpoint* cp, const string& section)
 
     string filename;
     UNSERIALIZE_SCALAR(filename);
-    string filepath = cp->cptDir + "/" + filename;
+    string filepath = cp.cptDir + "/" + filename;
 
     // mmap memoryfile
     gzFile compressed_mem = gzopen(filepath.c_str(), "rb");
index 0f53b1d9d264019bf04fe658197097a68fad105c..c577cd3eaccc8a4bb909cdb63cfdab9fde608602 100644 (file)
@@ -197,7 +197,7 @@ class PhysicalMemory : public Serializable
      *
      * @param os stream to serialize to
      */
-    void serialize(std::ostream& os);
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
 
     /**
      * Serialize a specific store.
@@ -206,20 +206,20 @@ class PhysicalMemory : public Serializable
      * @param range The address range of this backing store
      * @param pmem The host pointer to this backing store
      */
-    void serializeStore(std::ostream& os, unsigned int store_id,
-                        AddrRange range, uint8_t* pmem);
+    void serializeStore(CheckpointOut &cp, unsigned int store_id,
+                        AddrRange range, uint8_t* pmem) const;
 
     /**
      * Unserialize the memories in the system. As with the
      * serialization, this action is independent of how the address
      * ranges are mapped to logical memories in the guest system.
      */
-    void unserialize(Checkpoint* cp, const std::string& section);
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 
     /**
      * Unserialize a specific backing store, identified by a section.
      */
-    void unserializeStore(Checkpoint* cp, const std::string& section);
+    void unserializeStore(CheckpointIn &cp);
 
 };
 
index 75ebc8caf545321f7ad9ce8bf9d8558a57bde3e2..9d63643cc221cd0d8c620f8d05dc64a757a6fb31 100644 (file)
@@ -109,7 +109,7 @@ RubySystem::writeCompressedTrace(uint8_t *raw_data, string filename,
                                  uint64 uncompressed_trace_size)
 {
     // Create the checkpoint file for the memory
-    string thefile = Checkpoint::dir() + "/" + filename.c_str();
+    string thefile = CheckpointIn::dir() + "/" + filename.c_str();
 
     int fd = creat(thefile.c_str(), 0664);
     if (fd < 0) {
@@ -134,7 +134,7 @@ RubySystem::writeCompressedTrace(uint8_t *raw_data, string filename,
 }
 
 void
-RubySystem::serialize(std::ostream &os)
+RubySystem::serializeOld(CheckpointOut &cp)
 {
     m_cooldown_enabled = true;
     vector<Sequencer*> sequencer_map;
@@ -234,7 +234,7 @@ RubySystem::readCompressedTrace(string filename, uint8_t *&raw_data,
 }
 
 void
-RubySystem::unserialize(Checkpoint *cp, const string &section)
+RubySystem::unserialize(CheckpointIn &cp)
 {
     uint8_t *uncompressed_trace = NULL;
 
@@ -249,7 +249,7 @@ RubySystem::unserialize(Checkpoint *cp, const string &section)
 
     UNSERIALIZE_SCALAR(cache_trace_file);
     UNSERIALIZE_SCALAR(cache_trace_size);
-    cache_trace_file = cp->cptDir + "/" + cache_trace_file;
+    cache_trace_file = cp.cptDir + "/" + cache_trace_file;
 
     readCompressedTrace(cache_trace_file, uncompressed_trace,
                         cache_trace_size);
index 45e8aa8b4bce998a848b5fab1ab77cb41b9ea447..a59ade39893bdb84f6abaaa2dfb9ce409c73b157 100644 (file)
@@ -92,8 +92,8 @@ class RubySystem : public ClockedObject
     void collateStats() { m_profiler->collateStats(); }
     void resetStats();
 
-    void serialize(std::ostream &os);
-    void unserialize(Checkpoint *cp, const std::string &section);
+    void serializeOld(CheckpointOut &cp) M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
     void process();
     void startup();
     bool functionalRead(Packet *ptr);
index 240b449dfa1f168f2c23915a6e4ed6a099d500f7..4a509e57dcc34bd9cf87de5fa69b5345c57001af 100644 (file)
@@ -920,7 +920,7 @@ class SimObject(object):
     def export_methods(cls, code):
         code('''
     void init();
-    void loadState(Checkpoint *cp);
+    void loadState(CheckpointIn &cp);
     void initState();
     void regStats();
     void resetStats();
index ed520e17a5ce52bbea2fd6e9b495e91812ba2a12..862c0e37e469bce296b9077c20202f8e7c32327c 100644 (file)
@@ -86,8 +86,8 @@ Tick curTick();
 class Checkpoint;
 
 void serializeAll(const std::string &cpt_dir);
-Checkpoint *getCheckpoint(const std::string &cpt_dir);
-void unserializeGlobals(Checkpoint *cp);
+CheckpointIn *getCheckpoint(const std::string &cpt_dir);
+void unserializeGlobals(CheckpointIn &cp);
 
 bool want_warn, warn_verbose;
 bool want_info, info_verbose;
index 08b9ee69f8be1d6ab1589d2f55d0ed77fa37f74c..f90e456e2a73847f9325eb54db5a45146801266f 100644 (file)
@@ -192,8 +192,8 @@ PythonSimObjectResolver::resolveSimObject(const string &name)
     return obj;
 }
 
-Checkpoint *
+CheckpointIn *
 getCheckpoint(const std::string &cpt_dir)
 {
-    return new Checkpoint(cpt_dir, pythonSimObjectResolver);
+    return new CheckpointIn(cpt_dir, pythonSimObjectResolver);
 }
index a4f06555e902db4affe8eeec6b9b3b396c517296..ea2948826d35e181454dc9815b7d5069a42dc21f 100644 (file)
@@ -58,11 +58,11 @@ serializeAll(const std::string &cpt_dir)
     Serializable::serializeAll(cpt_dir);
 }
 
-Checkpoint *
+CheckpointIn *
 getCheckpoint(const std::string &cpt_dir);
 
 inline void
-unserializeGlobals(Checkpoint *cp)
+unserializeGlobals(CheckpointIn &cp)
 {
     Serializable::unserializeGlobals(cp);
 }
index 8f45bba0930138397a24c0b7665c56c39f16dae0..60c688b1a0a5ab2a28ea53e097d08186246aac5c 100644 (file)
@@ -156,16 +156,16 @@ SrcClockDomain::perfLevel(PerfLevel perf_level)
 }
 
 void
-SrcClockDomain::serialize(std::ostream &os)
+SrcClockDomain::serialize(CheckpointOut &cp) const
 {
     SERIALIZE_SCALAR(_perfLevel);
-    ClockDomain::serialize(os);
+    ClockDomain::serialize(cp);
 }
 
 void
-SrcClockDomain::unserialize(Checkpoint *cp, const std::string &section)
+SrcClockDomain::unserialize(CheckpointIn &cp)
 {
-    ClockDomain::unserialize(cp, section);
+    ClockDomain::unserialize(cp);
     UNSERIALIZE_SCALAR(_perfLevel);
 }
 
index edf2340ad013df431866197d49b96fbe297ffca9..c4242af55fde0ef4d102d942d6af64ad478ac505 100644 (file)
@@ -238,8 +238,9 @@ class SrcClockDomain : public ClockDomain
     }
 
     void startup();
-    void serialize(std::ostream &os);
-    void unserialize(Checkpoint *cp, const std::string &section);
+
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 
   private:
     /**
index 7f6a033985ec592029207d93b0448bb106164c21..6d4565dbcedd19b1b80596bc3eb3df3f047a8263 100644 (file)
@@ -671,7 +671,7 @@ CxxConfigManager::serialize(std::ostream &os)
 }
 
 void
-CxxConfigManager::loadState(Checkpoint *checkpoint)
+CxxConfigManager::loadState(CheckpointIn &checkpoint)
 {
     for (auto i = objectsInOrder.begin(); i != objectsInOrder.end(); ++ i)
         (*i)->loadState(checkpoint);
index caa115f037f60dce8c2d3893d4481fa244beb712..b2ba312146d7b028fd4bceccc5c7bf610737dd5b 100644 (file)
@@ -61,7 +61,7 @@
 #include "base/cprintf.hh"
 #include "sim/cxx_config.hh"
 
-class Checkpoint;
+class CheckpointIn;
 
 /** This class allows a config file to be read into gem5 (generating the
  *  appropriate SimObjects) from C++ */
@@ -292,7 +292,7 @@ class CxxConfigManager
     void serialize(std::ostream &os);
 
     /** Load all objects' state from the given Checkpoint */
-    void loadState(Checkpoint *checkpoint);
+    void loadState(CheckpointIn &checkpoint);
 
     /** Delete all objects and clear objectsByName and objectsByOrder */
     void deleteObjects();
index f4fe760a2d7944c0c21b9eee1d11632ac47f1070..f507897b30198484e8e7d19145cce5652ad840a2 100644 (file)
@@ -170,7 +170,7 @@ DVFSHandler::UpdateEvent::updatePerfLevel()
 }
 
 void
-DVFSHandler::serialize(std::ostream &os)
+DVFSHandler::serialize(CheckpointOut &cp) const
 {
     //This is to ensure that the handler status is maintained during the
     //entire simulation run and not changed from command line during checkpoint
@@ -182,23 +182,22 @@ DVFSHandler::serialize(std::ostream &os)
     std::vector<DomainID> domain_ids;
     std::vector<PerfLevel> perf_levels;
     std::vector<Tick> whens;
-    for (auto it = updatePerfLevelEvents.begin();
-         it != updatePerfLevelEvents.end(); ++it) {
-        DomainID id = it->first;
-        UpdateEvent *event = &it->second;
+    for (const auto &ev_pair : updatePerfLevelEvents) {
+        DomainID id = ev_pair.first;
+        const UpdateEvent *event = &ev_pair.second;
 
         assert(id == event->domainIDToSet);
         domain_ids.push_back(id);
         perf_levels.push_back(event->perfLevelToSet);
         whens.push_back(event->scheduled() ? event->when() : 0);
     }
-    arrayParamOut(os, "domain_ids", domain_ids);
-    arrayParamOut(os, "perf_levels", perf_levels);
-    arrayParamOut(os, "whens", whens);
+    SERIALIZE_CONTAINER(domain_ids);
+    SERIALIZE_CONTAINER(perf_levels);
+    SERIALIZE_CONTAINER(whens);
 }
 
 void
-DVFSHandler::unserialize(Checkpoint *cp, const std::string &section)
+DVFSHandler::unserialize(CheckpointIn &cp)
 {
     bool temp = enableHandler;
 
@@ -213,9 +212,9 @@ DVFSHandler::unserialize(Checkpoint *cp, const std::string &section)
     std::vector<DomainID> domain_ids;
     std::vector<PerfLevel> perf_levels;
     std::vector<Tick> whens;
-    arrayParamIn(cp, section, "domain_ids", domain_ids);
-    arrayParamIn(cp, section, "perf_levels", perf_levels);
-    arrayParamIn(cp, section, "whens", whens);
+    UNSERIALIZE_CONTAINER(domain_ids);
+    UNSERIALIZE_CONTAINER(perf_levels);
+    UNSERIALIZE_CONTAINER(whens);
 
     for (size_t i = 0; i < domain_ids.size(); ++i) {;
         UpdateEvent *event = &updatePerfLevelEvents[domain_ids[i]];
index a8b78d08b6d82e5f76af8329ae447ab11778cd90..6e495fff5c36b21a9a39b53dc1390d3ed77461d1 100644 (file)
@@ -198,8 +198,8 @@ class DVFSHandler : public SimObject
      */
     bool isEnabled() const { return enableHandler; }
 
-    void serialize(std::ostream &os);
-    void unserialize(Checkpoint *cp, const std::string &section);
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 
   private:
     typedef std::map<DomainID, SrcClockDomain*> Domains;
index 4fde796564df352669eecaa38180ef94e21e2450..f75ada47cdbb9cbad73ecda441a404cfa15193f1 100644 (file)
@@ -242,7 +242,7 @@ EventQueue::serviceOne()
 }
 
 void
-Event::serialize(std::ostream &os)
+Event::serialize(CheckpointOut &cp) const
 {
     SERIALIZE_SCALAR(_when);
     SERIALIZE_SCALAR(_priority);
@@ -251,12 +251,12 @@ Event::serialize(std::ostream &os)
 }
 
 void
-Event::unserialize(Checkpoint *cp, const string &section)
+Event::unserialize(CheckpointIn &cp)
 {
 }
 
 void
-Event::unserialize(Checkpoint *cp, const string &section, EventQueue *eventq)
+Event::unserializeEvent(CheckpointIn &cp, EventQueue *eventq)
 {
     if (scheduled())
         eventq->deschedule(this);
@@ -290,7 +290,7 @@ Event::unserialize(Checkpoint *cp, const string &section, EventQueue *eventq)
 }
 
 void
-EventQueue::serialize(ostream &os)
+EventQueue::serialize(CheckpointOut &cp) const
 {
     std::list<Event *> eventPtrs;
 
@@ -302,7 +302,7 @@ EventQueue::serialize(ostream &os)
         while (nextInBin) {
             if (nextInBin->flags.isSet(Event::AutoSerialize)) {
                 eventPtrs.push_back(nextInBin);
-                paramOut(os, csprintf("event%d", numEvents++),
+                paramOut(cp, csprintf("event%d", numEvents++),
                          nextInBin->name());
             }
             nextInBin = nextInBin->nextInBin;
@@ -313,15 +313,12 @@ EventQueue::serialize(ostream &os)
 
     SERIALIZE_SCALAR(numEvents);
 
-    for (std::list<Event *>::iterator it = eventPtrs.begin();
-         it != eventPtrs.end(); ++it) {
-        (*it)->nameOut(os);
-        (*it)->serialize(os);
-    }
+    for (Event *ev : eventPtrs)
+        ev->serializeSection(cp, ev->name());
 }
 
 void
-EventQueue::unserialize(Checkpoint *cp, const std::string &section)
+EventQueue::unserialize(CheckpointIn &cp)
 {
     int numEvents;
     UNSERIALIZE_SCALAR(numEvents);
@@ -329,7 +326,7 @@ EventQueue::unserialize(Checkpoint *cp, const std::string &section)
     std::string eventName;
     for (int i = 0; i < numEvents; i++) {
         // get the pointer value associated with the event
-        paramIn(cp, section, csprintf("event%d", i), eventName);
+        paramIn(cp, csprintf("event%d", i), eventName);
 
         // create the event based on its pointer value
         Serializable::create(cp, eventName);
index f726a6dbdc488e0c21dfb38023f8eb0f7d0c4b4f..b90e5d3827a68c056cf16e8a54dcea1f60aa91d8 100644 (file)
@@ -350,15 +350,14 @@ class Event : public EventBase, public Serializable
     virtual BaseGlobalEvent *globalEvent() { return NULL; }
 
 #ifndef SWIG
-    virtual void serialize(std::ostream &os);
-    virtual void unserialize(Checkpoint *cp, const std::string &section);
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 
     //! This function is required to support restoring from checkpoints
     //! when running with multiple queues. Since we still have not thrashed
     //! out all the details on checkpointing, this function is most likely
     //! to be revisited in future.
-    virtual void unserialize(Checkpoint *cp, const std::string &section,
-                     EventQueue *eventq);
+    virtual void unserializeEvent(CheckpointIn &cp, EventQueue *eventq);
 #endif
 };
 
@@ -647,8 +646,8 @@ class EventQueue : public Serializable
     /**@}*/
 
 #ifndef SWIG
-    virtual void serialize(std::ostream &os);
-    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
 
     virtual ~EventQueue() { }
index 35f981d1e52f8e0f112b91b2fbe0e1b1fe0a654d..a820b063296f47125d8fee46d681ec52da777156 100644 (file)
@@ -259,6 +259,13 @@ Process::initState()
     pTable->initState(tc);
 }
 
+unsigned int
+Process::drain(DrainManager *dm)
+{
+    find_file_offsets();
+    return 0;
+}
+
 // map simulator fd sim_fd to target fd tgt_fd
 void
 Process::dup_fd(int sim_fd, int tgt_fd)
@@ -488,7 +495,7 @@ Process::setReadPipeSource(int read_pipe_fd, int source_fd)
 }
 
 void
-Process::FdMap::serialize(std::ostream &os)
+Process::FdMap::serialize(CheckpointOut &cp) const
 {
     SERIALIZE_SCALAR(fd);
     SERIALIZE_SCALAR(isPipe);
@@ -499,7 +506,7 @@ Process::FdMap::serialize(std::ostream &os)
 }
 
 void
-Process::FdMap::unserialize(Checkpoint *cp, const std::string &section)
+Process::FdMap::unserialize(CheckpointIn &cp)
 {
     UNSERIALIZE_SCALAR(fd);
     UNSERIALIZE_SCALAR(isPipe);
@@ -510,7 +517,7 @@ Process::FdMap::unserialize(Checkpoint *cp, const std::string &section)
 }
 
 void
-Process::serialize(std::ostream &os)
+Process::serialize(CheckpointOut &cp) const
 {
     SERIALIZE_SCALAR(brk_point);
     SERIALIZE_SCALAR(stack_base);
@@ -521,18 +528,16 @@ Process::serialize(std::ostream &os)
     SERIALIZE_SCALAR(mmap_end);
     SERIALIZE_SCALAR(nxm_start);
     SERIALIZE_SCALAR(nxm_end);
-    find_file_offsets();
-    pTable->serialize(os);
+    pTable->serialize(cp);
     for (int x = 0; x <= MAX_FD; x++) {
-        nameOut(os, csprintf("%s.FdMap%d", name(), x));
-        fd_map[x].serialize(os);
+        fd_map[x].serializeSection(cp, csprintf("FdMap%d", x));
     }
     SERIALIZE_SCALAR(M5_pid);
 
 }
 
 void
-Process::unserialize(Checkpoint *cp, const std::string &section)
+Process::unserialize(CheckpointIn &cp)
 {
     UNSERIALIZE_SCALAR(brk_point);
     UNSERIALIZE_SCALAR(stack_base);
@@ -543,9 +548,9 @@ Process::unserialize(Checkpoint *cp, const std::string &section)
     UNSERIALIZE_SCALAR(mmap_end);
     UNSERIALIZE_SCALAR(nxm_start);
     UNSERIALIZE_SCALAR(nxm_end);
-    pTable->unserialize(cp, section);
+    pTable->unserialize(cp);
     for (int x = 0; x <= MAX_FD; x++) {
-        fd_map[x].unserialize(cp, csprintf("%s.FdMap%d", section, x));
+        fd_map[x].unserializeSection(cp, csprintf("FdMap%d", x));
     }
     fix_file_offsets();
     UNSERIALIZE_OPT_SCALAR(M5_pid);
index 04ce00f675a216582a3a6734ed488b9a79b4ccba..c1499ccf7f48d3795d5194520cbf048f22d423ce 100644 (file)
@@ -120,6 +120,8 @@ class Process : public SimObject
 
     virtual void initState();
 
+    unsigned int drain(DrainManager *dm) M5_ATTR_OVERRIDE;
+
   public:
 
     //This id is assigned by m5 and is used to keep process' tlb entries
@@ -133,7 +135,7 @@ class Process : public SimObject
 
     PageTableBase* pTable;
 
-    class FdMap
+    class FdMap : public Serializable
     {
       public:
         int fd;
@@ -150,8 +152,8 @@ class Process : public SimObject
               isPipe(false), readPipeSource(0), fileOffset(0), driver(NULL)
         { }
 
-        void serialize(std::ostream &os);
-        void unserialize(Checkpoint *cp, const std::string &section);
+        void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+        void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
     };
 
   protected:
@@ -233,8 +235,8 @@ class Process : public SimObject
      */
     bool map(Addr vaddr, Addr paddr, int size, bool cacheable = true);
 
-    void serialize(std::ostream &os);
-    void unserialize(Checkpoint *cp, const std::string &section);
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 };
 
 //
index 9bb8b4f05cba5fcf886869915fa71e3a3b3e5518..1d58c3bbe0f4e90583f5d3d135e04b8eb4fc2b53 100644 (file)
@@ -123,14 +123,14 @@ Root::initState()
 }
 
 void
-Root::loadState(Checkpoint *cp)
+Root::loadState(CheckpointIn &cp)
 {
     SimObject::loadState(cp);
     timeSyncEnable(params()->time_sync_enable);
 }
 
 void
-Root::serialize(std::ostream &os)
+Root::serialize(CheckpointOut &cp) const
 {
     uint64_t cpt_ver = gem5CheckpointVersion;
     SERIALIZE_SCALAR(cpt_ver);
@@ -140,7 +140,7 @@ Root::serialize(std::ostream &os)
 }
 
 void
-Root::unserialize(Checkpoint *cp, const std::string &section)
+Root::unserialize(CheckpointIn &cp)
 {
     uint64_t cpt_ver = 0;
     UNSERIALIZE_OPT_SCALAR(cpt_ver);
index 6a7b5dc938792f0c038b7fb6ecd0cf69adbd26be..1c330e2c47897ac4271e388810d276e987415f19 100644 (file)
@@ -106,15 +106,14 @@ class Root : public SimObject
 
     /** Schedule the timesync event at loadState() so that curTick is correct
      */
-    void loadState(Checkpoint *cp);
+    void loadState(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 
     /** Schedule the timesync event at initState() when not unserializing
      */
     void initState();
 
-    virtual void serialize(std::ostream &os);
-    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 // __SIM_ROOT_HH__
index 99426b5a6f93d85f5be3c2f3b827ee524a6a2d38..a7c1834cfd960087e3ea558daf7810f6f5c3400b 100644 (file)
@@ -1,4 +1,16 @@
 /*
+ * Copyright (c) 2015 ARM Limited
+ * All rights reserved
+ *
+ * The license below extends only to copyright in the software and shall
+ * not be construed as granting a license to any other intellectual
+ * property including but not limited to intellectual property relating
+ * to a hardware implementation of the functionality of the software
+ * licensed hereunder.  You may use the software subject to the license
+ * terms below provided that you ensure that this notice is replicated
+ * unmodified and in its entirety in all distributions of the software,
+ * modified or unmodified, in source code or in binary form.
+ *
  * Copyright (c) 2002-2005 The Regents of The University of Michigan
  * Copyright (c) 2013 Advanced Micro Devices, Inc.
  * Copyright (c) 2013 Mark D. Hill and David A. Wood
@@ -30,6 +42,7 @@
  * Authors: Nathan Binkert
  *          Erik Hallnor
  *          Steve Reinhardt
+ *          Andreas Sandberg
  */
 
 #include <sys/stat.h>
@@ -47,6 +60,7 @@
 #include "base/output.hh"
 #include "base/str.hh"
 #include "base/trace.hh"
+#include "debug/Checkpoint.hh"
 #include "sim/eventq.hh"
 #include "sim/serialize.hh"
 #include "sim/sim_events.hh"
@@ -71,7 +85,7 @@ parseParam(const string &s, T &value)
 
 template <class T>
 void
-showParam(ostream &os, const T &value)
+showParam(CheckpointOut &os, const T &value)
 {
     os << value;
 }
@@ -87,7 +101,7 @@ 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)
+showParam(CheckpointOut &os, const char &value)
 {
     os << (int)value;
 }
@@ -95,7 +109,7 @@ showParam(ostream &os, const char &value)
 
 template <>
 void
-showParam(ostream &os, const signed char &value)
+showParam(CheckpointOut &os, const signed char &value)
 {
     os << (int)value;
 }
@@ -103,7 +117,7 @@ showParam(ostream &os, const signed char &value)
 
 template <>
 void
-showParam(ostream &os, const unsigned char &value)
+showParam(CheckpointOut &os, const unsigned char &value)
 {
     os << (unsigned int)value;
 }
@@ -133,7 +147,7 @@ parseParam(const string &s, bool &value)
 // Display bools as strings
 template <>
 void
-showParam(ostream &os, const bool &value)
+showParam(CheckpointOut &os, const bool &value)
 {
     os << (value ? "true" : "false");
 }
@@ -151,22 +165,11 @@ parseParam(const string &s, string &value)
 int Serializable::ckptMaxCount = 0;
 int Serializable::ckptCount = 0;
 int Serializable::ckptPrevCount = -1;
-
-void
-Serializable::nameOut(ostream &os)
-{
-    os << "\n[" << name() << "]\n";
-}
-
-void
-Serializable::nameOut(ostream &os, const string &_name)
-{
-    os << "\n[" << _name << "]\n";
-}
+std::stack<std::string> Serializable::path;
 
 template <class T>
 void
-paramOut(ostream &os, const string &name, const T &param)
+paramOut(CheckpointOut &os, const string &name, const T &param)
 {
     os << name << "=";
     showParam(os, param);
@@ -175,7 +178,7 @@ paramOut(ostream &os, const string &name, const T &param)
 
 template <class T>
 void
-arrayParamOut(ostream &os, const string &name, const vector<T> &param)
+arrayParamOut(CheckpointOut &os, const string &name, const vector<T> &param)
 {
     typename vector<T>::size_type size = param.size();
     os << name << "=";
@@ -190,7 +193,7 @@ arrayParamOut(ostream &os, const string &name, const vector<T> &param)
 
 template <class T>
 void
-arrayParamOut(ostream &os, const string &name, const list<T> &param)
+arrayParamOut(CheckpointOut &os, const string &name, const list<T> &param)
 {
     typename list<T>::const_iterator it = param.begin();
 
@@ -208,20 +211,22 @@ arrayParamOut(ostream &os, const string &name, const list<T> &param)
 
 template <class T>
 void
-paramIn(Checkpoint *cp, const string &section, const string &name, T &param)
+paramIn(CheckpointIn &cp, const string &name, T &param)
 {
+    const string &section(Serializable::currentSection());
     string str;
-    if (!cp->find(section, name, str) || !parseParam(str, param)) {
+    if (!cp.find(section, name, str) || !parseParam(str, param)) {
         fatal("Can't unserialize '%s:%s'\n", section, name);
     }
 }
 
 template <class T>
 bool
-optParamIn(Checkpoint *cp, const string &section, const string &name, T &param)
+optParamIn(CheckpointIn &cp, const string &name, T &param)
 {
+    const string &section(Serializable::currentSection());
     string str;
-    if (!cp->find(section, name, str) || !parseParam(str, param)) {
+    if (!cp.find(section, name, str) || !parseParam(str, param)) {
         warn("optional parameter %s:%s not present\n", section, name);
         return false;
     } else {
@@ -231,7 +236,8 @@ optParamIn(Checkpoint *cp, const string &section, const string &name, T &param)
 
 template <class T>
 void
-arrayParamOut(ostream &os, const string &name, const T *param, unsigned size)
+arrayParamOut(CheckpointOut &os, const string &name,
+              const T *param, unsigned size)
 {
     os << name << "=";
     if (size > 0)
@@ -246,11 +252,11 @@ arrayParamOut(ostream &os, const string &name, const T *param, unsigned size)
 
 template <class T>
 void
-arrayParamIn(Checkpoint *cp, const string &section, const string &name,
-             T *param, unsigned size)
+arrayParamIn(CheckpointIn &cp, const string &name, T *param, unsigned size)
 {
+    const string &section(Serializable::currentSection());
     string str;
-    if (!cp->find(section, name, str)) {
+    if (!cp.find(section, name, str)) {
         fatal("Can't unserialize '%s:%s'\n", section, name);
     }
 
@@ -273,7 +279,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 = 0;
+        T scalar_value;
         if (!parseParam(tokens[i], scalar_value)) {
             string err("could not parse \"");
 
@@ -290,11 +296,11 @@ arrayParamIn(Checkpoint *cp, const string &section, const string &name,
 
 template <class T>
 void
-arrayParamIn(Checkpoint *cp, const string &section,
-             const string &name, vector<T> &param)
+arrayParamIn(CheckpointIn &cp, const string &name, vector<T> &param)
 {
+    const string &section(Serializable::currentSection());
     string str;
-    if (!cp->find(section, name, str)) {
+    if (!cp.find(section, name, str)) {
         fatal("Can't unserialize '%s:%s'\n", section, name);
     }
 
@@ -315,7 +321,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 = 0;
+        T scalar_value;
         if (!parseParam(tokens[i], scalar_value)) {
             string err("could not parse \"");
 
@@ -332,11 +338,11 @@ arrayParamIn(Checkpoint *cp, const string &section,
 
 template <class T>
 void
-arrayParamIn(Checkpoint *cp, const string &section,
-             const string &name, list<T> &param)
+arrayParamIn(CheckpointIn &cp, const string &name, list<T> &param)
 {
+    const string &section(Serializable::currentSection());
     string str;
-    if (!cp->find(section, name, str)) {
+    if (!cp.find(section, name, str)) {
         fatal("Can't unserialize '%s:%s'\n", section, name);
     }
     param.clear();
@@ -345,7 +351,7 @@ arrayParamIn(Checkpoint *cp, const string &section,
     tokenize(tokens, str, ' ');
 
     for (vector<string>::size_type i = 0; i < tokens.size(); i++) {
-        T scalar_value = 0;
+        T scalar_value;
         if (!parseParam(tokens[i], scalar_value)) {
             string err("could not parse \"");
 
@@ -362,42 +368,40 @@ arrayParamIn(Checkpoint *cp, const string &section,
 
 
 void
-objParamIn(Checkpoint *cp, const string &section,
-           const string &name, SimObject * &param)
+objParamIn(CheckpointIn &cp, const string &name, SimObject * &param)
 {
-    if (!cp->findObj(section, name, param)) {
+    const string &section(Serializable::currentSection());
+    if (!cp.findObj(section, name, param)) {
         fatal("Can't unserialize '%s:%s'\n", section, name);
     }
 }
 
 
 #define INSTANTIATE_PARAM_TEMPLATES(type)                               \
-template void                                                           \
-paramOut(ostream &os, const string &name, type const &param);           \
-template void                                                           \
-paramIn(Checkpoint *cp, const string &section,                          \
-        const string &name, type & param);                              \
-template bool                                                           \
-optParamIn(Checkpoint *cp, const string &section,                       \
-        const string &name, type & param);                              \
-template void                                                           \
-arrayParamOut(ostream &os, const string &name,                          \
-              type const *param, unsigned size);                        \
-template void                                                           \
-arrayParamIn(Checkpoint *cp, const string &section,                     \
-             const string &name, type *param, unsigned size);           \
-template void                                                           \
-arrayParamOut(ostream &os, const string &name,                          \
-              const vector<type> &param);                               \
-template void                                                           \
-arrayParamIn(Checkpoint *cp, const string &section,                     \
-             const string &name, vector<type> &param);                  \
-template void                                                           \
-arrayParamOut(ostream &os, const string &name,                          \
-              const list<type> &param);                                 \
-template void                                                           \
-arrayParamIn(Checkpoint *cp, const string &section,                     \
-             const string &name, list<type> &param);
+    template void                                                       \
+    paramOut(CheckpointOut &os, const string &name, type const &param); \
+    template void                                                       \
+    paramIn(CheckpointIn &cp, const string &name, type & param);        \
+    template bool                                                       \
+    optParamIn(CheckpointIn &cp, const string &name, type & param);     \
+    template void                                                       \
+    arrayParamOut(CheckpointOut &os, const string &name,                \
+                  type const *param, unsigned size);                    \
+    template void                                                       \
+    arrayParamIn(CheckpointIn &cp, const string &name,                  \
+                 type *param, unsigned size);                           \
+    template void                                                       \
+    arrayParamOut(CheckpointOut &os, const string &name,                \
+                  const vector<type> &param);                           \
+    template void                                                       \
+    arrayParamIn(CheckpointIn &cp, const string &name,                  \
+                 vector<type> &param);                                  \
+    template void                                                       \
+    arrayParamOut(CheckpointOut &os, const string &name,                \
+                  const list<type> &param);                             \
+    template void                                                       \
+    arrayParamIn(CheckpointIn &cp, const string &name,                  \
+                 list<type> &param);
 
 INSTANTIATE_PARAM_TEMPLATES(char)
 INSTANTIATE_PARAM_TEMPLATES(signed char)
@@ -423,45 +427,31 @@ INSTANTIATE_PARAM_TEMPLATES(string)
 class Globals : public Serializable
 {
   public:
-    const string name() const;
-    void serialize(ostream &os);
-    void unserialize(Checkpoint *cp, const std::string &section);
+    Globals()
+        : unserializedCurTick(0) {}
+
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
+
+    Tick unserializedCurTick;
 };
 
 /// The one and only instance of the Globals class.
 Globals globals;
 
-const string
-Globals::name() const
-{
-    return "Globals";
-}
-
 void
-Globals::serialize(ostream &os)
+Globals::serialize(CheckpointOut &cp) const
 {
-    nameOut(os);
-    paramOut(os, "curTick", curTick());
+    paramOut(cp, "curTick", curTick());
+    paramOut(cp, "numMainEventQueues", numMainEventQueues);
 
-    paramOut(os, "numMainEventQueues", numMainEventQueues);
-
-    for (uint32_t i = 0; i < numMainEventQueues; ++i) {
-        nameOut(os, "MainEventQueue");
-        mainEventQueue[i]->serialize(os);
-    }
 }
 
 void
-Globals::unserialize(Checkpoint *cp, const std::string &section)
+Globals::unserialize(CheckpointIn &cp)
 {
-    Tick tick;
-    paramIn(cp, section, "curTick", tick);
-    paramIn(cp, section, "numMainEventQueues", numMainEventQueues);
-
-    for (uint32_t i = 0; i < numMainEventQueues; ++i) {
-        mainEventQueue[i]->setCurTick(tick);
-        mainEventQueue[i]->unserialize(cp, "MainEventQueue");
-    }
+    paramIn(cp, "curTick", unserializedCurTick);
+    paramIn(cp, "numMainEventQueues", numMainEventQueues);
 }
 
 Serializable::Serializable()
@@ -473,37 +463,82 @@ Serializable::~Serializable()
 }
 
 void
-Serializable::serialize(ostream &os)
+Serializable::serializeSection(CheckpointOut &cp, const char *name) const
 {
+    Serializable::ScopedCheckpointSection sec(cp, name);
+    serialize(cp);
 }
 
 void
-Serializable::unserialize(Checkpoint *cp, const string &section)
+Serializable::serializeSectionOld(CheckpointOut &cp, const char *name)
 {
+    Serializable::ScopedCheckpointSection sec(cp, name);
+    serializeOld(cp);
+}
+
+void
+Serializable::unserializeSection(CheckpointIn &cp, const char *name)
+{
+    Serializable::ScopedCheckpointSection sec(cp, name);
+    unserialize(cp);
 }
 
 void
 Serializable::serializeAll(const string &cpt_dir)
 {
-    string dir = Checkpoint::setDir(cpt_dir);
+    string dir = CheckpointIn::setDir(cpt_dir);
     if (mkdir(dir.c_str(), 0775) == -1 && errno != EEXIST)
             fatal("couldn't mkdir %s\n", dir);
 
-    string cpt_file = dir + Checkpoint::baseFilename;
+    string cpt_file = dir + CheckpointIn::baseFilename;
     ofstream outstream(cpt_file.c_str());
     time_t t = time(NULL);
     if (!outstream.is_open())
         fatal("Unable to open file %s for writing\n", cpt_file.c_str());
     outstream << "## checkpoint generated: " << ctime(&t);
 
-    globals.serialize(outstream);
+    globals.serializeSection(outstream, "Globals");
+    for (uint32_t i = 0; i < numMainEventQueues; ++i)
+        mainEventQueue[i]->serializeSection(outstream, "MainEventQueue");
+
     SimObject::serializeAll(outstream);
 }
 
 void
-Serializable::unserializeGlobals(Checkpoint *cp)
+Serializable::unserializeGlobals(CheckpointIn &cp)
+{
+    globals.unserializeSection(cp, "Globals");
+
+    for (uint32_t i = 0; i < numMainEventQueues; ++i) {
+        mainEventQueue[i]->setCurTick(globals.unserializedCurTick);
+        mainEventQueue[i]->unserializeSection(cp, "MainEventQueue");
+    }
+}
+
+Serializable::ScopedCheckpointSection::~ScopedCheckpointSection()
+{
+    assert(!path.empty());
+    DPRINTF(Checkpoint, "Popping: %s\n", path.top());
+    path.pop();
+}
+
+void
+Serializable::ScopedCheckpointSection::pushName(const char *obj_name)
 {
-  globals.unserialize(cp, globals.name());
+    if (path.empty()) {
+        path.push(obj_name);
+    } else {
+        path.push(csprintf("%s.%s", path.top(), obj_name));
+    }
+    DPRINTF(Checkpoint, "ScopedCheckpointSection::pushName: %s\n", obj_name);
+}
+
+void
+Serializable::ScopedCheckpointSection::nameOut(CheckpointOut &cp)
+{
+    DPRINTF(Checkpoint, "ScopedCheckpointSection::nameOut: %s\n",
+            Serializable::currentSection());
+    cp << "\n[" << Serializable::currentSection() << "]\n";
 }
 
 void
@@ -542,11 +577,11 @@ SerializableClass::SerializableClass(const string &className,
 //
 //
 Serializable *
-SerializableClass::createObject(Checkpoint *cp, const string &section)
+SerializableClass::createObject(CheckpointIn &cp, const string &section)
 {
     string className;
 
-    if (!cp->find(section, "type", className)) {
+    if (!cp.find(section, "type", className)) {
         fatal("Serializable::create: no 'type' entry in section '%s'.\n",
               section);
     }
@@ -565,22 +600,29 @@ SerializableClass::createObject(Checkpoint *cp, const string &section)
     return object;
 }
 
+const std::string &
+Serializable::currentSection()
+{
+    assert(!path.empty());
+
+    return path.top();
+}
 
 Serializable *
-Serializable::create(Checkpoint *cp, const string &section)
+Serializable::create(CheckpointIn &cp, const string &section)
 {
     Serializable *object = SerializableClass::createObject(cp, section);
-    object->unserialize(cp, section);
+    object->unserializeSection(cp, section);
     return object;
 }
 
 
-const char *Checkpoint::baseFilename = "m5.cpt";
+const char *CheckpointIn::baseFilename = "m5.cpt";
 
-string Checkpoint::currentDirectory;
+string CheckpointIn::currentDirectory;
 
 string
-Checkpoint::setDir(const string &name)
+CheckpointIn::setDir(const string &name)
 {
     // use csprintf to insert curTick() into directory name if it
     // appears to have a format placeholder in it.
@@ -592,35 +634,35 @@ Checkpoint::setDir(const string &name)
 }
 
 string
-Checkpoint::dir()
+CheckpointIn::dir()
 {
     return currentDirectory;
 }
 
 
-Checkpoint::Checkpoint(const string &cpt_dir, SimObjectResolver &resolver)
+CheckpointIn::CheckpointIn(const string &cpt_dir, SimObjectResolver &resolver)
     : db(new IniFile), objNameResolver(resolver), cptDir(setDir(cpt_dir))
 {
-    string filename = cptDir + "/" + Checkpoint::baseFilename;
+    string filename = cptDir + "/" + CheckpointIn::baseFilename;
     if (!db->load(filename)) {
         fatal("Can't load checkpoint file '%s'\n", filename);
     }
 }
 
-Checkpoint::~Checkpoint()
+CheckpointIn::~CheckpointIn()
 {
     delete db;
 }
 
 bool
-Checkpoint::find(const string &section, const string &entry, string &value)
+CheckpointIn::find(const string &section, const string &entry, string &value)
 {
     return db->find(section, entry, value);
 }
 
 
 bool
-Checkpoint::findObj(const string &section, const string &entry,
+CheckpointIn::findObj(const string &section, const string &entry,
                     SimObject *&value)
 {
     string path;
@@ -634,7 +676,7 @@ Checkpoint::findObj(const string &section, const string &entry,
 
 
 bool
-Checkpoint::sectionExists(const string &section)
+CheckpointIn::sectionExists(const string &section)
 {
     return db->sectionExists(section);
 }
index 2fb7cddd03f7657bbf03607a189651920835da26..644ef400583f5b9816c9885a4bf8cc5ffb369796 100644 (file)
@@ -1,4 +1,16 @@
 /*
+ * Copyright (c) 2015 ARM Limited
+ * All rights reserved
+ *
+ * The license below extends only to copyright in the software and shall
+ * not be construed as granting a license to any other intellectual
+ * property including but not limited to intellectual property relating
+ * to a hardware implementation of the functionality of the software
+ * licensed hereunder.  You may use the software subject to the license
+ * terms below provided that you ensure that this notice is replicated
+ * unmodified and in its entirety in all distributions of the software,
+ * modified or unmodified, in source code or in binary form.
+ *
  * Copyright (c) 2002-2005 The Regents of The University of Michigan
  * All rights reserved.
  *
@@ -28,6 +40,7 @@
  * Authors: Nathan Binkert
  *          Erik Hallnor
  *          Steve Reinhardt
+ *          Andreas Sandberg
  */
 
 /* @file
@@ -41,6 +54,7 @@
 #include <iostream>
 #include <list>
 #include <map>
+#include <stack>
 #include <vector>
 
 #include "base/bitunion.hh"
 
 class IniFile;
 class Serializable;
-class Checkpoint;
+class CheckpointIn;
 class SimObject;
 class EventQueue;
 
+typedef std::ostream CheckpointOut;
+
+
 /** The current version of the checkpoint format.
  * This should be incremented by 1 and only 1 for every new version, where a new
  * version is defined as a checkpoint created before this version won't work on
@@ -62,66 +79,61 @@ class EventQueue;
 static const uint64_t gem5CheckpointVersion = 0x000000000000000e;
 
 template <class T>
-void paramOut(std::ostream &os, const std::string &name, const T &param);
+void paramOut(CheckpointOut &cp, const std::string &name, const T &param);
 
 template <typename DataType, typename BitUnion>
-void paramOut(std::ostream &os, const std::string &name,
+void paramOut(CheckpointOut &cp, const std::string &name,
               const BitfieldBackend::BitUnionOperators<DataType, BitUnion> &p)
 {
-    paramOut(os, name, p.__data);
+    paramOut(cp, name, p.__data);
 }
 
 template <class T>
-void paramIn(Checkpoint *cp, const std::string &section,
-             const std::string &name, T &param);
+void paramIn(CheckpointIn &cp, const std::string &name, T &param);
 
 template <typename DataType, typename BitUnion>
-void paramIn(Checkpoint *cp, const std::string &section,
-             const std::string &name,
+void paramIn(CheckpointIn &cp, const std::string &name,
              BitfieldBackend::BitUnionOperators<DataType, BitUnion> &p)
 {
-    paramIn(cp, section, name, p.__data);
+    paramIn(cp, name, p.__data);
 }
 
 template <class T>
-bool optParamIn(Checkpoint *cp, const std::string &section,
-             const std::string &name, T &param);
+bool optParamIn(CheckpointIn &cp, const std::string &name, T &param);
 
 template <typename DataType, typename BitUnion>
-bool optParamIn(Checkpoint *cp, const std::string &section,
-                const std::string &name,
+bool optParamIn(CheckpointIn &cp, const std::string &name,
                 BitfieldBackend::BitUnionOperators<DataType, BitUnion> &p)
 {
-    return optParamIn(cp, section, name, p.__data);
+    return optParamIn(cp, name, p.__data);
 }
 
 template <class T>
-void arrayParamOut(std::ostream &os, const std::string &name,
+void arrayParamOut(CheckpointOut &cp, const std::string &name,
                    const T *param, unsigned size);
 
 template <class T>
-void arrayParamOut(std::ostream &os, const std::string &name,
+void arrayParamOut(CheckpointOut &cp, const std::string &name,
                    const std::vector<T> &param);
 
 template <class T>
-void arrayParamOut(std::ostream &os, const std::string &name,
+void arrayParamOut(CheckpointOut &cp, const std::string &name,
                    const std::list<T> &param);
 
 template <class T>
-void arrayParamIn(Checkpoint *cp, const std::string &section,
-                  const std::string &name, T *param, unsigned size);
+void arrayParamIn(CheckpointIn &cp, const std::string &name,
+                  T *param, unsigned size);
 
 template <class T>
-void arrayParamIn(Checkpoint *cp, const std::string &section,
-                  const std::string &name, std::vector<T> &param);
+void arrayParamIn(CheckpointIn &cp, const std::string &name,
+                  std::vector<T> &param);
 
 template <class T>
-void arrayParamIn(Checkpoint *cp, const std::string &section,
-                  const std::string &name, std::list<T> &param);
+void arrayParamIn(CheckpointIn &cp, const std::string &name,
+                  std::list<T> &param);
 
 void
-objParamIn(Checkpoint *cp, const std::string &section,
-           const std::string &name, SimObject * &param);
+objParamIn(CheckpointIn &cp, const std::string &name, SimObject * &param);
 
 template <typename T>
 void fromInt(T &t, int i)
@@ -139,45 +151,66 @@ void fromSimObject(T &t, SimObject *s)
 // These macros are streamlined to use in serialize/unserialize
 // functions.  It's assumed that serialize() has a parameter 'os' for
 // the ostream, and unserialize() has parameters 'cp' and 'section'.
-#define SERIALIZE_SCALAR(scalar)        paramOut(os, #scalar, scalar)
+#define SERIALIZE_SCALAR(scalar)        paramOut(cp, #scalar, scalar)
 
-#define UNSERIALIZE_SCALAR(scalar)      paramIn(cp, section, #scalar, scalar)
-#define UNSERIALIZE_OPT_SCALAR(scalar)      optParamIn(cp, section, #scalar, scalar)
+#define UNSERIALIZE_SCALAR(scalar)      paramIn(cp, #scalar, scalar)
+#define UNSERIALIZE_OPT_SCALAR(scalar)      optParamIn(cp, #scalar, scalar)
 
 // ENUMs are like SCALARs, but we cast them to ints on the way out
-#define SERIALIZE_ENUM(scalar)          paramOut(os, #scalar, (int)scalar)
+#define SERIALIZE_ENUM(scalar)          paramOut(cp, #scalar, (int)scalar)
 
 #define UNSERIALIZE_ENUM(scalar)                \
  do {                                           \
     int tmp;                                    \
-    paramIn(cp, section, #scalar, tmp);         \
-    fromInt(scalar, tmp);                    \
+    paramIn(cp, #scalar, tmp);                  \
+    fromInt(scalar, tmp);                       \
   } while (0)
 
 #define SERIALIZE_ARRAY(member, size)           \
-        arrayParamOut(os, #member, member, size)
+        arrayParamOut(cp, #member, member, size)
 
 #define UNSERIALIZE_ARRAY(member, size)         \
-        arrayParamIn(cp, section, #member, member, size)
+        arrayParamIn(cp, #member, member, size)
 
 #define SERIALIZE_CONTAINER(member)             \
-        arrayParamOut(os, #member, member)
+        arrayParamOut(cp, #member, member)
 
 #define UNSERIALIZE_CONTAINER(member)           \
-        arrayParamIn(cp, section, #member, member)
+        arrayParamIn(cp, #member, member)
 
-#define SERIALIZE_OBJPTR(objptr)        paramOut(os, #objptr, (objptr)->name())
+#define SERIALIZE_OBJPTR(objptr)        paramOut(cp, #objptr, (objptr)->name())
 
 #define UNSERIALIZE_OBJPTR(objptr)                      \
   do {                                                  \
     SimObject *sptr;                                    \
-    objParamIn(cp, section, #objptr, sptr);             \
+    objParamIn(cp, #objptr, sptr);                      \
     fromSimObject(objptr, sptr);                        \
   } while (0)
 
 /**
  * Basic support for object serialization.
  *
+ * Objects that support serialization should derive from this
+ * class. Such objects can largely be divided into two categories: 1)
+ * True SimObjects (deriving from SimObject), and 2) child objects
+ * (non-SimObjects).
+ *
+ * SimObjects are serialized automatically into their own sections
+ * automatically by the SimObject base class (see
+ * SimObject::serializeAll().
+ *
+ * SimObjects can contain other serializable objects that are not
+ * SimObjects. Much like normal serialized members are not serialized
+ * automatically, these objects will not be serialized automatically
+ * and it is expected that the objects owning such serializable
+ * objects call the required serialization/unserialization methods on
+ * child objects. The preferred method to serialize a child object is
+ * to call serializeSection() on the child, which serializes the
+ * object into a new subsection in the current section. Another option
+ * is to call serialize() directly, which serializes the object into
+ * the current section. The latter is not recommended as it can lead
+ * to naming clashes between objects.
+ *
  * @note Many objects that support serialization need to be put in a
  * consistent state when serialization takes place. We refer to the
  * action of forcing an object into a consistent state as
@@ -187,26 +220,146 @@ void fromSimObject(T &t, SimObject *s)
 class Serializable
 {
   protected:
-    void nameOut(std::ostream &os);
-    void nameOut(std::ostream &os, const std::string &_name);
+    /**
+     * Scoped checkpoint section helper class
+     *
+     * This helper class creates a section within a checkpoint without
+     * the need for a separate serializeable object. It is mainly used
+     * within the Serializable class when serializing or unserializing
+     * section (see serializeSection() and unserializeSection()). It
+     * can also be used to maintain backwards compatibility in
+     * existing code that serializes structs that are not inheriting
+     * from Serializable into subsections.
+     *
+     * When the class is instantiated, it appends a name to the active
+     * path in a checkpoint. The old path is later restored when the
+     * instance is destroyed. For example, serializeSection() could be
+     * implemented by instantiating a ScopedCheckpointSection and then
+     * calling serialize() on an object.
+     */
+    class ScopedCheckpointSection {
+      public:
+        template<class CP>
+        ScopedCheckpointSection(CP &cp, const char *name) {
+            pushName(name);
+            nameOut(cp);
+        }
+
+        template<class CP>
+        ScopedCheckpointSection(CP &cp, const std::string &name) {
+            pushName(name.c_str());
+            nameOut(cp);
+        }
+
+        ~ScopedCheckpointSection();
+
+        ScopedCheckpointSection() = delete;
+        ScopedCheckpointSection(const ScopedCheckpointSection &) = delete;
+        ScopedCheckpointSection &operator=(
+            const ScopedCheckpointSection &) = delete;
+        ScopedCheckpointSection &operator=(
+            ScopedCheckpointSection &&) = delete;
+
+      private:
+        void pushName(const char *name);
+        void nameOut(CheckpointOut &cp);
+        void nameOut(CheckpointIn &cp) {};
+    };
 
   public:
     Serializable();
     virtual ~Serializable();
 
-    // manditory virtual function, so objects must provide names
-    virtual const std::string name() const = 0;
-
-    virtual void serialize(std::ostream &os);
-    virtual void unserialize(Checkpoint *cp, const std::string &section);
-
-    static Serializable *create(Checkpoint *cp, const std::string &section);
+    /**
+     * Serialize an object
+     *
+     * Output an object's state into the current checkpoint section.
+     *
+     * @param cp Checkpoint state
+     */
+    virtual void serialize(CheckpointOut &cp) const = 0;
+
+    /**
+     * Unserialize an object
+     *
+     * Read an object's state from the current checkpoint section.
+     *
+     * @param cp Checkpoint state
+     */
+    virtual void unserialize(CheckpointIn &cp) = 0;
+
+    /**
+     * Serialize an object into a new section
+     *
+     * This method creates a new section in a checkpoint and calls
+     * serialize() to serialize the current object into that
+     * section. The name of the section is appended to the current
+     * checkpoint path.
+     *
+     * @param cp Checkpoint state
+     * @param name Name to append to the active path
+     */
+    void serializeSection(CheckpointOut &cp, const char *name) const;
+
+    void serializeSection(CheckpointOut &cp, const std::string &name) const {
+        serializeSection(cp, name.c_str());
+    }
+
+    /**
+     * Unserialize an a child object
+     *
+     * This method loads a child object from a checkpoint. The object
+     * name is appended to the active path to form a fully qualified
+     * section name and unserialize() is called.
+     *
+     * @param cp Checkpoint state
+     * @param name Name to append to the active path
+     */
+    void unserializeSection(CheckpointIn &cp, const char *name);
+
+    void unserializeSection(CheckpointIn &cp, const std::string &name) {
+        unserializeSection(cp, name.c_str());
+    }
+
+    /**
+     * @{
+     * @name Legacy interface
+     *
+     * Interface for objects that insist on changing their state when
+     * serializing. Such state change should be done in drain(),
+     * memWriteback(), or memInvalidate() and not in the serialization
+     * method. In general, if state changes occur in serialize, it
+     * complicates testing since it breaks assumptions about draining
+     * and serialization. It potentially also makes components more
+     * fragile since they there are no ordering guarantees when
+     * serializing SimObjects.
+     *
+     * @warn This interface is considered deprecated and should never
+     * be used.
+     */
+
+    virtual void serializeOld(CheckpointOut &cp) {
+        serialize(cp);
+    }
+    void serializeSectionOld(CheckpointOut &cp, const char *name);
+    void serializeSectionOld(CheckpointOut &cp, const std::string &name) {
+        serializeSectionOld(cp, name.c_str());
+    }
+    /** @} */
+
+    /** Get the fully-qualified name of the active section */
+    static const std::string &currentSection();
+
+    static Serializable *create(CheckpointIn &cp, const std::string &section);
 
     static int ckptCount;
     static int ckptMaxCount;
     static int ckptPrevCount;
     static void serializeAll(const std::string &cpt_dir);
-    static void unserializeGlobals(Checkpoint *cp);
+    static void unserializeGlobals(CheckpointIn &cp);
+
+  private:
+    static std::stack<std::string> path;
 };
 
 void debug_serialize(const std::string &cpt_dir);
@@ -258,7 +411,7 @@ class SerializableClass
     // for the object (specified by the second string argument), and
     // an optional config hierarchy node (specified by the third
     // argument).  A pointer to the new SerializableBuilder is returned.
-    typedef Serializable *(*CreateFunc)(Checkpoint *cp,
+    typedef Serializable *(*CreateFunc)(CheckpointIn &cp,
                                         const std::string &section);
 
     static std::map<std::string,CreateFunc> *classMap;
@@ -272,7 +425,7 @@ class SerializableClass
 
     // create Serializable given name of class and pointer to
     // configuration hierarchy node
-    static Serializable *createObject(Checkpoint *cp,
+    static Serializable *createObject(CheckpointIn &cp,
                                       const std::string &section);
 };
 
@@ -297,7 +450,7 @@ class SimObjectResolver
     virtual SimObject *resolveSimObject(const std::string &name) = 0;
 };
 
-class Checkpoint
+class CheckpointIn
 {
   private:
 
@@ -306,8 +459,8 @@ class Checkpoint
     SimObjectResolver &objNameResolver;
 
   public:
-    Checkpoint(const std::string &cpt_dir, SimObjectResolver &resolver);
-    ~Checkpoint();
+    CheckpointIn(const std::string &cpt_dir, SimObjectResolver &resolver);
+    ~CheckpointIn();
 
     const std::string cptDir;
 
index 5e47adca1cd7023b1b8d445667a7d495eebd1d43..719a732ab4c430b3bc5141c53a2748357868ce15 100644 (file)
@@ -117,10 +117,10 @@ LocalSimLoopExitEvent::description() const
 }
 
 void
-LocalSimLoopExitEvent::serialize(ostream &os)
+LocalSimLoopExitEvent::serialize(CheckpointOut &cp) const
 {
-    paramOut(os, "type", string("SimLoopExitEvent"));
-    Event::serialize(os);
+    paramOut(cp, "type", string("SimLoopExitEvent"));
+    Event::serialize(cp);
 
     SERIALIZE_SCALAR(cause);
     SERIALIZE_SCALAR(code);
@@ -128,9 +128,9 @@ LocalSimLoopExitEvent::serialize(ostream &os)
 }
 
 void
-LocalSimLoopExitEvent::unserialize(Checkpoint *cp, const string &section)
+LocalSimLoopExitEvent::unserialize(CheckpointIn &cp)
 {
-    Event::unserialize(cp, section);
+    Event::unserialize(cp);
 
     UNSERIALIZE_SCALAR(cause);
     UNSERIALIZE_SCALAR(code);
@@ -138,10 +138,9 @@ LocalSimLoopExitEvent::unserialize(Checkpoint *cp, const string &section)
 }
 
 void
-LocalSimLoopExitEvent::unserialize(Checkpoint *cp, const string &section,
-                                   EventQueue *eventq)
+LocalSimLoopExitEvent::unserializeEvent(CheckpointIn &cp, EventQueue *eventq)
 {
-    Event::unserialize(cp, section, eventq);
+    Event::unserializeEvent(cp, eventq);
 
     UNSERIALIZE_SCALAR(cause);
     UNSERIALIZE_SCALAR(code);
@@ -149,7 +148,7 @@ LocalSimLoopExitEvent::unserialize(Checkpoint *cp, const string &section,
 }
 
 Serializable *
-LocalSimLoopExitEvent::createForUnserialize(Checkpoint *cp,
+LocalSimLoopExitEvent::createForUnserialize(CheckpointIn &cp,
                                             const string &section)
 {
     return new LocalSimLoopExitEvent();
index 5be2609fd02449b5bdbd328dcc11abcbf22b5dde..8d5d5da7b5bb40ce3f9cc7da91827db41d077f21 100644 (file)
@@ -93,11 +93,11 @@ class LocalSimLoopExitEvent : public Event
 
     virtual const char *description() const;
 
-    virtual void serialize(std::ostream &os);
-    virtual void unserialize(Checkpoint *cp, const std::string &section);
-    virtual void unserialize(Checkpoint *cp, const std::string &section,
-                             EventQueue *eventq);
-    static Serializable *createForUnserialize(Checkpoint *cp,
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
+    void unserializeEvent(CheckpointIn &cp,
+                          EventQueue *eventq) M5_ATTR_OVERRIDE;
+    static Serializable *createForUnserialize(CheckpointIn &cp,
                                               const std::string &section);
 };
 
index a7be4ebd2cdfe3bc04d9a57fc990a127b7485d8e..2c4ba48f6eda1208aa41a748337d07b92e7cd1a5 100644 (file)
@@ -81,11 +81,13 @@ SimObject::init()
 }
 
 void
-SimObject::loadState(Checkpoint *cp)
+SimObject::loadState(CheckpointIn &cp)
 {
-    if (cp->sectionExists(name())) {
+    if (cp.sectionExists(name())) {
         DPRINTF(Checkpoint, "unserializing\n");
-        unserialize(cp, name());
+        // This works despite name() returning a fully qualified name
+        // since we are at the top level.
+        unserializeSection(cp, name());
     } else {
         DPRINTF(Checkpoint, "no checkpoint section found\n");
     }
@@ -140,15 +142,16 @@ SimObject::getProbeManager()
 // static function: serialize all SimObjects.
 //
 void
-SimObject::serializeAll(std::ostream &os)
+SimObject::serializeAll(CheckpointOut &cp)
 {
     SimObjectList::reverse_iterator ri = simObjectList.rbegin();
     SimObjectList::reverse_iterator rend = simObjectList.rend();
 
     for (; ri != rend; ++ri) {
         SimObject *obj = *ri;
-        obj->nameOut(os);
-        obj->serialize(os);
+        // This works despite name() returning a fully qualified name
+        // since we are at the top level.
+        obj->serializeSectionOld(cp, obj->name());
    }
 }
 
index 9bf95d07f473dd76f2c0ea3ec22bcbb67fd045c3..16237d051bdefab2226167131cff0b20bde7104b 100644 (file)
@@ -126,7 +126,7 @@ class SimObject : public EventManager, public Serializable, public Drainable
      *
      * @param cp Checkpoint to restore the state from.
      */
-    virtual void loadState(Checkpoint *cp);
+    virtual void loadState(CheckpointIn &cp);
 
     /**
      * initState() is called on each SimObject when *not* restoring
@@ -175,10 +175,14 @@ class SimObject : public EventManager, public Serializable, public Drainable
      */
     unsigned int drain(DrainManager *drainManger);
 
+
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE {};
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE {};
+
     /**
      * Serialize all SimObjects in the system.
      */
-    static void serializeAll(std::ostream &os);
+    static void serializeAll(CheckpointOut &cp);
 
 #ifdef DEBUG
   public:
index 2f242776976d1c1cfba139f5f7c746440d1b1641..f781377f7e397746edb78b181f634de603336bde 100644 (file)
@@ -370,31 +370,30 @@ System::drainResume()
 }
 
 void
-System::serialize(ostream &os)
+System::serialize(CheckpointOut &cp) const
 {
     if (FullSystem)
-        kernelSymtab->serialize("kernel_symtab", os);
+        kernelSymtab->serialize("kernel_symtab", cp);
     SERIALIZE_SCALAR(pagePtr);
     SERIALIZE_SCALAR(nextPID);
-    serializeSymtab(os);
+    serializeSymtab(cp);
 
     // also serialize the memories in the system
-    nameOut(os, csprintf("%s.physmem", name()));
-    physmem.serialize(os);
+    physmem.serializeSection(cp, "physmem");
 }
 
 
 void
-System::unserialize(Checkpoint *cp, const string &section)
+System::unserialize(CheckpointIn &cp)
 {
     if (FullSystem)
-        kernelSymtab->unserialize("kernel_symtab", cp, section);
+        kernelSymtab->unserialize("kernel_symtab", cp);
     UNSERIALIZE_SCALAR(pagePtr);
     UNSERIALIZE_SCALAR(nextPID);
-    unserializeSymtab(cp, section);
+    unserializeSymtab(cp);
 
     // also unserialize the memories in the system
-    physmem.unserialize(cp, csprintf("%s.physmem", name()));
+    physmem.unserializeSection(cp, "physmem");
 }
 
 void
index 9ec349a478e975bbd66b79ad7e2a6b1254fd04b7..b8114d0ca36b336fe25ecce6d6980f455e756627 100644 (file)
@@ -517,8 +517,8 @@ class System : public MemObject
     int registerThreadContext(ThreadContext *tc, int assigned=-1);
     void replaceThreadContext(ThreadContext *tc, int context_id);
 
-    void serialize(std::ostream &os);
-    void unserialize(Checkpoint *cp, const std::string &section);
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 
     unsigned int drain(DrainManager *dm);
     void drainResume();
@@ -552,7 +552,7 @@ class System : public MemObject
      *
      * @param os stream to serialize to
      */
-    virtual void serializeSymtab(std::ostream &os) {}
+    virtual void serializeSymtab(CheckpointOut &os) const {}
 
     /**
      * If needed, unserialize additional symbol table entries for a
@@ -561,8 +561,7 @@ class System : public MemObject
      * @param cp checkpoint to unserialize from
      * @param section relevant section in the checkpoint
      */
-    virtual void unserializeSymtab(Checkpoint *cp,
-                                   const std::string &section) {}
+    virtual void unserializeSymtab(CheckpointIn &cp) {}
 
 };
 
index ef6ee1c20aa5acb36767ff54d311ae25f6a4240f..ecdb878274fd015666f47b127e373d3c816cb89b 100644 (file)
@@ -72,15 +72,15 @@ Ticked::regStats()
 }
 
 void
-Ticked::serialize(std::ostream &os)
+Ticked::serialize(CheckpointOut &cp) const
 {
     uint64_t lastStoppedUint = lastStopped;
 
-    paramOut(os, "lastStopped", lastStoppedUint);
+    paramOut(cp, "lastStopped", lastStoppedUint);
 }
 
 void
-Ticked::unserialize(Checkpoint *cp, const std::string &section)
+Ticked::unserialize(CheckpointIn &cp)
 {
     uint64_t lastStoppedUint = 0;
 
@@ -90,7 +90,7 @@ Ticked::unserialize(Checkpoint *cp, const std::string &section)
      *  checkpointed object but not this one.
      *  An example would be a CPU model using Ticked restores from a
      *  simple CPU without without Ticked */
-    optParamIn(cp, section, "lastStopped", lastStoppedUint);
+    optParamIn(cp, "lastStopped", lastStoppedUint);
 
     lastStopped = Cycles(lastStoppedUint);
 }
@@ -109,14 +109,14 @@ TickedObject::regStats()
 }
 
 void
-TickedObject::serialize(std::ostream &os)
+TickedObject::serialize(CheckpointOut &cp) const
 {
-    Ticked::serialize(os);
-    ClockedObject::serialize(os);
+    Ticked::serialize(cp);
+    ClockedObject::serialize(cp);
 }
 void
-TickedObject::unserialize(Checkpoint *cp, const std::string &section)
+TickedObject::unserialize(CheckpointIn &cp)
 {
-    Ticked::unserialize(cp, section);
-    ClockedObject::unserialize(cp, section);
+    Ticked::unserialize(cp);
+    ClockedObject::unserialize(cp);
 }
index ee143e0df07b1e33ed81c6f46e98f12db5b39acb..97750873f512b7daf8d0ee6d43448b811e5f3d83 100644 (file)
@@ -56,7 +56,7 @@
  *
  *  Ticked is not a ClockedObject but can be attached to one by
  *  inheritance and by calling regStats, serialize/unserialize */
-class Ticked
+class Ticked : public Serializable
 {
   protected:
     /** An event to call process periodically */
@@ -164,8 +164,8 @@ class Ticked
     }
 
     /** Checkpoint lastStopped */
-    void serialize(std::ostream &os);
-    void unserialize(Checkpoint *cp, const std::string &section);
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 
     /** Action to call on the clock tick */
     virtual void evaluate() = 0;
@@ -199,8 +199,8 @@ class TickedObject : public ClockedObject, public Ticked
 
     /** Pass on regStats, serialize etc. onto Ticked */
     void regStats();
-    void serialize(std::ostream &os);
-    void unserialize(Checkpoint *cp, const std::string &section);
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
 };
 
 #endif /* __SIM_TICKED_OBJECT_HH__ */
index 2b16d04b9c5918f2c7565665cca83d6c34b838a8..b82efda33012d3d01854ef624364de639c0ae011 100644 (file)
@@ -142,12 +142,14 @@ VoltageDomainParams::create()
 }
 
 void
-VoltageDomain::serialize(std::ostream &os) {
+VoltageDomain::serialize(CheckpointOut &cp) const
+{
     SERIALIZE_SCALAR(_perfLevel);
 }
 
 void
-VoltageDomain::unserialize(Checkpoint *cp, const std::string &section) {
+VoltageDomain::unserialize(CheckpointIn &cp)
+{
     UNSERIALIZE_SCALAR(_perfLevel);
     perfLevel(_perfLevel);
 }
index ab96abad84ff92cc917957c5ebaa786e608a0fff..596daba40b7a3ee8c0f010de6d7af76cce282d11 100644 (file)
@@ -128,8 +128,9 @@ class VoltageDomain : public SimObject
 
     void regStats();
 
-    void serialize(std::ostream &os);
-    void unserialize(Checkpoint *cp, const std::string &section);
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
+
   private:
     typedef std::vector<double> Voltages;
     /**