From eb17e9ef8260b2799f8edf7de86e2d8fa97da85c Mon Sep 17 00:00:00 2001 From: Horst Schirmeier <horst@schirmeier.com> Date: Thu, 14 Mar 2013 22:29:43 +0100 Subject: [PATCH] core/sal: move command-line parameter passing to SC::startup() --- src/core/sal/SimulatorController.cc | 7 ++++++- src/core/sal/SimulatorController.hpp | 5 ++++- src/core/sal/bochs/BochsController.cc | 6 ------ src/core/sal/bochs/BochsController.hpp | 14 -------------- src/core/sal/bochs/FailBochsInit.ah | 3 +-- src/core/sal/gem5/Gem5Controller.cc | 1 + src/core/sal/ovp/FailOVPInit.ah | 1 + src/core/sal/qemu/wrappers.cc | 1 + src/core/sal/t32/T32Controller.cc | 1 + 9 files changed, 15 insertions(+), 24 deletions(-) diff --git a/src/core/sal/SimulatorController.cc b/src/core/sal/SimulatorController.cc index a832dc0a..9a71f3e2 100644 --- a/src/core/sal/SimulatorController.cc +++ b/src/core/sal/SimulatorController.cc @@ -2,6 +2,7 @@ #include "SALInst.hpp" #include "Event.hpp" #include "Listener.hpp" +#include "util/CommandLine.hpp" namespace fail { @@ -35,12 +36,16 @@ BaseListener* SimulatorController::resume(void) return m_LstList.getLastFired(); } -void SimulatorController::startup() +void SimulatorController::startup(int argc, char **argv) { // Some greetings to the user: std::cout << "[SimulatorController] Initializing..." << std::endl; // TODO: Log-Level? + if (argv) { + CommandLine::Inst().collect_args(bx_startup_flags.argc, bx_startup_flags.argv); + } + // Activate previously added experiments to allow initialization: initExperiments(); } diff --git a/src/core/sal/SimulatorController.hpp b/src/core/sal/SimulatorController.hpp index 22c22a76..b2b42d1e 100644 --- a/src/core/sal/SimulatorController.hpp +++ b/src/core/sal/SimulatorController.hpp @@ -48,8 +48,11 @@ public: * This function needs to be invoked once the simulator starts, and * allows the SimulatorController to instantiate all needed experiment * components. + * + * @param argc main()'s argument counter + * @param argv main()'s argument value vector */ - void startup(); + void startup(int argc = 0, char **argv = 0); /** * Experiments need to hook here. */ diff --git a/src/core/sal/bochs/BochsController.cc b/src/core/sal/bochs/BochsController.cc index 1a3c14aa..6095f71f 100644 --- a/src/core/sal/bochs/BochsController.cc +++ b/src/core/sal/bochs/BochsController.cc @@ -4,7 +4,6 @@ #include "BochsMemory.hpp" #include "../SALInst.hpp" #include "../Listener.hpp" -#include "util/CommandLine.hpp" namespace fail { @@ -174,9 +173,4 @@ ConcreteCPU& BochsController::detectCPU(BX_CPU_C* pCPU) const return getCPU(i); } -void BochsController::collectCommandLineArguments(int argc, char **argv) const -{ - CommandLine::Inst().collect_args(bx_startup_flags.argc, bx_startup_flags.argv); -} - } // end-of-namespace: fail diff --git a/src/core/sal/bochs/BochsController.hpp b/src/core/sal/bochs/BochsController.hpp index 05cb7877..f3de852e 100644 --- a/src/core/sal/bochs/BochsController.hpp +++ b/src/core/sal/bochs/BochsController.hpp @@ -150,20 +150,6 @@ public: * @see The uses SimulatorController::getCPU(). */ ConcreteCPU& detectCPU(BX_CPU_C* pCPU) const; - -protected: - /** - * Hack: Indirection for commandline argument collection - * - * This prevents CommandLine.hpp (and optionparser.h) from being pulled - * inbe to every single Bochs translation unit via FailBochsInit.ah, - * leading to compilation errors in some of them. - * TODO: Move this upwards to SimulatorController? - * - * @param argc main()'s argument counter - * @param argv main()'s argument value vector - */ - void collectCommandLineArguments(int argc, char **argv) const; }; } // end-of-namespace: fail diff --git a/src/core/sal/bochs/FailBochsInit.ah b/src/core/sal/bochs/FailBochsInit.ah index 63a82082..c4366c16 100644 --- a/src/core/sal/bochs/FailBochsInit.ah +++ b/src/core/sal/bochs/FailBochsInit.ah @@ -10,8 +10,7 @@ aspect FailBochsInit { advice call("int bxmain()") : before () { - fail::simulator.collectCommandLineArguments(bx_startup_flags.argc, bx_startup_flags.argv); - fail::simulator.startup(); + fail::simulator.startup(bx_startup_flags.argc, bx_startup_flags.argv); } }; diff --git a/src/core/sal/gem5/Gem5Controller.cc b/src/core/sal/gem5/Gem5Controller.cc index 6658caaa..c4095ab4 100644 --- a/src/core/sal/gem5/Gem5Controller.cc +++ b/src/core/sal/gem5/Gem5Controller.cc @@ -19,6 +19,7 @@ void Gem5Controller::startup() addCPU(cpu); } + // TODO pass on command-line parameters SimulatorController::startup(); } diff --git a/src/core/sal/ovp/FailOVPInit.ah b/src/core/sal/ovp/FailOVPInit.ah index ca79042f..fe7ed613 100644 --- a/src/core/sal/ovp/FailOVPInit.ah +++ b/src/core/sal/ovp/FailOVPInit.ah @@ -14,6 +14,7 @@ aspect FailOVPInit { { std::cout << "OVP init aspect!" << std::endl; // TODO: Log-Level? + // TODO pass on command-line parameters fail::simulator.startup(); } }; diff --git a/src/core/sal/qemu/wrappers.cc b/src/core/sal/qemu/wrappers.cc index 24a31abe..4ae66729 100644 --- a/src/core/sal/qemu/wrappers.cc +++ b/src/core/sal/qemu/wrappers.cc @@ -14,6 +14,7 @@ void fail_init(struct CPUX86State *env) { std::cout << "FailQEMU v" FAIL_VERSION << std::endl; fail::simulator.setCPUEnv(env); + // TODO pass on command-line parameters fail::simulator.startup(); } diff --git a/src/core/sal/t32/T32Controller.cc b/src/core/sal/t32/T32Controller.cc index bf41278c..b9a394e9 100644 --- a/src/core/sal/t32/T32Controller.cc +++ b/src/core/sal/t32/T32Controller.cc @@ -7,6 +7,7 @@ void T32Controller::startup(){ // Do some T32-specific startup addCPU(new ConcreteCPU(0)); // Startup generic SimulatorController + // TODO pass on command-line parameters SimulatorController::startup(); } -- GitLab