diff --git a/Core/HLE/sceKernel.cpp b/Core/HLE/sceKernel.cpp index e58ccf50c6..359c342b23 100644 --- a/Core/HLE/sceKernel.cpp +++ b/Core/HLE/sceKernel.cpp @@ -769,8 +769,8 @@ const HLEFunction ThreadManForUser[] = {0x8125221D,WrapI_CUU, "sceKernelCreateMbx"}, {0x86255ADA,WrapI_I, "sceKernelDeleteMbx"}, {0xE9B3061E,WrapI_IU, "sceKernelSendMbx"}, - {0x18260574,WrapI_IUU, "sceKernelReceiveMbx", HLE_NOT_DISPATCH_SUSPENDED}, - {0xF3986382,WrapI_IUU, "sceKernelReceiveMbxCB", HLE_NOT_DISPATCH_SUSPENDED}, + {0x18260574,WrapI_IUU, "sceKernelReceiveMbx", HLE_NOT_IN_INTERRUPT | HLE_NOT_DISPATCH_SUSPENDED}, + {0xF3986382,WrapI_IUU, "sceKernelReceiveMbxCB", HLE_NOT_IN_INTERRUPT | HLE_NOT_DISPATCH_SUSPENDED}, {0x0D81716A,WrapI_IU, "sceKernelPollMbx"}, {0x87D4DD36,WrapI_IU, "sceKernelCancelReceiveMbx"}, {0xA8E8C846,WrapI_IU, "sceKernelReferMbxStatus"}, @@ -788,8 +788,8 @@ const HLEFunction ThreadManForUser[] = {0x56C039B5,WrapI_CIUUU, "sceKernelCreateVpl"}, {0x89B3D48C,WrapI_I, "sceKernelDeleteVpl"}, - {0xBED27435,WrapI_IUUU, "sceKernelAllocateVpl", HLE_NOT_DISPATCH_SUSPENDED}, - {0xEC0A693F,WrapI_IUUU, "sceKernelAllocateVplCB", HLE_NOT_DISPATCH_SUSPENDED}, + {0xBED27435,WrapI_IUUU, "sceKernelAllocateVpl", HLE_NOT_IN_INTERRUPT | HLE_NOT_DISPATCH_SUSPENDED}, + {0xEC0A693F,WrapI_IUUU, "sceKernelAllocateVplCB", HLE_NOT_IN_INTERRUPT | HLE_NOT_DISPATCH_SUSPENDED}, {0xAF36D708,WrapI_IUU, "sceKernelTryAllocateVpl"}, {0xB736E9FF,WrapI_IU, "sceKernelFreeVpl"}, {0x1D371B8A,WrapI_IU, "sceKernelCancelVpl"}, @@ -797,8 +797,8 @@ const HLEFunction ThreadManForUser[] = {0xC07BB470,WrapI_CUUUUU, "sceKernelCreateFpl"}, {0xED1410E0,WrapI_I, "sceKernelDeleteFpl"}, - {0xD979E9BF,WrapI_IUU, "sceKernelAllocateFpl", HLE_NOT_DISPATCH_SUSPENDED}, - {0xE7282CB6,WrapI_IUU, "sceKernelAllocateFplCB", HLE_NOT_DISPATCH_SUSPENDED}, + {0xD979E9BF,WrapI_IUU, "sceKernelAllocateFpl", HLE_NOT_IN_INTERRUPT | HLE_NOT_DISPATCH_SUSPENDED}, + {0xE7282CB6,WrapI_IUU, "sceKernelAllocateFplCB", HLE_NOT_IN_INTERRUPT | HLE_NOT_DISPATCH_SUSPENDED}, {0x623AE665,WrapI_IU, "sceKernelTryAllocateFpl"}, {0xF6414A71,WrapI_IU, "sceKernelFreeFpl"}, {0xA8AA591F,WrapI_IU, "sceKernelCancelFpl"}, diff --git a/Core/HLE/sceKernelMemory.cpp b/Core/HLE/sceKernelMemory.cpp index cbda9f753d..195e18de95 100644 --- a/Core/HLE/sceKernelMemory.cpp +++ b/Core/HLE/sceKernelMemory.cpp @@ -17,16 +17,17 @@ #include #include -#include "HLE.h" -#include "../System.h" -#include "../MIPS/MIPS.h" -#include "../MemMap.h" +#include "Core/HLE/HLE.h" +#include "Core/System.h" +#include "Core/MIPS/MIPS.h" +#include "Core/MemMap.h" #include "Core/CoreTiming.h" #include "Core/Reporting.h" -#include "sceKernel.h" -#include "sceKernelThread.h" -#include "sceKernelMemory.h" +#include "Core/HLE/sceKernel.h" +#include "Core/HLE/sceKernelThread.h" +#include "Core/HLE/sceKernelInterrupt.h" +#include "Core/HLE/sceKernelMemory.h" const int TLS_NUM_INDEXES = 16; @@ -1732,7 +1733,7 @@ int sceKernelAllocateTls(SceUID uid) // TODO: Allocate downward if PSP_TLS_ATTR_HIGHMEM? DEBUG_LOG(HLE, "sceKernelAllocateTls(%08x)", uid); - if (!__KernelIsDispatchEnabled()) + if (!__KernelIsDispatchEnabled() || __IsInInterrupt()) return 0; u32 error; diff --git a/Core/HLE/sceKernelMsgPipe.cpp b/Core/HLE/sceKernelMsgPipe.cpp index a4062d2669..4c3c05b1cb 100644 --- a/Core/HLE/sceKernelMsgPipe.cpp +++ b/Core/HLE/sceKernelMsgPipe.cpp @@ -23,6 +23,7 @@ #include "Core/HLE/sceKernel.h" #include "Core/HLE/sceKernelMsgPipe.h" #include "Core/HLE/sceKernelMemory.h" +#include "Core/HLE/sceKernelInterrupt.h" #include "Core/HLE/sceKernelThread.h" #include "Common/ChunkFile.h" @@ -427,7 +428,7 @@ int sceKernelDeleteMsgPipe(SceUID uid) return kernelObjects.Destroy(uid); } -int __KernelValidateSendMsgPipe(SceUID uid, u32 sendBufAddr, u32 sendSize, int waitMode, u32 resultAddr) +int __KernelValidateSendMsgPipe(SceUID uid, u32 sendBufAddr, u32 sendSize, int waitMode, u32 resultAddr, bool tryMode = false) { if (sendSize & 0x80000000) { @@ -447,10 +448,18 @@ int __KernelValidateSendMsgPipe(SceUID uid, u32 sendBufAddr, u32 sendSize, int w return SCE_KERNEL_ERROR_ILLEGAL_MODE; } - if (!__KernelIsDispatchEnabled()) + if (!tryMode) { - WARN_LOG(HLE, "__KernelSendMsgPipe(%d): dispatch disabled", uid, waitMode); - return SCE_KERNEL_ERROR_CAN_NOT_WAIT; + if (!__KernelIsDispatchEnabled()) + { + WARN_LOG(HLE, "__KernelSendMsgPipe(%d): dispatch disabled", uid, waitMode); + return SCE_KERNEL_ERROR_CAN_NOT_WAIT; + } + if (__IsInInterrupt()) + { + WARN_LOG(HLE, "__KernelSendMsgPipe(%d): in interrupt", uid, waitMode); + return SCE_KERNEL_ERROR_ILLEGAL_CONTEXT; + } } return 0; @@ -596,7 +605,7 @@ int sceKernelSendMsgPipeCB(SceUID uid, u32 sendBufAddr, u32 sendSize, u32 waitMo int sceKernelTrySendMsgPipe(SceUID uid, u32 sendBufAddr, u32 sendSize, u32 waitMode, u32 resultAddr) { - u32 error = __KernelValidateSendMsgPipe(uid, sendBufAddr, sendSize, waitMode, resultAddr); + u32 error = __KernelValidateSendMsgPipe(uid, sendBufAddr, sendSize, waitMode, resultAddr, true); if (error != 0) { return error; } @@ -610,7 +619,7 @@ int sceKernelTrySendMsgPipe(SceUID uid, u32 sendBufAddr, u32 sendSize, u32 waitM return __KernelSendMsgPipe(m, sendBufAddr, sendSize, waitMode, resultAddr, 0, false, true); } -int __KernelValidateReceiveMsgPipe(SceUID uid, u32 receiveBufAddr, u32 receiveSize, int waitMode, u32 resultAddr) +int __KernelValidateReceiveMsgPipe(SceUID uid, u32 receiveBufAddr, u32 receiveSize, int waitMode, u32 resultAddr, bool tryMode = false) { if (receiveSize & 0x80000000) { @@ -630,10 +639,18 @@ int __KernelValidateReceiveMsgPipe(SceUID uid, u32 receiveBufAddr, u32 receiveSi return SCE_KERNEL_ERROR_ILLEGAL_MODE; } - if (!__KernelIsDispatchEnabled()) + if (!tryMode) { - WARN_LOG(HLE, "__KernelReceiveMsgPipe(%d): dispatch disabled", uid, waitMode); - return SCE_KERNEL_ERROR_CAN_NOT_WAIT; + if (!__KernelIsDispatchEnabled()) + { + WARN_LOG(HLE, "__KernelReceiveMsgPipe(%d): dispatch disabled", uid, waitMode); + return SCE_KERNEL_ERROR_CAN_NOT_WAIT; + } + if (__IsInInterrupt()) + { + WARN_LOG(HLE, "__KernelReceiveMsgPipe(%d): in interrupt", uid, waitMode); + return SCE_KERNEL_ERROR_ILLEGAL_CONTEXT; + } } return 0; @@ -777,7 +794,7 @@ int sceKernelReceiveMsgPipeCB(SceUID uid, u32 receiveBufAddr, u32 receiveSize, u int sceKernelTryReceiveMsgPipe(SceUID uid, u32 receiveBufAddr, u32 receiveSize, u32 waitMode, u32 resultAddr) { - u32 error = __KernelValidateReceiveMsgPipe(uid, receiveBufAddr, receiveSize, waitMode, resultAddr); + u32 error = __KernelValidateReceiveMsgPipe(uid, receiveBufAddr, receiveSize, waitMode, resultAddr, true); if (error != 0) { return error; }