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

@ -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