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