ETISS 0.8.0
Extendable Translating Instruction Set Simulator (version 0.8.0)
GDBSystemWrapper.cpp
Go to the documentation of this file.
1 
52 #include <stdlib.h>
53 
55 
56 using namespace etiss::plugin::gdb;
57 
59 {
60  struct ETISS_System system;
63 };
64 
65 typedef struct ETISS_GDBSystem ETISS_GDBSystem;
66 
68 {
69  auto gdbsys = (ETISS_GDBSystem *)handle;
70  etiss_int32 exc = gdbsys->sys_->iread(gdbsys->sys_->handle, cpu, addr, length);
71  return gdbsys->server_->postMemAccessCallback(exc);
72 }
73 static etiss_int32 gdb_system_call_iwrite(void *handle, ETISS_CPU *cpu, etiss_uint64 addr, etiss_uint8 *buffer,
75 {
76  auto gdbsys = (ETISS_GDBSystem *)handle;
77  etiss_int32 exc = gdbsys->sys_->iwrite(gdbsys->sys_->handle, cpu, addr, buffer, length);
78  return gdbsys->server_->postMemAccessCallback(exc);
79 }
80 
81 static etiss_int32 gdb_system_call_dread(void *handle, ETISS_CPU *cpu, etiss_uint64 addr, etiss_uint8 *buffer,
83 {
84  auto gdbsys = (ETISS_GDBSystem *)handle;
85  gdbsys->server_->preDReadCallback(addr);
86  etiss_int32 exc = gdbsys->sys_->dread(gdbsys->sys_->handle, cpu, addr, buffer, length);
87  return gdbsys->server_->postMemAccessCallback(exc);
88 }
89 static etiss_int32 gdb_system_call_dwrite(void *handle, ETISS_CPU *cpu, etiss_uint64 addr, etiss_uint8 *buffer,
91 {
92  auto gdbsys = (ETISS_GDBSystem *)handle;
93  gdbsys->server_->preDWriteCallback(addr);
94  etiss_int32 exc = gdbsys->sys_->dwrite(gdbsys->sys_->handle, cpu, addr, buffer, length);
95  return gdbsys->server_->postMemAccessCallback(exc);
96 }
97 
99 {
100  ETISS_GDBSystem *gdbsys = (ETISS_GDBSystem *)handle;
101  return gdbsys->sys_->dbg_read(gdbsys->sys_->handle, addr, buffer, length);
102 }
103 
105 {
106  ETISS_GDBSystem *gdbsys = (ETISS_GDBSystem *)handle;
107  return gdbsys->sys_->dbg_write(gdbsys->sys_->handle, addr, buffer, length);
108 }
109 
110 static void gdb_system_call_syncTime(void *handle, ETISS_CPU *cpu)
111 {
112  ETISS_GDBSystem *gdbsys = (ETISS_GDBSystem *)handle;
113  gdbsys->sys_->syncTime(gdbsys->sys_->handle, cpu);
114 }
115 
117 {
118  if (sys == 0)
119  return 0;
120 
121  ETISS_GDBSystem *ret = new ETISS_GDBSystem();
122 
123  ETISS_System *retsys = (ETISS_System *)ret;
124 
125  retsys->iread = gdb_system_call_iread;
126  retsys->iwrite = gdb_system_call_iwrite;
127 
128  retsys->dread = gdb_system_call_dread;
129  retsys->dwrite = gdb_system_call_dwrite;
130 
133 
135 
136  retsys->handle = (void *)ret;
137 
138  ret->server_ = this;
139 
140  ret->sys_ = sys;
141  unwrappedSys_ = sys;
142 
143  return (ETISS_System *)ret;
144 }
145 
147 {
149  system = ret->sys_;
150  delete ret;
151  return system;
152 }
static etiss_int32 gdb_system_call_dbg_write(void *handle, etiss_uint64 addr, etiss_uint8 *buffer, etiss_uint32 length)
static etiss_int32 gdb_system_call_iwrite(void *handle, ETISS_CPU *cpu, etiss_uint64 addr, etiss_uint8 *buffer, etiss_uint32 length)
static etiss_int32 gdb_system_call_dwrite(void *handle, ETISS_CPU *cpu, etiss_uint64 addr, etiss_uint8 *buffer, etiss_uint32 length)
struct ETISS_GDBSystem ETISS_GDBSystem
static etiss_int32 gdb_system_call_dread(void *handle, ETISS_CPU *cpu, etiss_uint64 addr, etiss_uint8 *buffer, etiss_uint32 length)
static etiss_int32 gdb_system_call_dbg_read(void *handle, etiss_uint64 addr, etiss_uint8 *buffer, etiss_uint32 length)
static void gdb_system_call_syncTime(void *handle, ETISS_CPU *cpu)
static etiss_int32 gdb_system_call_iread(void *handle, ETISS_CPU *cpu, etiss_uint64 addr, etiss_uint32 length)
uint64_t etiss_uint64
Definition: types.h:96
uint32_t etiss_uint32
Definition: types.h:93
uint8_t etiss_uint8
Definition: types.h:87
int32_t etiss_int32
Definition: types.h:92
gdb server implementation that is used as a plugin in etiss
Definition: GDBServer.h:125
ETISS_System * unwrap(ETISS_CPU *cpu, ETISS_System *system) override
undo wrap function call this function will be called AFTER etiss::Plugin::cleanup
ETISS_System * wrap(ETISS_CPU *cpu, ETISS_System *system) override
SystemWrapper,.
ETISS_System * unwrappedSys_
Definition: GDBServer.h:162
float __ovld __cnfn length(float p)
Return the length of vector p, i.e., sqrt(p.x2 + p.y 2 + ...)
basic cpu state structure needed for execution of any cpu architecture.
Definition: CPU.h:89
ETISS_System * sys_
etiss::plugin::gdb::Server * server_
struct ETISS_System system
memory access and time synchronization functions.
Definition: System.h:78
etiss_int32(* dwrite)(void *handle, ETISS_CPU *cpu, etiss_uint64 addr, etiss_uint8 *buffer, etiss_uint32 length)
write data
Definition: System.h:97
etiss_int32(* iread)(void *handle, ETISS_CPU *cpu, etiss_uint64 addr, etiss_uint32 length)
used to simulate an instruction fetch.
Definition: System.h:84
void * handle
custom handle that will be passed to the functions of this structure
Definition: System.h:116
etiss_int32(* dbg_write)(void *handle, etiss_uint64 addr, etiss_uint8 *buffer, etiss_uint32 length)
direct debug write
Definition: System.h:108
etiss_int32(* dbg_read)(void *handle, etiss_uint64 addr, etiss_uint8 *buffer, etiss_uint32 length)
direct debug read
Definition: System.h:104
etiss_int32(* dread)(void *handle, ETISS_CPU *cpu, etiss_uint64 addr, etiss_uint8 *buffer, etiss_uint32 length)
read data
Definition: System.h:93
void(* syncTime)(void *handle, ETISS_CPU *cpu)
called after a block to synchronize the time
Definition: System.h:114
etiss_int32(* iwrite)(void *handle, ETISS_CPU *cpu, etiss_uint64 addr, etiss_uint8 *buffer, etiss_uint32 length)
write instruction data over instruction bus
Definition: System.h:88