Skip to content

Commit

Permalink
Kernel: Stop reporting invalid semaphore names.
Browse files Browse the repository at this point in the history
  • Loading branch information
unknownbrackets committed Oct 16, 2022
1 parent a000c32 commit 91bfa3e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 20 deletions.
4 changes: 2 additions & 2 deletions Core/HLE/sceKernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ const HLEFunction ThreadManForUser[] =
{0XA66B0120, &WrapU_IU<sceKernelReferEventFlagStatus>, "sceKernelReferEventFlagStatus", 'x', "ix" },

{0X8FFDF9A2, &WrapI_IIU<sceKernelCancelSema>, "sceKernelCancelSema", 'i', "iix" },
{0XD6DA4BA1, &WrapI_CUIIU<sceKernelCreateSema>, "sceKernelCreateSema", 'i', "sxiix" },
{0XD6DA4BA1, &WrapI_CUIIU<sceKernelCreateSema>, "sceKernelCreateSema", 'i', "sxiip" },
{0X28B6489C, &WrapI_I<sceKernelDeleteSema>, "sceKernelDeleteSema", 'i', "i" },
{0X58B1F937, &WrapI_II<sceKernelPollSema>, "sceKernelPollSema", 'i', "ii" },
{0XBC6FEBC5, &WrapI_IU<sceKernelReferSemaStatus>, "sceKernelReferSemaStatus", 'i', "ip" },
Expand Down Expand Up @@ -899,7 +899,7 @@ const HLEFunction ThreadManForKernel[] =
{0X75156E8F, &WrapI_I<sceKernelResumeThread>, "sceKernelResumeThread", 'i', "i", HLE_KERNEL_SYSCALL },
{0X94416130, &WrapU_UUUU<sceKernelGetThreadmanIdList>, "sceKernelGetThreadmanIdList", 'x', "xxxx", HLE_KERNEL_SYSCALL },
{0x278c0df5, &WrapI_IU<sceKernelWaitThreadEnd>, "sceKernelWaitThreadEnd", 'i', "ix", HLE_KERNEL_SYSCALL },
{0xd6da4ba1, &WrapI_CUIIU<sceKernelCreateSema>, "sceKernelCreateSema", 'i', "sxiix", HLE_KERNEL_SYSCALL },
{0xd6da4ba1, &WrapI_CUIIU<sceKernelCreateSema>, "sceKernelCreateSema", 'i', "sxiip", HLE_KERNEL_SYSCALL },
{0x28b6489c, &WrapI_I<sceKernelDeleteSema>, "sceKernelDeleteSema", 'i', "i", HLE_KERNEL_SYSCALL },
{0x3f53e640, &WrapI_II<sceKernelSignalSema>, "sceKernelSignalSema", 'i', "ii", HLE_KERNEL_SYSCALL },
{0x4e3a1105, &WrapI_IIU<sceKernelWaitSema>, "sceKernelWaitSema", 'i', "iix", HLE_NOT_IN_INTERRUPT | HLE_NOT_DISPATCH_SUSPENDED | HLE_KERNEL_SYSCALL},
Expand Down
28 changes: 10 additions & 18 deletions Core/HLE/sceKernelSemaphore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,18 +203,11 @@ int sceKernelCancelSema(SceUID id, int newCount, u32 numWaitThreadsPtr)
}
}

int sceKernelCreateSema(const char* name, u32 attr, int initVal, int maxVal, u32 optionPtr)
{
int sceKernelCreateSema(const char* name, u32 attr, int initVal, int maxVal, u32 optionPtr) {
if (!name)
{
WARN_LOG_REPORT(SCEKERNEL, "%08x=sceKernelCreateSema(): invalid name", SCE_KERNEL_ERROR_ERROR);
return SCE_KERNEL_ERROR_ERROR;
}
return hleLogWarning(SCEKERNEL, SCE_KERNEL_ERROR_ERROR, "invalid name");
if (attr >= 0x200)
{
WARN_LOG_REPORT(SCEKERNEL, "%08x=sceKernelCreateSema(): invalid attr parameter: %08x", SCE_KERNEL_ERROR_ILLEGAL_ATTR, attr);
return SCE_KERNEL_ERROR_ILLEGAL_ATTR;
}
return hleLogWarning(SCEKERNEL, SCE_KERNEL_ERROR_ILLEGAL_ATTR, "invalid attr parameter %08x", attr);

PSPSemaphore *s = new PSPSemaphore();
SceUID id = kernelObjects.Create(s);
Expand All @@ -228,18 +221,17 @@ int sceKernelCreateSema(const char* name, u32 attr, int initVal, int maxVal, u32
s->ns.maxCount = maxVal;
s->ns.numWaitThreads = 0;

DEBUG_LOG(SCEKERNEL, "%i=sceKernelCreateSema(%s, %08x, %i, %i, %08x)", id, s->ns.name, s->ns.attr, s->ns.initCount, s->ns.maxCount, optionPtr);

if (optionPtr != 0)
{
u32 size = Memory::Read_U32(optionPtr);
if (size > 4)
WARN_LOG_REPORT(SCEKERNEL, "sceKernelCreateSema(%s) unsupported options parameter, size = %d", name, size);
// Many games pass garbage into optionPtr, it doesn't have any options.
if (optionPtr != 0) {
if (!Memory::IsValidRange(optionPtr, 4))
hleLogWarning(SCEKERNEL, id, "invalid options parameter");
else if (Memory::Read_U32(optionPtr) > 4)
hleLogDebug(SCEKERNEL, id, "invalid options parameter size");
}
if ((attr & ~PSP_SEMA_ATTR_PRIORITY) != 0)
WARN_LOG_REPORT(SCEKERNEL, "sceKernelCreateSema(%s) unsupported attr parameter: %08x", name, attr);

return id;
return hleLogSuccessX(SCEKERNEL, id);
}

int sceKernelDeleteSema(SceUID id)
Expand Down

0 comments on commit 91bfa3e

Please sign in to comment.