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:
parent
8da9fcdd75
commit
af5277a678
8 changed files with 105 additions and 103 deletions
|
@ -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
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -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 <class T, void (T::* F)()>
|
||||
|
|
|
@ -355,6 +355,10 @@ Param<string> 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)
|
||||
serializeFilename = serialize_file;
|
||||
if (!serializeFilename.empty() && serialize_cycle > 0)
|
||||
event = new SerializeEvent(&mainEventQueue, serialize_cycle,
|
||||
serialize_file);
|
||||
serializeFilename);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -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__
|
||||
|
|
Loading…
Reference in a new issue