Serialization support for Alpha TLBs, PhysicalMemory, and SimpleCPU.

arch/alpha/alpha_memory.cc:
arch/alpha/alpha_memory.hh:
    Serialize TLB contents.
cpu/simple_cpu/simple_cpu.cc:
cpu/simple_cpu/simple_cpu.hh:
    Complete serialization of SimpleCPU (including owned events).
sim/eventq.cc:
sim/eventq.hh:
    Basic serialization for events.
    Still need to handle dynamic events (not owned by a SimObject).
sim/serialize.cc:
sim/serialize.hh:
    Export serialization filename so PhysicalMemory can
    derive its filename from that.

--HG--
extra : convert_revision : 4db851c5880f73f576ca092d5e5ad4256048eb51
This commit is contained in:
Steve Reinhardt 2003-10-29 13:35:07 -08:00
parent 8da9fcdd75
commit af5277a678
8 changed files with 105 additions and 103 deletions

View file

@ -197,47 +197,10 @@ AlphaTlb::serialize(ostream &os)
SERIALIZE_SCALAR(size); SERIALIZE_SCALAR(size);
SERIALIZE_SCALAR(nlu); SERIALIZE_SCALAR(nlu);
// should just add serialize/unserialize methods to AlphaPTE
#if 0
stringstream buf;
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
buf.str(""); nameOut(os, csprintf("%s.PTE%d", name(), i));
ccprintf(buf, "pte%02d.valid", i); table[i].serialize(os);
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);
} }
#endif
} }
void void
@ -246,56 +209,12 @@ AlphaTlb::unserialize(const IniFile *db, const string &section)
UNSERIALIZE_SCALAR(size); UNSERIALIZE_SCALAR(size);
UNSERIALIZE_SCALAR(nlu); UNSERIALIZE_SCALAR(nlu);
#if 0
string data;
stringstream buf;
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
buf.str(""); table[i].unserialize(db, csprintf("%s.PTE%d", section, i));
ccprintf(buf, "pte%02d.valid", i); if (table[i].valid) {
db.findDefault(category, buf.str(), data); lookupTable.insert(make_pair(table[i].tag, i));
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);
} }
#endif
} }

View file

@ -75,7 +75,6 @@ class AlphaTlb : public SimObject
// Checkpointing // Checkpointing
virtual void serialize(std::ostream &os); virtual void serialize(std::ostream &os);
virtual void unserialize(const IniFile *db, const std::string &section); virtual void unserialize(const IniFile *db, const std::string &section);
}; };
class AlphaItb : public AlphaTlb class AlphaItb : public AlphaTlb

View file

@ -75,8 +75,26 @@
using namespace std; 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) SimpleCPU::CacheCompletionEvent::CacheCompletionEvent(SimpleCPU *_cpu)
: Event(&mainEventQueue), : Event(&mainEventQueue, "SimpleCPU::CacheCompletionEvent"),
cpu(_cpu) cpu(_cpu)
{ {
} }
@ -89,7 +107,7 @@ void SimpleCPU::CacheCompletionEvent::process()
const char * const char *
SimpleCPU::CacheCompletionEvent::description() SimpleCPU::CacheCompletionEvent::description()
{ {
return "cache completion event"; return "SimpleCPU cache completion event";
} }
#ifdef FULL_SYSTEM #ifdef FULL_SYSTEM
@ -242,17 +260,24 @@ SimpleCPU::regStats()
void void
SimpleCPU::serialize(ostream &os) SimpleCPU::serialize(ostream &os)
{ {
SERIALIZE_ENUM(_status);
SERIALIZE_SCALAR(inst);
xc->serialize(os); xc->serialize(os);
nameOut(os, csprintf("%s.tickEvent", name()));
tickEvent.serialize(os);
nameOut(os, csprintf("%s.cacheCompletionEvent", name()));
cacheCompletionEvent.serialize(os);
} }
void void
SimpleCPU::unserialize(const IniFile *db, const string &category) SimpleCPU::unserialize(const IniFile *db, const string &section)
{ {
xc->unserialize(db, category); UNSERIALIZE_ENUM(_status);
UNSERIALIZE_SCALAR(inst);
// Read in Special registers xc->unserialize(db, section);
tickEvent.unserialize(db, csprintf("%s.tickEvent", name()));
// CPUTraitsType::unserializeSpecialRegs(db,category,node,xc->regs); cacheCompletionEvent
.unserialize(db, csprintf("%s.cacheCompletionEvent", name()));
} }
void void

View file

@ -68,10 +68,9 @@ class SimpleCPU : public BaseCPU
SimpleCPU *cpu; SimpleCPU *cpu;
public: public:
TickEvent(SimpleCPU *c) TickEvent(SimpleCPU *c);
: Event(&mainEventQueue, 100), cpu(c) { } void process();
void process() { cpu->tick(); } const char *description();
virtual const char *description() { return "tick event"; }
}; };
TickEvent tickEvent; TickEvent tickEvent;

View file

@ -118,6 +118,39 @@ EventQueue::serviceOne()
delete event; 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 &section)
{
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 void
EventQueue::nameChildren() EventQueue::nameChildren()
{ {

View file

@ -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() {} ~Event() {}
/// Determine if the current event is scheduled /// 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(); return l->when() >= r->when() || l->priority() >= r->priority();
} }
}; };
virtual void serialize(std::ostream &os);
virtual void unserialize(const IniFile *db, const std::string &section);
}; };
template <class T, void (T::* F)()> template <class T, void (T::* F)()>

View file

@ -355,6 +355,10 @@ Param<string> serialize_file(&serialParams,
"file", "file",
"file to write to", ""); "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 &section) SerializeParamContext::SerializeParamContext(const string &section)
: ParamContext(section), event(NULL) : ParamContext(section), event(NULL)
{ } { }
@ -366,9 +370,10 @@ SerializeParamContext::~SerializeParamContext()
void void
SerializeParamContext::checkParams() SerializeParamContext::checkParams()
{ {
if (!((string)serialize_file).empty() && serialize_cycle > 0) serializeFilename = serialize_file;
if (!serializeFilename.empty() && serialize_cycle > 0)
event = new SerializeEvent(&mainEventQueue, serialize_cycle, event = new SerializeEvent(&mainEventQueue, serialize_cycle,
serialize_file); serializeFilename);
} }
void void

View file

@ -235,5 +235,10 @@ SerializeableClass the##OBJ_CLASS##Class(CLASS_NAME, \
new##OBJ_CLASS##Builder); 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__ #endif // __SERIALIZE_HH__