1 /* heavily based on BochsIA32Plugin.h */ 2 /* Bochs seems to use error code 1 for execution errors. 3 * So we use > 1 for various errors 4 */ 5 #define NoError 0 6 #define ExecutionError 1 7 #define BadCPUInstance 2 8 #define MemoryBoundsError 3 9 #define PanicError 4 10 #define UnsupportedOperationError 5 11 #define SomethingLoggedError 6 12 13 // The library is compiled with TFlag, therefore, we also need to set it. 14 #define MODET 15 16 #if !defined(ulong) 17 typedef unsigned long ulong; 18 #endif 19 20 extern ulong minReadAddress, minWriteAddress; 21 extern int gdb_log_printf(void* stream, const char * format, ...); 22 23 24 /* 25 * Answer a pointer to a new ARMulator CPU (an instance of typedef ARMul_State) 26 */ 27 extern void *newCPU(); 28 /* 29 * reset the cpu to register contents 0, protected 32-bit mode. 30 */ 31 extern int resetCPU(void *cpu); 32 /* 33 * Single-step *cpu (an ARMul_state instance) using memory as its memory. 34 * Answer 0 on success, or an integer error code if something went awry. 35 */ 36 extern int singleStepCPUInSizeMinAddrReadWrite(void *cpu, void *memory, 37 ulong byteSize, ulong minReadAddr, ulong minWriteAddr); 38 /* 39 * Run *cpu (an ARMul_state instance) using memory as its memory. 40 * Answer an integer error code when the processor hits some exception. 41 * Answer 0 when it is interrupted. 42 */ 43 extern int runCPUInSizeMinAddrReadWrite(void *cpu, void *memory, 44 ulong byteSize, ulong minReadAddr, ulong minWriteAddr); 45 /* 46 * Flush any icache entries from start to end 47 */ 48 extern void flushICacheFromTo(void *cpu, ulong strt, ulong nd); 49 /* 50 * force runCPUInSize to exit asap. Used by interrupts. 51 */ 52 extern void forceStopRunning(); 53 /* 54 * The previous entry in the interruptCheckChain so forceStopRunning can chain. 55 */ 56 extern void (*prevInterruptCheckChain)(); 57 /* 58 * Disassemble the instruction at address in memory, writing the output to the 59 * log. 60 */ 61 extern int disassembleForAtInSize(void *cpu, ulong laddr, 62 void *memory, ulong byteSize); 63 /* 64 * The saved error if the previous singleStepIn failed. 65 */ 66 extern int errorAcorn(); 67 /* 68 * The current log (if singleStep failed with SomethingLoggedError). 69 */ 70 extern char *getlog(long *len); 71