diff options
author | Steve Reinhardt <stever@eecs.umich.edu> | 2003-10-29 13:35:07 -0800 |
---|---|---|
committer | Steve Reinhardt <stever@eecs.umich.edu> | 2003-10-29 13:35:07 -0800 |
commit | af5277a6784ed6a8e4671dfa79b1346bed687ae1 (patch) | |
tree | 81d91d5bc7287b146a0b0ee796ae3b8acb7fbbcf /sim | |
parent | 8da9fcdd751bcb74c17e72d7d0a6c7ccf259552c (diff) | |
download | gem5-af5277a6784ed6a8e4671dfa79b1346bed687ae1.tar.xz |
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
Diffstat (limited to 'sim')
-rw-r--r-- | sim/eventq.cc | 33 | ||||
-rw-r--r-- | sim/eventq.hh | 17 | ||||
-rw-r--r-- | sim/serialize.cc | 11 | ||||
-rw-r--r-- | sim/serialize.hh | 5 |
4 files changed, 63 insertions, 3 deletions
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 <class T, void (T::* F)()> 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<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) - 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__ |