diff options
231 files changed, 1787 insertions, 1773 deletions
diff --git a/src/arch/alpha/interrupts.hh b/src/arch/alpha/interrupts.hh index 3e9c90381..1e67f54b5 100644 --- a/src/arch/alpha/interrupts.hh +++ b/src/arch/alpha/interrupts.hh @@ -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 §ion) + unserialize(CheckpointIn &cp) { UNSERIALIZE_ARRAY(interrupts, NumInterruptLevels); UNSERIALIZE_SCALAR(intstatus); diff --git a/src/arch/alpha/isa.cc b/src/arch/alpha/isa.cc index 20f039166..8240037cc 100644 --- a/src/arch/alpha/isa.cc +++ b/src/arch/alpha/isa.cc @@ -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 §ion) +ISA::unserialize(CheckpointIn &cp) { UNSERIALIZE_SCALAR(fpcr); UNSERIALIZE_SCALAR(uniq); diff --git a/src/arch/alpha/isa.hh b/src/arch/alpha/isa.hh index 52e4e98be..6a88ee40b 100644 --- a/src/arch/alpha/isa.hh +++ b/src/arch/alpha/isa.hh @@ -92,8 +92,8 @@ namespace AlphaISA memset(ipr, 0, sizeof(ipr)); } - void serialize(std::ostream &os); - void unserialize(Checkpoint *cp, const std::string §ion); + void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; int flattenIntIndex(int reg) const diff --git a/src/arch/alpha/kernel_stats.cc b/src/arch/alpha/kernel_stats.cc index bac5d26cd..94142a031 100644 --- a/src/arch/alpha/kernel_stats.cc +++ b/src/arch/alpha/kernel_stats.cc @@ -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 §ion) +Statistics::unserialize(CheckpointIn &cp) { - ::Kernel::Statistics::unserialize(cp, section); + ::Kernel::Statistics::unserialize(cp); int exemode; UNSERIALIZE_SCALAR(exemode); UNSERIALIZE_SCALAR(idleProcess); diff --git a/src/arch/alpha/kernel_stats.hh b/src/arch/alpha/kernel_stats.hh index 837269309..188d3ec4b 100644 --- a/src/arch/alpha/kernel_stats.hh +++ b/src/arch/alpha/kernel_stats.hh @@ -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 §ion); + void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; }; } // namespace Kernel diff --git a/src/arch/alpha/pagetable.cc b/src/arch/alpha/pagetable.cc index 4dff04777..f2b1147f7 100644 --- a/src/arch/alpha/pagetable.cc +++ b/src/arch/alpha/pagetable.cc @@ -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 §ion) +TlbEntry::unserialize(CheckpointIn &cp) { UNSERIALIZE_SCALAR(tag); UNSERIALIZE_SCALAR(ppn); diff --git a/src/arch/alpha/pagetable.hh b/src/arch/alpha/pagetable.hh index ca44de7fa..0b6524043 100644 --- a/src/arch/alpha/pagetable.hh +++ b/src/arch/alpha/pagetable.hh @@ -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 §ion); + void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; }; } // namespace AlphaISA diff --git a/src/arch/alpha/process.cc b/src/arch/alpha/process.cc index f50131be0..e214c8874 100644 --- a/src/arch/alpha/process.cc +++ b/src/arch/alpha/process.cc @@ -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 diff --git a/src/arch/alpha/process.hh b/src/arch/alpha/process.hh index d3f9fdfc3..6701017e0 100644 --- a/src/arch/alpha/process.hh +++ b/src/arch/alpha/process.hh @@ -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); diff --git a/src/arch/alpha/system.cc b/src/arch/alpha/system.cc index 3ebc02b64..d2be5492f 100644 --- a/src/arch/alpha/system.cc +++ b/src/arch/alpha/system.cc @@ -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 §ion) +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 * diff --git a/src/arch/alpha/system.hh b/src/arch/alpha/system.hh index 11a5e90a4..3f4a2367e 100644 --- a/src/arch/alpha/system.hh +++ b/src/arch/alpha/system.hh @@ -60,8 +60,8 @@ class AlphaSystem : public System /** * Serialization stuff */ - virtual void serializeSymtab(std::ostream &os); - virtual void unserializeSymtab(Checkpoint *cp, const std::string §ion); + void serializeSymtab(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserializeSymtab(CheckpointIn &cp) M5_ATTR_OVERRIDE; /** Override startup() to provide a path to call setupFuncEvents() */ diff --git a/src/arch/alpha/tlb.cc b/src/arch/alpha/tlb.cc index a740da388..5f0ed85db 100644 --- a/src/arch/alpha/tlb.cc +++ b/src/arch/alpha/tlb.cc @@ -30,13 +30,15 @@ * 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 §ion) +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)); } diff --git a/src/arch/alpha/tlb.hh b/src/arch/alpha/tlb.hh index ccd4362d3..73ffda1f6 100644 --- a/src/arch/alpha/tlb.hh +++ b/src/arch/alpha/tlb.hh @@ -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 §ion); + void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; // Most recently used page table entries TlbEntry *EntryCache[3]; diff --git a/src/arch/arm/interrupts.hh b/src/arch/arm/interrupts.hh index f93ea5c8f..d5d2dac34 100644 --- a/src/arch/arm/interrupts.hh +++ b/src/arch/arm/interrupts.hh @@ -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 §ion) + unserialize(CheckpointIn &cp) { UNSERIALIZE_ARRAY(interrupts, NumInterruptTypes); UNSERIALIZE_SCALAR(intStatus); diff --git a/src/arch/arm/isa.hh b/src/arch/arm/isa.hh index 11f25de6d..a07017c17 100644 --- a/src/arch/arm/isa.hh +++ b/src/arch/arm/isa.hh @@ -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 §ion) + void unserialize(CheckpointIn &cp) { DPRINTF(Checkpoint, "Unserializing Arm Misc Registers\n"); UNSERIALIZE_ARRAY(miscRegs, NumMiscRegs); diff --git a/src/arch/arm/kvm/gic.cc b/src/arch/arm/kvm/gic.cc index 9010d8df8..a0e0e7899 100644 --- a/src/arch/arm/kvm/gic.cc +++ b/src/arch/arm/kvm/gic.cc @@ -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"); } diff --git a/src/arch/arm/kvm/gic.hh b/src/arch/arm/kvm/gic.hh index 3b196d108..4a115c87c 100644 --- a/src/arch/arm/kvm/gic.hh +++ b/src/arch/arm/kvm/gic.hh @@ -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 diff --git a/src/arch/arm/pagetable.hh b/src/arch/arm/pagetable.hh index c1956cf09..3de993d27 100644 --- a/src/arch/arm/pagetable.hh +++ b/src/arch/arm/pagetable.hh @@ -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 §ion) + 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 §ion) + 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_); } diff --git a/src/arch/arm/pmu.cc b/src/arch/arm/pmu.cc index d20f4e27d..6ea053e55 100644 --- a/src/arch/arm/pmu.cc +++ b/src/arch/arm/pmu.cc @@ -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 §ion) +PMU::unserialize(CheckpointIn &cp) { DPRINTF(Checkpoint, "Unserializing Arm PMU\n"); @@ -548,13 +545,13 @@ PMU::unserialize(Checkpoint *cp, const std::string §ion) 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 §ion) +PMU::CounterState::unserialize(CheckpointIn &cp) { UNSERIALIZE_SCALAR(eventId); UNSERIALIZE_SCALAR(value); diff --git a/src/arch/arm/pmu.hh b/src/arch/arm/pmu.hh index 94f8c2397..80be965a4 100644 --- a/src/arch/arm/pmu.hh +++ b/src/arch/arm/pmu.hh @@ -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 §ion); + 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. diff --git a/src/arch/arm/tlb.cc b/src/arch/arm/tlb.cc index 9a706a166..11075f02c 100644 --- a/src/arch/arm/tlb.cc +++ b/src/arch/arm/tlb.cc @@ -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 §ion) +TLB::unserialize(CheckpointIn &cp) { DPRINTF(Checkpoint, "Unserializing Arm TLB\n"); @@ -412,9 +410,8 @@ TLB::unserialize(Checkpoint *cp, const string §ion) 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 diff --git a/src/arch/arm/tlb.hh b/src/arch/arm/tlb.hh index 5d418ef17..28b99a8e0 100644 --- a/src/arch/arm/tlb.hh +++ b/src/arch/arm/tlb.hh @@ -287,8 +287,8 @@ class TLB : public BaseTLB void drainResume(); // Checkpointing - void serialize(std::ostream &os); - void unserialize(Checkpoint *cp, const std::string §ion); + void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; void regStats(); diff --git a/src/arch/arm/types.hh b/src/arch/arm/types.hh index eff8f13fb..c54bfb5f4 100644 --- a/src/arch/arm/types.hh +++ b/src/arch/arm/types.hh @@ -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 §ion) + unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE { - Base::unserialize(cp, section); + Base::unserialize(cp); UNSERIALIZE_SCALAR(flags); UNSERIALIZE_SCALAR(_size); UNSERIALIZE_SCALAR(nextFlags); diff --git a/src/arch/generic/types.hh b/src/arch/generic/types.hh index 0381e9953..8e35b5b2f 100644 --- a/src/arch/generic/types.hh +++ b/src/arch/generic/types.hh @@ -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 §ion) + 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 §ion) + 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 §ion) + 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 §ion) + unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE { - Base::unserialize(cp, section); + Base::unserialize(cp); UNSERIALIZE_SCALAR(_upc); UNSERIALIZE_SCALAR(_nupc); } diff --git a/src/arch/mips/interrupts.hh b/src/arch/mips/interrupts.hh index 8367bf91c..3c9165bfa 100755 --- a/src/arch/mips/interrupts.hh +++ b/src/arch/mips/interrupts.hh @@ -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 §ion) + unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE { fatal("Unserialization of Interrupts Unimplemented for MIPS"); } diff --git a/src/arch/mips/pagetable.cc b/src/arch/mips/pagetable.cc index b4304060c..26d9bf408 100644 --- a/src/arch/mips/pagetable.cc +++ b/src/arch/mips/pagetable.cc @@ -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 §ion) +PTE::unserialize(CheckpointIn &cp) { UNSERIALIZE_SCALAR(Mask); UNSERIALIZE_SCALAR(VPN); diff --git a/src/arch/mips/pagetable.hh b/src/arch/mips/pagetable.hh index 992d6649b..cc4e4a859 100755 --- a/src/arch/mips/pagetable.hh +++ b/src/arch/mips/pagetable.hh @@ -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 §ion); + 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 §ion) + void unserialize(CheckpointIn &cp) { UNSERIALIZE_SCALAR(_pageStart); } diff --git a/src/arch/mips/tlb.cc b/src/arch/mips/tlb.cc index 6c46cacc6..d2aa5ad70 100644 --- a/src/arch/mips/tlb.cc +++ b/src/arch/mips/tlb.cc @@ -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 §ion) +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)); } diff --git a/src/arch/mips/tlb.hh b/src/arch/mips/tlb.hh index c7cd5e631..5a9069e4c 100644 --- a/src/arch/mips/tlb.hh +++ b/src/arch/mips/tlb.hh @@ -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 §ion); + void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; void regStats(); diff --git a/src/arch/power/pagetable.cc b/src/arch/power/pagetable.cc index 091fb8bc8..4af0b7919 100644 --- a/src/arch/power/pagetable.cc +++ b/src/arch/power/pagetable.cc @@ -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 §ion) +PTE::unserialize(CheckpointIn &cp) { UNSERIALIZE_SCALAR(Mask); UNSERIALIZE_SCALAR(VPN); diff --git a/src/arch/power/pagetable.hh b/src/arch/power/pagetable.hh index 3097aa526..d835a5316 100644 --- a/src/arch/power/pagetable.hh +++ b/src/arch/power/pagetable.hh @@ -146,9 +146,8 @@ struct PTE return (V0 | V1); }; - void serialize(std::ostream &os); - - void unserialize(Checkpoint *cp, const std::string §ion); + void serialize(CheckpointOut &cp) const; + void unserialize(CheckpointIn &cp); }; } // namespace PowerISA diff --git a/src/arch/power/tlb.cc b/src/arch/power/tlb.cc index 458ed29bf..edfb4f453 100644 --- a/src/arch/power/tlb.cc +++ b/src/arch/power/tlb.cc @@ -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 §ion) +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)); } diff --git a/src/arch/power/tlb.hh b/src/arch/power/tlb.hh index 9818774d8..a07dad954 100644 --- a/src/arch/power/tlb.hh +++ b/src/arch/power/tlb.hh @@ -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 §ion) + 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 §ion); + void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; + void regStats(); }; diff --git a/src/arch/sparc/interrupts.hh b/src/arch/sparc/interrupts.hh index 56cbbf0eb..432132f66 100644 --- a/src/arch/sparc/interrupts.hh +++ b/src/arch/sparc/interrupts.hh @@ -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 §ion) + unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE { UNSERIALIZE_ARRAY(interrupts,NumInterruptTypes); UNSERIALIZE_SCALAR(intStatus); diff --git a/src/arch/sparc/isa.cc b/src/arch/sparc/isa.cc index c9a3a33b4..a588eaf66 100644 --- a/src/arch/sparc/isa.cc +++ b/src/arch/sparc/isa.cc @@ -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 §ion) +ISA::unserialize(CheckpointIn &cp) { UNSERIALIZE_SCALAR(asi); UNSERIALIZE_SCALAR(tick); diff --git a/src/arch/sparc/isa.hh b/src/arch/sparc/isa.hh index 4551cf3c1..1d2a457d2 100644 --- a/src/arch/sparc/isa.hh +++ b/src/arch/sparc/isa.hh @@ -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) {} diff --git a/src/arch/sparc/pagetable.cc b/src/arch/sparc/pagetable.cc index bdd3e97fe..f0d2c10cf 100644 --- a/src/arch/sparc/pagetable.cc +++ b/src/arch/sparc/pagetable.cc @@ -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 §ion) +TlbEntry::unserialize(CheckpointIn &cp) { UNSERIALIZE_SCALAR(range.va); UNSERIALIZE_SCALAR(range.size); diff --git a/src/arch/sparc/pagetable.hh b/src/arch/sparc/pagetable.hh index 727727f95..79b4d3cc5 100644 --- a/src/arch/sparc/pagetable.hh +++ b/src/arch/sparc/pagetable.hh @@ -277,8 +277,8 @@ struct TlbEntry range.va = new_vaddr; } - void serialize(std::ostream &os); - void unserialize(Checkpoint *cp, const std::string §ion); + void serialize(CheckpointOut &cp) const; + void unserialize(CheckpointIn &cp); }; } // namespace SparcISA diff --git a/src/arch/sparc/system.cc b/src/arch/sparc/system.cc index 0b36df9ca..b6fa645ce 100644 --- a/src/arch/sparc/system.cc +++ b/src/arch/sparc/system.cc @@ -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 §ion) +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 * diff --git a/src/arch/sparc/system.hh b/src/arch/sparc/system.hh index a4bd64aa5..68688cc1f 100644 --- a/src/arch/sparc/system.hh +++ b/src/arch/sparc/system.hh @@ -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 §ion); + void serializeSymtab(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserializeSymtab(CheckpointIn &cp) M5_ATTR_OVERRIDE; /** reset binary symbol table */ SymbolTable *resetSymtab; diff --git a/src/arch/sparc/tlb.cc b/src/arch/sparc/tlb.cc index 84d748dd3..c0c28f952 100644 --- a/src/arch/sparc/tlb.cc +++ b/src/arch/sparc/tlb.cc @@ -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 §ion) +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 §ion) 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]); diff --git a/src/arch/sparc/tlb.hh b/src/arch/sparc/tlb.hh index 1d229fba7..e64d3f1b4 100644 --- a/src/arch/sparc/tlb.hh +++ b/src/arch/sparc/tlb.hh @@ -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 §ion); + 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); diff --git a/src/arch/x86/interrupts.cc b/src/arch/x86/interrupts.cc index 171e8a1c5..556cdda37 100644 --- a/src/arch/x86/interrupts.cc +++ b/src/arch/x86/interrupts.cc @@ -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 §ion) +X86ISA::Interrupts::unserialize(CheckpointIn &cp) { UNSERIALIZE_ARRAY(regs, NUM_APIC_REGS); UNSERIALIZE_SCALAR(pendingSmi); diff --git a/src/arch/x86/interrupts.hh b/src/arch/x86/interrupts.hh index b584c234b..272cfea44 100644 --- a/src/arch/x86/interrupts.hh +++ b/src/arch/x86/interrupts.hh @@ -293,9 +293,8 @@ class Interrupts : public BasicPioDevice, IntDevice /* * Serialization. */ - - virtual void serialize(std::ostream &os); - virtual void unserialize(Checkpoint *cp, const std::string §ion); + 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 diff --git a/src/arch/x86/isa.cc b/src/arch/x86/isa.cc index f9b99db0f..213a9e2e3 100644 --- a/src/arch/x86/isa.cc +++ b/src/arch/x86/isa.cc @@ -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], diff --git a/src/arch/x86/isa.hh b/src/arch/x86/isa.hh index a82b4ae2f..88f4980ae 100644 --- a/src/arch/x86/isa.hh +++ b/src/arch/x86/isa.hh @@ -97,8 +97,9 @@ namespace X86ISA return reg; } - void serialize(std::ostream &os); - void unserialize(Checkpoint *cp, const std::string §ion); + 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 diff --git a/src/arch/x86/pagetable.cc b/src/arch/x86/pagetable.cc index cd4df42e7..4e8c39eb9 100644 --- a/src/arch/x86/pagetable.cc +++ b/src/arch/x86/pagetable.cc @@ -45,15 +45,22 @@ 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 §ion) +TlbEntry::unserialize(CheckpointIn &cp) { UNSERIALIZE_SCALAR(paddr); UNSERIALIZE_SCALAR(vaddr); diff --git a/src/arch/x86/pagetable.hh b/src/arch/x86/pagetable.hh index 639815893..3345366d0 100644 --- a/src/arch/x86/pagetable.hh +++ b/src/arch/x86/pagetable.hh @@ -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 §ion); + 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 diff --git a/src/arch/x86/tlb.cc b/src/arch/x86/tlb.cc index 86e051deb..d0e77bc9b 100644 --- a/src/arch/x86/tlb.cc +++ b/src/arch/x86/tlb.cc @@ -62,13 +62,12 @@ 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 §ion) +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 §ion) 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); } diff --git a/src/arch/x86/tlb.hh b/src/arch/x86/tlb.hh index 77f9fc49d..83ec7cc59 100644 --- a/src/arch/x86/tlb.hh +++ b/src/arch/x86/tlb.hh @@ -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 §ion); + 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 diff --git a/src/arch/x86/types.cc b/src/arch/x86/types.cc index 830a131e5..a960205b5 100644 --- a/src/arch/x86/types.cc +++ b/src/arch/x86/types.cc @@ -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 §ion, - 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; } diff --git a/src/arch/x86/types.hh b/src/arch/x86/types.hh index dd60c0aec..23d60020b 100644 --- a/src/arch/x86/types.hh +++ b/src/arch/x86/types.hh @@ -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 §ion) + 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 §ion, - const std::string &name, X86ISA::ExtMachInst &machInst); +paramIn(CheckpointIn &cp, const std::string &name, + X86ISA::ExtMachInst &machInst); #endif // __ARCH_X86_TYPES_HH__ diff --git a/src/base/cp_annotate.cc b/src/base/cp_annotate.cc index 4904949b4..5c421a5cf 100644 --- a/src/base/cp_annotate.cc +++ b/src/base/cp_annotate.cc @@ -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 §ion) +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 §ion) 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 §ion) 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 §ion) 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 §ion) 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 §ion) // 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 §ion) // 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 §ion) //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 §ion) 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 §ion) } 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 §ion) +CPA::AnnotateData::unserialize(CheckpointIn &cp) { UNSERIALIZE_SCALAR(time); UNSERIALIZE_SCALAR(data); diff --git a/src/base/cp_annotate.hh b/src/base/cp_annotate.hh index 5d554aa73..a57d9bc79 100644 --- a/src/base/cp_annotate.hh +++ b/src/base/cp_annotate.hh @@ -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 §ion); - + 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 §ion); - + void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; }; #endif // !CP_ANNOTATE diff --git a/src/base/loader/symtab.cc b/src/base/loader/symtab.cc index 2c868a9b1..439394852 100644 --- a/src/base/loader/symtab.cc +++ b/src/base/loader/symtab.cc @@ -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 §ion) +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); } } diff --git a/src/base/loader/symtab.hh b/src/base/loader/symtab.hh index 2a2fd068e..403cb13ac 100644 --- a/src/base/loader/symtab.hh +++ b/src/base/loader/symtab.hh @@ -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 §ion); + void serialize(const std::string &base, CheckpointOut &cp) const; + void unserialize(const std::string &base, CheckpointIn &cp); public: bool diff --git a/src/base/pollevent.cc b/src/base/pollevent.cc index ea4d632d0..a6c93c1f3 100644 --- a/src/base/pollevent.cc +++ b/src/base/pollevent.cc @@ -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 §ion) +PollEvent::unserialize(CheckpointIn &cp) { UNSERIALIZE_SCALAR(pfd.fd); UNSERIALIZE_SCALAR(pfd.events); diff --git a/src/base/pollevent.hh b/src/base/pollevent.hh index 5e0faa729..632239e08 100644 --- a/src/base/pollevent.hh +++ b/src/base/pollevent.hh @@ -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 §ion); + void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; }; class PollQueue diff --git a/src/base/random.cc b/src/base/random.cc index ced9a8f45..2eb60c6e5 100644 --- a/src/base/random.cc +++ b/src/base/random.cc @@ -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 §ion) +Random::unserialize(CheckpointIn &cp) { panic("Currently not used anywhere.\n"); @@ -90,7 +90,7 @@ Random::unserialize(Checkpoint *cp, const std::string §ion) // 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; } diff --git a/src/base/random.hh b/src/base/random.hh index cedbd6bd4..dca956306 100644 --- a/src/base/random.hh +++ b/src/base/random.hh @@ -53,11 +53,13 @@ #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 §ion); + void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; }; extern Random random_mt; diff --git a/src/base/time.cc b/src/base/time.cc index a0ae9bb82..86a31156c 100644 --- a/src/base/time.cc +++ b/src/base/time.cc @@ -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 §ion) +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); } diff --git a/src/base/time.hh b/src/base/time.hh index 734a86fa9..41d454a65 100644 --- a/src/base/time.hh +++ b/src/base/time.hh @@ -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 §ion); + void serialize(const std::string &base, CheckpointOut &cp) const; + void unserialize(const std::string &base, CheckpointIn &cp); }; void sleep(const Time &time); diff --git a/src/cpu/base.cc b/src/cpu/base.cc index 4d8b09ed2..0b704c48b 100644 --- a/src/cpu/base.cc +++ b/src/cpu/base.cc @@ -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 §ion) +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); + } } } diff --git a/src/cpu/base.hh b/src/cpu/base.hh index 662b24a99..660f0278e 100644 --- a/src/cpu/base.hh +++ b/src/cpu/base.hh @@ -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 §ion); + 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 §ion, - ThreadID tid) {}; + virtual void unserializeThread(CheckpointIn &cp, ThreadID tid) {}; virtual Counter totalInsts() const = 0; diff --git a/src/cpu/checker/cpu.cc b/src/cpu/checker/cpu.cc index 229066fcc..ac476e5f4 100644 --- a/src/cpu/checker/cpu.cc +++ b/src/cpu/checker/cpu.cc @@ -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 §ion) +CheckerCPU::unserialize(CheckpointIn &cp) { } diff --git a/src/cpu/checker/cpu.hh b/src/cpu/checker/cpu.hh index bed3b9e32..a363b6d0f 100644 --- a/src/cpu/checker/cpu.hh +++ b/src/cpu/checker/cpu.hh @@ -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 §ion); + 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. diff --git a/src/cpu/checker/thread_context.hh b/src/cpu/checker/thread_context.hh index 26d0dfa8b..71c231ba0 100644 --- a/src/cpu/checker/thread_context.hh +++ b/src/cpu/checker/thread_context.hh @@ -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 §ion) - { actualTC->unserialize(cp, section); } - EndQuiesceEvent *getQuiesceEvent() { return actualTC->getQuiesceEvent(); } Tick readLastActivate() { return actualTC->readLastActivate(); } diff --git a/src/cpu/kvm/BaseKvmCPU.py b/src/cpu/kvm/BaseKvmCPU.py index 644ca3620..b7c964669 100644 --- a/src/cpu/kvm/BaseKvmCPU.py +++ b/src/cpu/kvm/BaseKvmCPU.py @@ -53,7 +53,7 @@ class BaseKvmCPU(BaseCPU): @classmethod def export_methods(cls, code): code(''' - void dump(); + void dump() const; ''') @classmethod diff --git a/src/cpu/kvm/base.cc b/src/cpu/kvm/base.cc index 827cd5581..30e984366 100644 --- a/src/cpu/kvm/base.cc +++ b/src/cpu/kvm/base.cc @@ -259,7 +259,7 @@ BaseKvmCPU::regStats() } void -BaseKvmCPU::serializeThread(std::ostream &os, ThreadID tid) +BaseKvmCPU::serializeThread(CheckpointOut &cp, ThreadID tid) const { if (DTRACE(Checkpoint)) { DPRINTF(Checkpoint, "KVM: Serializing thread %i:\n", tid); @@ -268,18 +268,17 @@ BaseKvmCPU::serializeThread(std::ostream &os, ThreadID tid) assert(tid == 0); assert(_status == Idle); - thread->serialize(os); + thread->serialize(cp); } void -BaseKvmCPU::unserializeThread(Checkpoint *cp, const std::string §ion, - ThreadID tid) +BaseKvmCPU::unserializeThread(CheckpointIn &cp, ThreadID tid) { DPRINTF(Checkpoint, "KVM: Unserialize thread %i:\n", tid); assert(tid == 0); assert(_status == Idle); - thread->unserialize(cp, section); + thread->unserialize(cp); threadContextDirty = true; } @@ -511,7 +510,7 @@ BaseKvmCPU::totalOps() const } void -BaseKvmCPU::dump() +BaseKvmCPU::dump() const { inform("State dumping not implemented."); } diff --git a/src/cpu/kvm/base.hh b/src/cpu/kvm/base.hh index ce32cdbb1..a8e429dfa 100644 --- a/src/cpu/kvm/base.hh +++ b/src/cpu/kvm/base.hh @@ -84,9 +84,10 @@ class BaseKvmCPU : public BaseCPU void startup(); void regStats(); - void serializeThread(std::ostream &os, ThreadID tid); - void unserializeThread(Checkpoint *cp, const std::string §ion, - ThreadID tid); + void serializeThread(CheckpointOut &cp, + ThreadID tid) const M5_ATTR_OVERRIDE; + void unserializeThread(CheckpointIn &cp, + ThreadID tid) M5_ATTR_OVERRIDE; unsigned int drain(DrainManager *dm); void drainResume(); @@ -111,7 +112,7 @@ class BaseKvmCPU : public BaseCPU Counter totalOps() const; /** Dump the internal state to the terminal. */ - virtual void dump(); + virtual void dump() const; /** * Force an exit from KVM. diff --git a/src/cpu/kvm/x86_cpu.cc b/src/cpu/kvm/x86_cpu.cc index 34b51f137..cd46370a4 100644 --- a/src/cpu/kvm/x86_cpu.cc +++ b/src/cpu/kvm/x86_cpu.cc @@ -562,7 +562,7 @@ X86KvmCPU::startup() } void -X86KvmCPU::dump() +X86KvmCPU::dump() const { dumpIntRegs(); if (useXSave) diff --git a/src/cpu/kvm/x86_cpu.hh b/src/cpu/kvm/x86_cpu.hh index 18471040c..2e93a5f26 100644 --- a/src/cpu/kvm/x86_cpu.hh +++ b/src/cpu/kvm/x86_cpu.hh @@ -47,7 +47,7 @@ class X86KvmCPU : public BaseKvmCPU void startup(); /** @{ */ - void dump(); + void dump() const M5_ATTR_OVERRIDE; void dumpFpuRegs() const; void dumpIntRegs() const; void dumpSpecRegs() const; diff --git a/src/cpu/minor/cpu.cc b/src/cpu/minor/cpu.cc index 45817c3a8..d21bf7042 100644 --- a/src/cpu/minor/cpu.cc +++ b/src/cpu/minor/cpu.cc @@ -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 §ion, - 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 §ion) +MinorCPU::unserialize(CheckpointIn &cp) { - pipeline->unserialize(cp, section); - BaseCPU::unserialize(cp, section); + pipeline->unserialize(cp); + BaseCPU::unserialize(cp); } Addr diff --git a/src/cpu/minor/cpu.hh b/src/cpu/minor/cpu.hh index 507261fbd..fba54b515 100644 --- a/src/cpu/minor/cpu.hh +++ b/src/cpu/minor/cpu.hh @@ -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 §ion, - 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 §ion); + void serialize(CheckpointOut &cp) const; + void unserialize(CheckpointIn &cp); /** Drain interface */ unsigned int drain(DrainManager *drain_manager); diff --git a/src/cpu/o3/cpu.cc b/src/cpu/o3/cpu.cc index 34ef275a7..18e958278 100644 --- a/src/cpu/o3/cpu.cc +++ b/src/cpu/o3/cpu.cc @@ -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 §ion, - ThreadID tid) +FullO3CPU<Impl>::unserializeThread(CheckpointIn &cp, ThreadID tid) { - thread[tid]->unserialize(cp, section); + thread[tid]->unserialize(cp); } template <class Impl> diff --git a/src/cpu/o3/cpu.hh b/src/cpu/o3/cpu.hh index c4ccd562b..bbc9fde8e 100644 --- a/src/cpu/o3/cpu.hh +++ b/src/cpu/o3/cpu.hh @@ -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 §ion, - 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. diff --git a/src/cpu/o3/thread_state.hh b/src/cpu/o3/thread_state.hh index eea7a3d16..cf9403e48 100644 --- a/src/cpu/o3/thread_state.hh +++ b/src/cpu/o3/thread_state.hh @@ -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 §ion) + 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; } diff --git a/src/cpu/simple/base.cc b/src/cpu/simple/base.cc index 9cfbd5f93..2751a346c 100644 --- a/src/cpu/simple/base.cc +++ b/src/cpu/simple/base.cc @@ -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 §ion, - 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 diff --git a/src/cpu/simple/base.hh b/src/cpu/simple/base.hh index 6e8b4a8c8..2f7247010 100644 --- a/src/cpu/simple/base.hh +++ b/src/cpu/simple/base.hh @@ -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 §ion, - 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. diff --git a/src/cpu/simple_thread.cc b/src/cpu/simple_thread.cc index 36603a1c1..5e457f692 100644 --- a/src/cpu/simple_thread.cc +++ b/src/cpu/simple_thread.cc @@ -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 §ion) +SimpleThread::unserialize(CheckpointIn &cp) { - ThreadState::unserialize(cp, section); - ::unserialize(*tc, cp, section); + ThreadState::unserialize(cp); + ::unserialize(*tc, cp); } void diff --git a/src/cpu/simple_thread.hh b/src/cpu/simple_thread.hh index e862385c5..20acff6ee 100644 --- a/src/cpu/simple_thread.hh +++ b/src/cpu/simple_thread.hh @@ -154,8 +154,8 @@ class SimpleThread : public ThreadState void copyState(ThreadContext *oldContext); - void serialize(std::ostream &os); - void unserialize(Checkpoint *cp, const std::string §ion); + void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; void startup(); /*************************************************************** diff --git a/src/cpu/testers/traffic_gen/traffic_gen.cc b/src/cpu/testers/traffic_gen/traffic_gen.cc index 9f3192656..0fc8848fb 100644 --- a/src/cpu/testers/traffic_gen/traffic_gen.cc +++ b/src/cpu/testers/traffic_gen/traffic_gen.cc @@ -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; diff --git a/src/cpu/testers/traffic_gen/traffic_gen.hh b/src/cpu/testers/traffic_gen/traffic_gen.hh index eb9f6541d..ba7fda7dd 100644 --- a/src/cpu/testers/traffic_gen/traffic_gen.hh +++ b/src/cpu/testers/traffic_gen/traffic_gen.hh @@ -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(); diff --git a/src/cpu/thread_context.cc b/src/cpu/thread_context.cc index 09f91746a..fe1ae69dd 100644 --- a/src/cpu/thread_context.cc +++ b/src/cpu/thread_context.cc @@ -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 §ion) +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 §ion) #endif PCState pcState; - pcState.unserialize(cp, section); + pcState.unserialize(cp); tc.pcState(pcState); // thread_num and cpu_id are deterministic from the config diff --git a/src/cpu/thread_context.hh b/src/cpu/thread_context.hh index 966924c50..2544b19c6 100644 --- a/src/cpu/thread_context.hh +++ b/src/cpu/thread_context.hh @@ -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 §ion); +void serialize(ThreadContext &tc, CheckpointOut &cp); +void unserialize(ThreadContext &tc, CheckpointIn &cp); /** @} */ diff --git a/src/cpu/thread_state.cc b/src/cpu/thread_state.cc index 0e1e6c57e..424187613 100644 --- a/src/cpu/thread_state.cc +++ b/src/cpu/thread_state.cc @@ -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 §ion) +ThreadState::unserialize(CheckpointIn &cp) { UNSERIALIZE_ENUM(_status); @@ -96,7 +96,7 @@ ThreadState::unserialize(Checkpoint *cp, const std::string §ion) if (quiesceEndTick) baseCpu->schedule(quiesceEvent, quiesceEndTick); if (kernelStats) - kernelStats->unserialize(cp, section); + kernelStats->unserialize(cp); } void diff --git a/src/cpu/thread_state.hh b/src/cpu/thread_state.hh index f937964ff..485c9306f 100644 --- a/src/cpu/thread_state.hh +++ b/src/cpu/thread_state.hh @@ -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 §ion); + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; int cpuId() const { return baseCpu->cpuId(); } diff --git a/src/dev/alpha/backdoor.cc b/src/dev/alpha/backdoor.cc index 598620893..ec5765673 100644 --- a/src/dev/alpha/backdoor.cc +++ b/src/dev/alpha/backdoor.cc @@ -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 §ion) +AlphaBackdoor::Access::unserialize(CheckpointIn &cp) { UNSERIALIZE_SCALAR(last_offset); UNSERIALIZE_SCALAR(version); @@ -296,15 +296,15 @@ AlphaBackdoor::Access::unserialize(Checkpoint *cp, const std::string §ion) } void -AlphaBackdoor::serialize(ostream &os) +AlphaBackdoor::serialize(CheckpointOut &cp) const { - alphaAccess->serialize(os); + alphaAccess->serialize(cp); } void -AlphaBackdoor::unserialize(Checkpoint *cp, const std::string §ion) +AlphaBackdoor::unserialize(CheckpointIn &cp) { - alphaAccess->unserialize(cp, section); + alphaAccess->unserialize(cp); } AlphaBackdoor * diff --git a/src/dev/alpha/backdoor.hh b/src/dev/alpha/backdoor.hh index b9d04c7c0..da6201059 100644 --- a/src/dev/alpha/backdoor.hh +++ b/src/dev/alpha/backdoor.hh @@ -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 §ion); + 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 §ion); + void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; }; #endif // __DEV_ALPHA_BACKDOOR_HH__ diff --git a/src/dev/alpha/tsunami.cc b/src/dev/alpha/tsunami.cc index 41a2fef0c..36b1a9ded 100644 --- a/src/dev/alpha/tsunami.cc +++ b/src/dev/alpha/tsunami.cc @@ -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 §ion) +Tsunami::unserialize(CheckpointIn &cp) { UNSERIALIZE_ARRAY(intr_sum_type, Tsunami::Max_CPUs); } diff --git a/src/dev/alpha/tsunami.hh b/src/dev/alpha/tsunami.hh index 9380864b0..19df8093e 100644 --- a/src/dev/alpha/tsunami.hh +++ b/src/dev/alpha/tsunami.hh @@ -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 §ion); + void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; }; #endif // __DEV_TSUNAMI_HH__ diff --git a/src/dev/alpha/tsunami_cchip.cc b/src/dev/alpha/tsunami_cchip.cc index 7416de403..d67f4e3fb 100644 --- a/src/dev/alpha/tsunami_cchip.cc +++ b/src/dev/alpha/tsunami_cchip.cc @@ -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 §ion) +TsunamiCChip::unserialize(CheckpointIn &cp) { UNSERIALIZE_ARRAY(dim, Tsunami::Max_CPUs); UNSERIALIZE_ARRAY(dir, Tsunami::Max_CPUs); diff --git a/src/dev/alpha/tsunami_cchip.hh b/src/dev/alpha/tsunami_cchip.hh index e9aca5d5c..fdbe64ef1 100644 --- a/src/dev/alpha/tsunami_cchip.hh +++ b/src/dev/alpha/tsunami_cchip.hh @@ -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 §ion); - + void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; }; #endif // __TSUNAMI_CCHIP_HH__ diff --git a/src/dev/alpha/tsunami_io.cc b/src/dev/alpha/tsunami_io.cc index 2236546fc..8015ec2fe 100644 --- a/src/dev/alpha/tsunami_io.cc +++ b/src/dev/alpha/tsunami_io.cc @@ -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 §ion) +TsunamiIO::unserialize(CheckpointIn &cp) { UNSERIALIZE_SCALAR(rtcAddr); UNSERIALIZE_SCALAR(timerData); @@ -280,8 +280,8 @@ TsunamiIO::unserialize(Checkpoint *cp, const string §ion) UNSERIALIZE_SCALAR(picInterrupting); // Unserialize the timers - pitimer.unserialize("pitimer", cp, section); - rtc.unserialize("rtc", cp, section); + pitimer.unserialize("pitimer", cp); + rtc.unserialize("rtc", cp); } void diff --git a/src/dev/alpha/tsunami_io.hh b/src/dev/alpha/tsunami_io.hh index f242c9e2a..2b7f5484e 100644 --- a/src/dev/alpha/tsunami_io.hh +++ b/src/dev/alpha/tsunami_io.hh @@ -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 §ion); + void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; /** * Start running. diff --git a/src/dev/alpha/tsunami_pchip.cc b/src/dev/alpha/tsunami_pchip.cc index 328699f9f..cfd1e69e4 100644 --- a/src/dev/alpha/tsunami_pchip.cc +++ b/src/dev/alpha/tsunami_pchip.cc @@ -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 §ion) +TsunamiPChip::unserialize(CheckpointIn &cp) { UNSERIALIZE_SCALAR(pctl); UNSERIALIZE_ARRAY(wsba, 4); diff --git a/src/dev/alpha/tsunami_pchip.hh b/src/dev/alpha/tsunami_pchip.hh index 3e32db989..0eb992131 100644 --- a/src/dev/alpha/tsunami_pchip.hh +++ b/src/dev/alpha/tsunami_pchip.hh @@ -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 §ion); + void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; }; #endif // __TSUNAMI_PCHIP_HH__ diff --git a/src/dev/arm/energy_ctrl.cc b/src/dev/arm/energy_ctrl.cc index b77eaba3b..0e6925852 100644 --- a/src/dev/arm/energy_ctrl.cc +++ b/src/dev/arm/energy_ctrl.cc @@ -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 §ion) +EnergyCtrl::unserialize(CheckpointIn &cp) { UNSERIALIZE_SCALAR(domainID); UNSERIALIZE_SCALAR(domainIDIndexToRead); diff --git a/src/dev/arm/energy_ctrl.hh b/src/dev/arm/energy_ctrl.hh index 54a690679..a1a362879 100644 --- a/src/dev/arm/energy_ctrl.hh +++ b/src/dev/arm/energy_ctrl.hh @@ -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 §ion); + void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; void startup(); void init(); diff --git a/src/dev/arm/flash_device.cc b/src/dev/arm/flash_device.cc index eaa839178..96f8f0566 100644 --- a/src/dev/arm/flash_device.cc +++ b/src/dev/arm/flash_device.cc @@ -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 §ion) +FlashDevice::unserialize(CheckpointIn &cp) { UNSERIALIZE_SCALAR(planeMask); diff --git a/src/dev/arm/flash_device.hh b/src/dev/arm/flash_device.hh index 8dc4ba04a..330299451 100644 --- a/src/dev/arm/flash_device.hh +++ b/src/dev/arm/flash_device.hh @@ -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 §ion); + + void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; private: /** Defines the possible actions to the flash*/ diff --git a/src/dev/arm/generic_timer.cc b/src/dev/arm/generic_timer.cc index 41cb4bada..173855b88 100644 --- a/src/dev/arm/generic_timer.cc +++ b/src/dev/arm/generic_timer.cc @@ -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 §ion) +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 §ion) +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 §ion) +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 §ion) 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 §ion) +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 §ion) 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 diff --git a/src/dev/arm/generic_timer.hh b/src/dev/arm/generic_timer.hh index d8f7f54e2..97823f05f 100644 --- a/src/dev/arm/generic_timer.hh +++ b/src/dev/arm/generic_timer.hh @@ -58,7 +58,7 @@ class GenericTimerMemParams; /// Global system counter. It is shared by the architected timers. /// @todo: implement memory-mapped controls -class SystemCounter +class SystemCounter : public Serializable { protected: /// Counter frequency (as specified by CNTFRQ). @@ -93,8 +93,8 @@ class SystemCounter void setKernelControl(uint32_t val) { _regCntkctl = val; } uint32_t getKernelControl() { return _regCntkctl; } - void serialize(std::ostream &os) const; - void unserialize(Checkpoint *cp, const std::string §ion); + 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 §ion); + 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; } diff --git a/src/dev/arm/gic_pl390.cc b/src/dev/arm/gic_pl390.cc index b4dc37682..5a21f6cec 100644 --- a/src/dev/arm/gic_pl390.cc +++ b/src/dev/arm/gic_pl390.cc @@ -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 §ion) +Pl390::unserialize(CheckpointIn &cp) { DPRINTF(Checkpoint, "Unserializing Arm GIC\n"); diff --git a/src/dev/arm/gic_pl390.hh b/src/dev/arm/gic_pl390.hh index 2621e1a27..1adad6c9a 100644 --- a/src/dev/arm/gic_pl390.hh +++ b/src/dev/arm/gic_pl390.hh @@ -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 §ion); + 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 diff --git a/src/dev/arm/hdlcd.cc b/src/dev/arm/hdlcd.cc index 3fc30f16d..afeef7637 100644 --- a/src/dev/arm/hdlcd.cc +++ b/src/dev/arm/hdlcd.cc @@ -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 §ion) +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 §ion) 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 §ion) 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]) { diff --git a/src/dev/arm/hdlcd.hh b/src/dev/arm/hdlcd.hh index 519afeba6..1396c9a8b 100644 --- a/src/dev/arm/hdlcd.hh +++ b/src/dev/arm/hdlcd.hh @@ -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 §ion); + void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; /** * Determine the address ranges that this device responds to. diff --git a/src/dev/arm/kmi.cc b/src/dev/arm/kmi.cc index 2344b4cb5..d96810351 100644 --- a/src/dev/arm/kmi.cc +++ b/src/dev/arm/kmi.cc @@ -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 §ion) +Pl050::unserialize(CheckpointIn &cp) { uint8_t ctrlreg; UNSERIALIZE_SCALAR(ctrlreg); @@ -355,7 +355,7 @@ Pl050::unserialize(Checkpoint *cp, const std::string §ion) UNSERIALIZE_SCALAR(shiftDown); UNSERIALIZE_SCALAR(driverInitialized); - arrayParamIn(cp, section, "rxQueue", rxQueue); + UNSERIALIZE_CONTAINER(rxQueue); } diff --git a/src/dev/arm/kmi.hh b/src/dev/arm/kmi.hh index f9dbfcf76..9b30b3c15 100644 --- a/src/dev/arm/kmi.hh +++ b/src/dev/arm/kmi.hh @@ -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 §ion); + void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; }; #endif // __DEV_ARM_PL050_HH__ diff --git a/src/dev/arm/pl011.cc b/src/dev/arm/pl011.cc index 2abd82e96..f0c3d2d98 100644 --- a/src/dev/arm/pl011.cc +++ b/src/dev/arm/pl011.cc @@ -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 §ion) +Pl011::unserialize(CheckpointIn &cp) { DPRINTF(Checkpoint, "Unserializing Arm PL011\n"); @@ -298,8 +298,8 @@ Pl011::unserialize(Checkpoint *cp, const std::string §ion) 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 * diff --git a/src/dev/arm/pl011.hh b/src/dev/arm/pl011.hh index f2587c08d..b0f7d576d 100644 --- a/src/dev/arm/pl011.hh +++ b/src/dev/arm/pl011.hh @@ -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; diff --git a/src/dev/arm/pl111.cc b/src/dev/arm/pl111.cc index fcce09f50..179f1bf2d 100644 --- a/src/dev/arm/pl111.cc +++ b/src/dev/arm/pl111.cc @@ -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 §ion) +Pl111::unserialize(CheckpointIn &cp) { DPRINTF(PL111, "Unserializing ARM PL111\n"); @@ -731,7 +731,7 @@ Pl111::unserialize(Checkpoint *cp, const std::string §ion) 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]) diff --git a/src/dev/arm/pl111.hh b/src/dev/arm/pl111.hh index 85973bbc7..08d9147a4 100644 --- a/src/dev/arm/pl111.hh +++ b/src/dev/arm/pl111.hh @@ -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 §ion); + void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; /** * Determine the address ranges that this device responds to. diff --git a/src/dev/arm/rtc_pl031.cc b/src/dev/arm/rtc_pl031.cc index e619045c2..d5661877c 100644 --- a/src/dev/arm/rtc_pl031.cc +++ b/src/dev/arm/rtc_pl031.cc @@ -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 §ion) +PL031::unserialize(CheckpointIn &cp) { DPRINTF(Checkpoint, "Unserializing Arm PL031\n"); diff --git a/src/dev/arm/rtc_pl031.hh b/src/dev/arm/rtc_pl031.hh index 0f1929d29..406857e70 100644 --- a/src/dev/arm/rtc_pl031.hh +++ b/src/dev/arm/rtc_pl031.hh @@ -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 §ion); + void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; }; diff --git a/src/dev/arm/rv_ctrl.cc b/src/dev/arm/rv_ctrl.cc index f2b85d513..27ba2e8a6 100644 --- a/src/dev/arm/rv_ctrl.cc +++ b/src/dev/arm/rv_ctrl.cc @@ -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 §ion) +RealViewCtrl::unserialize(CheckpointIn &cp) { UNSERIALIZE_SCALAR(flags); } diff --git a/src/dev/arm/rv_ctrl.hh b/src/dev/arm/rv_ctrl.hh index adf065631..cae5e2e2c 100644 --- a/src/dev/arm/rv_ctrl.hh +++ b/src/dev/arm/rv_ctrl.hh @@ -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 §ion); + void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; }; diff --git a/src/dev/arm/timer_cpulocal.cc b/src/dev/arm/timer_cpulocal.cc index de2f99f0a..ac02d099f 100644 --- a/src/dev/arm/timer_cpulocal.cc +++ b/src/dev/arm/timer_cpulocal.cc @@ -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 §ion) +CpuLocalTimer::Timer::unserialize(CheckpointIn &cp) { DPRINTF(Checkpoint, "Unserializing Arm CpuLocalTimer\n"); @@ -416,20 +416,17 @@ CpuLocalTimer::Timer::unserialize(Checkpoint *cp, const std::string §ion) 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 §ion) +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 * diff --git a/src/dev/arm/timer_cpulocal.hh b/src/dev/arm/timer_cpulocal.hh index f53f5bc25..73a2d4493 100644 --- a/src/dev/arm/timer_cpulocal.hh +++ b/src/dev/arm/timer_cpulocal.hh @@ -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 §ion); + 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 §ion); + void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; }; diff --git a/src/dev/arm/timer_sp804.cc b/src/dev/arm/timer_sp804.cc index 9f7867107..54a5a2516 100644 --- a/src/dev/arm/timer_sp804.cc +++ b/src/dev/arm/timer_sp804.cc @@ -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 §ion) +Sp804::Timer::unserialize(CheckpointIn &cp) { DPRINTF(Checkpoint, "Unserializing Arm Sp804\n"); @@ -264,19 +264,17 @@ Sp804::Timer::unserialize(Checkpoint *cp, const std::string §ion) 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 §ion) +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 * diff --git a/src/dev/arm/timer_sp804.hh b/src/dev/arm/timer_sp804.hh index 03dc20ec1..c5b3bb633 100644 --- a/src/dev/arm/timer_sp804.hh +++ b/src/dev/arm/timer_sp804.hh @@ -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 §ion); - + 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 §ion); + void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; }; diff --git a/src/dev/arm/ufs_device.cc b/src/dev/arm/ufs_device.cc index d271656cd..02df00e35 100644 --- a/src/dev/arm/ufs_device.cc +++ b/src/dev/arm/ufs_device.cc @@ -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 §ion) +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)); diff --git a/src/dev/arm/ufs_device.hh b/src/dev/arm/ufs_device.hh index 07f038175..15e983ad8 100644 --- a/src/dev/arm/ufs_device.hh +++ b/src/dev/arm/ufs_device.hh @@ -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 §ion); + void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; private: /** diff --git a/src/dev/arm/vgic.cc b/src/dev/arm/vgic.cc index 4a63c796a..f4a3e8c3f 100644 --- a/src/dev/arm/vgic.cc +++ b/src/dev/arm/vgic.cc @@ -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 §ion) +void VGic::unserialize(CheckpointIn &cp) { DPRINTF(Checkpoint, "Unserializing Arm GIC\n"); @@ -502,37 +502,7 @@ void VGic::unserialize(Checkpoint *cp, const std::string §ion) 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 §ion) 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() { diff --git a/src/dev/arm/vgic.hh b/src/dev/arm/vgic.hh index e1c4960e9..ac88f842f 100644 --- a/src/dev/arm/vgic.hh +++ b/src/dev/arm/vgic.hh @@ -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 §ion); + void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; private: Tick readVCpu(PacketPtr pkt); diff --git a/src/dev/copy_engine.cc b/src/dev/copy_engine.cc index a3d73b634..5506103b1 100644 --- a/src/dev/copy_engine.cc +++ b/src/dev/copy_engine.cc @@ -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 §ion) +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 §ion) +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); } diff --git a/src/dev/copy_engine.hh b/src/dev/copy_engine.hh index 1186d0b1d..80c9798ee 100644 --- a/src/dev/copy_engine.hh +++ b/src/dev/copy_engine.hh @@ -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 §ion); + 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 §ion); + void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; unsigned int drain(DrainManager *drainManger); void drainResume(); diff --git a/src/dev/copy_engine_defs.hh b/src/dev/copy_engine_defs.hh index 98216e64c..afefac2b5 100644 --- a/src/dev/copy_engine_defs.hh +++ b/src/dev/copy_engine_defs.hh @@ -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 §ion) + 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 §ion) + 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 §ion) + 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); } diff --git a/src/dev/disk_image.cc b/src/dev/disk_image.cc index 8194eb507..e4907853f 100644 --- a/src/dev/disk_image.cc +++ b/src/dev/disk_image.cc @@ -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 §ion) +CowDiskImage::unserialize(CheckpointIn &cp) { string cowFilename; UNSERIALIZE_SCALAR(cowFilename); - cowFilename = cp->cptDir + "/" + cowFilename; + cowFilename = cp.cptDir + "/" + cowFilename; open(cowFilename); } diff --git a/src/dev/disk_image.hh b/src/dev/disk_image.hh index da96082cb..25483eed5 100644 --- a/src/dev/disk_image.hh +++ b/src/dev/disk_image.hh @@ -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 §ion); + + void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; virtual std::streampos size() const; diff --git a/src/dev/etherlink.cc b/src/dev/etherlink.cc index c5ef66d99..27179d508 100644 --- a/src/dev/etherlink.cc +++ b/src/dev/etherlink.cc @@ -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 §ion) +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 §ion) {} - void unserialize(Checkpoint *cp, const string §ion, - 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 §ion); }; @@ -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 §ion) +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 §ion, - 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 §ion, 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 §ion) +LinkDelayEvent::createForUnserialize(CheckpointIn &cp, const string §ion) { return new LinkDelayEvent(); } diff --git a/src/dev/etherlink.hh b/src/dev/etherlink.hh index ca17b837d..525e8250d 100644 --- a/src/dev/etherlink.hh +++ b/src/dev/etherlink.hh @@ -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 §ion); + 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 §ion); + void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; }; diff --git a/src/dev/etherpkt.cc b/src/dev/etherpkt.cc index 2c8343eb0..548a1f179 100644 --- a/src/dev/etherpkt.cc +++ b/src/dev/etherpkt.cc @@ -37,17 +37,16 @@ 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 §ion) +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); } diff --git a/src/dev/etherpkt.hh b/src/dev/etherpkt.hh index febd303a1..acda9fb47 100644 --- a/src/dev/etherpkt.hh +++ b/src/dev/etherpkt.hh @@ -41,11 +41,11 @@ #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 §ion); + void serialize(const std::string &base, CheckpointOut &cp) const; + void unserialize(const std::string &base, CheckpointIn &cp); }; typedef std::shared_ptr<EthPacketData> EthPacketPtr; diff --git a/src/dev/ethertap.cc b/src/dev/ethertap.cc index 38ce4a2b3..d062b5d8a 100644 --- a/src/dev/ethertap.cc +++ b/src/dev/ethertap.cc @@ -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 §ion) +EtherTap::unserialize(CheckpointIn &cp) { UNSERIALIZE_SCALAR(socket); UNSERIALIZE_SCALAR(buflen); @@ -329,7 +329,7 @@ EtherTap::unserialize(Checkpoint *cp, const std::string §ion) if (tapevent_present) { event = new TapEvent(this, socket, POLLIN|POLLERR); - event->unserialize(cp,section); + event->unserialize(cp); if (event->queued()) { pollQueue.schedule(event); diff --git a/src/dev/ethertap.hh b/src/dev/ethertap.hh index 2f38d57b4..9c21dfc03 100644 --- a/src/dev/ethertap.hh +++ b/src/dev/ethertap.hh @@ -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 §ion); + void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; }; class EtherTapInt : public EtherInt diff --git a/src/dev/i2cbus.cc b/src/dev/i2cbus.cc index 9d7da44d0..03ca6769c 100644 --- a/src/dev/i2cbus.cc +++ b/src/dev/i2cbus.cc @@ -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 §ion) +I2CBus::unserialize(CheckpointIn &cp) { DPRINTF(Checkpoint, "Unserializing I2C bus.\n"); UNSERIALIZE_SCALAR(scl); diff --git a/src/dev/i2cbus.hh b/src/dev/i2cbus.hh index 318950b39..3ebfa308b 100644 --- a/src/dev/i2cbus.hh +++ b/src/dev/i2cbus.hh @@ -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 diff --git a/src/dev/i8254xGBe.cc b/src/dev/i8254xGBe.cc index 213ad580a..0ff52bda0 100644 --- a/src/dev/i8254xGBe.cc +++ b/src/dev/i8254xGBe.cc @@ -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 §ion) +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 §ion) 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 §ion) 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 §ion) +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 §ion) +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 §ion) +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 §ion) 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 §ion) 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 * diff --git a/src/dev/i8254xGBe.hh b/src/dev/i8254xGBe.hh index 27439740d..d353c1d83 100644 --- a/src/dev/i8254xGBe.hh +++ b/src/dev/i8254xGBe.hh @@ -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 §ion); + + 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 §ion); + 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 §ion); - + 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 §ion); + void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; unsigned int drain(DrainManager *dm); void drainResume(); diff --git a/src/dev/i8254xGBe_defs.hh b/src/dev/i8254xGBe_defs.hh index 3b45f6498..92257aea7 100644 --- a/src/dev/i8254xGBe_defs.hh +++ b/src/dev/i8254xGBe_defs.hh @@ -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 §ion) + 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 §ion) + 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); } }; diff --git a/src/dev/ide_ctrl.cc b/src/dev/ide_ctrl.cc index d931fab2b..3e6086265 100644 --- a/src/dev/ide_ctrl.cc +++ b/src/dev/ide_ctrl.cc @@ -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 §ion) +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 §ion) } void -IdeController::Channel::unserialize(const std::string &base, Checkpoint *cp, - const std::string §ion) +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); } diff --git a/src/dev/ide_ctrl.hh b/src/dev/ide_ctrl.hh index 414e31087..7917432e4 100644 --- a/src/dev/ide_ctrl.hh +++ b/src/dev/ide_ctrl.hh @@ -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 §ion); + 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 §ion); + void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; }; #endif // __IDE_CTRL_HH_ diff --git a/src/dev/ide_disk.cc b/src/dev/ide_disk.cc index 4bf1a13c8..bbdee8e51 100644 --- a/src/dev/ide_disk.cc +++ b/src/dev/ide_disk.cc @@ -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 §ion) +IdeDisk::unserialize(CheckpointIn &cp) { // Reschedule events that were outstanding // these are all mutually exclusive diff --git a/src/dev/ide_disk.hh b/src/dev/ide_disk.hh index 6ccca985e..79e931a29 100644 --- a/src/dev/ide_disk.hh +++ b/src/dev/ide_disk.hh @@ -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 §ion); + void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; }; diff --git a/src/dev/intel_8254_timer.cc b/src/dev/intel_8254_timer.cc index 63bb6e8af..75600fb72 100644 --- a/src/dev/intel_8254_timer.cc +++ b/src/dev/intel_8254_timer.cc @@ -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 §ion) +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 §ion) +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; } diff --git a/src/dev/intel_8254_timer.hh b/src/dev/intel_8254_timer.hh index b2fd949f2..86b91620d 100644 --- a/src/dev/intel_8254_timer.hh +++ b/src/dev/intel_8254_timer.hh @@ -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 §ion); + 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 §ion); + void unserialize(const std::string &base, CheckpointIn &cp); /** Start ticking */ void startup(); diff --git a/src/dev/mc146818.cc b/src/dev/mc146818.cc index b5467f8cc..02c302bae 100644 --- a/src/dev/mc146818.cc +++ b/src/dev/mc146818.cc @@ -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 §ion) +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; // diff --git a/src/dev/mc146818.hh b/src/dev/mc146818.hh index 936f597d0..e19040ec3 100644 --- a/src/dev/mc146818.hh +++ b/src/dev/mc146818.hh @@ -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 §ion); + void unserialize(const std::string &base, CheckpointIn &cp); }; #endif // __DEV_MC146818_HH__ diff --git a/src/dev/mips/malta.cc b/src/dev/mips/malta.cc index 277633c6b..0c37e2713 100755 --- a/src/dev/mips/malta.cc +++ b/src/dev/mips/malta.cc @@ -91,13 +91,13 @@ Malta::pciToDma(Addr pciAddr) const } void -Malta::serialize(std::ostream &os) +Malta::serialize(CheckpointOut &cp) const { SERIALIZE_ARRAY(intr_sum_type, Malta::Max_CPUs); } void -Malta::unserialize(Checkpoint *cp, const std::string §ion) +Malta::unserialize(CheckpointIn &cp) { UNSERIALIZE_ARRAY(intr_sum_type, Malta::Max_CPUs); } diff --git a/src/dev/mips/malta.hh b/src/dev/mips/malta.hh index e612fb295..c5ee92e3d 100755 --- a/src/dev/mips/malta.hh +++ b/src/dev/mips/malta.hh @@ -135,18 +135,8 @@ class Malta : public Platform M5_DUMMY_RETURN } - /** - * Serialize this object to the given output stream. - * @param os The stream to serialize to. - */ - virtual void serialize(std::ostream &os); - - /** - * Reconstruct the state of this object from a checkpoint. - * @param cp The checkpoint use. - * @param section The section name of this object - */ - virtual void unserialize(Checkpoint *cp, const std::string §ion); + void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; }; #endif // __DEV_MALTA_HH__ diff --git a/src/dev/mips/malta_cchip.cc b/src/dev/mips/malta_cchip.cc index dc5211122..34f79b65b 100755 --- a/src/dev/mips/malta_cchip.cc +++ b/src/dev/mips/malta_cchip.cc @@ -501,7 +501,7 @@ MaltaCChip::clearIntr(uint32_t interrupt) void -MaltaCChip::serialize(std::ostream &os) +MaltaCChip::serialize(CheckpointOut &cp) const { // SERIALIZE_ARRAY(dim, Malta::Max_CPUs); //SERIALIZE_ARRAY(dir, Malta::Max_CPUs); @@ -511,7 +511,7 @@ MaltaCChip::serialize(std::ostream &os) } void -MaltaCChip::unserialize(Checkpoint *cp, const std::string §ion) +MaltaCChip::unserialize(CheckpointIn &cp) { //UNSERIALIZE_ARRAY(dim, Malta::Max_CPUs); //UNSERIALIZE_ARRAY(dir, Malta::Max_CPUs); diff --git a/src/dev/mips/malta_cchip.hh b/src/dev/mips/malta_cchip.hh index 9a17f632f..707cd1048 100755 --- a/src/dev/mips/malta_cchip.hh +++ b/src/dev/mips/malta_cchip.hh @@ -133,20 +133,8 @@ class MaltaCChip : public BasicPioDevice */ void reqIPI(uint64_t ipreq); - - /** - * Serialize this object to the given output stream. - * @param os The stream to serialize to. - */ - virtual void serialize(std::ostream &os); - - /** - * Reconstruct the state of this object from a checkpoint. - * @param cp The checkpoint use. - * @param section The section name of this object - */ - virtual void unserialize(Checkpoint *cp, const std::string §ion); - + void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; }; #endif // __MALTA_CCHIP_HH__ diff --git a/src/dev/mips/malta_io.cc b/src/dev/mips/malta_io.cc index d79e43260..bd3791163 100755 --- a/src/dev/mips/malta_io.cc +++ b/src/dev/mips/malta_io.cc @@ -111,7 +111,7 @@ MaltaIO::clearIntr(uint8_t interrupt) } void -MaltaIO::serialize(ostream &os) +MaltaIO::serialize(CheckpointOut &cp) const { SERIALIZE_SCALAR(timerData); SERIALIZE_SCALAR(mask1); @@ -122,12 +122,12 @@ MaltaIO::serialize(ostream &os) SERIALIZE_SCALAR(picInterrupting); // Serialize the timers - pitimer.serialize("pitimer", os); - rtc.serialize("rtc", os); + pitimer.serialize("pitimer", cp); + rtc.serialize("rtc", cp); } void -MaltaIO::unserialize(Checkpoint *cp, const string §ion) +MaltaIO::unserialize(CheckpointIn &cp) { UNSERIALIZE_SCALAR(timerData); UNSERIALIZE_SCALAR(mask1); @@ -138,8 +138,8 @@ MaltaIO::unserialize(Checkpoint *cp, const string §ion) UNSERIALIZE_SCALAR(picInterrupting); // Unserialize the timers - pitimer.unserialize("pitimer", cp, section); - rtc.unserialize("rtc", cp, section); + pitimer.unserialize("pitimer", cp); + rtc.unserialize("rtc", cp); } void diff --git a/src/dev/mips/malta_io.hh b/src/dev/mips/malta_io.hh index dd035aea2..bea6733fc 100755 --- a/src/dev/mips/malta_io.hh +++ b/src/dev/mips/malta_io.hh @@ -130,18 +130,8 @@ class MaltaIO : public BasicPioDevice /** Clear an Interrupt to the CPU */ void clearIntr(uint8_t interrupt); - /** - * Serialize this object to the given output stream. - * @param os The stream to serialize to. - */ - virtual void serialize(std::ostream &os); - - /** - * Reconstruct the state of this object from a checkpoint. - * @param cp The checkpoint use. - * @param section The section name of this object - */ - virtual void unserialize(Checkpoint *cp, const std::string §ion); + void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; /** * Start running. diff --git a/src/dev/mips/malta_pchip.cc b/src/dev/mips/malta_pchip.cc index bee61fddd..d0ae3daaa 100755 --- a/src/dev/mips/malta_pchip.cc +++ b/src/dev/mips/malta_pchip.cc @@ -312,7 +312,7 @@ MaltaPChip::calcConfigAddr(int bus, int dev, int func) void -MaltaPChip::serialize(std::ostream &os) +MaltaPChip::serialize(CheckpointOut &cp) const { SERIALIZE_SCALAR(pctl); SERIALIZE_ARRAY(wsba, 4); @@ -321,7 +321,7 @@ MaltaPChip::serialize(std::ostream &os) } void -MaltaPChip::unserialize(Checkpoint *cp, const std::string §ion) +MaltaPChip::unserialize(CheckpointIn &cp) { UNSERIALIZE_SCALAR(pctl); UNSERIALIZE_ARRAY(wsba, 4); diff --git a/src/dev/mips/malta_pchip.hh b/src/dev/mips/malta_pchip.hh index a6145515a..368faf9c5 100755 --- a/src/dev/mips/malta_pchip.hh +++ b/src/dev/mips/malta_pchip.hh @@ -88,18 +88,8 @@ class MaltaPChip : public BasicPioDevice virtual Tick read(PacketPtr pkt); virtual Tick write(PacketPtr pkt); - /** - * Serialize this object to the given output stream. - * @param os The stream to serialize to. - */ - virtual void serialize(std::ostream &os); - - /** - * Reconstruct the state of this object from a checkpoint. - * @param cp The checkpoint use. - * @param section The section name of this object - */ - virtual void unserialize(Checkpoint *cp, const std::string §ion); + void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; }; #endif // __TSUNAMI_PCHIP_HH__ diff --git a/src/dev/ns_gige.cc b/src/dev/ns_gige.cc index d87975759..c525f6359 100644 --- a/src/dev/ns_gige.cc +++ b/src/dev/ns_gige.cc @@ -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 §ion) +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 §ion) /* * 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 §ion) 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 §ion) 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; diff --git a/src/dev/ns_gige.hh b/src/dev/ns_gige.hh index 6d5068a2b..f8e9be853 100644 --- a/src/dev/ns_gige.hh +++ b/src/dev/ns_gige.hh @@ -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 §ion); + void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; void drainResume(); }; diff --git a/src/dev/pcidev.cc b/src/dev/pcidev.cc index 40be9716d..581ae2ebd 100644 --- a/src/dev/pcidev.cc +++ b/src/dev/pcidev.cc @@ -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 §ion) +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 §ion) // 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 §ion) 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(); } diff --git a/src/dev/pcidev.hh b/src/dev/pcidev.hh index 1c29293a6..4f997932b 100644 --- a/src/dev/pcidev.hh +++ b/src/dev/pcidev.hh @@ -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 §ion); + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; virtual unsigned int drain(DrainManager *dm); diff --git a/src/dev/pktfifo.cc b/src/dev/pktfifo.cc index efd8b083d..fb2564b71 100644 --- a/src/dev/pktfifo.cc +++ b/src/dev/pktfifo.cc @@ -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 §ion) +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 §ion) +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); } } diff --git a/src/dev/pktfifo.hh b/src/dev/pktfifo.hh index b548627e0..95d46fc76 100644 --- a/src/dev/pktfifo.hh +++ b/src/dev/pktfifo.hh @@ -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 §ion); + 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 §ion); + void serialize(const std::string &base, CheckpointOut &cp) const; + void unserialize(const std::string &base, CheckpointIn &cp); }; #endif // __DEV_PKTFIFO_HH__ diff --git a/src/dev/sinic.cc b/src/dev/sinic.cc index a5608fb36..d5a05b319 100644 --- a/src/dev/sinic.cc +++ b/src/dev/sinic.cc @@ -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 §ion) +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 §ion) } 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 §ion) +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 §ion) 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 §ion) 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 §ion) 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 §ion) 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 §ion) 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 §ion) 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); } /* diff --git a/src/dev/sinic.hh b/src/dev/sinic.hh index 58f9e7253..ac7af34af 100644 --- a/src/dev/sinic.hh +++ b/src/dev/sinic.hh @@ -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 §ion); + 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 §ion); + void serializeOld(CheckpointOut &cp) M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; public: Device(const Params *p); diff --git a/src/dev/sparc/dtod.cc b/src/dev/sparc/dtod.cc index 3853abb16..5b74bbcb7 100644 --- a/src/dev/sparc/dtod.cc +++ b/src/dev/sparc/dtod.cc @@ -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 §ion) +DumbTOD::unserialize(CheckpointIn &cp) { UNSERIALIZE_SCALAR(todTime); } diff --git a/src/dev/sparc/dtod.hh b/src/dev/sparc/dtod.hh index a5b2dfaff..a7b451364 100644 --- a/src/dev/sparc/dtod.hh +++ b/src/dev/sparc/dtod.hh @@ -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 §ion); - - + void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; }; #endif // __DEV_BADDEV_HH__ diff --git a/src/dev/sparc/iob.cc b/src/dev/sparc/iob.cc index c71edd9f0..bee0323c8 100644 --- a/src/dev/sparc/iob.cc +++ b/src/dev/sparc/iob.cc @@ -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 §ion) +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); }; } diff --git a/src/dev/sparc/iob.hh b/src/dev/sparc/iob.hh index fc5e61092..033ee3867 100644 --- a/src/dev/sparc/iob.hh +++ b/src/dev/sparc/iob.hh @@ -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 §ion); - + void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; }; #endif //__DEV_SPARC_IOB_HH__ diff --git a/src/dev/sparc/mm_disk.cc b/src/dev/sparc/mm_disk.cc index 0a6d14445..5fe9157bc 100644 --- a/src/dev/sparc/mm_disk.cc +++ b/src/dev/sparc/mm_disk.cc @@ -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 diff --git a/src/dev/sparc/mm_disk.hh b/src/dev/sparc/mm_disk.hh index d14e1d4a4..2de3cac7d 100644 --- a/src/dev/sparc/mm_disk.hh +++ b/src/dev/sparc/mm_disk.hh @@ -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__ diff --git a/src/dev/uart8250.cc b/src/dev/uart8250.cc index e840d2a56..a9446e6d5 100644 --- a/src/dev/uart8250.cc +++ b/src/dev/uart8250.cc @@ -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 §ion) +Uart8250::unserialize(CheckpointIn &cp) { UNSERIALIZE_SCALAR(status); UNSERIALIZE_SCALAR(IER); diff --git a/src/dev/uart8250.hh b/src/dev/uart8250.hh index 7d577954c..6b255594a 100644 --- a/src/dev/uart8250.hh +++ b/src/dev/uart8250.hh @@ -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 §ion); - + void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; }; #endif // __TSUNAMI_UART_HH__ diff --git a/src/dev/virtio/base.cc b/src/dev/virtio/base.cc index a65fe7fa4..ad97de99c 100644 --- a/src/dev/virtio/base.cc +++ b/src/dev/virtio/base.cc @@ -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 §ion) +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 §ion) +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 diff --git a/src/dev/virtio/base.hh b/src/dev/virtio/base.hh index fe1685767..de68f92e1 100644 --- a/src/dev/virtio/base.hh +++ b/src/dev/virtio/base.hh @@ -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 §ion); - /** @} */ + 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 §ion); - + void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; /** @} */ diff --git a/src/dev/virtio/fs9p.cc b/src/dev/virtio/fs9p.cc index 4861821d7..336757bb9 100644 --- a/src/dev/virtio/fs9p.cc +++ b/src/dev/virtio/fs9p.cc @@ -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 §ion) +VirtIO9PProxy::unserialize(CheckpointIn &cp) { fatal("Can't checkpoint a system with a VirtIO 9p proxy!\n"); } diff --git a/src/dev/virtio/fs9p.hh b/src/dev/virtio/fs9p.hh index 2cbdbc9eb..a7fb780aa 100644 --- a/src/dev/virtio/fs9p.hh +++ b/src/dev/virtio/fs9p.hh @@ -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 §ion); + 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); diff --git a/src/dev/x86/cmos.cc b/src/dev/x86/cmos.cc index 6a778b758..73cfe853e 100644 --- a/src/dev/x86/cmos.cc +++ b/src/dev/x86/cmos.cc @@ -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 §ion) +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 * diff --git a/src/dev/x86/cmos.hh b/src/dev/x86/cmos.hh index fa5865c0a..f0234da54 100644 --- a/src/dev/x86/cmos.hh +++ b/src/dev/x86/cmos.hh @@ -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 §ion); + void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; }; } // namespace X86ISA diff --git a/src/dev/x86/i8042.cc b/src/dev/x86/i8042.cc index a0a7c35ec..03b12dc14 100644 --- a/src/dev/x86/i8042.cc +++ b/src/dev/x86/i8042.cc @@ -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 §ion) +X86ISA::I8042::unserialize(CheckpointIn &cp) { uint8_t statusRegData; uint8_t commandByteData; @@ -490,38 +490,37 @@ X86ISA::I8042::unserialize(Checkpoint *cp, const std::string §ion) 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 §ion) +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 §ion) +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; } diff --git a/src/dev/x86/i8042.hh b/src/dev/x86/i8042.hh index 791922142..9d2548857 100644 --- a/src/dev/x86/i8042.hh +++ b/src/dev/x86/i8042.hh @@ -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 §ion); + 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 §ion); + 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 §ion); + void serializeOld(CheckpointOut &cp) M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; }; } // namespace X86ISA diff --git a/src/dev/x86/i82094aa.cc b/src/dev/x86/i82094aa.cc index 12697ce62..44fa29154 100644 --- a/src/dev/x86/i82094aa.cc +++ b/src/dev/x86/i82094aa.cc @@ -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 §ion) +X86ISA::I82094AA::unserialize(CheckpointIn &cp) { uint64_t redirTableArray[TableSize]; UNSERIALIZE_SCALAR(regSel); diff --git a/src/dev/x86/i82094aa.hh b/src/dev/x86/i82094aa.hh index 4fe927ae4..afa597e65 100644 --- a/src/dev/x86/i82094aa.hh +++ b/src/dev/x86/i82094aa.hh @@ -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 §ion); + void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; }; } // namespace X86ISA diff --git a/src/dev/x86/i8237.cc b/src/dev/x86/i8237.cc index a43c1ec91..b16f78883 100644 --- a/src/dev/x86/i8237.cc +++ b/src/dev/x86/i8237.cc @@ -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 §ion) +X86ISA::I8237::unserialize(CheckpointIn &cp) { UNSERIALIZE_SCALAR(maskReg); } diff --git a/src/dev/x86/i8237.hh b/src/dev/x86/i8237.hh index b1b11091b..481983b8e 100644 --- a/src/dev/x86/i8237.hh +++ b/src/dev/x86/i8237.hh @@ -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 §ion); + void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; }; } // namespace X86ISA diff --git a/src/dev/x86/i8254.cc b/src/dev/x86/i8254.cc index b80952237..f784a0107 100644 --- a/src/dev/x86/i8254.cc +++ b/src/dev/x86/i8254.cc @@ -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 §ion) +X86ISA::I8254::unserialize(CheckpointIn &cp) { - pit.unserialize("pit", cp, section); + pit.unserialize("pit", cp); } void diff --git a/src/dev/x86/i8254.hh b/src/dev/x86/i8254.hh index 76521e73e..c4f04bd42 100644 --- a/src/dev/x86/i8254.hh +++ b/src/dev/x86/i8254.hh @@ -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 §ion); + void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; + virtual void startup(); }; diff --git a/src/dev/x86/i8259.cc b/src/dev/x86/i8259.cc index d599ecef3..84f2d1321 100644 --- a/src/dev/x86/i8259.cc +++ b/src/dev/x86/i8259.cc @@ -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 §ion) +X86ISA::I8259::unserialize(CheckpointIn &cp) { UNSERIALIZE_ARRAY(pinStates, NumLines); UNSERIALIZE_ENUM(mode); diff --git a/src/dev/x86/i8259.hh b/src/dev/x86/i8259.hh index 2d6080cc3..567ad7a32 100644 --- a/src/dev/x86/i8259.hh +++ b/src/dev/x86/i8259.hh @@ -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 §ion); + void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; }; } // namespace X86ISA diff --git a/src/dev/x86/speaker.cc b/src/dev/x86/speaker.cc index 70f52dd1a..235860815 100644 --- a/src/dev/x86/speaker.cc +++ b/src/dev/x86/speaker.cc @@ -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 §ion) +X86ISA::Speaker::unserialize(CheckpointIn &cp) { uint8_t controlValData; UNSERIALIZE_SCALAR(controlValData); diff --git a/src/dev/x86/speaker.hh b/src/dev/x86/speaker.hh index 22fc03e1c..3c879060f 100644 --- a/src/dev/x86/speaker.hh +++ b/src/dev/x86/speaker.hh @@ -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 §ion); - + void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; }; } // namespace X86ISA diff --git a/src/kern/kernel_stats.cc b/src/kern/kernel_stats.cc index 96e219bd4..f0f010748 100644 --- a/src/kern/kernel_stats.cc +++ b/src/kern/kernel_stats.cc @@ -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 §ion) +Statistics::unserialize(CheckpointIn &cp) { UNSERIALIZE_SCALAR(iplLast); UNSERIALIZE_SCALAR(iplLastTick); diff --git a/src/kern/kernel_stats.hh b/src/kern/kernel_stats.hh index 0c8ed248a..8cc1ca84e 100644 --- a/src/kern/kernel_stats.hh +++ b/src/kern/kernel_stats.hh @@ -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 §ion); + void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; }; } // namespace Kernel diff --git a/src/mem/cache/cache.hh b/src/mem/cache/cache.hh index 4c70d3a40..27d4b9ee1 100644 --- a/src/mem/cache/cache.hh +++ b/src/mem/cache/cache.hh @@ -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 §ion); + void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; }; /** diff --git a/src/mem/cache/cache_impl.hh b/src/mem/cache/cache_impl.hh index 94a3ad4ee..03593554a 100644 --- a/src/mem/cache/cache_impl.hh +++ b/src/mem/cache/cache_impl.hh @@ -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 §ion) +Cache::unserialize(CheckpointIn &cp) { bool bad_checkpoint; UNSERIALIZE_SCALAR(bad_checkpoint); diff --git a/src/mem/multi_level_page_table.hh b/src/mem/multi_level_page_table.hh index 232121c21..f622bbbed 100644 --- a/src/mem/multi_level_page_table.hh +++ b/src/mem/multi_level_page_table.hh @@ -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 §ion); + void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; }; #endif // __MEM_MULTI_LEVEL_PAGE_TABLE_HH__ diff --git a/src/mem/multi_level_page_table_impl.hh b/src/mem/multi_level_page_table_impl.hh index 6714a170e..610240562 100644 --- a/src/mem/multi_level_page_table_impl.hh +++ b/src/mem/multi_level_page_table_impl.hh @@ -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 §ion) +MultiLevelPageTable<ISAOps>::unserialize(CheckpointIn &cp) { - paramIn(cp, section, "ptable.pointer", basePtr); + paramIn(cp, "ptable.pointer", basePtr); } diff --git a/src/mem/page_table.cc b/src/mem/page_table.cc index d3af09e1e..6875d6f9b 100644 --- a/src/mem/page_table.cc +++ b/src/mem/page_table.cc @@ -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 §ion) +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; } } diff --git a/src/mem/page_table.hh b/src/mem/page_table.hh index 22b5c61eb..ddec104a7 100644 --- a/src/mem/page_table.hh +++ b/src/mem/page_table.hh @@ -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 §ion) = 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 §ion); + void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; }; /** diff --git a/src/mem/physical.cc b/src/mem/physical.cc index e6d682624..d757b8c5d 100644 --- a/src/mem/physical.cc +++ b/src/mem/physical.cc @@ -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"); diff --git a/src/mem/physical.hh b/src/mem/physical.hh index 0f53b1d9d..c577cd3ea 100644 --- a/src/mem/physical.hh +++ b/src/mem/physical.hh @@ -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); }; diff --git a/src/mem/ruby/system/System.cc b/src/mem/ruby/system/System.cc index 75ebc8caf..9d63643cc 100644 --- a/src/mem/ruby/system/System.cc +++ b/src/mem/ruby/system/System.cc @@ -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 §ion) +RubySystem::unserialize(CheckpointIn &cp) { uint8_t *uncompressed_trace = NULL; @@ -249,7 +249,7 @@ RubySystem::unserialize(Checkpoint *cp, const string §ion) 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); diff --git a/src/mem/ruby/system/System.hh b/src/mem/ruby/system/System.hh index 45e8aa8b4..a59ade398 100644 --- a/src/mem/ruby/system/System.hh +++ b/src/mem/ruby/system/System.hh @@ -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 §ion); + void serializeOld(CheckpointOut &cp) M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; void process(); void startup(); bool functionalRead(Packet *ptr); diff --git a/src/python/m5/SimObject.py b/src/python/m5/SimObject.py index 240b449df..4a509e57d 100644 --- a/src/python/m5/SimObject.py +++ b/src/python/m5/SimObject.py @@ -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(); diff --git a/src/python/swig/core.i b/src/python/swig/core.i index ed520e17a..862c0e37e 100644 --- a/src/python/swig/core.i +++ b/src/python/swig/core.i @@ -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; diff --git a/src/python/swig/pyobject.cc b/src/python/swig/pyobject.cc index 08b9ee69f..f90e456e2 100644 --- a/src/python/swig/pyobject.cc +++ b/src/python/swig/pyobject.cc @@ -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); } diff --git a/src/python/swig/pyobject.hh b/src/python/swig/pyobject.hh index a4f06555e..ea2948826 100644 --- a/src/python/swig/pyobject.hh +++ b/src/python/swig/pyobject.hh @@ -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); } diff --git a/src/sim/clock_domain.cc b/src/sim/clock_domain.cc index 8f45bba09..60c688b1a 100644 --- a/src/sim/clock_domain.cc +++ b/src/sim/clock_domain.cc @@ -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 §ion) +SrcClockDomain::unserialize(CheckpointIn &cp) { - ClockDomain::unserialize(cp, section); + ClockDomain::unserialize(cp); UNSERIALIZE_SCALAR(_perfLevel); } diff --git a/src/sim/clock_domain.hh b/src/sim/clock_domain.hh index edf2340ad..c4242af55 100644 --- a/src/sim/clock_domain.hh +++ b/src/sim/clock_domain.hh @@ -238,8 +238,9 @@ class SrcClockDomain : public ClockDomain } void startup(); - void serialize(std::ostream &os); - void unserialize(Checkpoint *cp, const std::string §ion); + + void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; private: /** diff --git a/src/sim/cxx_manager.cc b/src/sim/cxx_manager.cc index 7f6a03398..6d4565dbc 100644 --- a/src/sim/cxx_manager.cc +++ b/src/sim/cxx_manager.cc @@ -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); diff --git a/src/sim/cxx_manager.hh b/src/sim/cxx_manager.hh index caa115f03..b2ba31214 100644 --- a/src/sim/cxx_manager.hh +++ b/src/sim/cxx_manager.hh @@ -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(); diff --git a/src/sim/dvfs_handler.cc b/src/sim/dvfs_handler.cc index f4fe760a2..f507897b3 100644 --- a/src/sim/dvfs_handler.cc +++ b/src/sim/dvfs_handler.cc @@ -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 §ion) +DVFSHandler::unserialize(CheckpointIn &cp) { bool temp = enableHandler; @@ -213,9 +212,9 @@ DVFSHandler::unserialize(Checkpoint *cp, const std::string §ion) 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]]; diff --git a/src/sim/dvfs_handler.hh b/src/sim/dvfs_handler.hh index a8b78d08b..6e495fff5 100644 --- a/src/sim/dvfs_handler.hh +++ b/src/sim/dvfs_handler.hh @@ -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 §ion); + void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; private: typedef std::map<DomainID, SrcClockDomain*> Domains; diff --git a/src/sim/eventq.cc b/src/sim/eventq.cc index 4fde79656..f75ada47c 100644 --- a/src/sim/eventq.cc +++ b/src/sim/eventq.cc @@ -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 §ion) +Event::unserialize(CheckpointIn &cp) { } void -Event::unserialize(Checkpoint *cp, const string §ion, EventQueue *eventq) +Event::unserializeEvent(CheckpointIn &cp, EventQueue *eventq) { if (scheduled()) eventq->deschedule(this); @@ -290,7 +290,7 @@ Event::unserialize(Checkpoint *cp, const string §ion, 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 §ion) +EventQueue::unserialize(CheckpointIn &cp) { int numEvents; UNSERIALIZE_SCALAR(numEvents); @@ -329,7 +326,7 @@ EventQueue::unserialize(Checkpoint *cp, const std::string §ion) 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); diff --git a/src/sim/eventq.hh b/src/sim/eventq.hh index f726a6dbd..b90e5d382 100644 --- a/src/sim/eventq.hh +++ b/src/sim/eventq.hh @@ -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 §ion); + 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 §ion, - 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 §ion); + void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; #endif virtual ~EventQueue() { } diff --git a/src/sim/process.cc b/src/sim/process.cc index 35f981d1e..a820b0632 100644 --- a/src/sim/process.cc +++ b/src/sim/process.cc @@ -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 §ion) +Process::FdMap::unserialize(CheckpointIn &cp) { UNSERIALIZE_SCALAR(fd); UNSERIALIZE_SCALAR(isPipe); @@ -510,7 +517,7 @@ Process::FdMap::unserialize(Checkpoint *cp, const std::string §ion) } 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 §ion) +Process::unserialize(CheckpointIn &cp) { UNSERIALIZE_SCALAR(brk_point); UNSERIALIZE_SCALAR(stack_base); @@ -543,9 +548,9 @@ Process::unserialize(Checkpoint *cp, const std::string §ion) 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); diff --git a/src/sim/process.hh b/src/sim/process.hh index 04ce00f67..c1499ccf7 100644 --- a/src/sim/process.hh +++ b/src/sim/process.hh @@ -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 §ion); + 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 §ion); + void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; }; // diff --git a/src/sim/root.cc b/src/sim/root.cc index 9bb8b4f05..1d58c3bbe 100644 --- a/src/sim/root.cc +++ b/src/sim/root.cc @@ -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 §ion) +Root::unserialize(CheckpointIn &cp) { uint64_t cpt_ver = 0; UNSERIALIZE_OPT_SCALAR(cpt_ver); diff --git a/src/sim/root.hh b/src/sim/root.hh index 6a7b5dc93..1c330e2c4 100644 --- a/src/sim/root.hh +++ b/src/sim/root.hh @@ -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 §ion); - + void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; }; #endif // __SIM_ROOT_HH__ diff --git a/src/sim/serialize.cc b/src/sim/serialize.cc index 99426b5a6..a7c1834cf 100644 --- a/src/sim/serialize.cc +++ b/src/sim/serialize.cc @@ -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 ¶m) +paramOut(CheckpointOut &os, const string &name, const T ¶m) { os << name << "="; showParam(os, param); @@ -175,7 +178,7 @@ paramOut(ostream &os, const string &name, const T ¶m) template <class T> void -arrayParamOut(ostream &os, const string &name, const vector<T> ¶m) +arrayParamOut(CheckpointOut &os, const string &name, const vector<T> ¶m) { typename vector<T>::size_type size = param.size(); os << name << "="; @@ -190,7 +193,7 @@ arrayParamOut(ostream &os, const string &name, const vector<T> ¶m) template <class T> void -arrayParamOut(ostream &os, const string &name, const list<T> ¶m) +arrayParamOut(CheckpointOut &os, const string &name, const list<T> ¶m) { typename list<T>::const_iterator it = param.begin(); @@ -208,20 +211,22 @@ arrayParamOut(ostream &os, const string &name, const list<T> ¶m) template <class T> void -paramIn(Checkpoint *cp, const string §ion, const string &name, T ¶m) +paramIn(CheckpointIn &cp, const string &name, T ¶m) { + const string §ion(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 §ion, const string &name, T ¶m) +optParamIn(CheckpointIn &cp, const string &name, T ¶m) { + const string §ion(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 §ion, const string &name, T ¶m) 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 §ion, const string &name, - T *param, unsigned size) +arrayParamIn(CheckpointIn &cp, const string &name, T *param, unsigned size) { + const string §ion(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 §ion, 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 §ion, const string &name, template <class T> void -arrayParamIn(Checkpoint *cp, const string §ion, - const string &name, vector<T> ¶m) +arrayParamIn(CheckpointIn &cp, const string &name, vector<T> ¶m) { + const string §ion(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 §ion, // 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 §ion, template <class T> void -arrayParamIn(Checkpoint *cp, const string §ion, - const string &name, list<T> ¶m) +arrayParamIn(CheckpointIn &cp, const string &name, list<T> ¶m) { + const string §ion(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 §ion, 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 §ion, void -objParamIn(Checkpoint *cp, const string §ion, - const string &name, SimObject * ¶m) +objParamIn(CheckpointIn &cp, const string &name, SimObject * ¶m) { - if (!cp->findObj(section, name, param)) { + const string §ion(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 ¶m); \ -template void \ -paramIn(Checkpoint *cp, const string §ion, \ - const string &name, type & param); \ -template bool \ -optParamIn(Checkpoint *cp, const string §ion, \ - 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 §ion, \ - const string &name, type *param, unsigned size); \ -template void \ -arrayParamOut(ostream &os, const string &name, \ - const vector<type> ¶m); \ -template void \ -arrayParamIn(Checkpoint *cp, const string §ion, \ - const string &name, vector<type> ¶m); \ -template void \ -arrayParamOut(ostream &os, const string &name, \ - const list<type> ¶m); \ -template void \ -arrayParamIn(Checkpoint *cp, const string §ion, \ - const string &name, list<type> ¶m); + template void \ + paramOut(CheckpointOut &os, const string &name, type const ¶m); \ + 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> ¶m); \ + template void \ + arrayParamIn(CheckpointIn &cp, const string &name, \ + vector<type> ¶m); \ + template void \ + arrayParamOut(CheckpointOut &os, const string &name, \ + const list<type> ¶m); \ + template void \ + arrayParamIn(CheckpointIn &cp, const string &name, \ + list<type> ¶m); 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 §ion); + 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 §ion) +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 §ion) +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 §ion) +SerializableClass::createObject(CheckpointIn &cp, const string §ion) { 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 §ion) return object; } +const std::string & +Serializable::currentSection() +{ + assert(!path.empty()); + + return path.top(); +} Serializable * -Serializable::create(Checkpoint *cp, const string §ion) +Serializable::create(CheckpointIn &cp, const string §ion) { 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 §ion, const string &entry, string &value) +CheckpointIn::find(const string §ion, const string &entry, string &value) { return db->find(section, entry, value); } bool -Checkpoint::findObj(const string §ion, const string &entry, +CheckpointIn::findObj(const string §ion, const string &entry, SimObject *&value) { string path; @@ -634,7 +676,7 @@ Checkpoint::findObj(const string §ion, const string &entry, bool -Checkpoint::sectionExists(const string §ion) +CheckpointIn::sectionExists(const string §ion) { return db->sectionExists(section); } diff --git a/src/sim/serialize.hh b/src/sim/serialize.hh index 2fb7cddd0..644ef4005 100644 --- a/src/sim/serialize.hh +++ b/src/sim/serialize.hh @@ -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" @@ -48,10 +62,13 @@ 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 ¶m); +void paramOut(CheckpointOut &cp, const std::string &name, const T ¶m); 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 §ion, - const std::string &name, T ¶m); +void paramIn(CheckpointIn &cp, const std::string &name, T ¶m); template <typename DataType, typename BitUnion> -void paramIn(Checkpoint *cp, const std::string §ion, - 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 §ion, - const std::string &name, T ¶m); +bool optParamIn(CheckpointIn &cp, const std::string &name, T ¶m); template <typename DataType, typename BitUnion> -bool optParamIn(Checkpoint *cp, const std::string §ion, - 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> ¶m); template <class T> -void arrayParamOut(std::ostream &os, const std::string &name, +void arrayParamOut(CheckpointOut &cp, const std::string &name, const std::list<T> ¶m); template <class T> -void arrayParamIn(Checkpoint *cp, const std::string §ion, - 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 §ion, - const std::string &name, std::vector<T> ¶m); +void arrayParamIn(CheckpointIn &cp, const std::string &name, + std::vector<T> ¶m); template <class T> -void arrayParamIn(Checkpoint *cp, const std::string §ion, - const std::string &name, std::list<T> ¶m); +void arrayParamIn(CheckpointIn &cp, const std::string &name, + std::list<T> ¶m); void -objParamIn(Checkpoint *cp, const std::string §ion, - const std::string &name, SimObject * ¶m); +objParamIn(CheckpointIn &cp, const std::string &name, SimObject * ¶m); 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 §ion); - - static Serializable *create(Checkpoint *cp, const std::string §ion); + /** + * 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 ¤tSection(); + + static Serializable *create(CheckpointIn &cp, const std::string §ion); 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 §ion); 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 §ion); }; @@ -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; diff --git a/src/sim/sim_events.cc b/src/sim/sim_events.cc index 5e47adca1..719a732ab 100644 --- a/src/sim/sim_events.cc +++ b/src/sim/sim_events.cc @@ -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 §ion) +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 §ion) } void -LocalSimLoopExitEvent::unserialize(Checkpoint *cp, const string §ion, - 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 §ion, } Serializable * -LocalSimLoopExitEvent::createForUnserialize(Checkpoint *cp, +LocalSimLoopExitEvent::createForUnserialize(CheckpointIn &cp, const string §ion) { return new LocalSimLoopExitEvent(); diff --git a/src/sim/sim_events.hh b/src/sim/sim_events.hh index 5be2609fd..8d5d5da7b 100644 --- a/src/sim/sim_events.hh +++ b/src/sim/sim_events.hh @@ -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 §ion); - virtual void unserialize(Checkpoint *cp, const std::string §ion, - 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 §ion); }; diff --git a/src/sim/sim_object.cc b/src/sim/sim_object.cc index a7be4ebd2..2c4ba48f6 100644 --- a/src/sim/sim_object.cc +++ b/src/sim/sim_object.cc @@ -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()); } } diff --git a/src/sim/sim_object.hh b/src/sim/sim_object.hh index 9bf95d07f..16237d051 100644 --- a/src/sim/sim_object.hh +++ b/src/sim/sim_object.hh @@ -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: diff --git a/src/sim/system.cc b/src/sim/system.cc index 2f2427769..f781377f7 100644 --- a/src/sim/system.cc +++ b/src/sim/system.cc @@ -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 §ion) +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 diff --git a/src/sim/system.hh b/src/sim/system.hh index 9ec349a47..b8114d0ca 100644 --- a/src/sim/system.hh +++ b/src/sim/system.hh @@ -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 §ion); + 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 §ion) {} + virtual void unserializeSymtab(CheckpointIn &cp) {} }; diff --git a/src/sim/ticked_object.cc b/src/sim/ticked_object.cc index ef6ee1c20..ecdb87827 100644 --- a/src/sim/ticked_object.cc +++ b/src/sim/ticked_object.cc @@ -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 §ion) +Ticked::unserialize(CheckpointIn &cp) { uint64_t lastStoppedUint = 0; @@ -90,7 +90,7 @@ Ticked::unserialize(Checkpoint *cp, const std::string §ion) * 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 §ion) +TickedObject::unserialize(CheckpointIn &cp) { - Ticked::unserialize(cp, section); - ClockedObject::unserialize(cp, section); + Ticked::unserialize(cp); + ClockedObject::unserialize(cp); } diff --git a/src/sim/ticked_object.hh b/src/sim/ticked_object.hh index ee143e0df..97750873f 100644 --- a/src/sim/ticked_object.hh +++ b/src/sim/ticked_object.hh @@ -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 §ion); + 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 §ion); + void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; }; #endif /* __SIM_TICKED_OBJECT_HH__ */ diff --git a/src/sim/voltage_domain.cc b/src/sim/voltage_domain.cc index 2b16d04b9..b82efda33 100644 --- a/src/sim/voltage_domain.cc +++ b/src/sim/voltage_domain.cc @@ -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 §ion) { +VoltageDomain::unserialize(CheckpointIn &cp) +{ UNSERIALIZE_SCALAR(_perfLevel); perfLevel(_perfLevel); } diff --git a/src/sim/voltage_domain.hh b/src/sim/voltage_domain.hh index ab96abad8..596daba40 100644 --- a/src/sim/voltage_domain.hh +++ b/src/sim/voltage_domain.hh @@ -128,8 +128,9 @@ class VoltageDomain : public SimObject void regStats(); - void serialize(std::ostream &os); - void unserialize(Checkpoint *cp, const std::string §ion); + void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; + void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; + private: typedef std::vector<double> Voltages; /** |