all repos — mgba @ d5241484693fd9d280470c9b0e8c703f068c9024

mGBA Game Boy Advance Emulator

ARM7: Add emulation for Undefined CPU mode
Jeffrey Pfau jeffrey@endrift.com
Fri, 19 Jun 2015 00:59:52 -0700
commit

d5241484693fd9d280470c9b0e8c703f068c9024

parent

270ce0cba344a65f0e73d7071e3d07193491bf58

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

jump to
M CHANGESCHANGES

@@ -77,6 +77,7 @@ - Qt: Rename "Fullscreen" to "Toggle fullscreen"

- Qt: Don't save window size when entering fullscreen - Qt: Make the default fullscreen binding for Windows be Alt-Enter - GBA Video: Refactor software renderer into separate files + - ARM7: Add emulation for Undefined CPU mode 0.2.1: (2015-05-13) Bugfixes:
M src/arm/arm.csrc/arm/arm.c

@@ -190,6 +190,26 @@ cpu->cpsr.i = 1;

cpu->cycles += currentCycles; } +void ARMRaiseUndefined(struct ARMCore* cpu) { + union PSR cpsr = cpu->cpsr; + int instructionWidth; + if (cpu->executionMode == MODE_THUMB) { + instructionWidth = WORD_SIZE_THUMB; + } else { + instructionWidth = WORD_SIZE_ARM; + } + ARMSetPrivilegeMode(cpu, MODE_UNDEFINED); + cpu->cpsr.priv = MODE_UNDEFINED; + cpu->gprs[ARM_LR] = cpu->gprs[ARM_PC] - instructionWidth; + cpu->gprs[ARM_PC] = BASE_UNDEF; + int currentCycles = 0; + ARM_WRITE_PC; + _ARMSetMode(cpu, MODE_ARM); + cpu->spsr = cpsr; + cpu->cpsr.i = 1; + cpu->cycles += currentCycles; +} + static inline void ARMStep(struct ARMCore* cpu) { uint32_t opcode = cpu->prefetch[0]; cpu->prefetch[0] = cpu->prefetch[1];
M src/arm/arm.hsrc/arm/arm.h

@@ -172,6 +172,7 @@ void ARMReset(struct ARMCore* cpu);

void ARMSetPrivilegeMode(struct ARMCore*, enum PrivilegeMode); void ARMRaiseIRQ(struct ARMCore*); void ARMRaiseSWI(struct ARMCore*); +void ARMRaiseUndefined(struct ARMCore*); void ARMRun(struct ARMCore* cpu); void ARMRunLoop(struct ARMCore* cpu);
M src/gba/gba.csrc/gba/gba.c

@@ -650,7 +650,7 @@ }

void GBAHitStub(struct ARMCore* cpu, uint32_t opcode) { struct GBA* gba = (struct GBA*) cpu->master; - enum GBALogLevel level = GBA_LOG_FATAL; + enum GBALogLevel level = GBA_LOG_ERROR; if (gba->debugger) { level = GBA_LOG_STUB; struct DebuggerEntryInfo info = {

@@ -671,6 +671,8 @@ .address = _ARMPCAddress(cpu),

.opcode = opcode }; ARMDebuggerEnter(gba->debugger, DEBUGGER_ENTER_ILLEGAL_OP, &info); + } else { + ARMRaiseUndefined(cpu); } }