19 ret->sys.handle = system->
handle;
23 std::set<std::string> headers;
27 auto makeWrapper = [&](
void *funcPtr,
void *handle,
bool isDbg,
bool isSync,
bool isIRead)
29 std::string funcAddr = std::to_string((
uintptr_t)funcPtr);
30 std::string params, cast, call;
31 params +=
"void *handle";
33 call +=
"(void*)" + std::to_string((
uintptr_t)handle) +
"ull";
36 params +=
", ETISS_CPU *cpu";
37 cast +=
", ETISS_CPU*";
42 params +=
", etiss_uint64 addr";
43 cast +=
", etiss_uint64";
47 params +=
", etiss_uint8 *buffer";
48 cast +=
", etiss_uint8*";
51 params +=
", etiss_uint32 length";
52 cast +=
", etiss_uint32";
56 std::string code =
"#include \"etiss/jit/System.h\"\n";
57 code +=
"etiss_int32 wrapper(" + params +
"){\n";
58 code +=
" return ((etiss_int32 (*)(" + cast +
"))" + funcAddr +
")(" + call +
");\n}\n";
60 void *jitHandle = jit->translate(code, headers, {}, {}, jitErr,
false);
61 ret->jitHandles.push_back(jitHandle);
62 return jit->getFunction(jitHandle,
"wrapper", jitErr);
70 (decltype(ret->sys.iread))makeWrapper((
void *)wrapInfo.
iread, wrapInfo.
handle,
false,
false,
true);
75 (decltype(ret->sys.iwrite))makeWrapper((
void *)wrapInfo.
iwrite, wrapInfo.
handle,
false,
false,
false);
80 (decltype(ret->sys.dread))makeWrapper((
void *)wrapInfo.
dread, wrapInfo.
handle,
false,
false,
false);
85 (decltype(ret->sys.dwrite))makeWrapper((
void *)wrapInfo.
dwrite, wrapInfo.
handle,
false,
false,
false);
90 (decltype(ret->sys.dbg_read))makeWrapper((
void *)wrapInfo.
dbg_read, wrapInfo.
handle,
true,
false,
false);
95 (decltype(ret->sys.dbg_write))makeWrapper((
void *)wrapInfo.
dbg_write, wrapInfo.
handle,
true,
false,
false);
100 (decltype(ret->sys.syncTime))makeWrapper((
void *)wrapInfo.
syncTime, wrapInfo.
handle,
false,
true,
false);
110 for (
auto h : wrapSys->jitHandles)
Header file of the ETISS library.
CPUCore is responsible for the simulation of a CPU core in ETISS.
ETISS_System * unwrap(ETISS_CPU *cpu, ETISS_System *system) final
undo wrap function call this function will be called AFTER etiss::Plugin::cleanup
virtual ETISS_System getWrapInfo(ETISS_System *origSystem)=0
Defines which System functions to wrap.
ETISS_System * wrap(ETISS_CPU *cpu, ETISS_System *system) final
change/wrap the passed system structure.
Page Table Entry (PTE) defines the composition of Page Frame Number (PFN) and relavant flags.
std::string jitFiles()
Get ETISS JIT files path.
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
basic cpu state structure needed for execution of any cpu architecture.
void * _etiss_private_handle_
private helper handle for plugins
memory access and time synchronization functions.
etiss_int32(* dwrite)(void *handle, ETISS_CPU *cpu, etiss_uint64 addr, etiss_uint8 *buffer, etiss_uint32 length)
write data
etiss_int32(* iread)(void *handle, ETISS_CPU *cpu, etiss_uint64 addr, etiss_uint32 length)
used to simulate an instruction fetch.
void * handle
custom handle that will be passed to the functions of this structure
etiss_int32(* dbg_write)(void *handle, etiss_uint64 addr, etiss_uint8 *buffer, etiss_uint32 length)
direct debug write
etiss_int32(* dbg_read)(void *handle, etiss_uint64 addr, etiss_uint8 *buffer, etiss_uint32 length)
direct debug read
etiss_int32(* dread)(void *handle, ETISS_CPU *cpu, etiss_uint64 addr, etiss_uint8 *buffer, etiss_uint32 length)
read data
void(* syncTime)(void *handle, ETISS_CPU *cpu)
called after a block to synchronize the time
etiss_int32(* iwrite)(void *handle, ETISS_CPU *cpu, etiss_uint64 addr, etiss_uint8 *buffer, etiss_uint32 length)
write instruction data over instruction bus
std::vector< void * > jitHandles