From 429ac9de8797d973bafe6dcad89dbbf492063bd0 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Wed, 14 Nov 2012 23:15:33 -0800 Subject: [PATCH] Oops, CreateMutex was missing a parameter. --- Core/HLE/FunctionWrappers.h | 5 +++++ Core/HLE/sceKernel.cpp | 2 +- Core/HLE/sceKernelMutex.cpp | 7 ++++--- Core/HLE/sceKernelMutex.h | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Core/HLE/FunctionWrappers.h b/Core/HLE/FunctionWrappers.h index 706faa3c05..768b31bf11 100644 --- a/Core/HLE/FunctionWrappers.h +++ b/Core/HLE/FunctionWrappers.h @@ -133,6 +133,11 @@ template void WrapU_CUU() { RETURN((u32)retval); } +template void WrapU_CUUU() { + int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), PARAM(3)); + RETURN((u32)retval); +} + template void WrapU_UUU() { u32 retval = func(PARAM(0), PARAM(1), PARAM(2)); RETURN(retval); diff --git a/Core/HLE/sceKernel.cpp b/Core/HLE/sceKernel.cpp index 6cfc721498..480c640f7f 100644 --- a/Core/HLE/sceKernel.cpp +++ b/Core/HLE/sceKernel.cpp @@ -343,7 +343,7 @@ const HLEFunction ThreadManForUser[] = {0xB011B11F,&WrapU_UUU,"sceKernelLockMutex"}, {0x5bf4dd27,&WrapU_UUU,"sceKernelLockMutexCB"}, {0x6b30100f,&WrapV_UU,"sceKernelUnlockMutex"}, - {0xb7d098c6,&WrapU_CUU,"sceKernelCreateMutex"}, + {0xb7d098c6,&WrapU_CUUU,"sceKernelCreateMutex"}, {0x0DDCD2C9, 0, "sceKernelTryLockMutex"}, // NOTE: LockLwMutex and UnlockLwMutex are in Kernel_Library, see sceKernelInterrupt.cpp. diff --git a/Core/HLE/sceKernelMutex.cpp b/Core/HLE/sceKernelMutex.cpp index 5db6ea4e7f..56823dc7c1 100644 --- a/Core/HLE/sceKernelMutex.cpp +++ b/Core/HLE/sceKernelMutex.cpp @@ -28,7 +28,7 @@ #define PSP_MUTEX_ATTR_ALLOW_RECURSIVE 0x200 // Not sure about the names of these -#define PSP_MUTEX_ERROR_NOT_LOCKED 0x800201C7 +#define PSP_MUTEX_ERROR_NOT_LOCKED 0x800201C5 #define PSP_MUTEX_ERROR_NO_SUCH_MUTEX 0x800201C3 #define PSP_MUTEX_ERROR_UNLOCK_UNDERFLOW 0x800201C7 @@ -63,7 +63,7 @@ struct LWMutex : public KernelObject std::vector waitingThreads; }; -u32 sceKernelCreateMutex(const char *name, u32 attr, u32 options) +u32 sceKernelCreateMutex(const char *name, u32 attr, u32 initial_count, u32 options) { DEBUG_LOG(HLE,"sceKernelCreateMutex(%s, %08x, %08x)", name, attr, options); @@ -72,7 +72,8 @@ u32 sceKernelCreateMutex(const char *name, u32 attr, u32 options) mutex->nm.size = sizeof(mutex); mutex->nm.attr = attr; - mutex->nm.lockLevel = 0; + mutex->nm.lockLevel = initial_count; + // TODO: Does initial_count > 0 mean lock automatically by the current thread? Would make sense. mutex->nm.lockThread = -1; strncpy(mutex->nm.name, name, 32); diff --git a/Core/HLE/sceKernelMutex.h b/Core/HLE/sceKernelMutex.h index 7f8c982b0c..752e04914d 100644 --- a/Core/HLE/sceKernelMutex.h +++ b/Core/HLE/sceKernelMutex.h @@ -18,7 +18,7 @@ #pragma once // TODO -u32 sceKernelCreateMutex(const char *name, u32 attr, u32 options); +u32 sceKernelCreateMutex(const char *name, u32 attr, u32 initial_count, u32 options); u32 sceKernelDeleteMutex(u32 id); u32 sceKernelLockMutex(u32 id, u32 count, u32 timeoutPtr); u32 sceKernelLockMutexCB(u32 id, u32 count, u32 timeoutPtr);