Fail* directories reorganized, Code-cleanup (-> coding-style), Typos+comments fixed.

git-svn-id: https://www4.informatik.uni-erlangen.de/i4svn/danceos/trunk/devel/fail@1321 8c4709b5-6ec9-48aa-a5cd-a96041d1645a
This commit is contained in:
adrian
2012-06-08 20:09:43 +00:00
parent d474a5b952
commit 2575604b41
866 changed files with 1848 additions and 1879 deletions

View File

@ -0,0 +1,17 @@
#ifndef __OVPINIT_AH__
#define __OVPINIT_AH__
#include <iostream>
#include "../SALInst.hpp"
aspect FailOVPInit {
advice call("% ...::startSimulation(...)") : before ()
{
std::cout << "OVP init aspect!" << std::endl;
// TODO: Log-Level?
fail::simulator.startup();
}
};
#endif // __OVPINIT_AH__

View File

@ -0,0 +1,20 @@
/**
* \brief Type definitions and configuration settings for
* the OVP simulator.
*/
#ifndef __OVP_CONFIG_HPP__
#define __OVP_CONFIG_HPP__
#include <sys/types.h>
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
} // end-of-namespace: fail
#endif // __OVP_CONFIG_HPP__

View File

@ -0,0 +1,131 @@
#include <iostream>
#include "OVPController.hpp"
#include "OVPMemory.hpp"
#include "OVPRegister.hpp"
#include "ovp/OVPStatusRegister.hpp"
namespace fail {
OVPController::OVPController()
: SimulatorController(new OVPRegisterManager(), new OVPMemoryManager())
{
// FIXME: This should be obsolete now...
// set = new UniformRegisterSet(RT_GP);
// setStatus = new UniformRegisterSet(RT_ST);
// setPC = new UniformRegisterSet(RT_PC);
}
OVPController::~OVPController()
{
// FIXME: This should be obsolete now...
// delete set;
// delete setStatus;
// delete setPC;
// Free memory of OVPRegister objects (actually allocated in make*Register):
for (RegisterManager::iterator it = m_Regs->begin(); it != m_Regs->end(); it++)
delete (*it); // free the memory, allocated in the constructor
}
void OVPController::makeGPRegister(int width, void *link, const string& name)
{
// Add general purpose register
OVPRegister *reg = new OVPRegister(m_currentRegId++, width, link, RT_GP);
reg->setName(name);
m_Regs->add(reg);
// Note: The RegisterManager (aka m_Regs) automatically assigns the
// added registers (herein typed OVPRegister) to their matching
// UniformRegisterSet (@see RegisterManager::add).
}
void OVPController::makeSTRegister(Register *reg, const string& name)
{
// Add status register
reg->setName(name);
cerr << "Add Status Register: " << reg << endl;
m_Regs->add(reg);
}
void OVPController::makePCRegister(int width, void *link, const string& name)
{
// Add general purpose register
OVPRegister *reg = new OVPRegister(m_currentRegId++, width, link, RT_PC);
reg->setName(name);
m_Regs->add(reg);
}
// FIXME: This should be obsolete now...
/*
void OVPController::finishedRegisterCreation()
{
m_Regs->add(*set);
m_Regs->add(*setStatus);
m_Regs->add(*setPC);
}
*/
void OVPController::onInstrPtrChanged(address_t instrPtr)
{
// make some funny outputs
unsigned int r0 = m_Regs->getSetOfType(RT_GP)->getRegister(0)->getData();
OVPRegisterManager *ovp_Regs = (OVPRegisterManager*) m_Regs;
// FIXME: This cast seems to be invalid: RT_GP vs. OVPStatusRegister (= RT_ST)?
OVPStatusRegister *rid_st = (OVPStatusRegister*) m_Regs->getSetOfType(RT_GP)->first();
// cerr << "Addr: " << rid_st << endl;
unsigned int st = rid_st->getData();
// save("/srv/scratch/sirozipp/test.txt");
// ovpplatform.setPC(0x123);
// restore("/srv/scratch/sirozipp/test.txt");
// cerr << "instrPtr: 0x" << hex << instrPtr << " SP: 0x" << hex << m_Regs->getStackPointer() \
// << " R0: 0x" << hex << r0 << " ST: 0x" << hex << st << endl;
// Check for active breakpoint-events:
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).
BPSingleEvent* pEvBreakpt = dynamic_cast<BPSingleEvent*>(*it);
if (pEvBreakpt && (instrPtr == pEvBreakpt->getWatchInstructionPointer() ||
pEvBreakpt->getWatchInstructionPointer() == ANY_ADDR)) {
pEvBreakpt->setTriggerInstructionPointer(instrPtr);
it = m_EvList.makeActive(it);
// "it" has already been set to the next element (by calling
// makeActive()):
continue; // -> skip iterator increment
}
BPRangeEvent* pEvRange = dynamic_cast<BPRangeEvent*>(*it);
if (pEvRange && pEvRange->isMatching(instrPtr)) {
pEvBreakpt->setTriggerInstructionPointer(instrPtr);
it = m_EvList.makeActive(it);
continue; // dito.
}
it++;
}
m_EvList.fireActiveEvents();
}
void OVPController::save(const string& path)
{
// TODO!
ovpplatform.save(path);
}
void OVPController::restore(const string& path)
{
//TODO!
assert(path.length() > 0 &&
"FATAL ERROR: Tried to restore state without valid path!");
ovpplatform.restore(path);
}
void OVPController::reboot()
{
// TODO!
}
} // end-of-namespace: fail

View File

@ -0,0 +1,72 @@
#ifndef __OVP_CONTROLLER_HPP__
#define __OVP_CONTROLLER_HPP__
#include <string>
#include <cassert>
#include <string.h>
#include <string>
#include "../SimulatorController.hpp"
#include "../Event.hpp"
#include "../Register.hpp"
#include "ovp/OVPPlatform.hpp"
namespace fail {
extern OVPPlatform ovpplatform;
/**
* \class OVPController
* OVP-specific implementation of a SimulatorController.
*/
class OVPController : public SimulatorController {
private:
// FIXME: This should be obsolete now...
// UniformRegisterSet *set; //(RT_GP);
// UniformRegisterSet *setStatus;//(RT_ST);
// UniformRegisterSet *setPC;//(RT_PC);
// FIXME: Perhaps this should be declared as a static member:
unsigned int m_currentRegId;
// NOTE: Constants (such as GPRegisterId in sal/bochs/BochsRegister.hpp)
// are much easier to read...
public:
/**
* Initialize the controller.
*/
OVPController();
virtual ~OVPController();
virtual void onInstrPtrChanged(address_t instrPtr);
/**
* Save simulator state.
* @param path Location to store state information
*/
virtual void save(const std::string& path);
/**
* Restore simulator state.
* @param path Location to previously saved state information
*/
virtual void restore(const std::string& path);
/**
* Reboot simulator.
*/
virtual void reboot();
/**
* Returns the current instruction pointer.
* @return the current eip
*/
void makeGPRegister(int, void*, const std::string&);
void makeSTRegister(Register *, const std::string&);
void makePCRegister(int, void*, const std::string&);
/**
* Due to empty RegisterSets are not allowed, OVP platform
* must tell OVPController when it is finished
*
* FIXME: This should be obsolete now...
*/
// void finishedRegisterCreation();
};
} // end-of-namespace: fail
#endif // __OVP_CONTROLLER_HPP__

View File

@ -0,0 +1,73 @@
#ifndef __OVP_MEMORY_HPP__
#define __OVP_MEMORY_HPP__
#include "../Memory.hpp"
namespace fail {
/**
* \class OVPMemoryManager
* Represents a concrete implemenation of the abstract
* MemoryManager to provide access to OVP's memory pool.
*/
class OVPMemoryManager : public MemoryManager {
public:
/**
* Constructs a new MemoryManager object and initializes
* it's attributes appropriately.
*/
OVPMemoryManager() : MemoryManager() { }
/**
* Retrieves the size of the available simulated memory.
* @return the size of the memory pool in bytes
*/
size_t getPoolSize() const { return 0; }
/**
* Retrieves the starting address of the host memory. This is the
* first valid address in memory.
* @return the starting address
*/
host_address_t getStartAddr() const { return 0; }
/**
* Retrieves the byte at address \a addr in the memory.
* @param addr The guest address where the byte is located.
* The address is expected to be valid.
* @return the byte at \a addr
*/
byte_t getByte(guest_address_t addr) { return 0; }
/**
* Retrieves \a cnt bytes at address \a addr in the memory.
* @param addr The guest address where the bytes are located.
* The address is expected to be valid.
* @param cnt the number of bytes to be retrieved. \a addr + \a cnt
* is expected to not exceed the memory limit.
* @param dest Pointer to destination buffer to copy the data to.
*/
void getBytes(guest_address_t addr, size_t cnt, void *dest) { }
/**
* Writes the byte \a data to memory.
* @param addr The guest address to write.
* The address is expected to be valid.
* @param data The new byte to write
*/
void setByte(guest_address_t addr, byte_t data) { }
/**
* Copies data to memory.
* @param addr The guest address to write.
* The address is expected to be valid.
* @param cnt The number of bytes to be retrieved. \a addr + \a cnt
* is expected to not exceed the memory limit.
* @param src Pointer to data to be copied.
*/
void setBytes(guest_address_t addr, size_t cnt, void const *src) { }
/**
* Transforms the guest address \a addr to a host address.
* @param addr The (logical) guest address to be transformed
* @return the transformed (host) address or \c ADDR_INV on errors
*/
host_address_t guestToHost(guest_address_t addr) { return 0; }
};
} // end-of-namespace: fail
#endif // __OVP_MEMORY_HPP__

View File

@ -0,0 +1,76 @@
#ifndef __OVP_REGISTER_HPP__
#define __OVP_REGISTER_HPP__
#include "../Register.hpp"
#include "ovp/OVPPlatform.hpp"
//#include "ovp/OVPStatusRegister.hpp"
extern OVPPlatform ovpplatform;
namespace fail {
/**
* \class OVPRegister
* OVP-specific implementation of x86 registers.
*/
class OVPRegister : public Register {
private:
void *reg;
public:
/**
* Constructs a new register object.
* @param id the unique id of this register (simulator specific)
* @param width width of the register (8, 16, 32 or 64 bit should suffice)
* @param link pointer to bochs internal register memory
* @param t type of the register
*/
OVPRegister(unsigned int id, regwidth_t width, void* link, RegisterType t)
: Register(id, t, width) { reg = link; }
/**
* Retrieves the data of the register.
* @return the current register data
*/
regdata_t getData() { return ovpplatform.getRegisterData(reg); }
/**
* Sets the content of the register.
* @param data the new register data to be written
*/
void setData(regdata_t data) { ovpplatform.setRegisterData(reg, data); }
};
/**
* \class OVPRegister
* OVP-specific implementation of the RegisterManager.
*/
class OVPRegisterManager : public RegisterManager {
public:
/**
* Returns the current instruction pointer.
* @return the current eip
*/
virtual address_t getInstructionPointer()
{
return ovpplatform.getPC();
}
/**
* Retruns the top address of the stack.
* @return the starting address of the stack
*/
virtual address_t getStackPointer()
{
return ovpplatform.getSP();
}
/**
* Retrieves the base ptr (holding the address of the
* current stack frame).
* @return the base pointer
*/
virtual address_t getBasePointer()
{
return 0;
}
};
} // end-of-namespace: fail
#endif // __OVP_REGISTER_HPP__