diff --git a/arch/alpha/alpha_memory.cc b/arch/alpha/alpha_memory.cc index b95916105..7c0b1120f 100644 --- a/arch/alpha/alpha_memory.cc +++ b/arch/alpha/alpha_memory.cc @@ -197,47 +197,10 @@ AlphaTlb::serialize(ostream &os) SERIALIZE_SCALAR(size); SERIALIZE_SCALAR(nlu); - // should just add serialize/unserialize methods to AlphaPTE -#if 0 - stringstream buf; for (int i = 0; i < size; i++) { - buf.str(""); - ccprintf(buf, "pte%02d.valid", i); - paramOut(buf.str(), table[i].valid); - - buf.str(""); - ccprintf(buf, "pte%02d.tag", i); - paramOut(buf.str(), table[i].tag); - - buf.str(""); - ccprintf(buf, "pte%02d.ppn", i); - paramOut(buf.str(), table[i].ppn); - - buf.str(""); - ccprintf(buf, "pte%02d.xre", i); - paramOut(buf.str(), table[i].xre); - - buf.str(""); - ccprintf(buf, "pte%02d.xwe", i); - paramOut(buf.str(), table[i].xwe); - - buf.str(""); - ccprintf(buf, "pte%02d.fonr", i); - paramOut(buf.str(), table[i].fonr); - - buf.str(""); - ccprintf(buf, "pte%02d.fonw", i); - paramOut(buf.str(), table[i].fonw); - - buf.str(""); - ccprintf(buf, "pte%02d.asma", i); - paramOut(buf.str(), table[i].asma); - - buf.str(""); - ccprintf(buf, "pte%02d.asn", i); - paramOut(buf.str(), table[i].asn); + nameOut(os, csprintf("%s.PTE%d", name(), i)); + table[i].serialize(os); } -#endif } void @@ -246,56 +209,12 @@ AlphaTlb::unserialize(const IniFile *db, const string §ion) UNSERIALIZE_SCALAR(size); UNSERIALIZE_SCALAR(nlu); -#if 0 - string data; - stringstream buf; for (int i = 0; i < size; i++) { - buf.str(""); - ccprintf(buf, "pte%02d.valid", i); - db.findDefault(category, buf.str(), data); - to_number(data, table[i].valid); - - buf.str(""); - ccprintf(buf, "pte%02d.tag", i); - db.findDefault(category, buf.str(), data); - to_number(data, table[i].tag); - - buf.str(""); - ccprintf(buf, "pte%02d.ppn", i); - db.findDefault(category, buf.str(), data); - to_number(data, table[i].ppn); - - buf.str(""); - ccprintf(buf, "pte%02d.xre", i); - db.findDefault(category, buf.str(), data); - to_number(data, table[i].xre); - - buf.str(""); - ccprintf(buf, "pte%02d.xwe", i); - db.findDefault(category, buf.str(), data); - to_number(data, table[i].xwe); - - buf.str(""); - ccprintf(buf, "pte%02d.fonr", i); - db.findDefault(category, buf.str(), data); - to_number(data, table[i].fonr); - - buf.str(""); - ccprintf(buf, "pte%02d.fonw", i); - db.findDefault(category, buf.str(), data); - to_number(data, table[i].fonw); - - buf.str(""); - ccprintf(buf, "pte%02d.asma", i); - db.findDefault(category, buf.str(), data); - to_number(data, table[i].asma); - - buf.str(""); - ccprintf(buf, "pte%02d.asn", i); - db.findDefault(category, buf.str(), data); - to_number(data, table[i].asn); + table[i].unserialize(db, csprintf("%s.PTE%d", section, i)); + if (table[i].valid) { + lookupTable.insert(make_pair(table[i].tag, i)); + } } -#endif } diff --git a/arch/alpha/alpha_memory.hh b/arch/alpha/alpha_memory.hh index e6637893c..fc4d46191 100644 --- a/arch/alpha/alpha_memory.hh +++ b/arch/alpha/alpha_memory.hh @@ -75,7 +75,6 @@ class AlphaTlb : public SimObject // Checkpointing virtual void serialize(std::ostream &os); virtual void unserialize(const IniFile *db, const std::string §ion); - }; class AlphaItb : public AlphaTlb diff --git a/cpu/simple_cpu/simple_cpu.cc b/cpu/simple_cpu/simple_cpu.cc index 27576d558..3179b7b1f 100644 --- a/cpu/simple_cpu/simple_cpu.cc +++ b/cpu/simple_cpu/simple_cpu.cc @@ -75,8 +75,26 @@ using namespace std; +SimpleCPU::TickEvent::TickEvent(SimpleCPU *c) + : Event(&mainEventQueue, "SimpleCPU::TickEvent", 100), cpu(c) +{ +} + +void +SimpleCPU::TickEvent::process() +{ + cpu->tick(); +} + +const char * +SimpleCPU::TickEvent::description() +{ + return "SimpleCPU tick event"; +} + + SimpleCPU::CacheCompletionEvent::CacheCompletionEvent(SimpleCPU *_cpu) - : Event(&mainEventQueue), + : Event(&mainEventQueue, "SimpleCPU::CacheCompletionEvent"), cpu(_cpu) { } @@ -89,7 +107,7 @@ void SimpleCPU::CacheCompletionEvent::process() const char * SimpleCPU::CacheCompletionEvent::description() { - return "cache completion event"; + return "SimpleCPU cache completion event"; } #ifdef FULL_SYSTEM @@ -242,17 +260,24 @@ SimpleCPU::regStats() void SimpleCPU::serialize(ostream &os) { + SERIALIZE_ENUM(_status); + SERIALIZE_SCALAR(inst); xc->serialize(os); + nameOut(os, csprintf("%s.tickEvent", name())); + tickEvent.serialize(os); + nameOut(os, csprintf("%s.cacheCompletionEvent", name())); + cacheCompletionEvent.serialize(os); } void -SimpleCPU::unserialize(const IniFile *db, const string &category) +SimpleCPU::unserialize(const IniFile *db, const string §ion) { - xc->unserialize(db, category); - - // Read in Special registers - - // CPUTraitsType::unserializeSpecialRegs(db,category,node,xc->regs); + UNSERIALIZE_ENUM(_status); + UNSERIALIZE_SCALAR(inst); + xc->unserialize(db, section); + tickEvent.unserialize(db, csprintf("%s.tickEvent", name())); + cacheCompletionEvent + .unserialize(db, csprintf("%s.cacheCompletionEvent", name())); } void diff --git a/cpu/simple_cpu/simple_cpu.hh b/cpu/simple_cpu/simple_cpu.hh index aee8159ce..61831cb3c 100644 --- a/cpu/simple_cpu/simple_cpu.hh +++ b/cpu/simple_cpu/simple_cpu.hh @@ -68,10 +68,9 @@ class SimpleCPU : public BaseCPU SimpleCPU *cpu; public: - TickEvent(SimpleCPU *c) - : Event(&mainEventQueue, 100), cpu(c) { } - void process() { cpu->tick(); } - virtual const char *description() { return "tick event"; } + TickEvent(SimpleCPU *c); + void process(); + const char *description(); }; TickEvent tickEvent; diff --git a/sim/eventq.cc b/sim/eventq.cc index 7138d8688..77eb490c7 100644 --- a/sim/eventq.cc +++ b/sim/eventq.cc @@ -118,6 +118,39 @@ EventQueue::serviceOne() delete event; } + +void +Event::serialize(std::ostream &os) +{ + SERIALIZE_SCALAR(_when); + SERIALIZE_SCALAR(_priority); + SERIALIZE_ENUM(_flags); +} + + +void +Event::unserialize(const IniFile *db, const string §ion) +{ + if (scheduled()) + deschedule(); + + UNSERIALIZE_SCALAR(_when); + UNSERIALIZE_SCALAR(_priority); + + // need to see if original event was in a scheduled, unsquashed + // state, but don't want to restore those flags in the current + // object itself (since they aren't immediately true) + UNSERIALIZE_ENUM(_flags); + bool wasScheduled = (_flags & Scheduled) && !(_flags & Squashed); + _flags &= ~(Squashed | Scheduled); + + if (wasScheduled) { + DPRINTF(Config, "rescheduling at %d\n", _when); + schedule(_when); + } +} + + void EventQueue::nameChildren() { diff --git a/sim/eventq.hh b/sim/eventq.hh index cd86512e4..a8eae1248 100644 --- a/sim/eventq.hh +++ b/sim/eventq.hh @@ -112,6 +112,20 @@ class Event : public Serializeable, public FastAlloc { } + /* + * Event constructor + * @param queue that the event gets scheduled on + */ + Event(EventQueue *q, std::string _name, int p = 0) + : Serializeable(_name), queue(q), next(NULL), + _priority(p), _flags(None), +#if TRACING_ON + when_created(curTick), when_scheduled(0), +#endif + annotated_value(0) + { + } + ~Event() {} /// Determine if the current event is scheduled @@ -174,6 +188,9 @@ class Event : public Serializeable, public FastAlloc return l->when() >= r->when() || l->priority() >= r->priority(); } }; + + virtual void serialize(std::ostream &os); + virtual void unserialize(const IniFile *db, const std::string §ion); }; template diff --git a/sim/serialize.cc b/sim/serialize.cc index 00321b932..f838acc8d 100644 --- a/sim/serialize.cc +++ b/sim/serialize.cc @@ -355,6 +355,10 @@ Param serialize_file(&serialParams, "file", "file to write to", ""); +// Copy filename into regular string so we can export it without +// having to include param.hh all over the place. +string serializeFilename; + SerializeParamContext::SerializeParamContext(const string §ion) : ParamContext(section), event(NULL) { } @@ -366,9 +370,10 @@ SerializeParamContext::~SerializeParamContext() void SerializeParamContext::checkParams() { - if (!((string)serialize_file).empty() && serialize_cycle > 0) - event = new SerializeEvent(&mainEventQueue, serialize_cycle, - serialize_file); + serializeFilename = serialize_file; + if (!serializeFilename.empty() && serialize_cycle > 0) + event = new SerializeEvent(&mainEventQueue, serialize_cycle, + serializeFilename); } void diff --git a/sim/serialize.hh b/sim/serialize.hh index d7842b47d..4e0dbd1bd 100644 --- a/sim/serialize.hh +++ b/sim/serialize.hh @@ -235,5 +235,10 @@ SerializeableClass the##OBJ_CLASS##Class(CLASS_NAME, \ new##OBJ_CLASS##Builder); +// +// Export checkpoint filename param so other objects can derive +// filenames from it (e.g., memory). +// +extern std::string serializeFilename; #endif // __SERIALIZE_HH__