From 69fd74ba56e6911413bda8443f8fed7c231ca422 Mon Sep 17 00:00:00 2001 From: zilmar Date: Thu, 18 May 2023 10:56:06 +0930 Subject: [PATCH] Core: Convert DoSysCallException to TriggerException --- .../N64System/Interpreter/InterpreterOps.cpp | 4 +-- .../N64System/Mips/Register.cpp | 30 ------------------- .../Project64-core/N64System/Mips/Register.h | 1 - .../Recompiler/x86/x86RecompilerOps.cpp | 6 ++-- 4 files changed, 5 insertions(+), 36 deletions(-) diff --git a/Source/Project64-core/N64System/Interpreter/InterpreterOps.cpp b/Source/Project64-core/N64System/Interpreter/InterpreterOps.cpp index 39c41cb02..dfd670b74 100644 --- a/Source/Project64-core/N64System/Interpreter/InterpreterOps.cpp +++ b/Source/Project64-core/N64System/Interpreter/InterpreterOps.cpp @@ -1309,9 +1309,7 @@ void R4300iOp::SPECIAL_JALR() void R4300iOp::SPECIAL_SYSCALL() { - g_Reg->DoSysCallException(g_System->m_PipelineStage == PIPELINE_STAGE_JUMP); - g_System->m_PipelineStage = PIPELINE_STAGE_JUMP; - g_System->m_JumpToLocation = (*_PROGRAM_COUNTER); + g_Reg->TriggerException(EXC_SYSCALL); } void R4300iOp::SPECIAL_BREAK() diff --git a/Source/Project64-core/N64System/Mips/Register.cpp b/Source/Project64-core/N64System/Mips/Register.cpp index 7e0afce54..4d15c3048 100644 --- a/Source/Project64-core/N64System/Mips/Register.cpp +++ b/Source/Project64-core/N64System/Mips/Register.cpp @@ -826,36 +826,6 @@ void CRegisters::DoTLBWriteMiss(bool DelaySlot, uint64_t BadVaddr) } } -void CRegisters::DoSysCallException(bool DelaySlot) -{ - if (HaveDebugger()) - { - if ((STATUS_REGISTER & STATUS_EXL) != 0) - { - g_Notify->DisplayError("EXL set in syscall exception"); - } - if ((STATUS_REGISTER & STATUS_ERL) != 0) - { - g_Notify->DisplayError("ERL set in syscall exception"); - } - } - - CAUSE_REGISTER.ExceptionCode = EXC_SYSCALL; - CAUSE_REGISTER.CoprocessorUnitNumber = 0; - if (DelaySlot) - { - CAUSE_REGISTER.BranchDelay = 1; - EPC_REGISTER = (int64_t)((int32_t)m_PROGRAM_COUNTER - 4); - } - else - { - CAUSE_REGISTER.BranchDelay = 0; - EPC_REGISTER = (int64_t)(int32_t)m_PROGRAM_COUNTER; - } - STATUS_REGISTER |= STATUS_EXL; - m_PROGRAM_COUNTER = 0x80000180; -} - void CRegisters::TriggerException(uint32_t ExceptionCode, uint32_t Coprocessor) { if (GenerateLog() && LogExceptions()) diff --git a/Source/Project64-core/N64System/Mips/Register.h b/Source/Project64-core/N64System/Mips/Register.h index af0a23378..34c110e4e 100644 --- a/Source/Project64-core/N64System/Mips/Register.h +++ b/Source/Project64-core/N64System/Mips/Register.h @@ -413,7 +413,6 @@ public: void DoOverflowException(bool DelaySlot); void DoTLBReadMiss(bool DelaySlot, uint64_t BadVaddr); void DoTLBWriteMiss(bool DelaySlot, uint64_t BadVaddr); - void DoSysCallException(bool DelaySlot); void FixFpuLocations(); void Reset(); void SetAsCurrentSystem(); diff --git a/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.cpp b/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.cpp index 488a5044e..715465473 100644 --- a/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.cpp +++ b/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.cpp @@ -9472,8 +9472,10 @@ void CX86RecompilerOps::CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo ExitCodeBlock(); break; case ExitReason_DoSysCall: - m_Assembler.PushImm32(InDelaySlot ? "true" : "false", InDelaySlot); - m_Assembler.CallThis((uint32_t)g_Reg, AddressOf(&CRegisters::DoSysCallException), "CRegisters::DoSysCallException", 8); + m_Assembler.MoveConstToVariable(&g_System->m_PipelineStage, "System->m_PipelineStage", m_PipelineStage == PIPELINE_STAGE_JUMP || m_PipelineStage == PIPELINE_STAGE_DELAY_SLOT ? PIPELINE_STAGE_JUMP : PIPELINE_STAGE_NORMAL); + m_Assembler.push(0); + m_Assembler.PushImm32("EXC_SYSCALL", EXC_SYSCALL); + m_Assembler.CallThis((uint32_t)g_Reg, AddressOf(&CRegisters::TriggerException), "CRegisters::TriggerException", 12); ExitCodeBlock(); break; case ExitReason_Break: