From 292b3f675f16e7e2ca98f884787607928460cc47 Mon Sep 17 00:00:00 2001 From: nakeee Date: Tue, 30 Jun 2009 10:10:30 +0000 Subject: [PATCH] DSPLLE got rid of exception in progress hack. I didn't get any change in behaviour though. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3621 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/DSPCore/Src/DSPCore.cpp | 16 +++++++--------- Source/Core/DSPCore/Src/DSPHWInterface.cpp | 12 +++++++++++- Source/Core/DSPCore/Src/DSPInterpreter.h | 1 - Source/Core/DSPCore/Src/DspIntBranch.cpp | 7 ++----- 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/Source/Core/DSPCore/Src/DSPCore.cpp b/Source/Core/DSPCore/Src/DSPCore.cpp index 565e2e6b1a..3217bf0fb8 100644 --- a/Source/Core/DSPCore/Src/DSPCore.cpp +++ b/Source/Core/DSPCore/Src/DSPCore.cpp @@ -157,11 +157,10 @@ void DSPCore_CheckExternalInterrupt() // check if there is an external interrupt if (g_dsp.cr & CR_EXTERNAL_INT) { - if (dsp_SR_is_flag_set(FLAG_ENABLE_INTERUPT) && (g_dsp.exception_in_progress_hack == false)) + if (dsp_SR_is_flag_set(SR_INT_ENABLE)) { - // level 7 is the interrupt exception - DSPCore_SetException(7); - + // level 7 is the interrupt exception. is it? + // DSPCore_SetException(7); g_dsp.cr &= ~CR_EXTERNAL_INT; } } @@ -170,21 +169,20 @@ void DSPCore_CheckExternalInterrupt() void DSPCore_CheckExceptions() { // check exceptions - if ((g_dsp.exceptions != 0) && (!g_dsp.exception_in_progress_hack)) + if (g_dsp.exceptions != 0) { for (int i = 0; i < 8; i++) { - if (g_dsp.exceptions & (1 << i)) + if (g_dsp.exceptions & (1 << i) && dsp_SR_is_flag_set(SR_INT_ENABLE)) { - _assert_msg_(MASTER_LOG, !g_dsp.exception_in_progress_hack, "assert while exception"); - + dsp_reg_store_stack(DSP_STACK_C, g_dsp.pc); dsp_reg_store_stack(DSP_STACK_D, g_dsp.r[DSP_REG_SR]); + g_dsp.r[DSP_REG_SR] &= ~ SR_INT_ENABLE; g_dsp.pc = i * 2; g_dsp.exceptions &= ~(1 << i); - g_dsp.exception_in_progress_hack = true; break; } } diff --git a/Source/Core/DSPCore/Src/DSPHWInterface.cpp b/Source/Core/DSPCore/Src/DSPHWInterface.cpp index 9c0d631aeb..5ef3f5e071 100644 --- a/Source/Core/DSPCore/Src/DSPHWInterface.cpp +++ b/Source/Core/DSPCore/Src/DSPHWInterface.cpp @@ -75,6 +75,15 @@ void gdsp_mbox_write_h(u8 mbx, u16 val) gdsp_mbox[mbx][0] = val & 0x7fff; if (DSPHost_OnThread()) g_CriticalSection.Leave(); + + if (mbx == GDSP_MBOX_DSP) + { + DEBUG_LOG(DSPLLE, " - DSP writes mail to mbx %i: 0x%08x (pc=0x%04x)", mbx, gdsp_mbox_peek(GDSP_MBOX_DSP), g_dsp.pc); + } else { + // mailbox + DSPCore_SetException(7); + } + } @@ -91,7 +100,8 @@ void gdsp_mbox_write_l(u8 mbx, u16 val) { DEBUG_LOG(DSPLLE, " - DSP writes mail to mbx %i: 0x%08x (pc=0x%04x)", mbx, gdsp_mbox_peek(GDSP_MBOX_DSP), g_dsp.pc); } else { - // Trigger exception? + // mailbox + DSPCore_SetException(7); } } diff --git a/Source/Core/DSPCore/Src/DSPInterpreter.h b/Source/Core/DSPCore/Src/DSPInterpreter.h index 4fc879c1c7..d8f4d84f58 100644 --- a/Source/Core/DSPCore/Src/DSPInterpreter.h +++ b/Source/Core/DSPCore/Src/DSPInterpreter.h @@ -21,7 +21,6 @@ #include "DSPTables.h" #define DSP_REG_MASK 0x1f -#define FLAG_ENABLE_INTERUPT 11 namespace DSPInterpreter { diff --git a/Source/Core/DSPCore/Src/DspIntBranch.cpp b/Source/Core/DSPCore/Src/DspIntBranch.cpp index b843526906..94e9d5d37b 100644 --- a/Source/Core/DSPCore/Src/DspIntBranch.cpp +++ b/Source/Core/DSPCore/Src/DspIntBranch.cpp @@ -48,8 +48,8 @@ void call(const UDSPInstruction& opc) // Generic callr implementation // CALLRcc $R // 0001 0111 rrr1 cccc -// Call functionif condition cc has been met.Push program counter of -// instruction following "call" tocall stack $st0. Set program counter to +// Call function if condition cc has been met.Push program counter of +// instruction following "call" to call stack $st0. Set program counter to // register $R. void callr(const UDSPInstruction& opc) { @@ -121,13 +121,10 @@ void ret(const UDSPInstruction& opc) // Return from exception. Pops stored status register $sr from data stack // $st1 and program counter PC from call stack $st0 and sets $pc to this // location. -// FIXME: is it also conditional? unknown opcodes 0x02fx void rti(const UDSPInstruction& opc) { g_dsp.r[DSP_REG_SR] = dsp_reg_load_stack(DSP_STACK_D); g_dsp.pc = dsp_reg_load_stack(DSP_STACK_C); - - g_dsp.exception_in_progress_hack = false; } // HALT