diff --git a/Source/Core/DSPCore/Src/DSPCore.cpp b/Source/Core/DSPCore/Src/DSPCore.cpp index c293651c89..e9c4d5f464 100644 --- a/Source/Core/DSPCore/Src/DSPCore.cpp +++ b/Source/Core/DSPCore/Src/DSPCore.cpp @@ -121,7 +121,6 @@ bool DSPCore_Init(const char *irom_filename, const char *coef_filename, g_dsp.r[DSP_REG_SR] |= SR_INT_ENABLE; g_dsp.r[DSP_REG_SR] |= SR_EXT_INT_ENABLE; - g_dsp.exception_in_progress = -1; g_dsp.cr = 0x804; gdsp_ifx_init(); @@ -155,9 +154,7 @@ void DSPCore_Shutdown() void DSPCore_Reset() { - _assert_msg_(MASTER_LOG, g_dsp.exception_in_progress == -1, "reset while exception"); g_dsp.pc = DSP_RESET_VECTOR; - g_dsp.exception_in_progress = -1; g_dsp.r[DSP_REG_WR0] = 0xffff; g_dsp.r[DSP_REG_WR1] = 0xffff; @@ -193,31 +190,21 @@ void DSPCore_CheckExceptions() if (g_dsp.exceptions == 0) return; - // it's unclear what to do when there are two exceptions at the same time - // but for sure they should not be called together therefore the - // g_dsp.exception_in_progress - if (g_dsp.exception_in_progress != -1) { -#if defined(_DEBUG) || defined(DEBUGFAST) - ERROR_LOG(DSPLLE, "Firing exception %d failed exception %d active", g_dsp.exceptions, g_dsp.exception_in_progress); -#endif - return; - } - for (int i = 7; i > 0; i--) { - // Seems exp int or reset are not masked by sr_int_enable + // Seems exp int are not masked by sr_int_enable if (g_dsp.exceptions & (1 << i)) { if (dsp_SR_is_flag_set(SR_INT_ENABLE) || (i == EXP_INT)) { - _assert_msg_(MASTER_LOG, g_dsp.exception_in_progress == -1, "assert %d while exception", g_dsp.exception_in_progress); - // store pc and sr until RTI 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.pc = i * 2; g_dsp.exceptions &= ~(1 << i); - if (i) - g_dsp.exception_in_progress = i; + if (i == 7) + g_dsp.r[DSP_REG_SR] &= ~SR_EXT_INT_ENABLE; + else + g_dsp.r[DSP_REG_SR] &= ~SR_INT_ENABLE; break; } else { #if defined(_DEBUG) || defined(DEBUGFAST) diff --git a/Source/Core/DSPCore/Src/DSPCore.h b/Source/Core/DSPCore/Src/DSPCore.h index 95a9fa5a85..3e807c3ee2 100644 --- a/Source/Core/DSPCore/Src/DSPCore.h +++ b/Source/Core/DSPCore/Src/DSPCore.h @@ -198,7 +198,6 @@ struct SDSP u8 reg_stack_ptr[4]; u8 exceptions; // pending exceptions - int exception_in_progress; // inside exp flag // DSP hardware stacks. They're mapped to a bunch of registers, such that writes // to them push and reads pop. diff --git a/Source/Core/DSPCore/Src/DSPEmitter.cpp b/Source/Core/DSPCore/Src/DSPEmitter.cpp index 1782714eb1..61fc9f6e04 100644 --- a/Source/Core/DSPCore/Src/DSPEmitter.cpp +++ b/Source/Core/DSPCore/Src/DSPEmitter.cpp @@ -66,8 +66,26 @@ void DSPEmitter::ClearIRAM() { } } + // Must go out of block if exception is detected void DSPEmitter::checkExceptions() { + /* + // check if there is an external interrupt + if (! dsp_SR_is_flag_set(SR_EXT_INT_ENABLE)) + return; + + if (! (g_dsp.cr & CR_EXTERNAL_INT)) + return; + + g_dsp.cr &= ~CR_EXTERNAL_INT; + + // Check for other exceptions + if (dsp_SR_is_flag_set(SR_INT_ENABLE)) + return; + + if (g_dsp.exceptions == 0) + return; + */ ABI_CallFunction((void *)&DSPCore_CheckExternalInterrupt); // Check for interrupts and exceptions TEST(8, M(&g_dsp.exceptions), Imm8(0xff)); @@ -75,16 +93,10 @@ void DSPEmitter::checkExceptions() { ABI_CallFunction((void *)&DSPCore_CheckExceptions); - MOV(32, R(EAX), M(&g_dsp.exception_in_progress)); - CMP(32, R(EAX), Imm32(0)); - FixupBranch noExceptionOccurred = J_CC(CC_L); - - // ABI_CallFunction((void *)DSPInterpreter::HandleLoop); ABI_RestoreStack(0); RET(); SetJumpTarget(skipCheck); - SetJumpTarget(noExceptionOccurred); } void DSPEmitter::WriteCallInterpreter(UDSPInstruction inst) diff --git a/Source/Core/DSPCore/Src/DspIntBranch.cpp b/Source/Core/DSPCore/Src/DspIntBranch.cpp index bece4f78e4..3a473aa204 100644 --- a/Source/Core/DSPCore/Src/DspIntBranch.cpp +++ b/Source/Core/DSPCore/Src/DspIntBranch.cpp @@ -126,7 +126,6 @@ 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 = -1; } // HALT