From 2b79e83d720292b9c87ef144e36106667419c6fe Mon Sep 17 00:00:00 2001 From: adrian Date: Thu, 4 Oct 2012 11:20:31 +0000 Subject: [PATCH] Make it comile again with CONFIG_FAST_BREAKPOINTS enabled (avoid include cycle, see r1706), set timer id correctly (setId), coding-style + comment fix. git-svn-id: https://www4.informatik.uni-erlangen.de/i4svn/danceos/trunk/devel/fail@1712 8c4709b5-6ec9-48aa-a5cd-a96041d1645a --- src/core/sal/bochs/BochsController.cc | 16 -------------- src/core/sal/bochs/BochsController.hpp | 17 --------------- src/core/sal/bochs/BochsListener.ah | 30 ++++++++++++++------------ src/core/sal/bochs/BochsListener.cc | 23 ++++++++++++++++++++ src/core/sal/bochs/BochsListener.hpp | 26 ++++++++++++++++++++++ 5 files changed, 65 insertions(+), 47 deletions(-) create mode 100644 src/core/sal/bochs/BochsListener.cc create mode 100644 src/core/sal/bochs/BochsListener.hpp diff --git a/src/core/sal/bochs/BochsController.cc b/src/core/sal/bochs/BochsController.cc index b920ca7d..b3db42f5 100644 --- a/src/core/sal/bochs/BochsController.cc +++ b/src/core/sal/bochs/BochsController.cc @@ -211,22 +211,6 @@ void BochsController::fireInterruptDone() m_Flows.toggle(m_CurrFlow); } -void BochsController::onTimerTrigger(void* thisPtr) -{ - // FIXME: The timer logic can be modified to use only one timer in Bochs. - // (For now, this suffices.) - TimerListener* pli = static_cast(thisPtr); - // Check for a matching TimerListener. (In fact, we are only - // interessted in the iterator pointing at pli.) - ListenerManager::iterator it = std::find(simulator.m_LstList.begin(), - simulator.m_LstList.end(), pli); - // TODO: This has O(|m_LstList|) time complexity. We can further improve this - // by creating a method such that makeActive(pli) works as well, - // reducing the time complexity to O(1). - simulator.m_LstList.makeActive(it); - simulator.m_LstList.triggerActiveListeners(); -} - const std::string& BochsController::getMnemonic() const { static std::string str; diff --git a/src/core/sal/bochs/BochsController.hpp b/src/core/sal/bochs/BochsController.hpp index 4c6e8927..8aa1383b 100644 --- a/src/core/sal/bochs/BochsController.hpp +++ b/src/core/sal/bochs/BochsController.hpp @@ -64,23 +64,6 @@ public: * @param out true if the I/O traffic has been outbound, false otherwise */ void onIOPort(unsigned char data, unsigned port, bool out); - /** - * Static internal handler for TimerListeners. This static function is - * called when a previously registered (Bochs) timer triggers. This function - * searches for the provided TimerListener object within the ListenerManager and - * fires such an event by calling \c triggerActiveListeners(). - * @param thisPtr a pointer to the TimerListener-object triggered - * - * FIXME: Due to Bochs internal timer and ips-configuration related stuff, - * the simulator sometimes panics with "keyboard error:21" (see line - * 1777 in bios/rombios.c, function keyboard_init()) if a TimerListener - * is added *before* the bios has been loaded and initialized. To - * reproduce this error, try adding a \c TimerListener as the initial step - * in your experiment code and wait for it (\c addListenerAndResume()). - * This leads to the consequence that timers cannot be added/enabled at - * boot time. - */ - static void onTimerTrigger(void *thisPtr); /* ******************************************************************** * Simulator Controller & Access API: * ********************************************************************/ diff --git a/src/core/sal/bochs/BochsListener.ah b/src/core/sal/bochs/BochsListener.ah index d71dc71d..54c4b58e 100644 --- a/src/core/sal/bochs/BochsListener.ah +++ b/src/core/sal/bochs/BochsListener.ah @@ -1,43 +1,45 @@ -#ifndef __BOCHSLISTENER_AH__ - #define __BOCHSLISTENER_AH__ +#ifndef __BOCHS_LISTENER_AH__ + #define __BOCHS_LISTENER_AH__ #include "config/VariantConfig.hpp" #include "config/FailConfig.hpp" #if defined(BUILD_BOCHS) && defined(CONFIG_EVENT_BREAKPOINTS) +#include #include "bochs.h" -#include "BochsController.hpp" +#include "BochsListener.hpp" -aspect BochsListener -{ - advice "fail::TimerListener" : slice class - { +/* + * Note: A (Fail)Bochs bug currently leads to the consequence that timers + * cannot be added/enabled at boot time (see BochsController.hpp for further + * details). + */ +aspect BochsListener { + advice "fail::TimerListener" : slice class { public: bool onAddition() { // Register the timer listener in the Bochs simulator: - setId(m_registerTimer(this)); - if(getId() == -1) + if(m_registerTimer(this) == -1) { + setId(INVALID_TIMER); return false; // unable to register the timer (error in Bochs' function call) + } return true; } - void onDeletion() { // Unregister the time listener: m_unregisterTimer(this); } - private: timer_id_t m_registerTimer(TimerListener* pev) { assert(pev != NULL && "FATAL ERROR: TimerListener object ptr cannot be NULL!"); return static_cast( - bx_pc_system.register_timer(pev, BochsController::onTimerTrigger, pev->getTimeout(), + bx_pc_system.register_timer(pev, fail::onTimerTrigger, pev->getTimeout(), false, 1/*start immediately*/, "Fail*: BochsController"/*name*/)); } - bool m_unregisterTimer(TimerListener* pev) { assert(pev != NULL && "FATAL ERROR: TimerListener object ptr cannot be NULL!"); @@ -48,4 +50,4 @@ aspect BochsListener }; #endif // BUILD_BOCHS && CONFIG_EVENT_BREAKPOINTS -#endif // __BOCHSLISTENER_AH__ +#endif // __BOCHS_LISTENER_AH__ diff --git a/src/core/sal/bochs/BochsListener.cc b/src/core/sal/bochs/BochsListener.cc new file mode 100644 index 00000000..6a68f2b0 --- /dev/null +++ b/src/core/sal/bochs/BochsListener.cc @@ -0,0 +1,23 @@ +#include "BochsListener.hpp" +#include "../Listener.hpp" +#include "../ListenerManager.hpp" + +namespace fail { + +void onTimerTrigger(void* thisPtr) +{ + // FIXME: The timer logic can be modified to use only one timer in Bochs. + // (For now, this suffices.) + TimerListener* pli = static_cast(thisPtr); + // Check for a matching TimerListener. (In fact, we are only + // interessted in the iterator pointing at pli.) + ListenerManager::iterator it = std::find(simulator.m_LstList.begin(), + simulator.m_LstList.end(), pli); + // TODO: This has O(|m_LstList|) time complexity. We can further improve this + // by creating a method such that makeActive(pli) works as well, + // reducing the time complexity to O(1). + simulator.m_LstList.makeActive(it); + simulator.m_LstList.triggerActiveListeners(); +} + +} // end-of-namespace: fail diff --git a/src/core/sal/bochs/BochsListener.hpp b/src/core/sal/bochs/BochsListener.hpp new file mode 100644 index 00000000..81f217ad --- /dev/null +++ b/src/core/sal/bochs/BochsListener.hpp @@ -0,0 +1,26 @@ +#ifndef __BOCHS_LISTENER_HPP__ + #define __BOCHS_LISTENER_HPP__ + +namespace fail { + +/** + * Static internal handler for TimerListeners. This static function is + * called when a previously registered (Bochs) timer triggers. This function + * searches for the provided TimerListener object within the ListenerManager and + * fires such an event by calling \c triggerActiveListeners(). + * @param thisPtr a pointer to the TimerListener-object triggered + * + * FIXME: Due to Bochs internal timer and ips-configuration related stuff, + * the simulator sometimes panics with "keyboard error:21" (see line + * 1777 in bios/rombios.c, function keyboard_init()) if a TimerListener + * is added *before* the bios has been loaded and initialized. To + * reproduce this error, try adding a \c TimerListener as the initial step + * in your experiment code and wait for it (\c addListenerAndResume()). + * This leads to the consequence that timers cannot be added/enabled at + * boot time. + */ +void onTimerTrigger(void *thisPtr); + +} // end-of-namespace: fail + +#endif // __BOCHS_LISTENER_HPP__