summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Binkert <binkertn@umich.edu>2004-01-14 02:00:20 -0500
committerNathan Binkert <binkertn@umich.edu>2004-01-14 02:00:20 -0500
commit5d7224cc927979c6107dd630ab10d53d20a9854e (patch)
tree8917cf1a0ebb92671c1abde411dfc8a0c6c8ec09
parente650870c159b481890f062b78910967124b1e3b6 (diff)
downloadgem5-5d7224cc927979c6107dd630ab10d53d20a9854e.tar.xz
Setup initialization callbacks
--HG-- extra : convert_revision : ec56a839a0489c5494bfcd9ead0fc3866f1e8ac2
-rw-r--r--sim/main.cc3
-rw-r--r--sim/sim_object.cc20
-rw-r--r--sim/sim_object.hh4
3 files changed, 27 insertions, 0 deletions
diff --git a/sim/main.cc b/sim/main.cc
index 3cb6c8b71..d0cf23039 100644
--- a/sim/main.cc
+++ b/sim/main.cc
@@ -51,6 +51,7 @@
#include "sim/host.hh"
#include "sim/sim_events.hh"
#include "sim/sim_exit.hh"
+#include "sim/sim_init.hh"
#include "sim/sim_object.hh"
#include "sim/sim_stats.hh"
@@ -398,6 +399,8 @@ main(int argc, char **argv)
exit(1);
}
+ SimInit();
+
while (!mainEventQueue.empty()) {
assert(curTick <= mainEventQueue.nextTick() &&
"event scheduled in the past");
diff --git a/sim/sim_object.cc b/sim/sim_object.cc
index 364dbe035..b3ac2c7a4 100644
--- a/sim/sim_object.cc
+++ b/sim/sim_object.cc
@@ -60,6 +60,11 @@ SimObject::SimObject(const string &_name)
simObjectList.push_back(this);
}
+void
+SimObject::init()
+{
+}
+
//
// no default statistics, so nothing to do in base implementation
//
@@ -127,6 +132,21 @@ SimObject::regAllStats()
}
//
+// static function: call init() on all SimObjects.
+//
+void
+SimObject::initAll()
+{
+ SimObjectList::iterator i = simObjectList.begin();
+ SimObjectList::iterator end = simObjectList.end();
+
+ for (; i != end; ++i) {
+ SimObject *obj = *i;
+ obj->init();
+ }
+}
+
+//
// static function: call resetStats() on all SimObjects.
//
void
diff --git a/sim/sim_object.hh b/sim/sim_object.hh
index 937ff9427..165931b2b 100644
--- a/sim/sim_object.hh
+++ b/sim/sim_object.hh
@@ -65,6 +65,10 @@ class SimObject : public Serializable
virtual std::string name() const { return objName; }
+ // initialization pass of all objects. Gets invoked by SimInit()
+ virtual void init();
+ static void initAll();
+
// register statistics for this object
virtual void regStats();
virtual void regFormulas();