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:
@ -30,7 +30,7 @@ if(BUILD_OVP)
|
||||
else(BUILD_OVP)
|
||||
message(STATUS "[${PROJECT_NAME}] Building Bochs variant...")
|
||||
## add necessary additional header search paths.
|
||||
add_definitions(-I${CMAKE_SOURCE_DIR}/bochs/instrument/stubs/ -I${CMAKE_SOURCE_DIR}/bochs/)
|
||||
add_definitions(-I${CMAKE_SOURCE_DIR}/simulators/bochs/instrument/stubs/ -I${CMAKE_SOURCE_DIR}/simulators/bochs)
|
||||
SET(VARIANT bochs)
|
||||
endif(BUILD_OVP)
|
||||
|
||||
@ -40,11 +40,16 @@ set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}")
|
||||
## Tell the linker where to find the libfail.a
|
||||
link_directories("${LIBRARY_OUTPUT_PATH}")
|
||||
|
||||
## Add CMakeLists from subdirectories (at the moment only core)
|
||||
add_subdirectory(core)
|
||||
# Add "simulators"-directory to the include path. This allows
|
||||
# us to use simulator-specific headers in a comfortable way.
|
||||
include_directories(${CMAKE_BINARY_DIR}/src/core)
|
||||
# FIXME: this should be in src/core/CMakeLists.txt but actually doesn't work
|
||||
|
||||
## Add CMakeLists from subdirectories:
|
||||
add_subdirectory(src)
|
||||
|
||||
if(BUILD_OVP)
|
||||
add_subdirectory(ovp)
|
||||
add_subdirectory(simulators/ovp)
|
||||
else(BUILD_OVP)
|
||||
endif(BUILD_OVP)
|
||||
|
||||
@ -63,3 +68,9 @@ endif(BUILD_OVP)
|
||||
# BUILD_IN_SOURCE 1
|
||||
# PREFIX ${BOCHS_PREFIX_DIR}
|
||||
#)
|
||||
#
|
||||
#message(STATUS "Include directories are:")
|
||||
#get_property(dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)
|
||||
#foreach(dir ${dirs})
|
||||
# message(STATUS " ${dir}")
|
||||
#endforeach(dir)
|
||||
|
||||
@ -31,7 +31,7 @@ message(STATUS "[${PROJECT_NAME}] Compiler: ${CMAKE_C_COMPILER}/${CMAKE_CXX_COMP
|
||||
#### Add some custom targets for the autoconf-based Bochs
|
||||
if(BUILD_BOCHS)
|
||||
|
||||
set(bochs_src_dir ${CMAKE_CURRENT_SOURCE_DIR}/bochs )
|
||||
set(bochs_src_dir ${CMAKE_CURRENT_SOURCE_DIR}/simulators/bochs )
|
||||
|
||||
add_custom_target( bochsclean
|
||||
COMMAND +make -C ${bochs_src_dir} clean
|
||||
@ -44,14 +44,14 @@ if(BUILD_BOCHS)
|
||||
)
|
||||
|
||||
add_custom_target( bochs
|
||||
COMMAND +make -C ${bochs_src_dir} CXX=\"ag++ -p ${CMAKE_SOURCE_DIR} -I${CMAKE_SOURCE_DIR}/core -I${CMAKE_BINARY_DIR}/core --real-instances --Xcompiler\" LIBTOOL=\"/bin/sh ./libtool --tag=CXX\"
|
||||
COMMAND +make -C ${bochs_src_dir} CXX=\"ag++ -p ${CMAKE_SOURCE_DIR} -I${CMAKE_SOURCE_DIR}/src/core -I${CMAKE_BINARY_DIR}/src/core --real-instances --Xcompiler\" LIBTOOL=\"/bin/sh ./libtool --tag=CXX\"
|
||||
COMMENT "[${PROJECT_NAME}] Building Bochs"
|
||||
)
|
||||
add_dependencies(bochs fail)
|
||||
|
||||
|
||||
add_custom_target( bochsinstall
|
||||
COMMAND +make -C ${bochs_src_dir} CXX=\"ag++ -p ${CMAKE_SOURCE_DIR} -I${CMAKE_SOURCE_DIR}/core -I${CMAKE_BINARY_DIR}/core --real-instances --Xcompiler\" LIBTOOL=\"/bin/sh ./libtool --tag=CXX\" install
|
||||
COMMAND +make -C ${bochs_src_dir} CXX=\"ag++ -p ${CMAKE_SOURCE_DIR} -I${CMAKE_SOURCE_DIR}/src/core -I${CMAKE_BINARY_DIR}/src/core --real-instances --Xcompiler\" LIBTOOL=\"/bin/sh ./libtool --tag=CXX\" install
|
||||
COMMENT "[${PROJECT_NAME}] Installing Bochs..."
|
||||
)
|
||||
|
||||
|
||||
@ -15,5 +15,5 @@ if [ ! -d "$PREFIX_DIR" ]; then
|
||||
fi
|
||||
|
||||
|
||||
./configure CXX="ag++ -p $SOURCE_DIR -I$SOURCE_DIR/core -I"$BINARY_DIR"/core --real-instances --Xcompiler" LIBTOOL="/bin/sh ./libtool --tag=CXX" --prefix=$PREFIX_DIR --enable-{a20-pin,x86-64,cpu-level=6,ne2000,acpi,pci,usb,repeat-speedups,trace-cache,fast-function-calls,host-specific-asms,disasm,all-optimizations,readline,clgd54xx,fpu,vmx=2,monitor-mwait,cdrom,sb16=linux,gdb-stub} --with-all-libs
|
||||
./configure CXX="ag++ -p $SOURCE_DIR -I$SOURCE_DIR/src -I"$BINARY_DIR"/src --real-instances --Xcompiler" LIBTOOL="/bin/sh ./libtool --tag=CXX" --prefix=$PREFIX_DIR --enable-{a20-pin,x86-64,cpu-level=6,ne2000,acpi,pci,usb,repeat-speedups,trace-cache,fast-function-calls,host-specific-asms,disasm,all-optimizations,readline,clgd54xx,fpu,vmx=2,monitor-mwait,cdrom,sb16=linux,gdb-stub} --with-all-libs
|
||||
|
||||
|
||||
@ -1,64 +0,0 @@
|
||||
### Setup search paths for headers ##
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
### Add Boost and Threads
|
||||
find_package(Boost 1.42 COMPONENTS thread REQUIRED)
|
||||
find_package(Threads)
|
||||
include_directories(${Boost_INCLUDE_DIRS})
|
||||
link_directories(${Boost_LIBRARY_DIRS})
|
||||
|
||||
### Setup doxygen documentation
|
||||
# TODO put into helpers.cmake
|
||||
find_package(Doxygen)
|
||||
if(DOXYGEN_FOUND)
|
||||
# Using a .in file means we can use CMake to insert project settings
|
||||
# into the doxyfile. For example, CMake will replace @PROJECT_NAME@ in
|
||||
# a configured file with the CMake PROJECT_NAME variable's value.
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY}
|
||||
)
|
||||
|
||||
## call make doc to generate documentation
|
||||
add_custom_target( doc
|
||||
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
|
||||
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
COMMENT "[${PROJECT_NAME}] Generating fail* documentation with Doxygen" VERBATIM
|
||||
)
|
||||
endif(DOXYGEN_FOUND)
|
||||
|
||||
## Add CMakeLists from subdirectories ##
|
||||
# The autogenerated header files
|
||||
add_subdirectory(config)
|
||||
|
||||
# fail* targets
|
||||
add_subdirectory(jobserver)
|
||||
add_subdirectory(controller)
|
||||
add_subdirectory(SAL)
|
||||
add_subdirectory(util)
|
||||
|
||||
# Here we add all user-defined experiments (which fills the target list)
|
||||
add_subdirectory(experiments/)
|
||||
message(STATUS "[${PROJECT_NAME}] chosen experiment targets:")
|
||||
foreach(experiment_name ${EXPERIMENTS_ACTIVATED})
|
||||
message(STATUS "[${PROJECT_NAME}] -> ${experiment_name}")
|
||||
endforeach(experiment_name)
|
||||
|
||||
# Here we add activated plugins
|
||||
add_subdirectory(plugins/)
|
||||
message(STATUS "[${PROJECT_NAME}] chosen plugin targets:")
|
||||
foreach(plugin_name ${PLUGINS_ACTIVATED})
|
||||
message(STATUS "[${PROJECT_NAME}] -> ${plugin_name}")
|
||||
endforeach(plugin_name)
|
||||
|
||||
## Merge all resulting fail* libs into a single libfail.a and copy it into the fail source directory
|
||||
add_custom_target(fail
|
||||
COMMAND ${CMAKE_SOURCE_DIR}/cmake/mergelib.sh ${LIBRARY_OUTPUT_PATH} && ${CMAKE_COMMAND} -E copy ${LIBRARY_OUTPUT_PATH}/libfail.a ${CMAKE_SOURCE_DIR}/core
|
||||
)
|
||||
## Setup build dependencies of the fail* lib
|
||||
## -> the fail* targets and user defined experiment targets
|
||||
add_dependencies(fail SAL util controller jobserver protomessages ${EXPERIMENTS_ACTIVATED} ${PLUGINS_ACTIVATED})
|
||||
|
||||
# Let make clean also delete libfail.a
|
||||
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${LIBRARY_OUTPUT_PATH}/libfail.a)
|
||||
@ -1,197 +0,0 @@
|
||||
#ifndef __BOCHS_CONTROLLER_HPP__
|
||||
#define __BOCHS_CONTROLLER_HPP__
|
||||
|
||||
#define DEBUG
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <string.h>
|
||||
|
||||
#include "FailBochsGlobals.hpp"
|
||||
|
||||
#include "../SimulatorController.hpp"
|
||||
#include "../../controller/Event.hpp"
|
||||
|
||||
#include "../../../bochs/bochs.h"
|
||||
#include "../../../bochs/cpu/cpu.h"
|
||||
#include "../../../bochs/config.h"
|
||||
#include "../../../bochs/iodev/iodev.h"
|
||||
#include "../../../bochs/pc_system.h"
|
||||
|
||||
namespace fail {
|
||||
|
||||
class ExperimentFlow;
|
||||
|
||||
/**
|
||||
* \class BochsController
|
||||
* Bochs-specific implementation of a SimulatorController.
|
||||
*/
|
||||
class BochsController : public SimulatorController
|
||||
{
|
||||
private:
|
||||
ExperimentFlow* m_CurrFlow; //!< Stores the current flow for save/restore-operations
|
||||
#ifdef DEBUG
|
||||
unsigned m_Regularity;
|
||||
unsigned m_Counter;
|
||||
std::ostream* m_pDest;
|
||||
#endif
|
||||
/**
|
||||
* Static internal event handler for TimerEvents. This static function is
|
||||
* called when a previously registered (Bochs) timer triggers. This function
|
||||
* searches for the provided TimerEvent object within the EventList and
|
||||
* fires such an event by calling \c fireActiveEvents().
|
||||
* @param thisPtr a pointer to the TimerEvent-object triggered
|
||||
*
|
||||
* FIXME: Due to Bochs internal timer and ips-configuration related stuff,
|
||||
* the simulator sometimes panics with "keyboard error:21" (see line
|
||||
* 1777 in bios/rombios.c, function keyboard_init()) if a TimerEvent
|
||||
* is added *before* the bios has been loaded and initialized. To
|
||||
* reproduce this error, try adding a TimerEvent as the initial step
|
||||
* in your experiment code and wait for it (addEventAndWait()).
|
||||
*/
|
||||
static void m_onTimerTrigger(void *thisPtr);
|
||||
/**
|
||||
* Registers a timer in the Bochs simulator. This timer fires \a TimerEvents
|
||||
* to inform the corresponding experiment-flow. Note that the number of timers
|
||||
* (in Bochs) is limited to \c BX_MAX_TIMERS (defaults to 64 in v2.4.6).
|
||||
* @param pev a pointer to the (experiment flow-) allocated TimerEvent object,
|
||||
* providing all required information to start the time, e.g. the
|
||||
* timeout value.
|
||||
* @return \c The unique id of the timer recently created. This id is carried
|
||||
* 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(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(TimerEvent* pev);
|
||||
public:
|
||||
// Initialize the controller.
|
||||
BochsController();
|
||||
~BochsController();
|
||||
/* ********************************************************************
|
||||
* Standard Event Handler API:
|
||||
* ********************************************************************/
|
||||
/**
|
||||
* 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 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).
|
||||
* More specifically, the event will be added to the event-list first
|
||||
* (buffer-list, to be precise) and then this event handler is called.
|
||||
* @param pev the event which has been added
|
||||
* @return You should return \c true to continue and \c false to prevent
|
||||
* the addition of the event \a 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()
|
||||
* or by deleting a complete flow (\c removeFlow). More specifically,
|
||||
* 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(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
|
||||
* will be called *before* the event is actually triggered, i.e. before the
|
||||
* corresponding coroutine is toggled.
|
||||
* @param pev the event to be triggered when returning from the event handler
|
||||
*/
|
||||
void onEventTrigger(BaseEvent* pev);
|
||||
/* ********************************************************************
|
||||
* Simulator Controller & Access API:
|
||||
* ********************************************************************/
|
||||
/**
|
||||
* Save simulator state.
|
||||
* @param path Location to store state information
|
||||
*/
|
||||
void save(const std::string& path);
|
||||
/**
|
||||
* Save finished: Callback from Simulator
|
||||
*/
|
||||
void saveDone();
|
||||
/**
|
||||
* Restore simulator state. Clears all Events.
|
||||
* @param path Location to previously saved state information
|
||||
*/
|
||||
void restore(const std::string& path);
|
||||
/**
|
||||
* Restore finished: Callback from Simulator
|
||||
*/
|
||||
void restoreDone();
|
||||
/**
|
||||
* Reboot simulator. Clears all Events.
|
||||
*/
|
||||
void reboot();
|
||||
/**
|
||||
* Reboot finished: Callback from Simulator
|
||||
*/
|
||||
void rebootDone();
|
||||
/**
|
||||
* Fire an interrupt.
|
||||
* @param irq Interrupt to be fired
|
||||
*/
|
||||
void fireInterrupt(unsigned irq);
|
||||
/**
|
||||
* Fire done: Callback from Simulator
|
||||
*/
|
||||
void fireInterruptDone();
|
||||
#ifdef DEBUG
|
||||
/**
|
||||
* Enables instruction pointer debugging output.
|
||||
* @param regularity the output regularity; 1 to display every
|
||||
* instruction pointer, 0 to disable
|
||||
* @param dest specifies the output destition; defaults to \c std::cout
|
||||
*/
|
||||
void dbgEnableInstrPtrOutput(unsigned regularity, std::ostream* dest = &std::cout);
|
||||
#endif
|
||||
/* ********************************************************************
|
||||
* BochsController-specific (not implemented in SimulatorController!):
|
||||
* ********************************************************************/
|
||||
/**
|
||||
* Retrieves the textual description (mnemonic) for the current
|
||||
* instruction. The format of the returned string is Bochs-specific.
|
||||
* @return the mnemonic of the current instruction whose address
|
||||
* is given by \c Register::getInstructionPointer(). On
|
||||
* errors, the returned string is empty
|
||||
*/
|
||||
const std::string& getMnemonic() const
|
||||
{
|
||||
static std::string str;
|
||||
bxICacheEntry_c* pEntry = BX_CPU(0)->getICacheEntry();
|
||||
assert(pEntry != NULL && "FATAL ERROR: Bochs internal function returned NULL (not expected)!");
|
||||
bxInstruction_c* pInstr = pEntry->i;
|
||||
assert(pInstr != NULL && "FATAL ERROR: Bochs internal member was NULL (not expected)!");
|
||||
const char* pszName = get_bx_opcode_name(pInstr->getIaOpcode());
|
||||
if (pszName != NULL)
|
||||
str = pszName;
|
||||
else
|
||||
str.clear();
|
||||
return str;
|
||||
}
|
||||
};
|
||||
|
||||
} // end-of-namespace: fail
|
||||
|
||||
#endif // __BOCHS_CONTROLLER_HPP__
|
||||
@ -1,119 +0,0 @@
|
||||
#ifndef __BOCHS_MEMORY_HPP__
|
||||
#define __BOCHS_MEMORY_HPP__
|
||||
|
||||
#include "../Memory.hpp"
|
||||
|
||||
namespace fail {
|
||||
|
||||
/**
|
||||
* \class BochsMemoryManager
|
||||
* Represents a concrete implemenation of the abstract
|
||||
* MemoryManager to provide access to Bochs' memory pool.
|
||||
*/
|
||||
class BochsMemoryManager : public MemoryManager
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Constructs a new MemoryManager object and initializes
|
||||
* it's attributes appropriately.
|
||||
*/
|
||||
BochsMemoryManager() : MemoryManager() { }
|
||||
/**
|
||||
* Retrieves the size of the available simulated memory.
|
||||
* @return the size of the memory pool in bytes
|
||||
*/
|
||||
size_t getPoolSize() const
|
||||
{
|
||||
return (static_cast<size_t>(BX_MEM(0)->get_memory_len()));
|
||||
}
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
host_address_t haddr = guestToHost(addr);
|
||||
assert(haddr != (host_address_t)ADDR_INV && "FATAL ERROR: Invalid guest address provided!");
|
||||
return (static_cast<byte_t>(*reinterpret_cast<Bit8u*>(haddr)));
|
||||
}
|
||||
/**
|
||||
* Retrieves \a cnt bytes at address \a addr from 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)
|
||||
{
|
||||
char *d = static_cast<char *>(dest);
|
||||
for (size_t i = 0; i < cnt; ++i) {
|
||||
d[i] = getByte(addr + i);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
host_address_t haddr = guestToHost(addr);
|
||||
assert(haddr != (host_address_t)ADDR_INV &&
|
||||
"FATAL ERROR: Invalid guest address provided!");
|
||||
*reinterpret_cast<Bit8u*>(haddr) = 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)
|
||||
{
|
||||
char const *s = static_cast<char const *>(src);
|
||||
for (size_t i = 0; i < cnt; ++i) {
|
||||
setByte(addr + i, s[i]);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
const unsigned SEGMENT_SELECTOR_IDX = 2; // always the code segment
|
||||
const bx_address logicalAddr = static_cast<bx_address>(addr); // offset within the segment
|
||||
// Get the linear address:
|
||||
Bit32u linearAddr = BX_CPU(0)->get_laddr32(SEGMENT_SELECTOR_IDX/*seg*/, logicalAddr/*offset*/);
|
||||
// Map the linear address to the physical address:
|
||||
bx_phy_address physicalAddr;
|
||||
bx_bool fValid = BX_CPU(0)->dbg_xlate_linear2phy(linearAddr, (bx_phy_address*)&physicalAddr);
|
||||
// Determine the *host* address of the physical address:
|
||||
Bit8u* hostAddr = BX_MEM(0)->getHostMemAddr(BX_CPU(0), physicalAddr, BX_READ);
|
||||
// Now, hostAddr contains the "final" address
|
||||
if(!fValid)
|
||||
return ((host_address_t)ADDR_INV); // error
|
||||
else
|
||||
return (reinterpret_cast<host_address_t>(hostAddr)); // okay
|
||||
}
|
||||
};
|
||||
|
||||
} // end-of-namespace: fail
|
||||
|
||||
#endif // __BOCHS_MEMORY_HPP__
|
||||
@ -1,245 +0,0 @@
|
||||
#ifndef __BOCHS_REGISTER_HPP__
|
||||
#define __BOCHS_REGISTER_HPP__
|
||||
|
||||
#include "../Register.hpp"
|
||||
#include "../../../bochs/bochs.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <cassert>
|
||||
|
||||
namespace fail {
|
||||
|
||||
/**
|
||||
* \class BochsRegister
|
||||
* Bochs-specific implementation of x86 registers.
|
||||
*/
|
||||
class BochsRegister : public Register
|
||||
{
|
||||
protected:
|
||||
regdata_t* m_pData;
|
||||
public:
|
||||
/**
|
||||
* Constructs a new register object.
|
||||
* @param id the global unique id
|
||||
* @param width width of the register (8, 16, 32 or 64 bit should
|
||||
* suffice)
|
||||
* @param link pointer to bochs interal register memory
|
||||
* @param t type of the register
|
||||
*/
|
||||
BochsRegister(unsigned int id, regwidth_t width, regdata_t* link, RegisterType t)
|
||||
: Register(id, t, width), m_pData(link) { }
|
||||
/**
|
||||
* Retrieves the data of the register.
|
||||
* @return the current register data
|
||||
*/
|
||||
regdata_t getData() { return (*m_pData); }
|
||||
/**
|
||||
* Sets the content of the register.
|
||||
* @param data the new register data to be written
|
||||
*/
|
||||
void setData(regdata_t data) { *m_pData = data; }
|
||||
};
|
||||
|
||||
/**
|
||||
* \class BxGPReg
|
||||
* Bochs-specific implementation of x86 general purpose (GP) registers.
|
||||
*/
|
||||
class BxGPReg : public BochsRegister
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Constructs a new general purpose register.
|
||||
* @param id the global unique id
|
||||
* @param width width of the register (8, 16, 32 or 64 bit should
|
||||
* suffice)
|
||||
* @param link pointer to bochs interal register memory
|
||||
*/
|
||||
BxGPReg(unsigned int id, regwidth_t width, regdata_t* link)
|
||||
: BochsRegister(id, width, link, RT_GP) { }
|
||||
};
|
||||
|
||||
/**
|
||||
* \enum GPRegisterId
|
||||
* Symbolic identifier to access Bochs' general purpose register
|
||||
* (within the corresponding GP set), e.g.
|
||||
* \code
|
||||
* // Print %eax register data:
|
||||
* BochsController bc(...);
|
||||
* cout << bc.getRegisterManager().getSetOfType(RT_GP)
|
||||
* .getRegister(RID_EAX)->getData();
|
||||
* \endcode
|
||||
*/
|
||||
enum GPRegisterId
|
||||
{
|
||||
#if BX_SUPPORT_X86_64 // 64 bit register id's:
|
||||
RID_RAX = 0, RID_RCX, RID_RDX, RID_RBX, RID_RSP, RID_RBP, RID_RSI, RID_RDI,
|
||||
RID_R8, RID_R9, RID_R10, RID_R11, RID_R12, RID_R13, RID_R14, RID_R15,
|
||||
#else // 32 bit register id's:
|
||||
RID_EAX = 0, RID_ECX, RID_EDX, RID_EBX, RID_ESP, RID_EBP, RID_ESI, RID_EDI,
|
||||
#endif
|
||||
RID_CAX = 0, RID_CCX, RID_CDX, RID_CBX, RID_CSP, RID_CBP, RID_CSI, RID_CDI,
|
||||
RID_LAST_GP_ID
|
||||
};
|
||||
|
||||
/**
|
||||
* \enum PCRegisterId
|
||||
* Symbolic identifier to access Bochs' program counter register.
|
||||
*/
|
||||
enum PCRegisterId { RID_PC = RID_LAST_GP_ID, RID_LAST_PC_ID };
|
||||
|
||||
/**
|
||||
* \enum FlagsRegisterId
|
||||
* Symbolic identifier to access Bochs' flags register.
|
||||
*/
|
||||
enum FlagsRegisterId { RID_FLAGS = RID_LAST_PC_ID };
|
||||
|
||||
/**
|
||||
* \class BxPCReg
|
||||
* Bochs-specific implementation of the x86 program counter register.
|
||||
*/
|
||||
class BxPCReg : public BochsRegister
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Constructs a new program counter register.
|
||||
* @param id the global unique id
|
||||
* @param width width of the register (8, 16, 32 or 64 bit should
|
||||
* suffice)
|
||||
* @param link pointer to bochs internal register memory
|
||||
*/
|
||||
BxPCReg(unsigned int id, regwidth_t width, regdata_t* link)
|
||||
: BochsRegister(id, width, link, RT_PC) { }
|
||||
};
|
||||
|
||||
/**
|
||||
* \class BxFlagsReg
|
||||
* Bochs-specific implementation of the FLAGS status register.
|
||||
*/
|
||||
class BxFlagsReg : public BochsRegister
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Constructs a new FLAGS status register. The refenced FLAGS are
|
||||
* allocated as follows:
|
||||
* --------------------------------------------------
|
||||
* 31|30|29|28| 27|26|25|24| 23|22|21|20| 19|18|17|16
|
||||
* ==|==|=====| ==|==|==|==| ==|==|==|==| ==|==|==|==
|
||||
* 0| 0| 0| 0| 0| 0| 0| 0| 0| 0|ID|VP| VF|AC|VM|RF
|
||||
*
|
||||
* 15|14|13|12| 11|10| 9| 8| 7| 6| 5| 4| 3| 2| 1| 0
|
||||
* ==|==|=====| ==|==|==|==| ==|==|==|==| ==|==|==|==
|
||||
* 0|NT| IOPL| OF|DF|IF|TF| SF|ZF| 0|AF| 0|PF| 1|CF
|
||||
* --------------------------------------------------
|
||||
* @param id the global unique id
|
||||
* @param link pointer to bochs internal register memory
|
||||
*/
|
||||
BxFlagsReg(unsigned int id, regdata_t* link)
|
||||
: BochsRegister(id, 32, link, RT_ST) { }
|
||||
|
||||
/**
|
||||
* Returns \c true if the corresponding flag is set, or \c false
|
||||
* otherwise.
|
||||
*/
|
||||
bool getCarryFlag() const { return (BX_CPU(0)->get_CF()); }
|
||||
bool getParityFlag() const { return (BX_CPU(0)->get_PF()); }
|
||||
bool getZeroFlag() const { return (BX_CPU(0)->get_ZF()); }
|
||||
bool getSignFlag() const { return (BX_CPU(0)->get_SF()); }
|
||||
bool getOverflowFlag() const { return (BX_CPU(0)->get_OF()); }
|
||||
|
||||
bool getTrapFlag() const { return (BX_CPU(0)->get_TF()); }
|
||||
bool getInterruptFlag() const { return (BX_CPU(0)->get_IF()); }
|
||||
bool getDirectionFlag() const { return (BX_CPU(0)->get_DF()); }
|
||||
unsigned getIOPrivilegeLevel() const { return (BX_CPU(0)->get_IOPL()); }
|
||||
bool getNestedTaskFlag() const { return (BX_CPU(0)->get_NT()); }
|
||||
bool getResumeFlag() const { return (BX_CPU(0)->get_RF()); }
|
||||
bool getVMFlag() const { return (BX_CPU(0)->get_VM()); }
|
||||
bool getAlignmentCheckFlag() const { return (BX_CPU(0)->get_AC()); }
|
||||
bool getVInterruptFlag() const { return (BX_CPU(0)->get_VIF()); }
|
||||
bool getVInterruptPendingFlag() const { return (BX_CPU(0)->get_VIP()); }
|
||||
bool getIdentificationFlag() const { return (BX_CPU(0)->get_ID()); }
|
||||
|
||||
/**
|
||||
* Sets/resets various status FLAGS.
|
||||
*/
|
||||
void setCarryFlag(bool bit) { BX_CPU(0)->set_CF(bit); }
|
||||
void setParityFlag(bool bit) { BX_CPU(0)->set_PF(bit); }
|
||||
void setZeroFlag(bool bit) { BX_CPU(0)->set_ZF(bit); }
|
||||
void setSignFlag(bool bit) { BX_CPU(0)->set_SF(bit); }
|
||||
void setOverflowFlag(bool bit) { BX_CPU(0)->set_OF(bit); }
|
||||
|
||||
void setTrapFlag(bool bit) { BX_CPU(0)->set_TF(bit); }
|
||||
void setInterruptFlag(bool bit) { BX_CPU(0)->set_IF(bit); }
|
||||
void setDirectionFlag(bool bit) { BX_CPU(0)->set_DF(bit); }
|
||||
void setIOPrivilegeLevel(unsigned lvl) { BX_CPU(0)->set_IOPL(lvl); }
|
||||
void setNestedTaskFlag(bool bit) { BX_CPU(0)->set_NT(bit); }
|
||||
void setResumeFlag(bool bit) { BX_CPU(0)->set_RF(bit); }
|
||||
void setVMFlag(bool bit) { BX_CPU(0)->set_VM(bit); }
|
||||
void setAlignmentCheckFlag(bool bit) { BX_CPU(0)->set_AC(bit); }
|
||||
void setVInterruptFlag(bool bit) { BX_CPU(0)->set_VIF(bit); }
|
||||
void setVInterruptPendingFlag(bool bit) { BX_CPU(0)->set_VIP(bit); }
|
||||
void setIdentificationFlag(bool bit) { BX_CPU(0)->set_ID(bit); }
|
||||
|
||||
/**
|
||||
* Sets the content of the status register.
|
||||
* @param data the new register data to be written; note that only the
|
||||
* 32 lower bits are used (bits 32-63 are ignored in 64 bit mode)
|
||||
*/
|
||||
void setData(regdata_t data)
|
||||
{
|
||||
#ifdef BX_SUPPORT_X86_64
|
||||
// We are in 64 bit mode: Just assign the lower 32 bits!
|
||||
(*m_pData) = ((*m_pData) & 0xFFFFFFFF00000000ULL) |
|
||||
(data & 0xFFFFFFFFULL);
|
||||
#else
|
||||
*m_pData = data;
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* \class BochsRegister
|
||||
* Bochs-specific implementation of the RegisterManager.
|
||||
*/
|
||||
class BochsRegisterManager : public RegisterManager
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Returns the current instruction pointer.
|
||||
* @return the current eip
|
||||
*/
|
||||
address_t getInstructionPointer()
|
||||
{
|
||||
return (static_cast<address_t>(
|
||||
getSetOfType(RT_PC)->first()->getData()
|
||||
));
|
||||
}
|
||||
/**
|
||||
* Retruns the top address of the stack.
|
||||
* @return the starting address of the stack
|
||||
*/
|
||||
address_t getStackPointer()
|
||||
{
|
||||
#if BX_SUPPORT_X86_64
|
||||
return (static_cast<address_t>(getRegister(RID_RSP)->getData()));
|
||||
#else
|
||||
return (static_cast<address_t>(getRegister(RID_ESP)->getData()));
|
||||
#endif
|
||||
}
|
||||
/**
|
||||
* Retrieves the base ptr (holding the address of the
|
||||
* current stack frame).
|
||||
* @return the base pointer
|
||||
*/
|
||||
address_t getBasePointer()
|
||||
{
|
||||
#if BX_SUPPORT_X86_64
|
||||
return (static_cast<address_t>(getRegister(RID_RBP)->getData()));
|
||||
#else
|
||||
return (static_cast<address_t>(getRegister(RID_EBP)->getData()));
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
} // end-of-namespace: fail
|
||||
|
||||
#endif // __BOCHS_REGISTER_HPP__
|
||||
@ -1,71 +0,0 @@
|
||||
#ifndef __OVP_CONTROLLER_HPP__
|
||||
#define __OVP_CONTROLLER_HPP__
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
|
||||
#include "../SimulatorController.hpp"
|
||||
#include "../../controller/Event.hpp"
|
||||
#include "../../../ovp/OVPPlatform.hpp"
|
||||
#include "../Register.hpp"
|
||||
|
||||
extern OVPPlatform ovpplatform;
|
||||
|
||||
namespace fail {
|
||||
|
||||
/**
|
||||
* \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&);
|
||||
|
||||
//DELETE-ME:This should be obsolete now...
|
||||
/**
|
||||
* Due to empty RegisterSets are not allowed, OVP platform
|
||||
* must tell OVPController when it is finished
|
||||
*/
|
||||
//void finishedRegisterCreation();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // __OVP_CONTROLLER_HPP__
|
||||
@ -1,92 +0,0 @@
|
||||
#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);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // __OVP_MEMORY_HPP__
|
||||
@ -1,81 +0,0 @@
|
||||
#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;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // __OVP_REGISTER_HPP__
|
||||
@ -1,7 +0,0 @@
|
||||
#ifndef VARIANT_CONFIG_H
|
||||
#define VARIANT_CONFIG_H
|
||||
|
||||
#cmakedefine BUILD_OVP
|
||||
#cmakedefine BUILD_BOCHS
|
||||
|
||||
#endif
|
||||
@ -1,9 +0,0 @@
|
||||
set(SRCS
|
||||
BufferCache.cc
|
||||
CampaignManager.cc
|
||||
CoroutineManager.cc
|
||||
Event.cc
|
||||
EventList.cc
|
||||
)
|
||||
|
||||
add_library(controller ${SRCS})
|
||||
@ -1,73 +0,0 @@
|
||||
#ifndef __COROUTINE_MANAGER_HPP__
|
||||
#define __COROUTINE_MANAGER_HPP__
|
||||
|
||||
#include <map>
|
||||
#include <stack>
|
||||
|
||||
#include <pcl.h> // the underlying "portable coroutine library"
|
||||
|
||||
namespace fail {
|
||||
|
||||
class ExperimentFlow;
|
||||
|
||||
/**
|
||||
* \class CoroutineManager
|
||||
* Manages the experiments flow encapsulated in coroutines. Each
|
||||
* experiment (flow) has it's associated data structure which is
|
||||
* represented by the ExperimentData-class.
|
||||
*/
|
||||
class CoroutineManager
|
||||
{
|
||||
private:
|
||||
//! the default stack size for coroutines (= experiment flows)
|
||||
static const unsigned STACK_SIZE_DEFAULT = 4096*4096;
|
||||
//! the abstraction for coroutine identification
|
||||
typedef coroutine_t corohandle_t;
|
||||
typedef std::map<ExperimentFlow*,corohandle_t> flowmap_t;
|
||||
//! the mapping "flows <-> coro-handle"
|
||||
flowmap_t m_Flows;
|
||||
//! the simulator/backend coroutine handle
|
||||
corohandle_t m_simCoro;
|
||||
//! stack of coroutines that explicitly activated another one with toggle()
|
||||
std::stack<corohandle_t> m_togglerstack;
|
||||
//! manages the run-calls for each ExperimentFlow-object
|
||||
static void m_invoke(void* pData);
|
||||
public:
|
||||
static const ExperimentFlow* SIM_FLOW; //!< the simulator coroutine flow
|
||||
|
||||
CoroutineManager() : m_simCoro(co_current()) { }
|
||||
~CoroutineManager();
|
||||
/**
|
||||
* Creates a new coroutine for the specified experiment flow.
|
||||
* @param flow the flow to be executed in the newly created coroutine
|
||||
*/
|
||||
void create(ExperimentFlow* flow);
|
||||
/**
|
||||
* Destroys coroutine for the specified experiment flow.
|
||||
* @param flow the flow to be removed
|
||||
*/
|
||||
void remove(ExperimentFlow* flow);
|
||||
/**
|
||||
* Switches the control flow to the experiment \a flow. If \a flow is
|
||||
* equal to \c SIM_FLOW, the control will be handed back to the
|
||||
* simulator. The current control flow is pushed onto an
|
||||
* internal stack.
|
||||
* @param flow the destination control flow or \c SIM_FLOW (= \c NULL )
|
||||
*/
|
||||
void toggle(ExperimentFlow* flow);
|
||||
/**
|
||||
* Gives the control back to the coroutine that toggle()d the
|
||||
* current one, by drawing from the internal stack built from
|
||||
* calls to toggle().
|
||||
*/
|
||||
void resume();
|
||||
/**
|
||||
* Retrieves the current (active) coroutine (= flow).
|
||||
* @return the current experiment flow.
|
||||
*/
|
||||
ExperimentFlow* getCurrent();
|
||||
};
|
||||
|
||||
} // end-of-namespace: fail
|
||||
|
||||
#endif // __COROUTINE_MANAGER_HPP__
|
||||
@ -1,38 +0,0 @@
|
||||
#ifndef __EXPERIMENT_FLOW_HPP__
|
||||
#define __EXPERIMENT_FLOW_HPP__
|
||||
|
||||
#include "../SAL/SALInst.hpp"
|
||||
|
||||
namespace fail {
|
||||
|
||||
/**
|
||||
* \class ExperimentFlow
|
||||
* Basic interface for user-defined experiments. To create a new experiment,
|
||||
* derive your own class from ExperimentFlow and define the run method.
|
||||
*/
|
||||
class ExperimentFlow
|
||||
{
|
||||
public:
|
||||
ExperimentFlow() { }
|
||||
/**
|
||||
* Defines the experiment flow.
|
||||
* @return \c true if the experiment was successful, \c false otherwise
|
||||
*/
|
||||
virtual bool run() = 0;
|
||||
/**
|
||||
* The entry point for this experiment's coroutine.
|
||||
* Should do some cleanup afterwards.
|
||||
*/
|
||||
void coroutine_entry()
|
||||
{
|
||||
run();
|
||||
simulator.clearEvents(this); // remove residual events
|
||||
// FIXME: Consider removing this call (see EventList.cc, void remove(ExperimentFlow* flow))
|
||||
// a) with the advantage that we will potentially prevent serious segfaults but
|
||||
// b) with the drawback that we cannot enforce any cleanups.
|
||||
}
|
||||
};
|
||||
|
||||
} // end-of-namespace: fail
|
||||
|
||||
#endif // __EXPERIMENT_FLOW_HPP__
|
||||
@ -1,73 +0,0 @@
|
||||
/**
|
||||
* \brief The representation of a minion.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __MINION_HPP__
|
||||
#define __MINION_HPP__
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "controller/ExperimentData.hpp"
|
||||
|
||||
namespace fail {
|
||||
|
||||
/**
|
||||
* \class Minion
|
||||
*
|
||||
* Contains all informations about a minion.
|
||||
*/
|
||||
class Minion
|
||||
{
|
||||
private:
|
||||
std::string hostname;
|
||||
bool isWorking;
|
||||
ExperimentData* currentExperimentData;
|
||||
int sockfd;
|
||||
public:
|
||||
Minion() : isWorking(false), currentExperimentData(0), sockfd(-1) { }
|
||||
/**
|
||||
* Sets the socket descriptor.
|
||||
* @param sock the new socket descriptor (used internal)
|
||||
*/
|
||||
void setSocketDescriptor(int sock) { sockfd = sock; }
|
||||
/**
|
||||
* Retrives the socket descriptor.
|
||||
* @return the socket descriptor
|
||||
*/
|
||||
int getSocketDescriptor() const { return (sockfd); }
|
||||
/**
|
||||
* Returns the hostname of the minion.
|
||||
* @return the hostname
|
||||
*/
|
||||
const std::string& getHostname() { return (hostname); }
|
||||
/**
|
||||
* Sets the hostname of the minion.
|
||||
* @param host the hostname
|
||||
*/
|
||||
void setHostname(const std::string& host) { hostname = host; }
|
||||
/**
|
||||
* Returns the current ExperimentData which the minion is working with.
|
||||
* @return a pointer of the current ExperimentData
|
||||
*/
|
||||
ExperimentData* getCurrentExperimentData() { return currentExperimentData; }
|
||||
/**
|
||||
* Sets the current ExperimentData which the minion is working with.
|
||||
* @param exp the current ExperimentData
|
||||
*/
|
||||
void setCurrentExperimentData(ExperimentData* exp) { currentExperimentData = exp; }
|
||||
/**
|
||||
* Returns the current state of the minion.
|
||||
* @return the current state
|
||||
*/
|
||||
bool isBusy() { return (isWorking); }
|
||||
/**
|
||||
* Sets the current state of the minion
|
||||
* @param state the current state
|
||||
*/
|
||||
void setBusy(bool state) { isWorking = state; }
|
||||
};
|
||||
|
||||
} // end-of-namespace: fail
|
||||
|
||||
#endif // __MINION_HPP__
|
||||
@ -1,13 +0,0 @@
|
||||
#ifndef __FIREINTERRUPT_EXPERIMENT_HPP__
|
||||
#define __FIREINTERRUPT_EXPERIMENT_HPP__
|
||||
|
||||
#include "controller/ExperimentFlow.hpp"
|
||||
|
||||
class fireinterruptExperiment : public fail::ExperimentFlow
|
||||
{
|
||||
public:
|
||||
fireinterruptExperiment() { }
|
||||
bool run();
|
||||
};
|
||||
|
||||
#endif // __FIREINTERRUPT_EXPERIMENT_HPP__
|
||||
@ -1,14 +0,0 @@
|
||||
#ifndef __HSCSIMPLE_EXPERIMENT_HPP__
|
||||
#define __HSCSIMPLE_EXPERIMENT_HPP__
|
||||
|
||||
#include "controller/ExperimentFlow.hpp"
|
||||
|
||||
class hscsimpleExperiment : public fail::ExperimentFlow
|
||||
{
|
||||
public:
|
||||
hscsimpleExperiment() { }
|
||||
|
||||
bool run();
|
||||
};
|
||||
|
||||
#endif // __HSCSIMPLE_EXPERIMENT_HPP__
|
||||
@ -1,19 +0,0 @@
|
||||
#ifndef __WEATHERMONITOR_CAMPAIGN_HPP__
|
||||
#define __WEATHERMONITOR_CAMPAIGN_HPP__
|
||||
|
||||
#include "controller/Campaign.hpp"
|
||||
#include "controller/ExperimentData.hpp"
|
||||
#include "weathermonitor.pb.h"
|
||||
|
||||
class WeathermonitorExperimentData : public fail::ExperimentData {
|
||||
public:
|
||||
WeathermonitorProtoMsg msg;
|
||||
WeathermonitorExperimentData() : fail::ExperimentData(&msg) {}
|
||||
};
|
||||
|
||||
class WeathermonitorCampaign : public fail::Campaign {
|
||||
public:
|
||||
virtual bool run();
|
||||
};
|
||||
|
||||
#endif // __WEATHERMONITOR_CAMPAIGN_HPP__
|
||||
@ -1,14 +0,0 @@
|
||||
#ifndef __WEATHERMONITOR_EXPERIMENT_HPP__
|
||||
#define __WEATHERMONITOR_EXPERIMENT_HPP__
|
||||
|
||||
#include "controller/ExperimentFlow.hpp"
|
||||
#include "jobserver/JobClient.hpp"
|
||||
|
||||
class WeathermonitorExperiment : public fail::ExperimentFlow {
|
||||
fail::JobClient m_jc;
|
||||
public:
|
||||
WeathermonitorExperiment() : m_jc("ios.cs.tu-dortmund.de") {}
|
||||
bool run();
|
||||
};
|
||||
|
||||
#endif // __WEATHERMONITOR_EXPERIMENT_HPP__
|
||||
@ -1,8 +0,0 @@
|
||||
set(SRCS
|
||||
JobClient.cc
|
||||
JobServer.cc
|
||||
SocketComm.cc
|
||||
)
|
||||
add_subdirectory(messagedefs)
|
||||
add_library(jobserver ${SRCS})
|
||||
add_dependencies(jobserver protomessages)
|
||||
@ -1,65 +0,0 @@
|
||||
#ifndef __LOGGER_HPP__
|
||||
#define __LOGGER_HPP__
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
namespace fail {
|
||||
|
||||
/**
|
||||
* \class Logger
|
||||
* Provides logging mechanisms.
|
||||
*/
|
||||
class Logger
|
||||
{
|
||||
private:
|
||||
std::ostream* m_pDest;
|
||||
std::string m_description;
|
||||
bool m_showTime;
|
||||
void timestamp();
|
||||
|
||||
public:
|
||||
/**
|
||||
* Constructor.
|
||||
* @param description Description shown alongside each log entry in
|
||||
* square brackets [ ]. Can be overridden in single add() calls.
|
||||
* @param show_time Show a timestamp with each log entry.
|
||||
* @param dest Stream to log into.
|
||||
*/
|
||||
Logger(const std::string& description = "Fail*", bool show_time = true,
|
||||
std::ostream& dest = std::cout)
|
||||
: m_pDest(&dest), m_description(description), m_showTime(show_time) { }
|
||||
/**
|
||||
* Change the default description which is shown alongside each log
|
||||
* entry in square brackets [ ].
|
||||
* @param descr The description text.
|
||||
*/
|
||||
void setDescription(const std::string& descr)
|
||||
{
|
||||
m_description = descr;
|
||||
}
|
||||
/**
|
||||
* Change the default option of show_time which shows a timestamp
|
||||
* each log entry.
|
||||
* @param choice The choice for show_time
|
||||
*/
|
||||
void showTime(bool choice)
|
||||
{
|
||||
m_showTime = choice;
|
||||
}
|
||||
/**
|
||||
* Add a new log entry. Returns a std::ostream reference to continue
|
||||
* streaming a longer log entry.
|
||||
* @param v data to log
|
||||
*/
|
||||
template<class T>
|
||||
inline std::ostream& operator <<(const T& v)
|
||||
{
|
||||
timestamp();
|
||||
return (*m_pDest) << v;
|
||||
}
|
||||
};
|
||||
|
||||
} // end-of-namespace: fail
|
||||
|
||||
#endif // __LOGGER_HPP__
|
||||
@ -1,86 +0,0 @@
|
||||
/** brief One way to manage large protobuf-messages
|
||||
*
|
||||
* Google protobuf is not designed for large messages.
|
||||
* That leads to much memory which is consumed by processing large
|
||||
* messages. To solve this problem the ProtoStream class stores the
|
||||
* protobuf-messages in an other way.
|
||||
* Instead of using the repeat-function the data is written
|
||||
* sequentially in a file.
|
||||
* Written in the format:
|
||||
* |4 bytes length-information of the first message | first message
|
||||
* |4 bytes length-information of the second message| second message
|
||||
* | ...
|
||||
*/
|
||||
|
||||
#ifndef __PROTOSTREAM_HPP__
|
||||
#define __PROTOSTREAM_HPP__
|
||||
|
||||
#include <iostream>
|
||||
#include <sys/types.h>
|
||||
#include <netinet/in.h>
|
||||
#include <google/protobuf/message.h>
|
||||
|
||||
#include "Logger.hpp"
|
||||
|
||||
namespace fail {
|
||||
|
||||
/**
|
||||
* \class ProtoOStream
|
||||
*
|
||||
* This class can be used to sequentially write a large number of protocol
|
||||
* buffer messages to a std::ostream.
|
||||
*/
|
||||
class ProtoOStream
|
||||
{
|
||||
private:
|
||||
uint32_t m_size;
|
||||
|
||||
Logger m_log;
|
||||
std::ostream* m_outfile;
|
||||
|
||||
public:
|
||||
ProtoOStream(std::ostream *outfile);
|
||||
virtual ~ProtoOStream() {};
|
||||
/**
|
||||
* Writes a message to a file.
|
||||
* @param m The protobuf-message to be written.
|
||||
* @return Returns true on success.
|
||||
*/
|
||||
bool writeMessage(google::protobuf::Message* m);
|
||||
};
|
||||
|
||||
/**
|
||||
* \class ProtoIStream
|
||||
*
|
||||
* This class can be used to read protocol buffer messages sequentially from a
|
||||
* std::istream.
|
||||
*/
|
||||
class ProtoIStream
|
||||
{
|
||||
private:
|
||||
uint32_t m_size;
|
||||
long m_sizeOfInfile;
|
||||
|
||||
Logger m_log;
|
||||
std::istream *m_infile;
|
||||
|
||||
|
||||
public:
|
||||
ProtoIStream(std::istream *infile);
|
||||
virtual ~ProtoIStream() {};
|
||||
/**
|
||||
* Resets the position of the get pointer. After that getNext
|
||||
* reads the first message again.
|
||||
*/
|
||||
void reset();
|
||||
/**
|
||||
* Reads the next protobuf message from the input stream.
|
||||
* @param m The output protobuf message.
|
||||
* @return Returns true on success.
|
||||
*/
|
||||
bool getNext(google::protobuf::Message* m);
|
||||
};
|
||||
|
||||
} // end-of-namespace: fail
|
||||
|
||||
#endif // __PROTOSTREAM_HPP__
|
||||
@ -1,30 +0,0 @@
|
||||
// Thread safe counter
|
||||
|
||||
#ifndef __SYNCHRONIZED_COUNTER_HPP__
|
||||
#define __SYNCHRONIZED_COUNTER_HPP__
|
||||
|
||||
#ifndef __puma
|
||||
#include <boost/thread.hpp>
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
namespace fail {
|
||||
|
||||
class SynchronizedCounter
|
||||
{
|
||||
private:
|
||||
int m_counter;
|
||||
#ifndef __puma
|
||||
boost::mutex m_mutex; // The mutex to synchronise on
|
||||
#endif
|
||||
public:
|
||||
SynchronizedCounter() : m_counter(0) {};
|
||||
|
||||
int increment();
|
||||
int decrement();
|
||||
int getValue();
|
||||
};
|
||||
|
||||
} // end-of-namespace: fail
|
||||
|
||||
#endif // __SYNCHRONIZED_COUNTER_HPP__
|
||||
@ -174,12 +174,13 @@ all: @PRIMARY_TARGET@ @PLUGIN_TARGET@ bximage@EXE@ bxcommit@EXE@ @BUILD_DOCBOOK_
|
||||
|
||||
@EXTERNAL_DEPENDENCY@
|
||||
|
||||
# DanceOS (added "../../src/libfail.a"):
|
||||
bochs@EXE@: @IODEV_LIB_VAR@ @DEBUGGER_VAR@ \
|
||||
cpu/libcpu.a memory/libmemory.a ../core/libfail.a gui/libgui.a \
|
||||
cpu/libcpu.a memory/libmemory.a ../../src/libfail.a gui/libgui.a \
|
||||
@DISASM_VAR@ @INSTRUMENT_VAR@ $(BX_OBJS) \
|
||||
$(SIMX86_OBJS) @FPU_VAR@ @GDBSTUB_VAR@ @PLUGIN_VAR@
|
||||
@LINK@ @EXPORT_DYNAMIC@ $(BX_OBJS) $(SIMX86_OBJS) \
|
||||
@IODEV_LIB_VAR@ @DEBUGGER_VAR@ cpu/libcpu.a memory/libmemory.a ../core/libfail.a gui/libgui.a \
|
||||
@IODEV_LIB_VAR@ @DEBUGGER_VAR@ cpu/libcpu.a memory/libmemory.a ../../src/libfail.a gui/libgui.a \
|
||||
@DISASM_VAR@ @INSTRUMENT_VAR@ @PLUGIN_VAR@ \
|
||||
@GDBSTUB_VAR@ @FPU_VAR@ \
|
||||
@NONPLUGIN_GUI_LINK_OPTS@ \
|
||||
@ -189,23 +190,25 @@ bochs@EXE@: @IODEV_LIB_VAR@ @DEBUGGER_VAR@ \
|
||||
$(EXTRA_LINK_OPTS) \
|
||||
$(LIBS)
|
||||
|
||||
# DanceOS (added ../../src/libfail.a):
|
||||
|
||||
# Special make target for cygwin/mingw using dlltool instead of
|
||||
# libtool. This creates a .DEF file, and exports file, an import library,
|
||||
# and then links bochs.exe with the exports file.
|
||||
.win32_dll_plugin_target: @IODEV_LIB_VAR@ @DEBUGGER_VAR@ \
|
||||
cpu/libcpu.a memory/libmemory.a ../core/libfail.a gui/libgui.a \
|
||||
cpu/libcpu.a memory/libmemory.a ../../src/libfail.a gui/libgui.a \
|
||||
@DISASM_VAR@ @INSTRUMENT_VAR@ $(BX_OBJS) \
|
||||
$(SIMX86_OBJS) @FPU_VAR@ @GDBSTUB_VAR@ @PLUGIN_VAR@
|
||||
$(DLLTOOL) --export-all-symbols --output-def bochs.def \
|
||||
$(BX_OBJS) $(SIMX86_OBJS) \
|
||||
@IODEV_LIB_VAR@ cpu/libcpu.a memory/libmemory.a ../core/libfail.a gui/libgui.a \
|
||||
@IODEV_LIB_VAR@ cpu/libcpu.a memory/libmemory.a ../../src/libfail.a gui/libgui.a \
|
||||
@DEBUGGER_VAR@ @DISASM_VAR@ @INSTRUMENT_VAR@ @PLUGIN_VAR@ \
|
||||
@GDBSTUB_VAR@ @FPU_VAR@
|
||||
$(DLLTOOL) --dllname bochs.exe --def bochs.def --output-lib dllexports.a
|
||||
$(DLLTOOL) --dllname bochs.exe --output-exp bochs.exp --def bochs.def
|
||||
$(CXX) -o bochs.exe $(CXXFLAGS) $(LDFLAGS) -export-dynamic \
|
||||
$(BX_OBJS) bochs.exp $(SIMX86_OBJS) \
|
||||
@IODEV_LIB_VAR@ cpu/libcpu.a memory/libmemory.a ../core/libfail.a gui/libgui.a \
|
||||
@IODEV_LIB_VAR@ cpu/libcpu.a memory/libmemory.a ../../src/libfail.a gui/libgui.a \
|
||||
@DEBUGGER_VAR@ @DISASM_VAR@ @INSTRUMENT_VAR@ @PLUGIN_VAR@ \
|
||||
@GDBSTUB_VAR@ @FPU_VAR@ \
|
||||
$(GUI_LINK_OPTS) \
|
||||
@ -31,7 +31,7 @@
|
||||
#include "config.h" /* generated by configure script from config.h.in */
|
||||
|
||||
//DanceOS
|
||||
#include "../core/SAL/bochs/FailBochsGlobals.hpp"
|
||||
#include "../../src/core/sal/bochs/FailBochsGlobals.hpp"
|
||||
|
||||
#ifndef __QNXNTO__
|
||||
extern "C" {
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user