}
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);
}
void
-ISA::serialize(std::ostream &os)
+ISA::serialize(CheckpointOut &cp) const
{
SERIALIZE_SCALAR(fpcr);
SERIALIZE_SCALAR(uniq);
}
void
-ISA::unserialize(Checkpoint *cp, const std::string §ion)
+ISA::unserialize(CheckpointIn &cp)
{
UNSERIALIZE_SCALAR(fpcr);
UNSERIALIZE_SCALAR(uniq);
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
}
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);
}
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);
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
namespace AlphaISA {
void
-TlbEntry::serialize(std::ostream &os)
+TlbEntry::serialize(CheckpointOut &cp) const
{
SERIALIZE_SCALAR(tag);
SERIALIZE_SCALAR(ppn);
}
void
-TlbEntry::unserialize(Checkpoint *cp, const std::string §ion)
+TlbEntry::unserialize(CheckpointIn &cp)
{
UNSERIALIZE_SCALAR(tag);
UNSERIALIZE_SCALAR(ppn);
};
// ITB/DTB table entry
-struct TlbEntry
+struct TlbEntry : public Serializable
{
Addr tag; // virtual page number tag
Addr ppn; // physical page number
}
TlbEntry()
- {}
+ : tag(0), ppn(0), xre(0), xwe(0), asn(0),
+ asma(false), fonr(0), fonw(0), valid(0)
+ {
+ }
void
updateVaddr(Addr new_vaddr)
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
void
-AlphaLiveProcess::loadState(Checkpoint *cp)
+AlphaLiveProcess::loadState(CheckpointIn &cp)
{
LiveProcess::loadState(cp);
// need to set up ASN after unserialization since M5_pid value may
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);
}
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 *
/**
* 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()
*/
* 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"
#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
TLB::flushAll()
{
DPRINTF(TLB, "flushAll\n");
- memset(table, 0, sizeof(TlbEntry) * size);
+ std::fill(table.begin(), table.end(), TlbEntry());
flushCache();
lookupTable.clear();
nlu = 0;
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));
}
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:
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);
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];
}
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);
return flat_idx;
}
- void serialize(std::ostream &os)
+ void serialize(CheckpointOut &cp) const
{
DPRINTF(Checkpoint, "Serializing Arm Misc Registers\n");
SERIALIZE_ARRAY(miscRegs, NumMiscRegs);
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);
}
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");
}
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
// 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");
}
};
// ITB/DTB table entry
-struct TlbEntry
+struct TlbEntry : public Serializable
{
public:
enum class MemoryType : std::uint8_t {
}
void
- serialize(std::ostream &os)
+ serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE
{
SERIALIZE_SCALAR(longDescFormat);
SERIALIZE_SCALAR(pfn);
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);
UNSERIALIZE_SCALAR(ap);
UNSERIALIZE_SCALAR(hap);
uint8_t domain_;
- paramIn(cp, section, "domain", domain_);
+ paramIn(cp, "domain", domain_);
domain = static_cast<DomainType>(domain_);
}
}
void
-PMU::serialize(std::ostream &os)
+PMU::serialize(CheckpointOut &cp) const
{
DPRINTF(Checkpoint, "Serializing Arm PMU\n");
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");
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);
}
void
-PMU::CounterState::unserialize(Checkpoint *cp, const std::string §ion)
+PMU::CounterState::unserialize(CheckpointIn &cp)
{
UNSERIALIZE_SCALAR(eventId);
UNSERIALIZE_SCALAR(value);
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;
};
/** State of a counter within the PMU. */
- struct CounterState {
+ struct CounterState : public Serializable {
CounterState()
: eventId(0), filter(0), value(0), enabled(false),
overflow64(false) {
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.
}
void
-TLB::serialize(ostream &os)
+TLB::serialize(CheckpointOut &cp) const
{
DPRINTF(Checkpoint, "Serializing Arm TLB\n");
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");
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
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();
}
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);
}
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);
{
// The guaranteed interface.
-class PCStateBase
+class PCStateBase : public Serializable
{
protected:
Addr _pc;
}
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);
}
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);
}
}
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);
}
};
}
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);
}
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");
}
{
void
-PTE::serialize(std::ostream &os)
+PTE::serialize(CheckpointOut &cp) const
{
SERIALIZE_SCALAR(Mask);
SERIALIZE_SCALAR(VPN);
}
void
-PTE::unserialize(Checkpoint *cp, const std::string §ion)
+PTE::unserialize(CheckpointIn &cp)
{
UNSERIALIZE_SCALAR(Mask);
UNSERIALIZE_SCALAR(VPN);
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
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);
}
}
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));
}
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();
{
void
-PTE::serialize(std::ostream &os)
+PTE::serialize(CheckpointOut &cp) const
{
SERIALIZE_SCALAR(Mask);
SERIALIZE_SCALAR(VPN);
}
void
-PTE::unserialize(Checkpoint *cp, const std::string §ion)
+PTE::unserialize(CheckpointIn &cp)
{
UNSERIALIZE_SCALAR(Mask);
UNSERIALIZE_SCALAR(VPN);
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
}
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));
}
}
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);
}
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();
};
}
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);
}
void
-ISA::serialize(std::ostream &os)
+ISA::serialize(CheckpointOut &cp) const
{
SERIALIZE_SCALAR(asi);
SERIALIZE_SCALAR(tick);
}
void
-ISA::unserialize(Checkpoint *cp, const std::string §ion)
+ISA::unserialize(CheckpointIn &cp)
{
UNSERIALIZE_SCALAR(asi);
UNSERIALIZE_SCALAR(tick);
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) {}
{
void
-TlbEntry::serialize(std::ostream &os)
+TlbEntry::serialize(CheckpointOut &cp) const
{
SERIALIZE_SCALAR(range.va);
SERIALIZE_SCALAR(range.size);
void
-TlbEntry::unserialize(Checkpoint *cp, const std::string §ion)
+TlbEntry::unserialize(CheckpointIn &cp)
{
UNSERIALIZE_SCALAR(range.va);
UNSERIALIZE_SCALAR(range.size);
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
}
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 *
* 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;
}
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);
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);
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]);
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);
}
void
-X86ISA::Interrupts::serialize(std::ostream &os)
+X86ISA::Interrupts::serialize(CheckpointOut &cp) const
{
SERIALIZE_ARRAY(regs, NUM_APIC_REGS);
SERIALIZE_SCALAR(pendingSmi);
}
void
-X86ISA::Interrupts::unserialize(Checkpoint *cp, const std::string §ion)
+X86ISA::Interrupts::unserialize(CheckpointIn &cp)
{
UNSERIALIZE_ARRAY(regs, NUM_APIC_REGS);
UNSERIALIZE_SCALAR(pendingSmi);
/*
* 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
}
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],
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
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);
}
void
-TlbEntry::unserialize(Checkpoint *cp, const std::string §ion)
+TlbEntry::unserialize(CheckpointIn &cp)
{
UNSERIALIZE_SCALAR(paddr);
UNSERIALIZE_SCALAR(vaddr);
EndBitUnion(PageTableEntry)
- struct TlbEntry
+ struct TlbEntry : public Serializable
{
// The base of the physical page.
Addr paddr;
TlbEntry(Addr asn, Addr _vaddr, Addr _paddr,
bool uncacheable, bool read_only);
- TlbEntry() {}
+ TlbEntry();
void
updateVaddr(Addr new_vaddr)
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
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;
}
void
-TLB::serialize(std::ostream &os)
+TLB::serialize(CheckpointOut &cp) const
{
// Only store the entries in use.
uint32_t _size = size - freeList.size();
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;
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);
}
protected:
uint32_t size;
- TlbEntry * tlb;
+ std::vector<TlbEntry> tlb;
EntryList freeList;
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
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;
}
}
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);
}
};
// 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__
void
-CPA::serialize(std::ostream &os)
+CPA::serialize(CheckpointOut &cp) const
{
SERIALIZE_SCALAR(numSm);
arrayParamOut(os, "qSize", qSize);
arrayParamOut(os, "qBytes", qBytes);
- std::list<AnnDataPtr>::iterator ai;
-
SCache::iterator i;
int x = 0, y = 0;
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;
}
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;
}
}
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;
}
}
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;
}
}
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);
}
}
// 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;
}
// 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;
}
//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);
}
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);
}
}
void
-CPA::AnnotateData::serialize(std::ostream &os)
+CPA::AnnotateData::serialize(CheckpointOut &cp) const
{
SERIALIZE_SCALAR(time);
SERIALIZE_SCALAR(data);
}
void
-CPA::AnnotateData::unserialize(Checkpoint *cp, const std::string §ion)
+CPA::AnnotateData::unserialize(CheckpointIn &cp)
{
UNSERIALIZE_SCALAR(time);
UNSERIALIZE_SCALAR(data);
}
/* struct that is written to the annotation output file */
- struct AnnotateData {
+ struct AnnotateData : public Serializable {
Tick time;
uint32_t data;
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;
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
}
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);
}
}
#include <string>
#include "base/types.hh"
+#include "sim/serialize.hh"
-class Checkpoint;
class SymbolTable
{
public:
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
}
void
-PollEvent::serialize(ostream &os)
+PollEvent::serialize(CheckpointOut &cp) const
{
SERIALIZE_SCALAR(pfd.fd);
SERIALIZE_SCALAR(pfd.events);
}
void
-PollEvent::unserialize(Checkpoint *cp, const std::string §ion)
+PollEvent::unserialize(CheckpointIn &cp)
{
UNSERIALIZE_SCALAR(pfd.fd);
UNSERIALIZE_SCALAR(pfd.events);
class Checkpoint;
class PollQueue;
-class PollEvent
+class PollEvent : public Serializable
{
private:
friend class PollQueue;
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
}
void
-Random::serialize(std::ostream &os)
+Random::serialize(CheckpointOut &cp) const
{
panic("Currently not used anywhere.\n");
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");
// 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;
}
#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:
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;
}
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);
}
#include <string>
#include "base/types.hh"
-
-class Checkpoint;
+#include "sim/serialize.hh"
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);
}
void
-BaseCPU::serialize(std::ostream &os)
+BaseCPU::serialize(CheckpointOut &cp) const
{
SERIALIZE_SCALAR(instCnt);
* 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);
+ }
}
}
*
* @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;
/**
* Serialize a single thread.
* @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.
* @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;
}
void
-CheckerCPU::serialize(ostream &os)
+CheckerCPU::serialize(ostream &os) const
{
}
void
-CheckerCPU::unserialize(Checkpoint *cp, const string §ion)
+CheckerCPU::unserialize(CheckpointIn &cp)
{
}
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.
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(); }
@classmethod
def export_methods(cls, code):
code('''
- void dump();
+ void dump() const;
''')
@classmethod
}
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);
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;
}
}
void
-BaseKvmCPU::dump()
+BaseKvmCPU::dump() const
{
inform("State dumping not implemented.");
}
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();
Counter totalOps() const;
/** Dump the internal state to the terminal. */
- virtual void dump();
+ virtual void dump() const;
/**
* Force an exit from KVM.
}
void
-X86KvmCPU::dump()
+X86KvmCPU::dump() const
{
dumpIntRegs();
if (useXSave)
void startup();
/** @{ */
- void dump();
+ void dump() const M5_ATTR_OVERRIDE;
void dumpFpuRegs() const;
void dumpIntRegs() const;
void dumpSpecRegs() const;
}
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
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);
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>
/** 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.
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;
}
}
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
// 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.
}
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
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();
/***************************************************************
}
void
-TrafficGen::serialize(ostream &os)
+TrafficGen::serialize(CheckpointOut &cp) const
{
DPRINTF(Checkpoint, "Serializing TrafficGen\n");
}
void
-TrafficGen::unserialize(Checkpoint* cp, const string& section)
+TrafficGen::unserialize(CheckpointIn &cp)
{
// restore scheduled events
Tick nextEvent;
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();
}
void
-serialize(ThreadContext &tc, std::ostream &os)
+serialize(ThreadContext &tc, CheckpointOut &cp)
{
using namespace TheISA;
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)
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]);
#endif
PCState pcState;
- pcState.unserialize(cp, section);
+ pcState.unserialize(cp);
tc.pcState(pcState);
// thread_num and cpu_id are deterministic from the config
* 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);
/** @} */
}
void
-ThreadState::serialize(std::ostream &os)
+ThreadState::serialize(CheckpointOut &cp) const
{
SERIALIZE_ENUM(_status);
// thread_num and cpu_id are deterministic from the config
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);
if (quiesceEndTick)
baseCpu->schedule(quiesceEvent, quiesceEndTick);
if (kernelStats)
- kernelStats->unserialize(cp, section);
+ kernelStats->unserialize(cp);
}
void
* 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(); }
}
void
-AlphaBackdoor::Access::serialize(ostream &os)
+AlphaBackdoor::Access::serialize(CheckpointOut &cp) const
{
SERIALIZE_SCALAR(last_offset);
SERIALIZE_SCALAR(version);
}
void
-AlphaBackdoor::Access::unserialize(Checkpoint *cp, const std::string §ion)
+AlphaBackdoor::Access::unserialize(CheckpointIn &cp)
{
UNSERIALIZE_SCALAR(last_offset);
UNSERIALIZE_SCALAR(version);
}
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 *
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 {
/**
* 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__
}
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);
}
*/
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__
void
-TsunamiCChip::serialize(std::ostream &os)
+TsunamiCChip::serialize(CheckpointOut &cp) const
{
SERIALIZE_ARRAY(dim, Tsunami::Max_CPUs);
SERIALIZE_ARRAY(dir, Tsunami::Max_CPUs);
}
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);
*/
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__
}
void
-TsunamiIO::serialize(ostream &os)
+TsunamiIO::serialize(CheckpointOut &cp) const
{
SERIALIZE_SCALAR(rtcAddr);
SERIALIZE_SCALAR(timerData);
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);
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
*/
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.
}
void
-TsunamiPChip::serialize(std::ostream &os)
+TsunamiPChip::serialize(CheckpointOut &cp) const
{
SERIALIZE_SCALAR(pctl);
SERIALIZE_ARRAY(wsba, 4);
}
void
-TsunamiPChip::unserialize(Checkpoint *cp, const std::string §ion)
+TsunamiPChip::unserialize(CheckpointIn &cp)
{
UNSERIALIZE_SCALAR(pctl);
UNSERIALIZE_ARRAY(wsba, 4);
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__
}
void
-EnergyCtrl::serialize(std::ostream &os)
+EnergyCtrl::serialize(CheckpointOut &cp) const
{
SERIALIZE_SCALAR(domainID);
SERIALIZE_SCALAR(domainIDIndexToRead);
}
void
-EnergyCtrl::unserialize(Checkpoint *cp, const std::string §ion)
+EnergyCtrl::unserialize(CheckpointIn &cp)
{
UNSERIALIZE_SCALAR(domainID);
UNSERIALIZE_SCALAR(domainIDIndexToRead);
*/
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();
*/
void
-FlashDevice::serialize(std::ostream &os)
+FlashDevice::serialize(CheckpointOut &cp) const
{
SERIALIZE_SCALAR(planeMask);
*/
void
-FlashDevice::unserialize(Checkpoint *cp, const std::string §ion)
+FlashDevice::unserialize(CheckpointIn &cp)
{
UNSERIALIZE_SCALAR(planeMask);
/** 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*/
}
void
-SystemCounter::serialize(std::ostream &os) const
+SystemCounter::serialize(CheckpointOut &cp) const
{
SERIALIZE_SCALAR(_regCntkctl);
SERIALIZE_SCALAR(_freq);
}
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.
}
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);
}
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.
}
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
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));
}
}
}
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);
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
/// 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).
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
};
/// Per-CPU architected timer.
-class ArchTimer
+class ArchTimer : public Serializable
{
public:
class Interrupt
/// 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
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);
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; }
void
-Pl390::serialize(std::ostream &os)
+Pl390::serialize(CheckpointOut &cp) const
{
DPRINTF(Checkpoint, "Serializing Arm GIC\n");
}
void
-Pl390::unserialize(Checkpoint *cp, const std::string §ion)
+Pl390::unserialize(CheckpointIn &cp)
{
DPRINTF(Checkpoint, "Unserializing Arm GIC\n");
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
}
void
-HDLcd::serialize(std::ostream &os)
+HDLcd::serialize(CheckpointOut &cp) const
{
DPRINTF(HDLcd, "Serializing ARM HDLCD\n");
SERIALIZE_SCALAR(dmaPendingNum);
SERIALIZE_SCALAR(frameUnderrun);
- arrayParamOut(os, "virtualDisplayBuffer", virtualDisplayBuffer);
+ arrayParamOut(cp, "virtualDisplayBuffer", virtualDisplayBuffer);
SERIALIZE_SCALAR(pixelBufferSize);
SERIALIZE_SCALAR(pixelIndex);
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,
UNSERIALIZE_SCALAR(frameUnderrun);
UNSERIALIZE_SCALAR(dmaBytesInFlight);
- arrayParamIn(cp, section, "virtualDisplayBuffer", virtualDisplayBuffer);
+ arrayParamIn(cp, "virtualDisplayBuffer", virtualDisplayBuffer);
UNSERIALIZE_SCALAR(pixelBufferSize);
UNSERIALIZE_SCALAR(pixelIndex);
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]) {
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.
}
void
-Pl050::serialize(std::ostream &os)
+Pl050::serialize(CheckpointOut &cp) const
{
uint8_t ctrlreg = control;
SERIALIZE_SCALAR(ctrlreg);
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);
UNSERIALIZE_SCALAR(shiftDown);
UNSERIALIZE_SCALAR(driverInitialized);
- arrayParamIn(cp, section, "rxQueue", rxQueue);
+ UNSERIALIZE_CONTAINER(rxQueue);
}
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__
void
-Pl011::serialize(std::ostream &os)
+Pl011::serialize(CheckpointOut &cp) const
{
DPRINTF(Checkpoint, "Serializing Arm PL011\n");
SERIALIZE_SCALAR(control);
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");
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 *
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;
}
void
-Pl111::serialize(std::ostream &os)
+Pl111::serialize(CheckpointOut &cp) const
{
DPRINTF(PL111, "Serializing ARM PL111\n");
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");
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])
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.
}
void
-PL031::serialize(std::ostream &os)
+PL031::serialize(CheckpointOut &cp) const
{
DPRINTF(Checkpoint, "Serializing Arm PL031\n");
SERIALIZE_SCALAR(timeVal);
}
void
-PL031::unserialize(Checkpoint *cp, const std::string §ion)
+PL031::unserialize(CheckpointIn &cp)
{
DPRINTF(Checkpoint, "Unserializing Arm PL031\n");
*/
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;
};
}
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);
}
*/
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;
};
}
void
-CpuLocalTimer::Timer::serialize(std::ostream &os)
+CpuLocalTimer::Timer::serialize(CheckpointOut &cp) const
{
DPRINTF(Checkpoint, "Serializing Arm CpuLocalTimer\n");
SERIALIZE_SCALAR(intNumTimer);
}
void
-CpuLocalTimer::Timer::unserialize(Checkpoint *cp, const std::string §ion)
+CpuLocalTimer::Timer::unserialize(CheckpointIn &cp)
{
DPRINTF(Checkpoint, "Unserializing Arm CpuLocalTimer\n");
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 *
class CpuLocalTimer : public BasicPioDevice
{
protected:
- class Timer
+ class Timer : public Serializable
{
public:
/** 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;
};
*/
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;
};
}
void
-Sp804::Timer::serialize(std::ostream &os)
+Sp804::Timer::serialize(CheckpointOut &cp) const
{
DPRINTF(Checkpoint, "Serializing Arm Sp804\n");
}
void
-Sp804::Timer::unserialize(Checkpoint *cp, const std::string §ion)
+Sp804::Timer::unserialize(CheckpointIn &cp)
{
DPRINTF(Checkpoint, "Unserializing Arm Sp804\n");
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 *
class Sp804 : public AmbaPioDevice
{
protected:
- class Timer
+ class Timer : public Serializable
{
public:
/** 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 */
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;
};
*/
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;
*/
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));
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:
/**
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);
}
}
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++) {
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");
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);
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()
{
#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"
/* 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;
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;
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);
}
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);
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);
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);
}
class CopyEngine : public PciDevice
{
- class CopyEngineChannel : public Drainable
+ class CopyEngineChannel : public Drainable, public Serializable
{
private:
DmaPort cePort;
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);
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();
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;
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);
};
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);
}
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");
}
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);
}
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;
{ }
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
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);
};
}
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);
}
}
}
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;
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();
}
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);
};
/*
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;
};
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);
}
#include <memory>
#include "base/types.hh"
+#include "sim/serialize.hh"
/*
* Reference counted class containing ethernet packet data
*/
-class Checkpoint;
class EthPacketData
{
public:
~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;
//=====================================================================
void
-EtherTap::serialize(ostream &os)
+EtherTap::serialize(CheckpointOut &cp) const
{
SERIALIZE_SCALAR(socket);
SERIALIZE_SCALAR(buflen);
if (event) {
tapevent_present = true;
SERIALIZE_SCALAR(tapevent_present);
- event->serialize(os);
+ event->serialize(cp);
}
else {
SERIALIZE_SCALAR(tapevent_present);
}
void
-EtherTap::unserialize(Checkpoint *cp, const std::string §ion)
+EtherTap::unserialize(CheckpointIn &cp)
{
UNSERIALIZE_SCALAR(socket);
UNSERIALIZE_SCALAR(buflen);
if (tapevent_present) {
event = new TapEvent(this, socket, POLLIN|POLLERR);
- event->unserialize(cp,section);
+ event->unserialize(cp);
if (event->queued()) {
pollQueue.schedule(event);
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
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);
}
void
-I2CBus::unserialize(Checkpoint *cp, const std::string §ion)
+I2CBus::unserialize(CheckpointIn &cp)
{
DPRINTF(Checkpoint, "Unserializing I2C bus.\n");
UNSERIALIZE_SCALAR(scl);
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
template<class T>
void
-IGbE::DescCache<T>::serialize(std::ostream &os)
+IGbE::DescCache<T>::serialize(CheckpointOut &cp) const
{
SERIALIZE_SCALAR(cachePnt);
SERIALIZE_SCALAR(curFetching);
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));
}
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);
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);
}
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);
}
}
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);
}
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);
}
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);
}
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);
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;
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);
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;
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 *
template<class T>
- class DescCache
+ class DescCache : public Serializable
{
protected:
virtual Addr descBase() const = 0;
* 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();
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;
}
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;
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();
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;
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);
}
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);
}
};
}
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);
}
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);
}
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);
}
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;
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_
}
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
}
void
-IdeDisk::unserialize(Checkpoint *cp, const string §ion)
+IdeDisk::unserialize(CheckpointIn &cp)
{
// Reschedule events that were outstanding
// these are all mutually exclusive
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;
};
}
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
}
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;
}
* @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.
* @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();
* @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.
* @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();
}
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
}
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;
//
* @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.
* @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__
}
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);
}
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__
void
-MaltaCChip::serialize(std::ostream &os)
+MaltaCChip::serialize(CheckpointOut &cp) const
{
// SERIALIZE_ARRAY(dim, Malta::Max_CPUs);
//SERIALIZE_ARRAY(dir, Malta::Max_CPUs);
}
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);
*/
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__
}
void
-MaltaIO::serialize(ostream &os)
+MaltaIO::serialize(CheckpointOut &cp) const
{
SERIALIZE_SCALAR(timerData);
SERIALIZE_SCALAR(mask1);
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);
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
/** 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.
void
-MaltaPChip::serialize(std::ostream &os)
+MaltaPChip::serialize(CheckpointOut &cp) const
{
SERIALIZE_SCALAR(pctl);
SERIALIZE_ARRAY(wsba, 4);
}
void
-MaltaPChip::unserialize(Checkpoint *cp, const std::string §ion)
+MaltaPChip::unserialize(CheckpointIn &cp)
{
UNSERIALIZE_SCALAR(pctl);
UNSERIALIZE_ARRAY(wsba, 4);
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__
//
//
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.
/*
* 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
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);
}
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);
}
}
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);
/*
* 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
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;
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;
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();
};
}
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) {
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]));
// 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
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();
}
* 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);
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);
}
}
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
* 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__
//
//
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);
}
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);
}
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",
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();
++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;
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);
SERIALIZE_SCALAR(rxState);
SERIALIZE_SCALAR(rxEmpty);
SERIALIZE_SCALAR(rxLow);
- rxFifo.serialize("rxFifo", os);
+ rxFifo.serialize("rxFifo", cp);
/*
* Serialize tx state machine
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);
}
}
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.
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);
}
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);
}
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);
}
UNSERIALIZE_SCALAR(rxEmpty);
UNSERIALIZE_SCALAR(rxLow);
this->rxState = (RxState) rxState;
- rxFifo.unserialize("rxFifo", cp, section);
+ rxFifo.unserialize("rxFifo", cp);
int rxFifoPtr;
UNSERIALIZE_SCALAR(rxFifoPtr);
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);
}
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);
}
/*
* 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
* 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);
}
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);
}
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__
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);
};
}
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__
}
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
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__
}
void
-Uart8250::serialize(ostream &os)
+Uart8250::serialize(CheckpointOut &cp) const
{
SERIALIZE_SCALAR(status);
SERIALIZE_SCALAR(IER);
}
void
-Uart8250::unserialize(Checkpoint *cp, const std::string §ion)
+Uart8250::unserialize(CheckpointIn &cp)
{
UNSERIALIZE_SCALAR(status);
UNSERIALIZE_SCALAR(IER);
*/
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__
}
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
}
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
* @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
/** @{
* @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;
/** @} */
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");
}
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);
}
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 *
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
}
void
-X86ISA::I8042::serialize(std::ostream &os)
+X86ISA::I8042::serializeOld(CheckpointOut &cp)
{
uint8_t statusRegData = statusReg.__data;
uint8_t commandByteData = commandByte.__data;
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;
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]);
}
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;
}
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
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
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
}
void
-X86ISA::I82094AA::serialize(std::ostream &os)
+X86ISA::I82094AA::serialize(CheckpointOut &cp) const
{
uint64_t* redirTableArray = (uint64_t*)redirTable;
SERIALIZE_SCALAR(regSel);
}
void
-X86ISA::I82094AA::unserialize(Checkpoint *cp, const std::string §ion)
+X86ISA::I82094AA::unserialize(CheckpointIn &cp)
{
uint64_t redirTableArray[TableSize];
UNSERIALIZE_SCALAR(regSel);
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
}
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);
}
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
}
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
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();
};
}
void
-X86ISA::I8259::serialize(std::ostream &os)
+X86ISA::I8259::serialize(CheckpointOut &cp) const
{
SERIALIZE_ARRAY(pinStates, NumLines);
SERIALIZE_ENUM(mode);
}
void
-X86ISA::I8259::unserialize(Checkpoint *cp, const std::string §ion)
+X86ISA::I8259::unserialize(CheckpointIn &cp)
{
UNSERIALIZE_ARRAY(pinStates, NumLines);
UNSERIALIZE_ENUM(mode);
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
}
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);
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
}
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);
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
/** 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;
};
/**
}
void
-Cache::serialize(std::ostream &os)
+Cache::serialize(CheckpointOut &cp) const
{
bool dirty(isDirty());
}
void
-Cache::unserialize(Checkpoint *cp, const std::string §ion)
+Cache::unserialize(CheckpointIn &cp)
{
bool bad_checkpoint;
UNSERIALIZE_SCALAR(bad_checkpoint);
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__
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);
}
*/
#include <fstream>
#include <map>
+#include <memory>
#include <string>
#include "base/bitfield.hh"
}
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;
}
}
/**
* Declaration of base class for page table
*/
-class PageTableBase
+class PageTableBase : public Serializable
{
protected:
struct cacheElement {
pTableCache[2].valid = false;
}
}
-
- virtual void serialize(std::ostream &os) = 0;
-
- virtual void unserialize(Checkpoint *cp, const std::string §ion) = 0;
};
/**
*/
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;
};
/**
}
void
-PhysicalMemory::serialize(ostream& os)
+PhysicalMemory::serialize(CheckpointOut &cp) const
{
// serialize all the locked addresses and their context ids
vector<Addr> lal_addr;
}
}
- 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();
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
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",
}
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]));
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;
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");
*
* @param os stream to serialize to
*/
- void serialize(std::ostream& os);
+ void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
/**
* Serialize a specific store.
* @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);
};
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) {
}
void
-RubySystem::serialize(std::ostream &os)
+RubySystem::serializeOld(CheckpointOut &cp)
{
m_cooldown_enabled = true;
vector<Sequencer*> sequencer_map;
}
void
-RubySystem::unserialize(Checkpoint *cp, const string §ion)
+RubySystem::unserialize(CheckpointIn &cp)
{
uint8_t *uncompressed_trace = NULL;
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);
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);
def export_methods(cls, code):
code('''
void init();
- void loadState(Checkpoint *cp);
+ void loadState(CheckpointIn &cp);
void initState();
void regStats();
void resetStats();
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;
return obj;
}
-Checkpoint *
+CheckpointIn *
getCheckpoint(const std::string &cpt_dir)
{
- return new Checkpoint(cpt_dir, pythonSimObjectResolver);
+ return new CheckpointIn(cpt_dir, pythonSimObjectResolver);
}
Serializable::serializeAll(cpt_dir);
}
-Checkpoint *
+CheckpointIn *
getCheckpoint(const std::string &cpt_dir);
inline void
-unserializeGlobals(Checkpoint *cp)
+unserializeGlobals(CheckpointIn &cp)
{
Serializable::unserializeGlobals(cp);
}
}
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);
}
}
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:
/**
}
void
-CxxConfigManager::loadState(Checkpoint *checkpoint)
+CxxConfigManager::loadState(CheckpointIn &checkpoint)
{
for (auto i = objectsInOrder.begin(); i != objectsInOrder.end(); ++ i)
(*i)->loadState(checkpoint);
#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++ */
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();
}
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
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;
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]];
*/
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;
}
void
-Event::serialize(std::ostream &os)
+Event::serialize(CheckpointOut &cp) const
{
SERIALIZE_SCALAR(_when);
SERIALIZE_SCALAR(_priority);
}
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);
}
void
-EventQueue::serialize(ostream &os)
+EventQueue::serialize(CheckpointOut &cp) const
{
std::list<Event *> eventPtrs;
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;
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);
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);
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
};
/**@}*/
#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() { }
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)
}
void
-Process::FdMap::serialize(std::ostream &os)
+Process::FdMap::serialize(CheckpointOut &cp) const
{
SERIALIZE_SCALAR(fd);
SERIALIZE_SCALAR(isPipe);
}
void
-Process::FdMap::unserialize(Checkpoint *cp, const std::string §ion)
+Process::FdMap::unserialize(CheckpointIn &cp)
{
UNSERIALIZE_SCALAR(fd);
UNSERIALIZE_SCALAR(isPipe);
}
void
-Process::serialize(std::ostream &os)
+Process::serialize(CheckpointOut &cp) const
{
SERIALIZE_SCALAR(brk_point);
SERIALIZE_SCALAR(stack_base);
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);
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);
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
PageTableBase* pTable;
- class FdMap
+ class FdMap : public Serializable
{
public:
int fd;
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:
*/
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;
};
//
}
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);
}
void
-Root::unserialize(Checkpoint *cp, const std::string §ion)
+Root::unserialize(CheckpointIn &cp)
{
uint64_t cpt_ver = 0;
UNSERIALIZE_OPT_SCALAR(cpt_ver);
/** 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__
/*
+ * 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
* Authors: Nathan Binkert
* Erik Hallnor
* Steve Reinhardt
+ * Andreas Sandberg
*/
#include <sys/stat.h>
#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"
template <class T>
void
-showParam(ostream &os, const T &value)
+showParam(CheckpointOut &os, const T &value)
{
os << 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;
}
template <>
void
-showParam(ostream &os, const signed char &value)
+showParam(CheckpointOut &os, const signed char &value)
{
os << (int)value;
}
template <>
void
-showParam(ostream &os, const unsigned char &value)
+showParam(CheckpointOut &os, const unsigned char &value)
{
os << (unsigned int)value;
}
// Display bools as strings
template <>
void
-showParam(ostream &os, const bool &value)
+showParam(CheckpointOut &os, const bool &value)
{
os << (value ? "true" : "false");
}
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);
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 << "=";
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();
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 {
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)
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);
}
// 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 \"");
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);
}
// 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 \"");
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();
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 \"");
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)
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()
}
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
//
//
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);
}
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.
}
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;
bool
-Checkpoint::sectionExists(const string §ion)
+CheckpointIn::sectionExists(const string §ion)
{
return db->sectionExists(section);
}
/*
+ * 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.
*
* Authors: Nathan Binkert
* Erik Hallnor
* Steve Reinhardt
+ * Andreas Sandberg
*/
/* @file
#include <iostream>
#include <list>
#include <map>
+#include <stack>
#include <vector>
#include "base/bitunion.hh"
class IniFile;
class Serializable;
-class Checkpoint;
+class CheckpointIn;
class SimObject;
class EventQueue;
+typedef std::ostream CheckpointOut;
+
+
/** The current version of the checkpoint format.
* This should be incremented by 1 and only 1 for every new version, where a new
* version is defined as a checkpoint created before this version won't work on
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)
// 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
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);
// 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;
// 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);
};
virtual SimObject *resolveSimObject(const std::string &name) = 0;
};
-class Checkpoint
+class CheckpointIn
{
private:
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;
}
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);
}
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);
}
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);
}
Serializable *
-LocalSimLoopExitEvent::createForUnserialize(Checkpoint *cp,
+LocalSimLoopExitEvent::createForUnserialize(CheckpointIn &cp,
const string §ion)
{
return new LocalSimLoopExitEvent();
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);
};
}
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");
}
// 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());
}
}
*
* @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
*/
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:
}
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
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();
*
* @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
* @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) {}
};
}
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;
* 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);
}
}
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);
}
*
* 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 */
}
/** 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;
/** 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__ */
}
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);
}
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;
/**