From fd0d314a678c1a880e3fa93971259c4de235f2c0 Mon Sep 17 00:00:00 2001 From: Jean-Philip Desjardins Date: Tue, 31 Oct 2023 11:02:09 -0400 Subject: [PATCH] Fix waiting for non blocking SIF RPC calls. LOTR: Fellowship of the Ring relies on that. --- Source/iop/Iop_SifCmd.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Source/iop/Iop_SifCmd.cpp b/Source/iop/Iop_SifCmd.cpp index fb542f8e61..4a434d9ef1 100644 --- a/Source/iop/Iop_SifCmd.cpp +++ b/Source/iop/Iop_SifCmd.cpp @@ -52,6 +52,7 @@ using namespace Iop; #define SYSTEM_COMMAND_ID 0x80000000 static constexpr uint32 INVALID_SEMAPHORE_ID = ~0U; +static constexpr uint32 DUMMY_PACKET_ADDR = 0xCAFECAFE; CSifCmd::CSifCmd(CIopBios& bios, CSifMan& sifMan, CSysmem& sysMem, uint8* ram) : m_bios(bios) @@ -669,6 +670,7 @@ void CSifCmd::ProcessRpcRequestEnd(uint32 commandHeaderAddr) { assert(0); } + clientData->header.packetAddr = 0; //Unlock/delete semaphore if(clientData->header.semaId != INVALID_SEMAPHORE_ID) { @@ -876,6 +878,9 @@ void CSifCmd::SifCallRpc(CMIPS& context) auto clientData = reinterpret_cast(m_ram + clientDataAddr); assert(clientData->serverDataAddr != 0); + assert(clientData->header.packetAddr == 0); + //Set packet addr to properly support testing for request completion with SifCheckStatRpc + clientData->header.packetAddr = DUMMY_PACKET_ADDR; clientData->endFctPtr = endFctAddr; clientData->endParam = endParam; if((mode & CALL_MODE_NOWAIT) == 0) @@ -1008,10 +1013,15 @@ void CSifCmd::SifExecRequest(CMIPS& context) context.m_State.nPC = m_sifExecRequestAddr; } -uint32 CSifCmd::SifCheckStatRpc(uint32 clientDataAddress) +uint32 CSifCmd::SifCheckStatRpc(uint32 clientDataAddr) { CLog::GetInstance().Print(LOG_NAME, FUNCTION_SIFCHECKSTATRPC "(clientData = 0x%08X);\r\n", - clientDataAddress); + clientDataAddr); + auto clientData = reinterpret_cast(m_ram + clientDataAddr); + if(clientData->header.packetAddr != 0) + { + return 1; + } return 0; }