Adding x86 I/O port communication capabilities (see IOPortEvent)
git-svn-id: https://www4.informatik.uni-erlangen.de/i4svn/danceos/trunk/devel/fail@1295 8c4709b5-6ec9-48aa-a5cd-a96041d1645a
This commit is contained in:
@ -117,6 +117,28 @@ void BochsController::onInstrPtrChanged(address_t instrPtr, address_t address_sp
|
||||
// implementation.
|
||||
}
|
||||
|
||||
void BochsController::onIOPortEvent(unsigned char data, unsigned port, bool out) {
|
||||
// Check for active breakpoint-events:
|
||||
fi::EventList::iterator it = m_EvList.begin();
|
||||
while(it != m_EvList.end())
|
||||
{
|
||||
// FIXME: Maybe we need to improve the performance of this check.
|
||||
fi::IOPortEvent* pIOPt = dynamic_cast<fi::IOPortEvent*>(*it);
|
||||
if(pIOPt && pIOPt->isMatching(port, out))
|
||||
{
|
||||
pIOPt->setData(data);
|
||||
it = m_EvList.makeActive(it);
|
||||
// "it" has already been set to the next element (by calling
|
||||
// makeActive()):
|
||||
continue; // -> skip iterator increment
|
||||
}
|
||||
it++;
|
||||
}
|
||||
m_EvList.fireActiveEvents();
|
||||
// Note: SimulatorController::onBreakpointEvent will not be invoked in this
|
||||
// implementation.
|
||||
}
|
||||
|
||||
void BochsController::save(const string& path)
|
||||
{
|
||||
int stat;
|
||||
|
||||
@ -86,9 +86,17 @@ class BochsController : public SimulatorController
|
||||
* Instruction pointer modification handler. This method is called (from
|
||||
* the Breakpoints aspect) every time when the Bochs-internal IP changes.
|
||||
* @param instrPtr the new instruction pointer
|
||||
* @param address_space
|
||||
* @param address_space the address space the CPU is currently in
|
||||
*/
|
||||
void onInstrPtrChanged(address_t instrPtr, address_t address_space);
|
||||
/**
|
||||
* I/O port communication handler. This method is called (from
|
||||
* the IOPortCom aspect) every time when Bochs performs a port I/O operation.
|
||||
* @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 onIOPortEvent(unsigned char data, unsigned port, bool out);
|
||||
/**
|
||||
* This method is called when an experiment flow adds a new event by
|
||||
* calling \c simulator.addEvent(pev) or \c simulator.addEventAndWait(pev).
|
||||
|
||||
38
core/SAL/bochs/IOPortCom.ah
Normal file
38
core/SAL/bochs/IOPortCom.ah
Normal file
@ -0,0 +1,38 @@
|
||||
#ifndef __IOPORT_COM_AH__
|
||||
#define __IOPORT_COM_AH__
|
||||
|
||||
#include "config/FailConfig.hpp"
|
||||
|
||||
#ifdef CONFIG_EVENT_IOPORT
|
||||
|
||||
#include "../../../bochs/bochs.h"
|
||||
#include "../../../bochs/cpu/cpu.h"
|
||||
#include "../SALInst.hpp"
|
||||
|
||||
#include "bochs_helpers.hpp"
|
||||
|
||||
aspect IOPortCom
|
||||
{
|
||||
// ATM only capturing bytewise output (most common, I suppose)
|
||||
pointcut outInstruction() = "% ...::bx_cpu_c::OUT_DXAL%(...)";
|
||||
|
||||
advice execution (outInstruction()) : after ()
|
||||
{
|
||||
unsigned rDX = getCPU(tjp->that())->gen_reg[2].word.rx; // port number
|
||||
unsigned char rAL = getCPU(tjp->that())->gen_reg[0].word.byte.rl; // data
|
||||
sal::simulator.onIOPortEvent(rAL, rDX, true);
|
||||
}
|
||||
|
||||
pointcut inInstruction() = "% ...::bx_cpu_c::IN_ALDX%(...)";
|
||||
|
||||
advice execution (inInstruction()) : after ()
|
||||
{
|
||||
unsigned rDX = getCPU(tjp->that())->gen_reg[2].word.rx; // port number
|
||||
unsigned char rAL = getCPU(tjp->that())->gen_reg[0].word.byte.rl; // data
|
||||
sal::simulator.onIOPortEvent(rAL, rDX, false);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // CONFIG_EVENT_IOPORT
|
||||
|
||||
#endif /* __IOPORT_COM_AH__ */
|
||||
Reference in New Issue
Block a user