first steps towards a QEMU target backend
- This commit only enables linking against QEMU. The abstraction layer is completely dysfunctional at this time. - QEMU's build system needs to be patched in order to create a static library. This patch is currently not included in the Fail* repository. - QEMU's JIT compilation may complicate or even preclude the implementation of some of Fail*'s backend abstractions. Only a minimal subset (serial I/O, memory, memory writes, save/restore) is planned for the first phase. git-svn-id: https://www4.informatik.uni-erlangen.de/i4svn/danceos/trunk/devel/fail@1615 8c4709b5-6ec9-48aa-a5cd-a96041d1645a
This commit is contained in:
@ -1,8 +1,9 @@
|
||||
#ifndef __VARIANT_CONFIG_HPP__
|
||||
#define __VARIANT_CONFIG_HPP__
|
||||
|
||||
#cmakedefine BUILD_OVP
|
||||
#cmakedefine BUILD_BOCHS
|
||||
#cmakedefine BUILD_GEM5
|
||||
#cmakedefine BUILD_OVP
|
||||
#cmakedefine BUILD_QEMU
|
||||
|
||||
#endif // __VARIANT_CONFIG_HPP__
|
||||
|
||||
@ -31,6 +31,17 @@ elseif(BUILD_OVP)
|
||||
SimulatorController.cc
|
||||
${VARIANT}/OVPController.cc
|
||||
)
|
||||
elseif(BUILD_QEMU)
|
||||
set(SRCS
|
||||
BufferCache.cc
|
||||
Listener.cc
|
||||
ListenerManager.cc
|
||||
SALConfig.cc
|
||||
Register.cc
|
||||
SimulatorController.cc
|
||||
qemu/QEMUController.cc
|
||||
qemu/QEMUListener.cc
|
||||
)
|
||||
endif(BUILD_BOCHS)
|
||||
|
||||
add_library(fail-sal ${SRCS})
|
||||
|
||||
@ -597,10 +597,12 @@ public:
|
||||
|
||||
#if defined BUILD_BOCHS
|
||||
#include "bochs/BochsListener.hpp"
|
||||
#elif defined BUILD_OVP
|
||||
// #include "ovp/OVPListener.hpp"
|
||||
#elif defined BUILD_GEM5
|
||||
#include "gem5/Gem5Listener.hpp"
|
||||
#elif defined BUILD_OVP
|
||||
// #include "ovp/OVPListener.hpp"
|
||||
#elif defined BUILD_QEMU
|
||||
#include "qemu/QEMUListener.hpp"
|
||||
#else
|
||||
#error SAL Config Target not defined
|
||||
#endif
|
||||
|
||||
@ -8,10 +8,12 @@
|
||||
// Type-config depends on the current selected simulator:
|
||||
#if defined BUILD_BOCHS
|
||||
#include "bochs/BochsConfig.hpp"
|
||||
#elif defined BUILD_OVP
|
||||
#include "ovp/OVPConfig.hpp"
|
||||
#elif defined BUILD_GEM5
|
||||
#include "gem5/Gem5Config.hpp"
|
||||
#elif defined BUILD_OVP
|
||||
#include "ovp/OVPConfig.hpp"
|
||||
#elif defined BUILD_QEMU
|
||||
#include "qemu/QEMUConfig.hpp"
|
||||
#else
|
||||
#error SAL Config Target not defined
|
||||
#endif
|
||||
|
||||
@ -9,21 +9,7 @@
|
||||
#include "bochs/BochsController.hpp"
|
||||
|
||||
namespace fail {
|
||||
|
||||
typedef BochsController ConcreteSimulatorController; //!< concrete simulator (type)
|
||||
extern ConcreteSimulatorController simulator; //!< the global simulator-controller instance
|
||||
|
||||
}
|
||||
|
||||
#elif defined BUILD_OVP
|
||||
|
||||
#include "ovp/OVPController.hpp"
|
||||
|
||||
namespace fail {
|
||||
|
||||
typedef OVPController ConcreteSimulatorController; //!< concrete simulator (type)
|
||||
extern ConcreteSimulatorController simulator; //!< the global simulator-controller instance
|
||||
|
||||
}
|
||||
|
||||
#elif defined BUILD_GEM5
|
||||
@ -31,14 +17,31 @@ extern ConcreteSimulatorController simulator; //!< the global simulator-controll
|
||||
#include "gem5/Gem5Controller.hpp"
|
||||
|
||||
namespace fail {
|
||||
|
||||
typedef Gem5Controller ConcreteSimulatorController; //!< concrete simulator (type)
|
||||
extern ConcreteSimulatorController simulator; //!< the global simulator-controller instance
|
||||
}
|
||||
|
||||
#elif defined BUILD_OVP
|
||||
|
||||
#include "ovp/OVPController.hpp"
|
||||
|
||||
namespace fail {
|
||||
typedef OVPController ConcreteSimulatorController; //!< concrete simulator (type)
|
||||
}
|
||||
|
||||
#elif defined BUILD_QEMU
|
||||
|
||||
#include "qemu/QEMUController.hpp"
|
||||
|
||||
namespace fail {
|
||||
typedef QEMUController ConcreteSimulatorController; //!< concrete simulator (type)
|
||||
}
|
||||
|
||||
#else
|
||||
#error SAL Instance not defined
|
||||
#endif
|
||||
|
||||
namespace fail {
|
||||
extern ConcreteSimulatorController simulator; //!< the global simulator-controller instance
|
||||
};
|
||||
|
||||
#endif // __SAL_INSTANCE_HPP__
|
||||
|
||||
20
src/core/sal/qemu/QEMUConfig.hpp
Normal file
20
src/core/sal/qemu/QEMUConfig.hpp
Normal file
@ -0,0 +1,20 @@
|
||||
/**
|
||||
* \brief Type definitions and configuration settings for the
|
||||
* qemu-system-x86_64 target backend.
|
||||
*/
|
||||
|
||||
#ifndef __QEMU_CONFIG_HPP__
|
||||
#define __QEMU_CONFIG_HPP__
|
||||
|
||||
// FIXME: qemu/targphys.h defines address types (but relies on a global preprocessor macro)
|
||||
|
||||
namespace fail {
|
||||
|
||||
typedef uint64_t guest_address_t; //!< the guest memory address type
|
||||
typedef unsigned char* host_address_t; //!< the host memory address type
|
||||
typedef uint64_t register_data_t; //!< register data type (64 bit)
|
||||
typedef int timer_t; //!< type of timer IDs
|
||||
|
||||
} // end-of-namespace: fail
|
||||
|
||||
#endif // __QEMU_CONFIG_HPP__
|
||||
23
src/core/sal/qemu/QEMUController.cc
Normal file
23
src/core/sal/qemu/QEMUController.cc
Normal file
@ -0,0 +1,23 @@
|
||||
#include <sstream>
|
||||
|
||||
#include "QEMUController.hpp"
|
||||
#include "QEMUMemory.hpp"
|
||||
#include "QEMURegister.hpp"
|
||||
#include "../Register.hpp"
|
||||
#include "../SALInst.hpp"
|
||||
|
||||
namespace fail {
|
||||
|
||||
QEMUController::QEMUController()
|
||||
: SimulatorController(new QEMURegisterManager(), new QEMUMemoryManager())
|
||||
{
|
||||
// TODO: probably do additional RegisterManager initializations
|
||||
}
|
||||
|
||||
QEMUController::~QEMUController()
|
||||
{
|
||||
delete m_Regs;
|
||||
delete m_Mem;
|
||||
}
|
||||
|
||||
} // end-of-namespace: fail
|
||||
59
src/core/sal/qemu/QEMUController.hpp
Normal file
59
src/core/sal/qemu/QEMUController.hpp
Normal file
@ -0,0 +1,59 @@
|
||||
#ifndef __QEMU_CONTROLLER_HPP__
|
||||
#define __QEMU_CONTROLLER_HPP__
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <string.h>
|
||||
|
||||
#include "../SimulatorController.hpp"
|
||||
#include "../Listener.hpp"
|
||||
|
||||
namespace fail {
|
||||
|
||||
class ExperimentFlow;
|
||||
|
||||
/**
|
||||
* \class QEMUController
|
||||
* Very rudimentary, QEMU-specific implementation of a SimulatorController.
|
||||
*/
|
||||
class QEMUController : public SimulatorController {
|
||||
private:
|
||||
public:
|
||||
// Initialize the controller.
|
||||
QEMUController();
|
||||
~QEMUController();
|
||||
/**
|
||||
* I/O port communication handler. This method is called from QEMU. TODO.
|
||||
* @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 onIOPort(unsigned char data, unsigned port, bool out) {}
|
||||
/**
|
||||
* Static internal handler for TimerListeners. TODO.
|
||||
*/
|
||||
static void onTimerTrigger(void *thisPtr) {}
|
||||
/* ********************************************************************
|
||||
* Simulator Controller & Access API:
|
||||
* ********************************************************************/
|
||||
/**
|
||||
* Save simulator state. TODO.
|
||||
* @param path Location to store state information
|
||||
*/
|
||||
void save(const std::string& path) {}
|
||||
/**
|
||||
* Restore simulator state. Clears all Listeners. TODO.
|
||||
* @param path Location to previously saved state information
|
||||
*/
|
||||
void restore(const std::string& path) {}
|
||||
/**
|
||||
* Reboot simulator. Clears all Listeners. TODO.
|
||||
*/
|
||||
void reboot() {}
|
||||
};
|
||||
|
||||
} // end-of-namespace: fail
|
||||
|
||||
#endif // __QEMU_CONTROLLER_HPP__
|
||||
8
src/core/sal/qemu/QEMUListener.cc
Normal file
8
src/core/sal/qemu/QEMUListener.cc
Normal file
@ -0,0 +1,8 @@
|
||||
#include "QEMUListener.hpp"
|
||||
#include "../SALInst.hpp"
|
||||
|
||||
namespace fail {
|
||||
|
||||
// TODO
|
||||
|
||||
} // end-of-namespace: fail
|
||||
24
src/core/sal/qemu/QEMUListener.hpp
Normal file
24
src/core/sal/qemu/QEMUListener.hpp
Normal file
@ -0,0 +1,24 @@
|
||||
#ifndef __QEMU_LISTENER_HPP__
|
||||
#define __QEMU_LISTENER_HPP__
|
||||
|
||||
#include "../Listener.hpp"
|
||||
|
||||
namespace fail {
|
||||
|
||||
typedef GenericBPSingleListener BPSingleListener;
|
||||
|
||||
/**
|
||||
* \class TimerListener
|
||||
* Concrete TimerListener implementation of GenericTimerListener for QEMU.
|
||||
*/
|
||||
class TimerListener : public GenericTimerListener {
|
||||
private:
|
||||
public:
|
||||
// TODO
|
||||
};
|
||||
|
||||
// TODO: MemWriteListener
|
||||
|
||||
} // end-of-namespace: fail
|
||||
|
||||
#endif // __QEMU_LISTENER_HPP__
|
||||
41
src/core/sal/qemu/QEMUMemory.hpp
Normal file
41
src/core/sal/qemu/QEMUMemory.hpp
Normal file
@ -0,0 +1,41 @@
|
||||
#ifndef __QEMU_MEMORY_HPP__
|
||||
#define __QEMU_MEMORY_HPP__
|
||||
|
||||
#include "../Memory.hpp"
|
||||
|
||||
namespace fail {
|
||||
|
||||
/**
|
||||
* \class QEMUMemoryManager
|
||||
* Represents a concrete implemenation of the abstract
|
||||
* MemoryManager to provide access to QEMU's memory pool.
|
||||
*/
|
||||
class QEMUMemoryManager : public MemoryManager {
|
||||
public:
|
||||
size_t getPoolSize() const { return 0; /* TODO */ }
|
||||
host_address_t getStartAddr() const { return 0; }
|
||||
byte_t getByte(guest_address_t addr)
|
||||
{
|
||||
return static_cast<byte_t>(0); /* TODO */
|
||||
}
|
||||
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);
|
||||
}
|
||||
void setByte(guest_address_t addr, byte_t data)
|
||||
{
|
||||
/* TODO */
|
||||
}
|
||||
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]);
|
||||
}
|
||||
};
|
||||
|
||||
} // end-of-namespace: fail
|
||||
|
||||
#endif // __QEMU_MEMORY_HPP__
|
||||
45
src/core/sal/qemu/QEMURegister.hpp
Normal file
45
src/core/sal/qemu/QEMURegister.hpp
Normal file
@ -0,0 +1,45 @@
|
||||
#ifndef __QEMU_REGISTER_HPP__
|
||||
#define __QEMU_REGISTER_HPP__
|
||||
|
||||
#include "../Register.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <cassert>
|
||||
|
||||
namespace fail {
|
||||
|
||||
/**
|
||||
* \class QEMURegister
|
||||
* QEMU-specific implementation of x86 registers. TODO.
|
||||
*/
|
||||
class QEMURegister : public Register {
|
||||
public:
|
||||
QEMURegister(unsigned int id, regwidth_t width, regdata_t* link, RegisterType t)
|
||||
: Register(id, t, width) { }
|
||||
regdata_t getData() { return 0; /* TODO */ }
|
||||
void setData(regdata_t data) { /* TODO */ }
|
||||
};
|
||||
|
||||
/**
|
||||
* \class QEMURegisterManager
|
||||
* QEMU-specific implementation of the RegisterManager. TODO.
|
||||
*/
|
||||
class QEMURegisterManager : public RegisterManager {
|
||||
public:
|
||||
address_t getInstructionPointer()
|
||||
{
|
||||
return static_cast<address_t>(0); /* TODO */
|
||||
}
|
||||
address_t getStackPointer()
|
||||
{
|
||||
return static_cast<address_t>(0); /* TODO */
|
||||
}
|
||||
address_t getBasePointer()
|
||||
{
|
||||
return static_cast<address_t>(0); /* TODO */
|
||||
}
|
||||
};
|
||||
|
||||
} // end-of-namespace: fail
|
||||
|
||||
#endif // __QEMU_REGISTER_HPP__
|
||||
1
src/core/sal/qemu/lol.h
Normal file
1
src/core/sal/qemu/lol.h
Normal file
@ -0,0 +1 @@
|
||||
#error YO DAWG
|
||||
Reference in New Issue
Block a user