all repos — mgba @ 7c5a6b121c4d9d4287ce0d178ea2cede753d808c

mGBA Game Boy Advance Emulator

Implement SWI
Jeffrey Pfau jeffrey@endrift.com
Sun, 14 Apr 2013 11:57:39 -0700
commit

7c5a6b121c4d9d4287ce0d178ea2cede753d808c

parent

475af6fde27b12dad701ee1cb67ddadf462e0755

4 files changed, 21 insertions(+), 1 deletions(-)

jump to
M src/arm.hsrc/arm.h

@@ -85,6 +85,8 @@

struct ARMBoard { struct ARMCore* cpu; void (*reset)(struct ARMBoard* board); + void (*swi16)(struct ARMBoard* board, int immediate); + void (*swi32)(struct ARMBoard* board, int immediate); void (*hitStub)(struct ARMBoard* board, uint32_t opcode); };
M src/gba.csrc/gba.c

@@ -21,6 +21,9 @@ static void GBAStore32(struct ARMMemory* memory, uint32_t address, int32_t value);

static void GBAStore16(struct ARMMemory* memory, uint32_t address, int16_t value); static void GBAStore8(struct ARMMemory* memory, uint32_t address, int8_t value); +static void GBASwi16(struct ARMBoard* board, int immediate); +static void GBASwi32(struct ARMBoard* board, int immediate); + static void GBASetActiveRegion(struct ARMMemory* memory, uint32_t region); static void GBAHitStub(struct ARMBoard* board, uint32_t opcode);

@@ -81,6 +84,8 @@ }

void GBABoardInit(struct GBABoard* board) { board->d.reset = GBABoardReset; + board->d.swi16 = GBASwi16; + board->d.swi32 = GBASwi32; board->d.hitStub = GBAHitStub; }

@@ -394,6 +399,17 @@ break;

default: break; } +} + +static void GBASwi16(struct ARMBoard* board, int immediate) { + switch (immediate) { + default: + GBALog(GBA_LOG_STUB, "Stub software interrupt: %02x", immediate); + } +} + +static void GBASwi32(struct ARMBoard* board, int immediate) { + GBASwi32(board, immediate >> 8); } void GBALog(int level, const char* format, ...) {
M src/gba.hsrc/gba.h

@@ -251,4 +251,6 @@ void GBAAttachDebugger(struct GBA* gba, struct ARMDebugger* debugger);

void GBALoadROM(struct GBA* gba, int fd); +void GBALog(int level, const char* format, ...); + #endif
M src/isa-thumb.csrc/isa-thumb.c

@@ -410,7 +410,7 @@ } else { \

ARM_WRITE_PC; \ }) -DEFINE_INSTRUCTION_THUMB(SWI, ARM_STUB) +DEFINE_INSTRUCTION_THUMB(SWI, cpu->board->swi16(cpu->board, opcode & 0xFF)) #define DECLARE_INSTRUCTION_THUMB(EMITTER, NAME) \ EMITTER ## NAME