summaryrefslogtreecommitdiff
path: root/sim/eventq.cc
diff options
context:
space:
mode:
authorSteve Reinhardt <stever@eecs.umich.edu>2003-10-29 21:45:39 -0800
committerSteve Reinhardt <stever@eecs.umich.edu>2003-10-29 21:45:39 -0800
commit5a1eb9049d16d37448282362529d462d73558181 (patch)
treefb1d5a05dad6869173a352abb16ddca7b3a1667f /sim/eventq.cc
parent976429121c7fddbf8de18b2a347a53546fe14264 (diff)
downloadgem5-5a1eb9049d16d37448282362529d462d73558181.tar.xz
Support for Serializable non-SimObject things like events.
Can now serialize & unserialize DmaRequestEvents and DmaTransferEvents. Also support serialize/unserialize of pointers to SimObjects and other Serializable objects. arch/alpha/alpha_memory.cc: arch/alpha/alpha_memory.hh: arch/alpha/isa_traits.hh: cpu/exec_context.cc: cpu/exec_context.hh: cpu/simple_cpu/simple_cpu.hh: dev/alpha_access.h: dev/alpha_console.cc: dev/alpha_console.hh: dev/console.cc: dev/console.hh: unserialize() now takes a Checkpoint* instead of an IniFile*. cpu/simple_cpu/simple_cpu.cc: unserialize() now takes a Checkpoint* instead of an IniFile*. Put ExecContext in its own section so its _status fields doesn't conflict. sim/eventq.cc: sim/eventq.hh: unserialize() now takes a Checkpoint* instead of an IniFile*. Events get serialized by the event queue only if they're marked as AutoSerialize... others are assumed to be serialized by something else (e.g. an owning SimObject) or to not matter. sim/param.cc: Shift 'const' in case T is a ptr type. sim/serialize.cc: sim/serialize.hh: Define Checkpoint object to encapsulate everything you need to know about a checkpoint. Use it to allow lookups of named Serializable objects (and SimObjects) during unserialization. unserialize() now takes a Checkpoint* instead of an IniFile*. --HG-- extra : convert_revision : 8e6baab32405f8f548bb67a097b2f713296537a5
Diffstat (limited to 'sim/eventq.cc')
-rw-r--r--sim/eventq.cc48
1 files changed, 30 insertions, 18 deletions
diff --git a/sim/eventq.cc b/sim/eventq.cc
index 77eb490c7..ef813eb13 100644
--- a/sim/eventq.cc
+++ b/sim/eventq.cc
@@ -129,7 +129,7 @@ Event::serialize(std::ostream &os)
void
-Event::unserialize(const IniFile *db, const string &section)
+Event::unserialize(Checkpoint *cp, const string &section)
{
if (scheduled())
deschedule();
@@ -154,39 +154,51 @@ Event::unserialize(const IniFile *db, const string &section)
void
EventQueue::nameChildren()
{
-#if 0
- int j = 0;
-
+ int numEvents = 0;
Event *event = head;
while (event) {
- stringstream stream;
- ccprintf(stream, "%s.event%d", name(), j++);
- event->setName(stream.str());
-
+ if (event->getFlags(Event::AutoSerialize)) {
+ event->setName(csprintf("%s.event%d", name(), numEvents++));
+ }
event = event->next;
}
-#endif
+
+ numAutoSerializeEvents = numEvents;
}
void
EventQueue::serialize(ostream &os)
{
-#if 0
- string objects = "";
+ // should have been set by a preceding call to nameChildren()
+ assert(numAutoSerializeEvents >= 0);
+ SERIALIZE_SCALAR(numAutoSerializeEvents);
+
+ int numEvents = 0;
Event *event = head;
while (event) {
- objects += event->name();
- objects += " ";
- event->serialize(os);
-
+ if (event->getFlags(Event::AutoSerialize)) {
+ event->nameOut(os);
+ event->serialize(os);
+ numEvents++;
+ }
event = event->next;
}
- nameOut(os, "Serialized");
- SERIALIZE_SCALAR(objects);
-#endif
+
+ assert(numEvents == numAutoSerializeEvents);
+}
+
+
+void
+EventQueue::unserialize(Checkpoint *cp, const std::string &section)
+{
+ UNSERIALIZE_SCALAR(numAutoSerializeEvents);
+ for (int eventNum = 0; eventNum < numAutoSerializeEvents; ++eventNum) {
+ Serializeable::create(cp, csprintf("%s.event%d", section, eventNum));
+ }
}
+
void
EventQueue::dump()
{