Log stubs
Jeffrey Pfau jeffrey@endrift.com
Wed, 10 Apr 2013 22:52:46 -0700
5 files changed,
50 insertions(+),
25 deletions(-)
M
src/gba.c
→
src/gba.c
@@ -1,11 +1,14 @@
#include "gba.h" +#include <stdarg.h> +#include <stdio.h> #include <sys/mman.h> #include <unistd.h> static const char* GBA_CANNOT_MMAP = "Could not map memory"; static void GBASetActiveRegion(struct ARMMemory* memory, uint32_t region); +static void GBAHitStub(struct ARMBoard* board, uint32_t opcode); void GBAInit(struct GBA* gba) { gba->errno = GBA_NO_ERROR;@@ -60,6 +63,7 @@ }
void GBABoardInit(struct GBABoard* board) { board->d.reset = GBABoardReset; + board->d.hitStub = GBAHitStub; } void GBABoardReset(struct ARMBoard* board) {@@ -367,3 +371,15 @@ default:
break; } } + +void GBALog(int level, const char* format, ...) { + va_list args; + va_start(args, format); + vprintf(format, args); + va_end(args); + printf("\n"); +} + +void GBAHitStub(struct ARMBoard* board, uint32_t opcode) { + GBALog(GBA_LOG_STUB, "Stub opcode: %08x", opcode); +}
M
src/isa-arm.c
→
src/isa-arm.c
@@ -345,18 +345,18 @@ // End ALU definitions
// Begin multiply definitions -DEFINE_INSTRUCTION_ARM(MLA,) -DEFINE_INSTRUCTION_ARM(MLAS,) -DEFINE_INSTRUCTION_ARM(MUL,) -DEFINE_INSTRUCTION_ARM(MULS,) -DEFINE_INSTRUCTION_ARM(SMLAL,) -DEFINE_INSTRUCTION_ARM(SMLALS,) -DEFINE_INSTRUCTION_ARM(SMULL,) -DEFINE_INSTRUCTION_ARM(SMULLS,) -DEFINE_INSTRUCTION_ARM(UMLAL,) -DEFINE_INSTRUCTION_ARM(UMLALS,) -DEFINE_INSTRUCTION_ARM(UMULL,) -DEFINE_INSTRUCTION_ARM(UMULLS,) +DEFINE_INSTRUCTION_ARM(MLA, ARM_STUB) +DEFINE_INSTRUCTION_ARM(MLAS, ARM_STUB) +DEFINE_INSTRUCTION_ARM(MUL, ARM_STUB) +DEFINE_INSTRUCTION_ARM(MULS, ARM_STUB) +DEFINE_INSTRUCTION_ARM(SMLAL, ARM_STUB) +DEFINE_INSTRUCTION_ARM(SMLALS, ARM_STUB) +DEFINE_INSTRUCTION_ARM(SMULL, ARM_STUB) +DEFINE_INSTRUCTION_ARM(SMULLS, ARM_STUB) +DEFINE_INSTRUCTION_ARM(UMLAL, ARM_STUB) +DEFINE_INSTRUCTION_ARM(UMLALS, ARM_STUB) +DEFINE_INSTRUCTION_ARM(UMULL, ARM_STUB) +DEFINE_INSTRUCTION_ARM(UMULLS, ARM_STUB) // End multiply definitions@@ -395,11 +395,11 @@ ARMSetPrivilegeMode(cpu, MODE_USER); \
cpu->memory->store8(cpu->memory, address, cpu->gprs[rd]); \ ARMSetPrivilegeMode(cpu, priv);) -DEFINE_LOAD_STORE_MULTIPLE_INSTRUCTION_ARM(LDM,) -DEFINE_LOAD_STORE_MULTIPLE_INSTRUCTION_ARM(STM,) +DEFINE_LOAD_STORE_MULTIPLE_INSTRUCTION_ARM(LDM, ARM_STUB) +DEFINE_LOAD_STORE_MULTIPLE_INSTRUCTION_ARM(STM, ARM_STUB) -DEFINE_INSTRUCTION_ARM(SWP,) -DEFINE_INSTRUCTION_ARM(SWPB,) +DEFINE_INSTRUCTION_ARM(SWP, ARM_STUB) +DEFINE_INSTRUCTION_ARM(SWPB, ARM_STUB) // End load/store definitions@@ -411,14 +411,15 @@ offset >>= 6; \
cpu->gprs[ARM_PC] += offset; \ ARM_WRITE_PC;) -DEFINE_INSTRUCTION_ARM(BL,) -DEFINE_INSTRUCTION_ARM(BX,) +DEFINE_INSTRUCTION_ARM(BL, ARM_STUB) +DEFINE_INSTRUCTION_ARM(BX, ARM_STUB) // End branch definitions -// TODO -DEFINE_INSTRUCTION_ARM(BKPT,) -DEFINE_INSTRUCTION_ARM(ILL,) // Illegal opcode +// Begin miscellaneous definitions + +DEFINE_INSTRUCTION_ARM(BKPT, ARM_STUB) // Not strictly in ARMv4T, but here for convenience +DEFINE_INSTRUCTION_ARM(ILL, ARM_STUB) // Illegal opcode DEFINE_INSTRUCTION_ARM(MSR, \ int c = opcode & 0x00010000; \@@ -449,10 +450,10 @@ cpu->cpsr.f = operand & 0x00000040; \
} \ }) -DEFINE_INSTRUCTION_ARM(MRS,) -DEFINE_INSTRUCTION_ARM(MSRI,) -DEFINE_INSTRUCTION_ARM(MRSI,) -DEFINE_INSTRUCTION_ARM(SWI,) +DEFINE_INSTRUCTION_ARM(MRS, ARM_STUB) +DEFINE_INSTRUCTION_ARM(MSRI, ARM_STUB) +DEFINE_INSTRUCTION_ARM(MRSI, ARM_STUB) +DEFINE_INSTRUCTION_ARM(SWI, ARM_STUB) #define DECLARE_INSTRUCTION_ARM(EMITTER, NAME) \ EMITTER ## NAME
M
src/isa-inlines.h
→
src/isa-inlines.h
@@ -52,6 +52,8 @@ #define ARM_BORROW_FROM(M, N, D) (((uint32_t) (M)) >= ((uint32_t) (N)))
#define ARM_V_ADDITION(M, N, D) (!(ARM_SIGN((M) ^ (N))) && (ARM_SIGN((M) ^ (D))) && (ARM_SIGN((N) ^ (D)))) #define ARM_V_SUBTRACTION(M, N, D) ((ARM_SIGN((M) ^ (N))) && (ARM_SIGN((M) ^ (D)))) +#define ARM_STUB cpu->board->hitStub(cpu->board, opcode) + static inline int _ARMModeHasSPSR(enum PrivilegeMode mode) { return mode != MODE_SYSTEM && mode != MODE_USER; }