Pre-/postprocessing is done within the event objects (Bochs-specific event added), ++coding-style.

git-svn-id: https://www4.informatik.uni-erlangen.de/i4svn/danceos/trunk/devel/fail@1366 8c4709b5-6ec9-48aa-a5cd-a96041d1645a
This commit is contained in:
adrian
2012-06-21 10:47:22 +00:00
parent 5effe564f0
commit ad0cfb9b11
12 changed files with 420 additions and 438 deletions

View File

@ -11,7 +11,7 @@ EventId SimulatorController::addEvent(BaseEvent* ev)
assert(ev != NULL && "FATAL ERROR: Argument (ptr) cannot be NULL!");
EventId ret = m_EvList.add(ev, m_Flows.getCurrent());
// Call the common postprocessing function:
if (!onEventAddition(ev)) { // If the return value signals "false"...,
if (!ev->onEventAddition()) { // If the return value signals "false"...,
m_EvList.remove(ev); // ...skip the addition
ret = INVALID_EVENT;
}
@ -20,10 +20,12 @@ EventId SimulatorController::addEvent(BaseEvent* ev)
BaseEvent* SimulatorController::waitAny(void)
{
if (!hasEvents())
return NULL;
m_Flows.resume();
assert(m_EvList.getLastFired() != NULL &&
"FATAL ERROR: getLastFired() expected to be non-NULL!");
return (m_EvList.getLastFired());
return m_EvList.getLastFired();
}
void SimulatorController::startup()
@ -45,26 +47,21 @@ void SimulatorController::onBreakpointEvent(address_t instrPtr, address_t addres
{
assert(false &&
"FIXME: SimulatorController::onBreakpointEvent() has not been tested before");
// FIXME: Improve performance
// FIXME: Improve performance!
// Loop through all events of type BP*Event:
EventList::iterator it = m_EvList.begin();
while (it != m_EvList.end())
{
while (it != m_EvList.end()) {
BaseEvent* pev = *it;
BPSingleEvent* pbp; BPRangeEvent* pbpr;
if((pbp = dynamic_cast<BPSingleEvent*>(pev)) && pbp->isMatching(instrPtr, address_space))
{
pbp->setTriggerInstructionPointer(instrPtr);
if ((pbp = dynamic_cast<BPSingleEvent*>(pev)) && pbp->isMatching(instrPtr, address_space)) {
pbp->setTriggerInstructionPointer(instrPtr);
it = m_EvList.makeActive(it);
// "it" has already been set to the next element (by calling
// makeActive()):
continue; // -> skip iterator increment
}
else if((pbpr = dynamic_cast<BPRangeEvent*>(pev)) &&
pbpr->isMatching(instrPtr, address_space))
{
} else if ((pbpr = dynamic_cast<BPRangeEvent*>(pev)) &&
pbpr->isMatching(instrPtr, address_space)) {
pbpr->setTriggerInstructionPointer(instrPtr);
it = m_EvList.makeActive(it);
continue; // dito
@ -77,20 +74,17 @@ void SimulatorController::onBreakpointEvent(address_t instrPtr, address_t addres
void SimulatorController::onMemoryAccessEvent(address_t addr, size_t len,
bool is_write, address_t instrPtr)
{
// FIXME: Improve performance
// FIXME: Improve performance!
MemAccessEvent::accessType_t accesstype =
is_write ? MemAccessEvent::MEM_WRITE
: MemAccessEvent::MEM_READ;
EventList::iterator it = m_EvList.begin();
while(it != m_EvList.end()) // check for active events
{
while (it != m_EvList.end()) { // check for active events
BaseEvent* pev = *it;
MemAccessEvent* ev = dynamic_cast<MemAccessEvent*>(pev);
// Is this a MemAccessEvent? Correct access type?
if(!ev || !ev->isMatching(addr, accesstype))
{
if (!ev || !ev->isMatching(addr, accesstype)) {
++it;
continue; // skip event activation
}
@ -106,12 +100,10 @@ void SimulatorController::onMemoryAccessEvent(address_t addr, size_t len,
void SimulatorController::onInterruptEvent(unsigned interruptNum, bool nmi)
{
EventList::iterator it = m_EvList.begin();
while(it != m_EvList.end()) // check for active events
{
while (it != m_EvList.end()) { // check for active events
BaseEvent* pev = *it;
InterruptEvent* pie = dynamic_cast<InterruptEvent*>(pev);
if(!pie || !pie->isMatching(interruptNum))
{
if (!pie || !pie->isMatching(interruptNum)) {
++it;
continue; // skip event activation
}
@ -124,55 +116,52 @@ void SimulatorController::onInterruptEvent(unsigned interruptNum, bool nmi)
bool SimulatorController::isSuppressedInterrupt(unsigned interruptNum)
{
for(size_t i = 0; i < m_SuppressedInterrupts.size(); i++)
if((m_SuppressedInterrupts[i] == interruptNum ||
m_SuppressedInterrupts[i] == ANY_INTERRUPT) && interruptNum != (unsigned) interrupt_to_fire+32 ){
if((int)interruptNum == interrupt_to_fire+32){
for (size_t i = 0; i < m_SuppressedInterrupts.size(); i++)
if ((m_SuppressedInterrupts[i] == interruptNum ||
m_SuppressedInterrupts[i] == ANY_INTERRUPT) &&
interruptNum != (unsigned)interrupt_to_fire + 32) {
if ((int)interruptNum == interrupt_to_fire + 32) {
interrupt_to_fire = -1;
return(true);
return true;
}
return (true);
return true;
}
return (false);
return false;
}
bool SimulatorController::addSuppressedInterrupt(unsigned interruptNum)
{
// Check if already existing:
if(isSuppressedInterrupt(interruptNum+32))
return (false); // already added: nothing to do here
if (isSuppressedInterrupt(interruptNum+32))
return false; // already added: nothing to do here
if(interruptNum == ANY_INTERRUPT){
if (interruptNum == ANY_INTERRUPT) {
m_SuppressedInterrupts.push_back(interruptNum);
return (true);
}else{
return true;
} else {
m_SuppressedInterrupts.push_back(interruptNum+32);
return (true);
return true;
}
}
bool SimulatorController::removeSuppressedInterrupt(unsigned interruptNum)
{
for(size_t i = 0; i < m_SuppressedInterrupts.size(); i++)
{
if(m_SuppressedInterrupts[i] == interruptNum+32 || m_SuppressedInterrupts[i] == ANY_INTERRUPT)
{
for (size_t i = 0; i < m_SuppressedInterrupts.size(); i++) {
if (m_SuppressedInterrupts[i] == interruptNum+32 ||
m_SuppressedInterrupts[i] == ANY_INTERRUPT)
m_SuppressedInterrupts.erase(m_SuppressedInterrupts.begin() + i);
return (true);
}
return true;
}
return (false);
return false;
}
void SimulatorController::onTrapEvent(unsigned trapNum)
{
EventList::iterator it = m_EvList.begin();
while(it != m_EvList.end()) // check for active events
{
while(it != m_EvList.end()) { // check for active events
BaseEvent* pev = *it;
TrapEvent* pte = dynamic_cast<TrapEvent*>(pev);
if(!pte || !pte->isMatching(trapNum))
{
if (!pte || !pte->isMatching(trapNum)) {
++it;
continue; // skip event activation
}
@ -185,12 +174,10 @@ void SimulatorController::onTrapEvent(unsigned trapNum)
void SimulatorController::onGuestSystemEvent(char data, unsigned port)
{
EventList::iterator it = m_EvList.begin();
while(it != m_EvList.end()) // check for active events
{
while (it != m_EvList.end()) { // check for active events
BaseEvent* pev = *it;
GuestEvent* pge = dynamic_cast<GuestEvent*>(pev);
if(pge != NULL)
{
if (pge != NULL) {
pge->setData(data);
pge->setPort(port);
it = m_EvList.makeActive(it);
@ -204,11 +191,9 @@ void SimulatorController::onGuestSystemEvent(char data, unsigned port)
void SimulatorController::onJumpEvent(bool flagTriggered, unsigned opcode)
{
EventList::iterator it = m_EvList.begin();
while(it != m_EvList.end()) // check for active events
{
while (it != m_EvList.end()) { // check for active events
JumpEvent* pje = dynamic_cast<JumpEvent*>(*it);
if(pje != NULL)
{
if (pje != NULL) {
pje->setOpcode(opcode);
pje->setFlagTriggered(flagTriggered);
it = m_EvList.makeActive(it);
@ -238,7 +223,7 @@ void SimulatorController::removeFlow(ExperimentFlow* flow)
BaseEvent* SimulatorController::addEventAndWait(BaseEvent* ev)
{
addEvent(ev);
return (waitAny());
return waitAny();
}
void SimulatorController::terminate(int exCode)