Namespaces unified (sal+fi -> fail), Code cleanups (-> coding-style.txt), Doxygen-comments fixed.

git-svn-id: https://www4.informatik.uni-erlangen.de/i4svn/danceos/trunk/devel/fail@1319 8c4709b5-6ec9-48aa-a5cd-a96041d1645a
This commit is contained in:
adrian
2012-06-07 17:47:19 +00:00
parent cdd5379e19
commit b7d904140e
136 changed files with 1487 additions and 1554 deletions

View File

@ -1,12 +1,9 @@
// Author: Adrian Böckenkamp
// Date: 09.09.2011
#include <cstdlib>
#include "Memory.hpp"
#include <cstdlib>
namespace fail {
const guest_address_t ADDR_INV = 0;
namespace sal
{
const guest_address_t ADDR_INV = 0;
}

View File

@ -1,17 +1,13 @@
#ifndef __MEMORY_HPP__
#define __MEMORY_HPP__
// Author: Adrian Böckenkamp
// Date: 07.09.2011
#include <vector>
#include <stdint.h>
#include <cstring> // Added for size_t support
#include "SALConfig.hpp"
namespace sal
{
namespace fail {
/**
* \class MemoryManager
@ -73,6 +69,6 @@ class MemoryManager
virtual host_address_t guestToHost(guest_address_t addr) = 0;
};
} // end-of-namespace: sal
} // end-of-namespace: fail
#endif /* __MEMORY_HPP__ */
#endif // __MEMORY_HPP__

View File

@ -1,72 +1,69 @@
// Author: Adrian Böckenkamp
// Date: 07.09.2011
#include "Register.hpp"
namespace sal
namespace fail {
Register* UniformRegisterSet::getRegister(size_t i)
{
Register* UniformRegisterSet::getRegister(size_t i)
{
assert(i < m_Regs.size() && "FATAL ERROR: Invalid index provided!");
return (m_Regs[i]);
}
Register* RegisterManager::getRegister(size_t i)
{
assert(i < m_Registers.size() && "FATAL ERROR: Invalid index provided!");
return (m_Registers[i]);
}
void RegisterManager::add(Register* reg)
{
assert(!reg->isAssigned() && "FATAL ERROR: The register is already assigned!");
m_Registers.push_back(reg);
UniformRegisterSet* urs = getSetOfType(reg->getType());
if(urs == NULL) {
urs = new UniformRegisterSet(reg->getType());
m_Subsets.push_back(urs);
}
urs->m_add(reg);
}
void UniformRegisterSet::m_add(Register* preg)
{
assert(!preg->m_Assigned &&
"FATAL ERROR: The register has already been assigned.");
m_Regs.push_back(preg);
preg->m_Assigned = true;
preg->m_Index = m_Regs.size()-1; // the index within the vector (set)
}
size_t RegisterManager::count() const
{
return (m_Registers.size());
}
UniformRegisterSet& RegisterManager::getSet(size_t i)
{
assert(i < m_Subsets.size() && "FATAL ERROR: Invalid index provided!");
return (*m_Subsets[i]);
}
UniformRegisterSet* RegisterManager::getSetOfType(RegisterType t)
{
for(std::vector< UniformRegisterSet* >::iterator it = m_Subsets.begin();
it != m_Subsets.end(); it++)
{
if((*it)->getType() == t)
return (*it);
}
return (NULL);
}
void RegisterManager::clear()
{
for(std::vector< UniformRegisterSet* >::iterator it = m_Subsets.begin();
it != m_Subsets.end(); it++)
delete (*it);
m_Subsets.clear();
}
assert(i < m_Regs.size() && "FATAL ERROR: Invalid index provided!");
return (m_Regs[i]);
}
Register* RegisterManager::getRegister(size_t i)
{
assert(i < m_Registers.size() && "FATAL ERROR: Invalid index provided!");
return (m_Registers[i]);
}
void RegisterManager::add(Register* reg)
{
assert(!reg->isAssigned() && "FATAL ERROR: The register is already assigned!");
m_Registers.push_back(reg);
UniformRegisterSet* urs = getSetOfType(reg->getType());
if(urs == NULL) {
urs = new UniformRegisterSet(reg->getType());
m_Subsets.push_back(urs);
}
urs->m_add(reg);
}
void UniformRegisterSet::m_add(Register* preg)
{
assert(!preg->m_Assigned &&
"FATAL ERROR: The register has already been assigned.");
m_Regs.push_back(preg);
preg->m_Assigned = true;
preg->m_Index = m_Regs.size()-1; // the index within the vector (set)
}
size_t RegisterManager::count() const
{
return (m_Registers.size());
}
UniformRegisterSet& RegisterManager::getSet(size_t i)
{
assert(i < m_Subsets.size() && "FATAL ERROR: Invalid index provided!");
return (*m_Subsets[i]);
}
UniformRegisterSet* RegisterManager::getSetOfType(RegisterType t)
{
for(std::vector< UniformRegisterSet* >::iterator it = m_Subsets.begin();
it != m_Subsets.end(); it++)
{
if((*it)->getType() == t)
return (*it);
}
return (NULL);
}
void RegisterManager::clear()
{
for(std::vector< UniformRegisterSet* >::iterator it = m_Subsets.begin();
it != m_Subsets.end(); it++)
delete (*it);
m_Subsets.clear();
}
} // end-of-namespace: fail

View File

@ -9,11 +9,11 @@
#include "SALConfig.hpp"
namespace sal
{
namespace fail {
/**
* \enum RegisterType
*
* Lists the different register types. You need to expand this enumeration
* to provide more detailed types for your concrete derived register classes
* specific to a simulator.
@ -27,6 +27,7 @@ enum RegisterType
/**
* \class Register
*
* Represents the basic generic register class. A set of registers is composed
* of classes which had been derived from this class.
*/
@ -106,6 +107,7 @@ class Register
/**
* \class UniformRegisterSet
*
* Represents a (type-uniform) set of registers, e.g. all general purpose
* registers. The granularity of the register type is determined by the
* enumeration \c RegisterType. (All registers within this set must be of the
@ -271,6 +273,6 @@ class RegisterManager
virtual address_t getBasePointer() = 0;
};
} // end-of-namespace: sal
} // end-of-namespace: fail
#endif /* __REGISTER_HPP__ */
#endif // __REGISTER_HPP__

View File

@ -13,8 +13,7 @@
#error SAL Config Target not defined
#endif
namespace sal
{
namespace fail {
typedef guest_address_t address_t; //!< common address type to be used in experiment flows
typedef uint8_t byte_t; //!< 8 bit type for memory access (read or write)
@ -24,6 +23,6 @@ typedef timer_t timer_id_t; //!< type of timer IDs
extern const address_t ADDR_INV; //!< invalid address flag (defined in Memory.cc)
}
} // end-of-namespace: fail
#endif // __SAL_CONFIG_HPP__

View File

@ -8,8 +8,7 @@
#include "bochs/BochsController.hpp"
namespace sal
{
namespace fail {
typedef BochsController ConcreteSimulatorController; //!< concrete simulator (type)
extern ConcreteSimulatorController simulator; //!< the global simulator-controller instance
@ -20,8 +19,7 @@ extern ConcreteSimulatorController simulator; //!< the global simulator-controll
#include "ovp/OVPController.hpp"
namespace sal
{
namespace fail {
typedef OVPController ConcreteSimulatorController; //!< concrete simulator (type)
extern ConcreteSimulatorController simulator; //!< the global simulator-controller instance
@ -32,4 +30,4 @@ extern ConcreteSimulatorController simulator; //!< the global simulator-controll
#error SAL Instance not defined
#endif
#endif /* __SAL_INSTANCE_HPP__ */
#endif // __SAL_INSTANCE_HPP__

View File

@ -2,25 +2,24 @@
#include "SALInst.hpp"
#include "../controller/Event.hpp"
namespace sal
{
namespace fail {
// External reference declared in SALInst.hpp
ConcreteSimulatorController simulator;
fi::EventId SimulatorController::addEvent(fi::BaseEvent* ev)
EventId SimulatorController::addEvent(BaseEvent* ev)
{
assert(ev != NULL && "FATAL ERROR: ev pointer cannot be NULL!");
fi::EventId ret = m_EvList.add(ev, m_Flows.getCurrent());
EventId ret = m_EvList.add(ev, m_Flows.getCurrent());
// Call the common postprocessing function:
if (!onEventAddition(ev)) { // If the return value signals "false"...,
m_EvList.remove(ev); // ...skip the addition
ret = -1;
ret = INVALID_EVENT;
}
return ret;
}
fi::BaseEvent* SimulatorController::waitAny(void)
BaseEvent* SimulatorController::waitAny(void)
{
m_Flows.resume();
assert(m_EvList.getLastFired() != NULL &&
@ -32,6 +31,7 @@ void SimulatorController::startup()
{
// Some greetings to the user:
std::cout << "[SimulatorController] Initializing..." << std::endl;
// TODO: Log-Level?
// Activate previously added experiments to allow initialization:
initExperiments();
@ -50,12 +50,12 @@ void SimulatorController::onBreakpointEvent(address_t instrPtr, address_t addres
// FIXME: Improve performance
// Loop through all events of type BP*Event:
fi::EventList::iterator it = m_EvList.begin();
EventList::iterator it = m_EvList.begin();
while (it != m_EvList.end())
{
fi::BaseEvent* pev = *it;
fi::BPSingleEvent* pbp; fi::BPRangeEvent* pbpr;
if((pbp = dynamic_cast<fi::BPSingleEvent*>(pev)) && pbp->isMatching(instrPtr, address_space))
BaseEvent* pev = *it;
BPSingleEvent* pbp; BPRangeEvent* pbpr;
if((pbp = dynamic_cast<BPSingleEvent*>(pev)) && pbp->isMatching(instrPtr, address_space))
{
pbp->setTriggerInstructionPointer(instrPtr);
it = m_EvList.makeActive(it);
@ -63,7 +63,7 @@ void SimulatorController::onBreakpointEvent(address_t instrPtr, address_t addres
// makeActive()):
continue; // -> skip iterator increment
}
else if((pbpr = dynamic_cast<fi::BPRangeEvent*>(pev)) &&
else if((pbpr = dynamic_cast<BPRangeEvent*>(pev)) &&
pbpr->isMatching(instrPtr, address_space))
{
pbpr->setTriggerInstructionPointer(instrPtr);
@ -80,15 +80,15 @@ void SimulatorController::onMemoryAccessEvent(address_t addr, size_t len,
{
// FIXME: Improve performance
fi::MemAccessEvent::accessType_t accesstype =
is_write ? fi::MemAccessEvent::MEM_WRITE
: fi::MemAccessEvent::MEM_READ;
MemAccessEvent::accessType_t accesstype =
is_write ? MemAccessEvent::MEM_WRITE
: MemAccessEvent::MEM_READ;
fi::EventList::iterator it = m_EvList.begin();
EventList::iterator it = m_EvList.begin();
while(it != m_EvList.end()) // check for active events
{
fi::BaseEvent* pev = *it;
fi::MemAccessEvent* ev = dynamic_cast<fi::MemAccessEvent*>(pev);
BaseEvent* pev = *it;
MemAccessEvent* ev = dynamic_cast<MemAccessEvent*>(pev);
// Is this a MemAccessEvent? Correct access type?
if(!ev || !ev->isMatching(addr, accesstype))
{
@ -106,11 +106,11 @@ void SimulatorController::onMemoryAccessEvent(address_t addr, size_t len,
void SimulatorController::onInterruptEvent(unsigned interruptNum, bool nmi)
{
fi::EventList::iterator it = m_EvList.begin();
EventList::iterator it = m_EvList.begin();
while(it != m_EvList.end()) // check for active events
{
fi::BaseEvent* pev = *it;
fi::InterruptEvent* pie = dynamic_cast<fi::InterruptEvent*>(pev);
BaseEvent* pev = *it;
InterruptEvent* pie = dynamic_cast<InterruptEvent*>(pev);
if(!pie || !pie->isMatching(interruptNum))
{
++it;
@ -127,7 +127,7 @@ bool SimulatorController::isSuppressedInterrupt(unsigned interruptNum)
{
for(size_t i = 0; i < m_SuppressedInterrupts.size(); i++)
if((m_SuppressedInterrupts[i] == interruptNum ||
m_SuppressedInterrupts[i] == fi::ANY_INTERRUPT) && interruptNum != (unsigned) interrupt_to_fire+32 ){
m_SuppressedInterrupts[i] == ANY_INTERRUPT) && interruptNum != (unsigned) interrupt_to_fire+32 ){
if((int)interruptNum == interrupt_to_fire+32){
interrupt_to_fire = -1;
return(true);
@ -143,7 +143,7 @@ bool SimulatorController::addSuppressedInterrupt(unsigned interruptNum)
if(isSuppressedInterrupt(interruptNum+32))
return (false); // already added: nothing to do here
if(interruptNum == fi::ANY_INTERRUPT){
if(interruptNum == ANY_INTERRUPT){
m_SuppressedInterrupts.push_back(interruptNum);
return (true);
}else{
@ -156,7 +156,7 @@ bool SimulatorController::removeSuppressedInterrupt(unsigned interruptNum)
{
for(size_t i = 0; i < m_SuppressedInterrupts.size(); i++)
{
if(m_SuppressedInterrupts[i] == interruptNum+32 || m_SuppressedInterrupts[i] == fi::ANY_INTERRUPT)
if(m_SuppressedInterrupts[i] == interruptNum+32 || m_SuppressedInterrupts[i] == ANY_INTERRUPT)
{
m_SuppressedInterrupts.erase(m_SuppressedInterrupts.begin() + i);
return (true);
@ -167,11 +167,11 @@ bool SimulatorController::removeSuppressedInterrupt(unsigned interruptNum)
void SimulatorController::onTrapEvent(unsigned trapNum)
{
fi::EventList::iterator it = m_EvList.begin();
EventList::iterator it = m_EvList.begin();
while(it != m_EvList.end()) // check for active events
{
fi::BaseEvent* pev = *it;
fi::TrapEvent* pte = dynamic_cast<fi::TrapEvent*>(pev);
BaseEvent* pev = *it;
TrapEvent* pte = dynamic_cast<TrapEvent*>(pev);
if(!pte || !pte->isMatching(trapNum))
{
++it;
@ -185,11 +185,11 @@ void SimulatorController::onTrapEvent(unsigned trapNum)
void SimulatorController::onGuestSystemEvent(char data, unsigned port)
{
fi::EventList::iterator it = m_EvList.begin();
EventList::iterator it = m_EvList.begin();
while(it != m_EvList.end()) // check for active events
{
fi::BaseEvent* pev = *it;
fi::GuestEvent* pge = dynamic_cast<fi::GuestEvent*>(pev);
BaseEvent* pev = *it;
GuestEvent* pge = dynamic_cast<GuestEvent*>(pev);
if(pge != NULL)
{
pge->setData(data);
@ -204,10 +204,10 @@ void SimulatorController::onGuestSystemEvent(char data, unsigned port)
void SimulatorController::onJumpEvent(bool flagTriggered, unsigned opcode)
{
fi::EventList::iterator it = m_EvList.begin();
EventList::iterator it = m_EvList.begin();
while(it != m_EvList.end()) // check for active events
{
fi::JumpEvent* pje = dynamic_cast<fi::JumpEvent*>(*it);
JumpEvent* pje = dynamic_cast<JumpEvent*>(*it);
if(pje != NULL)
{
pje->setOpcode(opcode);
@ -220,7 +220,7 @@ void SimulatorController::onJumpEvent(bool flagTriggered, unsigned opcode)
m_EvList.fireActiveEvents();
}
void SimulatorController::addFlow(fi::ExperimentFlow* flow)
void SimulatorController::addFlow(ExperimentFlow* flow)
{
// Store the (flow,corohandle)-tuple internally and create its coroutine:
m_Flows.create(flow);
@ -228,7 +228,7 @@ void SimulatorController::addFlow(fi::ExperimentFlow* flow)
m_Flows.toggle(flow);
}
void SimulatorController::removeFlow(fi::ExperimentFlow* flow)
void SimulatorController::removeFlow(ExperimentFlow* flow)
{
// remove all remaining events of this flow
clearEvents(flow);
@ -236,7 +236,7 @@ void SimulatorController::removeFlow(fi::ExperimentFlow* flow)
m_Flows.remove(flow);
}
fi::BaseEvent* SimulatorController::addEventAndWait(fi::BaseEvent* ev)
BaseEvent* SimulatorController::addEventAndWait(BaseEvent* ev)
{
addEvent(ev);
return (waitAny());
@ -247,7 +247,7 @@ T* SimulatorController::getExperimentData()
{
//BEGIN ONLY FOR TESTING------REMOVE--------REMOVE---------REMOVE--------REMOVE-------REMOVE-------
//Daten in Struktur schreiben und in Datei speichern
ofstream fileWrite;
std::ofstream fileWrite;
fileWrite.open("test.txt");
T* faultCovExWrite = new T();;
@ -261,7 +261,7 @@ T* SimulatorController::getExperimentData()
faultCovExWrite->set_m_instrptr2(0x1122);
//In ExperimentData verpacken
fi::ExperimentData exDaWrite(faultCovExWrite);
ExperimentData exDaWrite(faultCovExWrite);
//Serialisierung ueber Wrapper-Methode in ExperimentData
exDaWrite.serialize(&fileWrite);
@ -269,13 +269,13 @@ T* SimulatorController::getExperimentData()
fileWrite.close();
ifstream fileRead;
std::ifstream fileRead;
fileRead.open("test.txt");
//END ONLY FOR TESTING------REMOVE--------REMOVE---------REMOVE--------REMOVE-------REMOVE-------
//TODO: implement server-client communication----------------------------------------------
T* concreteExpDat = new T();
fi::ExperimentData exDaRead(concreteExpDat);
ExperimentData exDaRead(concreteExpDat);
exDaRead.unserialize(&fileRead);
return (concreteExpDat);
@ -285,8 +285,8 @@ void SimulatorController::terminate(int exCode)
{
// Attention: This could cause problems, e.g., because of non-closed sockets
std::cout << "[FAIL] Exit called by experiment with exit code: " << exCode << std::endl;
// TODO: (Non-)Verbose-Mode?
// TODO: (Non-)Verbose-Mode? Log-Level?
exit(exCode);
}
} // end-of-namespace: sal
} // end-of-namespace: fail

View File

@ -1,8 +1,5 @@
#ifndef __SIMULATOR_CONTROLLER_HPP__
#define __SIMULATOR_CONTROLLER_HPP__
// Author: Adrian Böckenkamp
// Date: 23.01.2012
#include <iostream>
#include <string>
@ -19,17 +16,10 @@
#include "../controller/ExperimentData.hpp"
#include "SALConfig.hpp"
using namespace std;
namespace fail {
namespace fi {
// Incomplete types suffice here:
class ExperimentFlow;
}
/// Simulator Abstraction Layer namespace
namespace sal
{
// incomplete types suffice here
class RegisterManager;
class MemoryManager;
@ -37,7 +27,8 @@ class MemoryManager;
* \class SimulatorController
*
* \brief The abstract interface for controlling simulators and
* accessing experiment data/flows.
* accessing experiment data/flows (as part of the "Simulator
* Abstraction Layer".
*
* This class manages (1..N) experiments and provides access to the underlying
* simulator/debugger system. Experiments can enlist arbritrary events
@ -48,13 +39,13 @@ class MemoryManager;
class SimulatorController
{
protected:
fi::EventList m_EvList; //!< storage where events are being buffered
fi::CoroutineManager m_Flows; //!< managed experiment flows
EventList m_EvList; //!< storage where events are being buffered
CoroutineManager m_Flows; //!< managed experiment flows
RegisterManager *m_Regs; //!< access to cpu register
MemoryManager *m_Mem; //!< access to memory pool
//! list of suppressed interrupts
std::vector<unsigned> m_SuppressedInterrupts;
friend class fi::EventList; //!< "outsources" the event management
friend class EventList; //!< "outsources" the event management
public:
SimulatorController()
: m_Regs(NULL), m_Mem(NULL) { }
@ -130,7 +121,7 @@ class SimulatorController
* the addition of the event \a pev, yielding an error in the
* experiment flow (i.e. -1 is returned).
*/
virtual bool onEventAddition(fi::BaseEvent* pev) { return true; }
virtual bool onEventAddition(BaseEvent* pev) { return true; }
/**
* This method is called when an experiment flow removes an event from
* the event-management by calling \c removeEvent(prev), \c clearEvents()
@ -138,7 +129,7 @@ class SimulatorController
* event handler will be called *before* the event is actually deleted.
* @param pev the event to be deleted when returning from the event handler
*/
virtual void onEventDeletion(fi::BaseEvent* pev) { }
virtual void onEventDeletion(BaseEvent* pev) { }
/**
* This method is called when an previously added event is about to be
* triggered by the simulator-backend. More specifically, this event handler
@ -146,7 +137,7 @@ class SimulatorController
* corresponding coroutine is toggled.
* @param pev the event to be triggered when returning from the event handler
*/
virtual void onEventTrigger(fi::BaseEvent* pev) { }
virtual void onEventTrigger(BaseEvent* pev) { }
/* ********************************************************************
* Simulator Controller & Access API:
* ********************************************************************/
@ -154,13 +145,13 @@ class SimulatorController
* Save simulator state.
* @param path Location to store state information
*/
virtual void save(const string& path) = 0;
virtual void save(const std::string& path) = 0;
/**
* Restore simulator state. Implicitly discards all previously
* registered events.
* @param path Location to previously saved state information
*/
virtual void restore(const string& path) = 0;
virtual void restore(const std::string& path) = 0;
/**
* Reboot simulator.
*/
@ -221,13 +212,13 @@ class SimulatorController
* run it in.
* @param flow the experiment flow object to be added
*/
void addFlow(fi::ExperimentFlow* flow);
void addFlow(ExperimentFlow* flow);
/**
* Removes the specified experiment or plugin and destroys its coroutine
* and all associated events.
* @param flow the experiment flow object to be removed
*/
void removeFlow(fi::ExperimentFlow* flow);
void removeFlow(ExperimentFlow* flow);
/**
* Add event ev to the event management. This causes the event to be
* active.
@ -235,19 +226,19 @@ class SimulatorController
* @return the id of the event used to identify the object on occurrence;
* -1 is returned on errors
*/
fi::EventId addEvent(fi::BaseEvent* ev);
EventId addEvent(BaseEvent* ev);
/**
* Removes the event with the specified id.
* @param ev the pointer of the event-object to be removed; if \a ev is
* equal to \c NULL all events (for all experiments) will be
* removed
*/
void removeEvent(fi::BaseEvent* ev) { m_EvList.remove(ev); }
void removeEvent(BaseEvent* ev) { m_EvList.remove(ev); }
/**
* Removes all previously added events for all experiments. To
* restrict this to a specific experiment flow, pass a pointer to it.
*/
void clearEvents(fi::ExperimentFlow *flow = 0) { m_EvList.remove(flow); }
void clearEvents(ExperimentFlow *flow = 0) { m_EvList.remove(flow); }
/**
* Waits on any events which have been added to the event management. If
* one of those events occour, waitAny() will return the id of that event.
@ -256,7 +247,7 @@ class SimulatorController
* FIXME: Maybe this should return immediately if there are not events?
* (additional parameter flag?)
*/
fi::BaseEvent* waitAny();
BaseEvent* waitAny();
/**
* Add event \a ev to the global buffer and wait for it (combines
* \c addEvent() and \c waitAny()).
@ -266,7 +257,7 @@ class SimulatorController
*
* FIXME: Rename to make clear this returns when *any* event occurs
*/
fi::BaseEvent* addEventAndWait(fi::BaseEvent* ev);
BaseEvent* addEventAndWait(BaseEvent* ev);
/**
* Checks whether any experiment flow has events in the event-list.
* @return \c true if there are still events, or \c false otherwise
@ -285,6 +276,6 @@ class SimulatorController
template <class T> T* getExperimentData();
};
} // end-of-namespace: sal
} // end-of-namespace: fail
#endif /* __SIMULATOR_CONTROLLER_HPP__ */
#endif // __SIMULATOR_CONTROLLER_HPP__

View File

@ -7,8 +7,7 @@
// Type definitions and configuration settings for
// the Bochs simulator.
namespace sal
{
namespace fail {
typedef bx_address guest_address_t; //!< the guest memory address type
typedef Bit8u* host_address_t; //!< the host memory address type
@ -19,7 +18,6 @@ typedef Bit8u* host_address_t; //!< the host memory address type
#endif
typedef int timer_t; //!< type of timer IDs
};
#endif /* __BOCHS_CONFIG_HPP__ */
} // end-of-namespace: fail
#endif // __BOCHS_CONFIG_HPP__

View File

@ -6,13 +6,12 @@
#include "../Register.hpp"
#include "../SALInst.hpp"
namespace sal
{
namespace fail {
#ifdef DANCEOS_RESTORE
bx_bool restore_bochs_request = false;
bx_bool save_bochs_request = false;
string sr_path = "";
std::string sr_path = "";
#endif
bx_bool reboot_bochs_request = false;
@ -26,9 +25,9 @@ BochsController::BochsController()
// Add the general purpose register:
#if BX_SUPPORT_X86_64
// -- 64 bit register --
const string names[] = { "RAX", "RCX", "RDX", "RBX", "RSP", "RBP", "RSI",
"RDI", "R8", "R9", "R10", "R11", "R12", "R13",
"R14", "R15" };
const std::string names[] = { "RAX", "RCX", "RDX", "RBX", "RSP", "RBP", "RSI",
"RDI", "R8", "R9", "R10", "R11", "R12", "R13",
"R14", "R15" };
for(unsigned short i = 0; i < 16; i++)
{
BxGPReg* pReg = new BxGPReg(i, 64, &(BX_CPU(0)->gen_reg[i].rrx));
@ -37,8 +36,8 @@ BochsController::BochsController()
}
#else
// -- 32 bit register --
const string names[] = { "EAX", "ECX", "EDX", "EBX", "ESP", "EBP", "ESI",
"EDI" };
const std::string names[] = { "EAX", "ECX", "EDX", "EBX", "ESP", "EBP", "ESI",
"EDI" };
for(unsigned short i = 0; i < 8; i++)
{
BxGPReg* pReg = new BxGPReg(i, 32, &(BX_CPU(0)->gen_reg[i].dword.erx));
@ -101,11 +100,11 @@ void BochsController::onInstrPtrChanged(address_t instrPtr, address_t address_sp
(*m_pDest) << "0x" << std::hex << instrPtr;
#endif
// Check for active breakpoint-events:
fi::EventList::iterator it = m_EvList.begin();
EventList::iterator it = m_EvList.begin();
while(it != m_EvList.end())
{
// FIXME: Maybe we need to improve the performance of this check.
fi::BPEvent* pEvBreakpt = dynamic_cast<fi::BPEvent*>(*it);
BPEvent* pEvBreakpt = dynamic_cast<BPEvent*>(*it);
if(pEvBreakpt && pEvBreakpt->isMatching(instrPtr, address_space))
{
pEvBreakpt->setTriggerInstructionPointer(instrPtr);
@ -121,18 +120,18 @@ void BochsController::onInstrPtrChanged(address_t instrPtr, address_t address_sp
//this code is highly optimised for the average case, so it me appear a bit ugly
bool do_fire = false;
unsigned i = 0;
fi::BufferCache<fi::BPEvent*> *buffer_cache = m_EvList.getBPBuffer();
while(i < buffer_cache->get_count()) {
fi::BPEvent *pEvBreakpt = buffer_cache->get(i);
BufferCache<BPEvent*> *buffer_cache = m_EvList.getBPBuffer();
while(i < buffer_cache->getCount()) {
BPEvent *pEvBreakpt = buffer_cache->get(i);
if(pEvBreakpt->isMatching(instrPtr, address_space)) {
pEvBreakpt->setTriggerInstructionPointer(instrPtr);
//transition to STL: find the element we are working on in the Event List
fi::EventList::iterator it = std::find(m_EvList.begin(), m_EvList.end(), pEvBreakpt);
EventList::iterator it = std::find(m_EvList.begin(), m_EvList.end(), pEvBreakpt);
it = m_EvList.makeActive(it);
//find out how much elements need to be skipped to get in sync again
//(should be one or none, the loop is just to make sure)
for(unsigned j = i; j < buffer_cache->get_count(); j++) {
for(unsigned j = i; j < buffer_cache->getCount(); j++) {
if(buffer_cache->get(j) == (*it)) {
i = j;
break;
@ -154,11 +153,11 @@ void BochsController::onInstrPtrChanged(address_t instrPtr, address_t address_sp
void BochsController::onIOPortEvent(unsigned char data, unsigned port, bool out) {
// Check for active breakpoint-events:
fi::EventList::iterator it = m_EvList.begin();
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);
IOPortEvent* pIOPt = dynamic_cast<IOPortEvent*>(*it);
if(pIOPt && pIOPt->isMatching(port, out))
{
pIOPt->setData(data);
@ -174,14 +173,14 @@ void BochsController::onIOPortEvent(unsigned char data, unsigned port, bool out)
// implementation.
}
void BochsController::save(const string& path)
void BochsController::save(const std::string& path)
{
int stat;
stat = mkdir(path.c_str(), 0777);
if(!(stat == 0 || errno == EEXIST))
std::cout << "[FAIL] Can not create target-directory to save!" << std::endl;
// TODO: (Non-)Verbose-Mode? Maybe better: use return value to indicate failure?
// TODO: (Non-)Verbose-Mode? Log-level? Maybe better: use return value to indicate failure?
save_bochs_request = true;
sr_path = path;
@ -195,7 +194,7 @@ void BochsController::saveDone()
m_Flows.toggle(m_CurrFlow);
}
void BochsController::restore(const string& path)
void BochsController::restore(const std::string& path)
{
clearEvents();
restore_bochs_request = true;
@ -242,10 +241,10 @@ void BochsController::m_onTimerTrigger(void* thisPtr)
{
// FIXME: The timer logic can be modified to use only one timer in Bochs.
// (For now, this suffices.)
fi::TimerEvent* pTmEv = static_cast<fi::TimerEvent*>(thisPtr);
TimerEvent* pTmEv = static_cast<TimerEvent*>(thisPtr);
// Check for a matching TimerEvent. (In fact, we are only
// interessted in the iterator pointing at pTmEv.):
fi::EventList::iterator it = std::find(simulator.m_EvList.begin(),
EventList::iterator it = std::find(simulator.m_EvList.begin(),
simulator.m_EvList.end(), pTmEv);
// TODO: This has O(|m_EvList|) time complexity. We can further improve this
// by creating a method such that makeActive(pTmEv) works as well,
@ -254,7 +253,7 @@ void BochsController::m_onTimerTrigger(void* thisPtr)
simulator.m_EvList.fireActiveEvents();
}
timer_id_t BochsController::m_registerTimer(fi::TimerEvent* pev)
timer_id_t BochsController::m_registerTimer(TimerEvent* pev)
{
assert(pev != NULL);
return static_cast<timer_id_t>(
@ -262,18 +261,18 @@ timer_id_t BochsController::m_registerTimer(fi::TimerEvent* pev)
1/*start immediately*/, "Fail*: BochsController"/*name*/));
}
bool BochsController::m_unregisterTimer(fi::TimerEvent* pev)
bool BochsController::m_unregisterTimer(TimerEvent* pev)
{
assert(pev != NULL);
bx_pc_system.deactivate_timer(static_cast<unsigned>(pev->getId()));
return bx_pc_system.unregisterTimer(static_cast<unsigned>(pev->getId()));
}
bool BochsController::onEventAddition(fi::BaseEvent* pev)
bool BochsController::onEventAddition(BaseEvent* pev)
{
fi::TimerEvent* tmev;
TimerEvent* tmev;
// Register the timer event in the Bochs simulator:
if ((tmev = dynamic_cast<fi::TimerEvent*>(pev)) != NULL) {
if ((tmev = dynamic_cast<TimerEvent*>(pev)) != NULL) {
tmev->setId(m_registerTimer(tmev));
if(tmev->getId() == -1)
return false; // unable to register the timer (error in Bochs' function call)
@ -282,21 +281,21 @@ bool BochsController::onEventAddition(fi::BaseEvent* pev)
return true;
}
void BochsController::onEventDeletion(fi::BaseEvent* pev)
void BochsController::onEventDeletion(BaseEvent* pev)
{
fi::TimerEvent* tmev;
TimerEvent* tmev;
// Unregister the time event:
if ((tmev = dynamic_cast<fi::TimerEvent*>(pev)) != NULL) {
if ((tmev = dynamic_cast<TimerEvent*>(pev)) != NULL) {
m_unregisterTimer(tmev);
}
// Note: Maybe more stuff to do here for other event types.
}
void BochsController::onEventTrigger(fi::BaseEvent* pev)
void BochsController::onEventTrigger(BaseEvent* pev)
{
fi::TimerEvent* tmev;
TimerEvent* tmev;
// Unregister the time event, if once-flag is true:
if ((tmev = dynamic_cast<fi::TimerEvent*>(pev)) != NULL) {
if ((tmev = dynamic_cast<TimerEvent*>(pev)) != NULL) {
if (tmev->getOnceFlag()) // deregister the timer (timer = single timeout)
m_unregisterTimer(tmev);
else // re-add the event (repetitive timer), tunneling the onEventAddition-handler
@ -305,4 +304,4 @@ void BochsController::onEventTrigger(fi::BaseEvent* pev)
// Note: Maybe more stuff to do here for other event types.
}
} // end-of-namespace: sal
} // end-of-namespace: fail

View File

@ -20,13 +20,9 @@
#include "../../../bochs/iodev/iodev.h"
#include "../../../bochs/pc_system.h"
using namespace std;
namespace fail {
namespace fi { class ExperimentFlow; }
/// Simulator Abstraction Layer namespace
namespace sal
{
class ExperimentFlow;
/**
* \class BochsController
@ -35,7 +31,7 @@ namespace sal
class BochsController : public SimulatorController
{
private:
fi::ExperimentFlow* m_CurrFlow; //!< Stores the current flow for save/restore-operations
ExperimentFlow* m_CurrFlow; //!< Stores the current flow for save/restore-operations
#ifdef DEBUG
unsigned m_Regularity;
unsigned m_Counter;
@ -67,14 +63,14 @@ class BochsController : public SimulatorController
* along with the TimerEvent, @see getId(). On error, -1 is returned
* (e.g. because a timer with the same id is already existing)
*/
timer_id_t m_registerTimer(fi::TimerEvent* pev);
timer_id_t m_registerTimer(TimerEvent* pev);
/**
* Deletes a timer. No further events will be triggered by the timer.
* @param pev a pointer to the TimerEvent-object to be removed
* @return \c true if the timer with \a pev->getId() has been removed
* successfully, \c false otherwise
*/
bool m_unregisterTimer(fi::TimerEvent* pev);
bool m_unregisterTimer(TimerEvent* pev);
public:
// Initialize the controller.
BochsController();
@ -106,7 +102,7 @@ class BochsController : public SimulatorController
* @return You should return \c true to continue and \c false to prevent
* the addition of the event \a pev.
*/
bool onEventAddition(fi::BaseEvent* pev);
bool onEventAddition(BaseEvent* pev);
/**
* This method is called when an experiment flow removes an event from
* the event-management by calling \c removeEvent(prev), \c clearEvents()
@ -114,7 +110,7 @@ class BochsController : public SimulatorController
* this event handler will be called *before* the event is actually deleted.
* @param pev the event to be deleted when returning from the event handler
*/
void onEventDeletion(fi::BaseEvent* pev);
void onEventDeletion(BaseEvent* pev);
/**
* This method is called when an previously added event is about to be
* triggered by the simulator-backend. More specifically, this event handler
@ -122,7 +118,7 @@ class BochsController : public SimulatorController
* corresponding coroutine is toggled.
* @param pev the event to be triggered when returning from the event handler
*/
void onEventTrigger(fi::BaseEvent* pev);
void onEventTrigger(BaseEvent* pev);
/* ********************************************************************
* Simulator Controller & Access API:
* ********************************************************************/
@ -130,7 +126,7 @@ class BochsController : public SimulatorController
* Save simulator state.
* @param path Location to store state information
*/
void save(const string& path);
void save(const std::string& path);
/**
* Save finished: Callback from Simulator
*/
@ -139,7 +135,7 @@ class BochsController : public SimulatorController
* Restore simulator state. Clears all Events.
* @param path Location to previously saved state information
*/
void restore(const string& path);
void restore(const std::string& path);
/**
* Restore finished: Callback from Simulator
*/
@ -168,7 +164,7 @@ class BochsController : public SimulatorController
* instruction pointer, 0 to disable
* @param dest specifies the output destition; defaults to \c std::cout
*/
void dbgEnableInstrPtrOutput(unsigned regularity, std::ostream* dest = &cout);
void dbgEnableInstrPtrOutput(unsigned regularity, std::ostream* dest = &std::cout);
#endif
/* ********************************************************************
* BochsController-specific (not implemented in SimulatorController!):
@ -196,6 +192,6 @@ class BochsController : public SimulatorController
}
};
} // end-of-namespace: sal
} // end-of-namespace: fail
#endif /* __BOCHS_CONTROLLER_HPP__ */
#endif // __BOCHS_CONTROLLER_HPP__

View File

@ -3,8 +3,7 @@
#include "../Memory.hpp"
namespace sal
{
namespace fail {
/**
* \class BochsMemoryManager
@ -115,6 +114,6 @@ class BochsMemoryManager : public MemoryManager
}
};
}
} // end-of-namespace: fail
#endif
#endif // __BOCHS_MEMORY_HPP__

View File

@ -2,13 +2,12 @@
#define __BOCHS_REGISTER_HPP__
#include "../Register.hpp"
#include "../../../bochs/bochs.h"
#include <iostream>
#include <cassert>
namespace sal {
namespace fail {
/**
* \class BochsRegister
@ -241,6 +240,6 @@ class BochsRegisterManager : public RegisterManager
}
};
} // end-of-namespace: sal
} // end-of-namespace: fail
#endif /* __BOCHS_REGISTER_HPP__ */
#endif // __BOCHS_REGISTER_HPP__

View File

@ -25,11 +25,11 @@ aspect Breakpoints
//bxInstruction_c* pInstr = *(tjp->arg<1>());
// report this event to the Bochs controller:
sal::simulator.onInstrPtrChanged(pThis->get_instruction_pointer(), pThis->cr3);
fail::simulator.onInstrPtrChanged(pThis->get_instruction_pointer(), pThis->cr3);
// Note: get_bx_opcode_name(pInstr->getIaOpcode()) retrieves the mnemonics.
}
};
#endif
#endif // CONFIG_EVENT_BREAKPOINTS
#endif
#endif // __BREAKPOINTS_AH__

View File

@ -13,10 +13,10 @@
// Fixed "port number" for "Guest system >> Bochs" communication
#define BOCHS_COM_PORT 0x378
// FIXME: This #define should be located in a config or passed within the event object...
aspect GuestSysCom
{
pointcut outInstructions() = "% ...::bx_cpu_c::OUT_DX%(...)";
advice execution (outInstructions()) : after ()
@ -27,11 +27,11 @@ aspect GuestSysCom
unsigned rDX = getCPU(tjp->that())->gen_reg[2].word.rx; // port number
unsigned rAL = getCPU(tjp->that())->gen_reg[0].word.byte.rl; // data
if (rDX == BOCHS_COM_PORT) {
sal::simulator.onGuestSystemEvent((char)rAL, rDX);
fail::simulator.onGuestSystemEvent((char)rAL, rDX);
}
}
};
#endif // CONFIG_EVENT_GUESTSYS
#endif /* __GUESTSYS_COM_AH__ */
#endif // __GUESTSYS_COM_AH__

View File

@ -1,5 +1,5 @@
#ifndef __IOPORT_COM_AH__
#define __IOPORT_COM_AH__
#define __IOPORT_COM_AH__
#include "config/FailConfig.hpp"
@ -20,7 +20,7 @@ aspect IOPortCom
{
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);
fail::simulator.onIOPortEvent(rAL, rDX, true);
}
pointcut inInstruction() = "% ...::bx_cpu_c::IN_ALDX(...)";
@ -29,10 +29,10 @@ aspect IOPortCom
{
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);
fail::simulator.onIOPortEvent(rAL, rDX, false);
}
};
#endif // CONFIG_EVENT_IOPORT
#endif /* __IOPORT_COM_AH__ */
#endif // __IOPORT_COM_AH__

View File

@ -29,12 +29,12 @@ aspect Interrupt
unsigned vector = *(tjp->arg<0>());
unsigned type = *(tjp->arg<1>());
if(type == BX_EXTERNAL_INTERRUPT)
sal::simulator.onInterruptEvent(vector, false);
fail::simulator.onInterruptEvent(vector, false);
else if(type == BX_NMI)
sal::simulator.onInterruptEvent(vector, true);
fail::simulator.onInterruptEvent(vector, true);
}
};
#endif // CONFIG_EVENT_INTERRUPT
#endif /* __INTERRUPT_AH__ */
#endif // __INTERRUPT_AH__

View File

@ -16,7 +16,7 @@ aspect Interrupt_FI
advice execution (interrupt_method()) : around ()
{
unsigned vector = *(tjp->arg<0>());
if(!sal::simulator.isSuppressedInterrupt(vector)){
if(!fail::simulator.isSuppressedInterrupt(vector)){
tjp->proceed();
}
}
@ -24,4 +24,4 @@ aspect Interrupt_FI
#endif // CONFIG_SUPPRESS_INTERRUPTS
#endif /* __INTERRUPT_SUPPRESSION_AH__ */
#endif // __INTERRUPT_SUPPRESSION_AH__

View File

@ -9,10 +9,11 @@
#include <cstdlib>
#include <string>
#include <ctime>
#include "../../../bochs/bochs.h"
#include "../SALInst.hpp"
using namespace std;
// FIXME: This seems (partial) deprecated as well...
aspect Jump
{
@ -59,7 +60,7 @@ aspect Jump
advice execution (defJumpInstructions()) : around()
{
bxInstruction_c* pInstr = *(tjp->arg<0>()); // bxInstruction_c-object
sal::simulator.onJumpEvent(true, pInstr->getIaOpcode());
fail::simulator.onJumpEvent(true, pInstr->getIaOpcode());
/*
JoinPoint::That* pThis = tjp->that();
if(pThis == NULL)
@ -108,7 +109,7 @@ aspect Jump
advice execution (regJumpInstructions()) : around ()
{
bxInstruction_c* pInstr = *(tjp->arg<0>()); // bxInstruction_c-object
sal::simulator.onJumpEvent(false, pInstr->getIaOpcode());
fail::simulator.onJumpEvent(false, pInstr->getIaOpcode());
/*
JoinPoint::That* pThis = tjp->that();
@ -135,5 +136,5 @@ aspect Jump
#endif // CONFIG_EVENT_JUMP
#endif /* __JUMP_AH__ */
#endif // __JUMP_AH__

View File

@ -3,6 +3,8 @@
#include "config/FailConfig.hpp"
// FIXME: What's the purpose of this file/code? Deprecated?
#if 0
// #if defined(CONFIG_SR_RESTORE) || defined(CONFIG_SR_REBOOT)
@ -18,11 +20,11 @@ aspect jumpToPreviousCtx
advice execution (end_reset_handler()) : after ()
{
if (sal::restore_bochs_request || sal::reboot_bochs_request )
if (fail::restore_bochs_request || fail::reboot_bochs_request )
{
sal::restore_bochs_request = false;
sal::reboot_bochs_request = false;
sal::simulator.toPreviousCtx();
fail::restore_bochs_request = false;
fail::reboot_bochs_request = false;
fail::simulator.toPreviousCtx();
}
}

View File

@ -8,11 +8,13 @@
#include <iostream>
#include <cstdlib>
#include <ctime>
#include "bochs.h"
#include "bochs.h"
#include "../../controller/EventList.hpp"
#include "../../controller/Event.hpp"
// FIXME: This is deprecated stuff. Delete this file.
using namespace std;
// FIXME this code doesn't make any sense for the read_virtual_% functions

View File

@ -18,7 +18,7 @@
// TODO warn on uncovered memory accesses
aspect MemEvents
{
sal::address_t rmw_address;
fail::address_t rmw_address;
pointcut write_methods() =
"% ...::bx_cpu_c::write_virtual_%(...)" && // -> access32/64.cc
@ -59,27 +59,29 @@ aspect MemEvents
//
#ifdef CONFIG_EVENT_MEMWRITE
advice execution (write_methods()) : after () {
sal::simulator.onMemoryAccessEvent(
fail::simulator.onMemoryAccessEvent(
*(tjp->arg<1>()), sizeof(*(tjp->arg<2>())), true,
getCPU(tjp->that())->prev_rip);
}
advice execution (write_methods_RMW()) : after () {
sal::simulator.onMemoryAccessEvent(
fail::simulator.onMemoryAccessEvent(
rmw_address, sizeof(*(tjp->arg<0>())), true,
getCPU(tjp->that())->prev_rip);
}
advice execution (write_methods_new_stack()) : after () {
std::cerr << "WOOOOOT write_methods_new_stack" << std::endl;
sal::simulator.onMemoryAccessEvent(
// TODO: Log-level?
fail::simulator.onMemoryAccessEvent(
*(tjp->arg<1>()), sizeof(*(tjp->arg<3>())), true,
getCPU(tjp->that())->prev_rip);
}
advice execution (write_methods_new_stack_64()) : after () {
std::cerr << "WOOOOOT write_methods_new_stack_64" << std::endl;
sal::simulator.onMemoryAccessEvent(
// TODO: Log-level?
fail::simulator.onMemoryAccessEvent(
*(tjp->arg<0>()), sizeof(*(tjp->arg<2>())), true,
getCPU(tjp->that())->prev_rip);
}
@ -90,7 +92,7 @@ aspect MemEvents
// memory (e.g., to read vectors from the interrupt vector
// table).
/*
sal::simulator.onMemoryAccessEvent(
fail::simulator.onMemoryAccessEvent(
*(tjp->arg<0>()), sizeof(*(tjp->arg<1>())), true,
getCPU(tjp->that())->prev_rip);
*/
@ -105,13 +107,13 @@ aspect MemEvents
//
#ifdef CONFIG_EVENT_MEMREAD
advice execution (read_methods()) : before () {
sal::simulator.onMemoryAccessEvent(
fail::simulator.onMemoryAccessEvent(
*(tjp->arg<1>()), sizeof(*(tjp->result())), false,
getCPU(tjp->that())->prev_rip);
}
advice execution (read_methods_dqword()) : before () {
sal::simulator.onMemoryAccessEvent(
fail::simulator.onMemoryAccessEvent(
*(tjp->arg<1>()), 16, false,
getCPU(tjp->that())->prev_rip);
}
@ -120,7 +122,7 @@ aspect MemEvents
advice execution (read_methods_RMW()) : before () {
rmw_address = *(tjp->arg<1>());
#ifdef CONFIG_EVENT_MEMREAD
sal::simulator.onMemoryAccessEvent(
fail::simulator.onMemoryAccessEvent(
*(tjp->arg<1>()), sizeof(*(tjp->result())), false,
getCPU(tjp->that())->prev_rip);
#endif
@ -133,7 +135,7 @@ aspect MemEvents
// memory (e.g., to read vectors from the interrupt vector
// table).
/*
sal::simulator.onMemoryAccessEvent(
fail::simulator.onMemoryAccessEvent(
*(tjp->arg<0>()), sizeof(*(tjp->result())), false,
getCPU(tjp->that())->prev_rip);
*/
@ -143,4 +145,4 @@ aspect MemEvents
#endif // CONFIG_EVENT_MEMACCESS
#endif /* __MEM_EVENTS_AH__ */
#endif // __MEM_EVENTS_AH__

View File

@ -16,7 +16,7 @@ aspect Trap
advice execution (exception_method()) : before ()
{
sal::simulator.onTrapEvent(*(tjp->arg<0>()));
fail::simulator.onTrapEvent(*(tjp->arg<0>()));
// TODO: There are some different types of exceptions at cpu.h (line 265-281)
// Which kind of a trap are these types?
}
@ -24,4 +24,4 @@ aspect Trap
#endif // CONFIG_EVENT_TRAP
#endif /* __TRAP_AH__ */
#endif // __TRAP_AH__

View File

@ -12,4 +12,4 @@ static inline BX_CPU_C *getCPU(BX_CPU_C *that)
#endif
}
#endif
#endif // __BOCHS_HELPERS_HPP__

View File

@ -11,7 +11,8 @@ aspect credits {
advice call ("% bx_center_print(...)")
&& within ("void bx_print_header()")
&& args(file, line, maxwidth)
: around (FILE *file, const char *line, unsigned maxwidth) {
: around (FILE *file, const char *line, unsigned maxwidth)
{
if (!first) {
tjp->proceed();
return;

View File

@ -16,4 +16,4 @@ aspect DisableLogfn {
advice execution (add_remove_logfn()) : around () {}
};
#endif /* __DISABLE_ADD_REMOVE_LOGFN_AH__ */
#endif // __DISABLE_ADD_REMOVE_LOGFN_AH__

View File

@ -21,6 +21,6 @@ aspect DisableKeybInt {
}
};
#endif /* CONFIG_DISABLE_KEYB_INTERRUPTS */
#endif // CONFIG_DISABLE_KEYB_INTERRUPTS
#endif /* __DISABLE_KEYBOARD_INTERRUPT_AH__ */
#endif // __DISABLE_KEYBOARD_INTERRUPT_AH__

View File

@ -1,13 +1,13 @@
#ifndef __FAILBOCHS_HPP__
#define __FAILBOCHS_HPP__
#define __FAILBOCHS_HPP__
#include <string>
#include <string.h>
#include "config.h"
namespace sal
{
// FIXME: Maybe rename this file to "FailBochsGlobals.hpp"?
namespace fail {
#ifdef DANCEOS_RESTORE
extern bx_bool restore_bochs_request;
@ -21,4 +21,4 @@ extern int interrupt_to_fire;
}
#endif /* __FAILBOCHS_HPP__ */
#endif // __FAILBOCHS_HPP__

View File

@ -16,11 +16,11 @@ aspect fireInterrupt
advice execution (cpuLoop()) : before ()
{
if (!sal::interrupt_injection_request) {
if (!fail::interrupt_injection_request) {
return;
}else{
BX_SET_INTR(sal::interrupt_to_fire);
DEV_pic_raise_irq(sal::interrupt_to_fire);
BX_SET_INTR(fail::interrupt_to_fire);
DEV_pic_raise_irq(fail::interrupt_to_fire);
}
}
};
@ -32,12 +32,12 @@ aspect InterruptDone
advice execution (interrupt_method()) : before ()
{
if (!sal::interrupt_injection_request) {
if (!fail::interrupt_injection_request) {
return;
}else{
if(*(tjp->arg<0>()) == 32 + sal::interrupt_to_fire){
DEV_pic_lower_irq(sal::interrupt_to_fire);
sal::simulator.fireInterruptDone();
if(*(tjp->arg<0>()) == 32 + fail::interrupt_to_fire){
DEV_pic_lower_irq(fail::interrupt_to_fire);
fail::simulator.fireInterruptDone();
}
}
}
@ -45,4 +45,4 @@ aspect InterruptDone
#endif // CONFIG_FIRE_INTERRUPTS
#endif /* __FIREINTERRUPT_AH__ */
#endif // __FIREINTERRUPT_AH__

View File

@ -3,11 +3,13 @@
#include <iostream>
// FIXME: This seems deprecated...?!
aspect fireTimer {
advice "bx_pc_system_c" : slice class {
public:
// TODO: Log-level?
void fireTimer(Bit32u timerNum){
if(timerNum <= numTimers){
if(!timer[timerNum].active){

View File

@ -4,8 +4,9 @@
#include "../SALInst.hpp"
aspect BochsInit {
advice call("int bxmain()") : before () {
sal::simulator.startup();
advice call("int bxmain()") : before ()
{
fail::simulator.startup();
}
};

View File

@ -12,13 +12,14 @@ aspect reboot {
pointcut cpuLoop() = "void defineCPULoopJoinPoint(...)";
advice execution (cpuLoop()) : after () {
if (!sal::reboot_bochs_request) {
if (!fail::reboot_bochs_request) {
return;
}
bx_gui_c::reset_handler();
std::cout << "[FAIL] Reboot finished" << std::endl;
sal::simulator.rebootDone();
// TODO: Log-level?
fail::simulator.rebootDone();
}
};

View File

@ -2,6 +2,7 @@
#define __RESTORE_AH__
#include <iostream>
#include "config/FailConfig.hpp"
#include "../SALInst.hpp"
@ -14,7 +15,7 @@ aspect restore {
advice execution (restoreState()) : after () {
std::cout << "[FAIL] Restore finished" << std::endl;
sal::simulator.restoreDone();
fail::simulator.restoreDone();
}
};

View File

@ -17,13 +17,13 @@ aspect save {
advice execution (cpuLoop()) : order ("save", "Breakpoints");
advice execution (cpuLoop()) : after () {
if (!sal::save_bochs_request) {
if (!fail::save_bochs_request) {
return;
}
assert(sal::sr_path.size() > 0 && "[FAIL] tried to save state without valid path");
SIM->save_state(sal::sr_path.c_str());
assert(fail::sr_path.size() > 0 && "[FAIL] tried to save state without valid path");
SIM->save_state(fail::sr_path.c_str());
std::cout << "[FAIL] Save finished" << std::endl;
sal::simulator.saveDone();
fail::simulator.saveDone();
}
};

View File

@ -49,6 +49,6 @@ aspect nonverbose {
}
};
#endif
#endif // CONFIG_STFU
#endif
#endif // __NONVERBOSE_AH__

View File

@ -1,10 +1,11 @@
#include <iostream>
#include "OVPController.hpp"
#include "OVPMemory.hpp"
#include "OVPRegister.hpp"
#include "../../../ovp/OVPStatusRegister.hpp"
namespace sal {
namespace fail {
OVPController::OVPController()
: SimulatorController(new OVPRegisterManager(), new OVPMemoryManager())
@ -78,14 +79,14 @@ void OVPController::onInstrPtrChanged(address_t instrPtr)
// << " R0: 0x" << hex << r0 << " ST: 0x" << hex << st << endl;
// Check for active breakpoint-events:
fi::EventList::iterator it = m_EvList.begin();
EventList::iterator it = m_EvList.begin();
while(it != m_EvList.end())
{
// FIXME: Performance verbessern (dazu muss entsprechend auch die Speicherung
// in EventList(.cc|.hpp) angepasst bzw. verbessert werden).
fi::BPSingleEvent* pEvBreakpt = dynamic_cast<fi::BPSingleEvent*>(*it);
BPSingleEvent* pEvBreakpt = dynamic_cast<BPSingleEvent*>(*it);
if(pEvBreakpt && (instrPtr == pEvBreakpt->getWatchInstructionPointer() ||
pEvBreakpt->getWatchInstructionPointer() == fi::ANY_ADDR))
pEvBreakpt->getWatchInstructionPointer() == ANY_ADDR))
{
pEvBreakpt->setTriggerInstructionPointer(instrPtr);
it = m_EvList.makeActive(it);
@ -93,7 +94,7 @@ void OVPController::onInstrPtrChanged(address_t instrPtr)
// makeActive()):
continue; // -> skip iterator increment
}
fi::BPRangeEvent* pEvRange = dynamic_cast<fi::BPRangeEvent*>(*it);
BPRangeEvent* pEvRange = dynamic_cast<BPRangeEvent*>(*it);
if(pEvRange && pEvRange->isMatching(instrPtr))
{
pEvBreakpt->setTriggerInstructionPointer(instrPtr);
@ -130,4 +131,4 @@ void OVPController::reboot()
//bx_gui_c::reset_handler();//TODO: leider protected, so geht das also nicht...
}
};
}

View File

@ -4,15 +4,13 @@
// Type definitions and configuration settings for
// the OVP simulator.
namespace sal
{
namespace fail {
typedef uint32_t guest_address_t; //!< the guest memory address type
typedef uint8_t* host_address_t; //!< the host memory address type
typedef uint32_t register_data_t; //!< register data type (32 bit)
typedef int timer_t; //!< type of timer IDs
};
#endif /* __OVP_CONFIG_HPP__ */
}
#endif // __OVP_CONFIG_HPP__

View File

@ -8,18 +8,12 @@
#include "../SimulatorController.hpp"
#include "../../controller/Event.hpp"
#include "../../../ovp/OVPPlatform.hpp"
#include "../Register.hpp"
using namespace std;
extern OVPPlatform ovpplatform;
/// Simulator Abstraction Layer namespace
namespace sal
{
namespace fail {
/**
* \class OVPController
@ -46,12 +40,12 @@ class OVPController : public SimulatorController
* Save simulator state.
* @param path Location to store state information
*/
virtual void save(const string& path);
virtual void save(const std::string& path);
/**
* Restore simulator state.
* @param path Location to previously saved state information
*/
virtual void restore(const string& path);
virtual void restore(const std::string& path);
/**
* Reboot simulator.
*/
@ -60,10 +54,9 @@ class OVPController : public SimulatorController
* Returns the current instruction pointer.
* @return the current eip
*/
void makeGPRegister(int, void*, const string&);
void makeSTRegister(Register *, const string&);
void makePCRegister(int, void*, const string&);
void makeGPRegister(int, void*, const std::string&);
void makeSTRegister(Register *, const std::string&);
void makePCRegister(int, void*, const std::string&);
//DELETE-ME:This should be obsolete now...
/**
@ -71,8 +64,8 @@ class OVPController : public SimulatorController
* must tell OVPController when it is finished
*/
//void finishedRegisterCreation();
};
};
#endif
}
#endif // __OVP_CONTROLLER_HPP__

View File

@ -3,8 +3,7 @@
#include "../Memory.hpp"
namespace sal
{
namespace fail {
/**
* \class OVPMemoryManager
@ -90,4 +89,4 @@ class OVPMemoryManager : public MemoryManager
}
#endif
#endif // __OVP_MEMORY_HPP__

View File

@ -7,7 +7,7 @@
extern OVPPlatform ovpplatform;
namespace sal {
namespace fail {
/**
* \class OVPRegister
@ -74,7 +74,8 @@ class OVPRegisterManager : public RegisterManager
{
return 0;
}
};
}
#endif
#endif // __OVP_REGISTER_HPP__

View File

@ -4,9 +4,10 @@
#include "../SALInst.hpp"
aspect OVPInit {
advice call("% ...::startSimulation(...)") : before () {
cout << "OVP init aspect!" << endl;
sal::simulator.startup();
advice call("% ...::startSimulation(...)") : before ()
{
std::cout << "OVP init aspect!" << std::endl;
fail::simulator.startup();
}
};