From 5d7224cc927979c6107dd630ab10d53d20a9854e Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Wed, 14 Jan 2004 02:00:20 -0500 Subject: [PATCH] Setup initialization callbacks --HG-- extra : convert_revision : ec56a839a0489c5494bfcd9ead0fc3866f1e8ac2 --- sim/main.cc | 3 +++ sim/sim_object.cc | 20 ++++++++++++++++++++ sim/sim_object.hh | 4 ++++ 3 files changed, 27 insertions(+) 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 // @@ -126,6 +131,21 @@ SimObject::regAllStats() Statistics::registerResetCallback(&StatResetCB); } +// +// 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. // 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(); -- 2.30.2