diff --git a/Core/HLE/sceKernel.cpp b/Core/HLE/sceKernel.cpp index f393223d33..4cf1849fa3 100644 --- a/Core/HLE/sceKernel.cpp +++ b/Core/HLE/sceKernel.cpp @@ -797,9 +797,9 @@ const HLEFunction ThreadManForUser[] = {0xC07BB470,WrapI_CUUUUU, "sceKernelCreateFpl"}, {0xED1410E0,WrapI_I, "sceKernelDeleteFpl"}, - {0xD979E9BF,sceKernelAllocateFpl,"sceKernelAllocateFpl"}, - {0xE7282CB6,sceKernelAllocateFplCB,"sceKernelAllocateFplCB"}, - {0x623AE665,sceKernelTryAllocateFpl,"sceKernelTryAllocateFpl"}, + {0xD979E9BF,WrapI_IUU, "sceKernelAllocateFpl"}, + {0xE7282CB6,WrapI_IUU, "sceKernelAllocateFplCB"}, + {0x623AE665,WrapI_IU, "sceKernelTryAllocateFpl"}, {0xF6414A71,sceKernelFreeFpl,"sceKernelFreeFpl"}, {0xA8AA591F,WrapI_IU, "sceKernelCancelFpl"}, {0xD8199E4C,WrapI_IU, "sceKernelReferFplStatus"}, diff --git a/Core/HLE/sceKernelMemory.cpp b/Core/HLE/sceKernelMemory.cpp index a1fea46033..ba1a57c070 100644 --- a/Core/HLE/sceKernelMemory.cpp +++ b/Core/HLE/sceKernelMemory.cpp @@ -457,100 +457,89 @@ void __KernelSetFplTimeout(u32 timeoutPtr) CoreTiming::ScheduleEvent(usToCycles(micro), fplWaitTimer, __KernelGetCurThread()); } -void sceKernelAllocateFpl() +int sceKernelAllocateFpl(SceUID uid, u32 blockPtrAddr, u32 timeoutPtr) { - SceUID id = PARAM(0); u32 error; - FPL *fpl = kernelObjects.Get(id, error); + FPL *fpl = kernelObjects.Get(uid, error); if (fpl) { - u32 blockPtrAddr = PARAM(1); - int timeOut = PARAM(2); + DEBUG_LOG(HLE, "sceKernelAllocateFpl(%i, %08x, %08x)", uid, blockPtrAddr, timeoutPtr); int blockNum = fpl->allocateBlock(); if (blockNum >= 0) { u32 blockPtr = fpl->address + fpl->alignedSize * blockNum; Memory::Write_U32(blockPtr, blockPtrAddr); - RETURN(0); } else { SceUID threadID = __KernelGetCurThread(); __KernelFplRemoveThread(fpl, threadID); FplWaitingThread waiting = {threadID, blockPtrAddr}; fpl->waitingThreads.push_back(waiting); - __KernelSetFplTimeout(timeOut); - __KernelWaitCurThread(WAITTYPE_FPL, id, 0, timeOut, false, "fpl waited"); - return; + __KernelSetFplTimeout(timeoutPtr); + __KernelWaitCurThread(WAITTYPE_FPL, uid, 0, timeoutPtr, false, "fpl waited"); } - DEBUG_LOG(HLE,"sceKernelAllocateFpl(%i, %08x, %i)", id, blockPtrAddr, timeOut); - RETURN(0); + return 0; } else { - DEBUG_LOG(HLE,"ERROR: sceKernelAllocateFpl(%i)", id); - RETURN(error); + DEBUG_LOG(HLE, "sceKernelAllocateFpl(%i, %08x, %08x): invalid fpl", uid, blockPtrAddr, timeoutPtr); + return error; } } -void sceKernelAllocateFplCB() +int sceKernelAllocateFplCB(SceUID uid, u32 blockPtrAddr, u32 timeoutPtr) { - SceUID id = PARAM(0); u32 error; - FPL *fpl = kernelObjects.Get(id, error); + FPL *fpl = kernelObjects.Get(uid, error); if (fpl) { - u32 blockPtrAddr = PARAM(1); - int timeOut = PARAM(2); + DEBUG_LOG(HLE, "sceKernelAllocateFplCB(%i, %08x, %08x)", uid, blockPtrAddr, timeoutPtr); int blockNum = fpl->allocateBlock(); if (blockNum >= 0) { u32 blockPtr = fpl->address + fpl->alignedSize * blockNum; Memory::Write_U32(blockPtr, blockPtrAddr); - RETURN(0); } else { SceUID threadID = __KernelGetCurThread(); __KernelFplRemoveThread(fpl, threadID); FplWaitingThread waiting = {threadID, blockPtrAddr}; fpl->waitingThreads.push_back(waiting); - __KernelSetFplTimeout(timeOut); - __KernelWaitCurThread(WAITTYPE_FPL, id, 0, timeOut, true, "fpl waited"); - return; + __KernelSetFplTimeout(timeoutPtr); + __KernelWaitCurThread(WAITTYPE_FPL, uid, 0, timeoutPtr, true, "fpl waited"); } - DEBUG_LOG(HLE,"sceKernelAllocateFpl(%i, %08x, %i)", id, PARAM(1), timeOut); + return 0; } else { - DEBUG_LOG(HLE,"ERROR: sceKernelAllocateFplCB(%i)", id); - RETURN(error); + DEBUG_LOG(HLE, "sceKernelAllocateFplCB(%i, %08x, %08x): invalid fpl", uid, blockPtrAddr, timeoutPtr); + return error; } } -void sceKernelTryAllocateFpl() +int sceKernelTryAllocateFpl(SceUID uid, u32 blockPtrAddr) { - SceUID id = PARAM(0); u32 error; - FPL *fpl = kernelObjects.Get(id, error); + FPL *fpl = kernelObjects.Get(uid, error); if (fpl) { - u32 blockPtrAddr = PARAM(1); - DEBUG_LOG(HLE,"sceKernelTryAllocateFpl(%i, %08x)", id, PARAM(1)); + DEBUG_LOG(HLE, "sceKernelTryAllocateFpl(%i, %08x)", uid, blockPtrAddr); int blockNum = fpl->allocateBlock(); if (blockNum >= 0) { u32 blockPtr = fpl->address + fpl->alignedSize * blockNum; Memory::Write_U32(blockPtr, blockPtrAddr); - RETURN(0); + return 0; } else { - RETURN(SCE_KERNEL_ERROR_NO_MEMORY); + return SCE_KERNEL_ERROR_NO_MEMORY; } } else { - DEBUG_LOG(HLE,"sceKernelTryAllocateFpl(%i) - bad UID", id); - RETURN(error); + DEBUG_LOG(HLE, "sceKernelTryAllocateFpl(%i, %08x): invalid fpl", uid, blockPtrAddr); + return error; } } diff --git a/Core/HLE/sceKernelMemory.h b/Core/HLE/sceKernelMemory.h index b2fba15895..6499df129d 100644 --- a/Core/HLE/sceKernelMemory.h +++ b/Core/HLE/sceKernelMemory.h @@ -48,9 +48,9 @@ int sceKernelReferVplStatus(SceUID uid, u32 infoPtr); int sceKernelCreateFpl(const char *name, u32 mpid, u32 attr, u32 blocksize, u32 numBlocks, u32 optPtr); int sceKernelDeleteFpl(SceUID uid); -void sceKernelAllocateFpl(); -void sceKernelAllocateFplCB(); -void sceKernelTryAllocateFpl(); +int sceKernelAllocateFpl(SceUID uid, u32 blockPtrAddr, u32 timeoutPtr); +int sceKernelAllocateFplCB(SceUID uid, u32 blockPtrAddr, u32 timeoutPtr); +int sceKernelTryAllocateFpl(SceUID uid, u32 blockPtrAddr); void sceKernelFreeFpl(); int sceKernelCancelFpl(SceUID uid, u32 numWaitThreadsPtr); int sceKernelReferFplStatus(SceUID uid, u32 statusPtr);