diff --git a/src/core/sal/bochs/BochsController.cc b/src/core/sal/bochs/BochsController.cc index e24226f2..d922f638 100644 --- a/src/core/sal/bochs/BochsController.cc +++ b/src/core/sal/bochs/BochsController.cc @@ -55,7 +55,7 @@ void BochsController::onTimerTrigger(void* thisPtr) simulator.m_LstList.triggerActiveListeners(); } -void BochsController::onIOPort(unsigned char data, unsigned port, bool out) { +void BochsController::onIOPort(ConcreteCPU* cpu, unsigned char data, unsigned port, bool out) { // Check for active IOPortListeners: ListenerManager::iterator it = m_LstList.begin(); while (it != m_LstList.end()) { @@ -63,6 +63,7 @@ void BochsController::onIOPort(unsigned char data, unsigned port, bool out) { IOPortListener* pIOPt = dynamic_cast(pLi); if (pIOPt != NULL && pIOPt->isMatching(port, out)) { pIOPt->setData(data); + pIOPt->setTriggerCPU(cpu); it = m_LstList.makeActive(it); // "it" has already been set to the next element (by calling // makeActive()): @@ -157,4 +158,16 @@ const std::string& BochsController::getMnemonic() const return str; } +ConcreteCPU& BochsController::detectCPU(BX_CPU_C* pCPU) const +{ + unsigned i = 0; + #if BX_SUPPORT_SMP + for (; i < BX_SMP_PROCESSORS; i++) { + if (BX_CPU_C[i] == pCPU) // cmp this ptr with all possible CPU objects + break; // index "i" found! -> stop! + } + #endif + return getCPU(i); +} + } // end-of-namespace: fail diff --git a/src/core/sal/bochs/BochsController.hpp b/src/core/sal/bochs/BochsController.hpp index a12de9ec..ed021646 100644 --- a/src/core/sal/bochs/BochsController.hpp +++ b/src/core/sal/bochs/BochsController.hpp @@ -55,11 +55,12 @@ public: /** * I/O port communication handler. This method is called (from * the IOPortCom aspect) every time when Bochs performs a port I/O operation. + * @param cpu the CPU that caused the IO port access * @param data the data transmitted * @param port the port it was transmitted on * @param out true if the I/O traffic has been outbound, false otherwise */ - void onIOPort(unsigned char data, unsigned port, bool out); + void onIOPort(ConcreteCPU* cpu, unsigned char data, unsigned port, bool out); /** * Internal handler for TimerListeners. This method is called when a previously * registered (Bochs) timer triggers. It searches for the provided TimerListener @@ -144,6 +145,13 @@ public: * @param cacheEntry the Bochs internal CPU cache entry ptr */ void updateBPEventInfo(BX_CPU_C *context, bxInstruction_c *instr); + /** + * Retrieves the concrete CPU object, based on the given Bochs' internal pointer \a pCPU. + * @param pCPU the Bochs' internal CPU object + * @return the FailBochs CPU representation that corresponds to Bochs' internal CPU \a pCPU + * @see The uses SimulatorController::getCPU(). + */ + ConcreteCPU& detectCPU(BX_CPU_C* pCPU) const; }; } // end-of-namespace: fail