mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 13:30:02 +00:00
Return proper errors while dispatch disabled.
In at least the majority of waits.
This commit is contained in:
parent
252bf04c64
commit
61fae4e920
@ -216,6 +216,9 @@ int __CtrlReadBuffer(u32 ctrlDataPtr, u32 nBufs, bool negative, bool peek)
|
||||
if (nBufs > NUM_CTRL_BUFFERS)
|
||||
return SCE_KERNEL_ERROR_INVALID_SIZE;
|
||||
|
||||
if (!peek && !__KernelIsDispatchEnabled())
|
||||
return SCE_KERNEL_ERROR_CAN_NOT_WAIT;
|
||||
|
||||
u32 resetRead = ctrlBufRead;
|
||||
|
||||
u32 availBufs;
|
||||
|
@ -626,6 +626,8 @@ u32 sceDisplayWaitVblankStartMulti(int vblanks) {
|
||||
return SCE_KERNEL_ERROR_INVALID_VALUE;
|
||||
}
|
||||
VERBOSE_LOG(HLE, "sceDisplayWaitVblankStartMulti(%d)", vblanks);
|
||||
if (!__KernelIsDispatchEnabled())
|
||||
return SCE_KERNEL_ERROR_CAN_NOT_WAIT;
|
||||
vblankWaitingThreads.push_back(WaitVBlankInfo(__KernelGetCurThread(), vblanks));
|
||||
__KernelWaitCurThread(WAITTYPE_VBLANK, 0, 0, 0, false, "vblank start multi waited");
|
||||
return 0;
|
||||
@ -657,6 +659,8 @@ u32 sceDisplayWaitVblankStartMultiCB(int vblanks) {
|
||||
return SCE_KERNEL_ERROR_INVALID_VALUE;
|
||||
}
|
||||
VERBOSE_LOG(HLE,"sceDisplayWaitVblankStartMultiCB(%d)", vblanks);
|
||||
if (!__KernelIsDispatchEnabled())
|
||||
return SCE_KERNEL_ERROR_CAN_NOT_WAIT;
|
||||
vblankWaitingThreads.push_back(WaitVBlankInfo(__KernelGetCurThread(), vblanks));
|
||||
__KernelWaitCurThread(WAITTYPE_VBLANK, 0, 0, 0, true, "vblank start multi waited");
|
||||
return 0;
|
||||
@ -749,10 +753,10 @@ const HLEFunction sceDisplay[] = {
|
||||
{0xEEDA2E54,WrapU_UUUI<sceDisplayGetFramebuf>,"sceDisplayGetFrameBuf"},
|
||||
{0x36CDFADE,WrapU_V<sceDisplayWaitVblank>, "sceDisplayWaitVblank", HLE_NOT_DISPATCH_SUSPENDED},
|
||||
{0x984C27E7,WrapU_V<sceDisplayWaitVblankStart>, "sceDisplayWaitVblankStart", HLE_NOT_DISPATCH_SUSPENDED},
|
||||
{0x40f1469c,WrapU_I<sceDisplayWaitVblankStartMulti>, "sceDisplayWaitVblankStartMulti", HLE_NOT_DISPATCH_SUSPENDED},
|
||||
{0x40f1469c,WrapU_I<sceDisplayWaitVblankStartMulti>, "sceDisplayWaitVblankStartMulti"},
|
||||
{0x8EB9EC49,WrapU_V<sceDisplayWaitVblankCB>, "sceDisplayWaitVblankCB", HLE_NOT_DISPATCH_SUSPENDED},
|
||||
{0x46F186C3,WrapU_V<sceDisplayWaitVblankStartCB>, "sceDisplayWaitVblankStartCB", HLE_NOT_DISPATCH_SUSPENDED},
|
||||
{0x77ed8b3a,WrapU_I<sceDisplayWaitVblankStartMultiCB>,"sceDisplayWaitVblankStartMultiCB", HLE_NOT_DISPATCH_SUSPENDED},
|
||||
{0x77ed8b3a,WrapU_I<sceDisplayWaitVblankStartMultiCB>,"sceDisplayWaitVblankStartMultiCB"},
|
||||
{0xdba6c4c4,WrapF_V<sceDisplayGetFramePerSec>,"sceDisplayGetFramePerSec"},
|
||||
{0x773dd3a3,WrapU_V<sceDisplayGetCurrentHcount>,"sceDisplayGetCurrentHcount"},
|
||||
{0x210eab3a,WrapU_V<sceDisplayGetAccumulatedHcount>,"sceDisplayGetAccumulatedHcount"},
|
||||
|
@ -769,8 +769,8 @@ const HLEFunction ThreadManForUser[] =
|
||||
{0x8125221D,WrapI_CUU<sceKernelCreateMbx>, "sceKernelCreateMbx"},
|
||||
{0x86255ADA,WrapI_I<sceKernelDeleteMbx>, "sceKernelDeleteMbx"},
|
||||
{0xE9B3061E,WrapI_IU<sceKernelSendMbx>, "sceKernelSendMbx"},
|
||||
{0x18260574,WrapI_IUU<sceKernelReceiveMbx>, "sceKernelReceiveMbx"},
|
||||
{0xF3986382,WrapI_IUU<sceKernelReceiveMbxCB>, "sceKernelReceiveMbxCB"},
|
||||
{0x18260574,WrapI_IUU<sceKernelReceiveMbx>, "sceKernelReceiveMbx", HLE_NOT_DISPATCH_SUSPENDED},
|
||||
{0xF3986382,WrapI_IUU<sceKernelReceiveMbxCB>, "sceKernelReceiveMbxCB", HLE_NOT_DISPATCH_SUSPENDED},
|
||||
{0x0D81716A,WrapI_IU<sceKernelPollMbx>, "sceKernelPollMbx"},
|
||||
{0x87D4DD36,WrapI_IU<sceKernelCancelReceiveMbx>, "sceKernelCancelReceiveMbx"},
|
||||
{0xA8E8C846,WrapI_IU<sceKernelReferMbxStatus>, "sceKernelReferMbxStatus"},
|
||||
@ -788,8 +788,8 @@ const HLEFunction ThreadManForUser[] =
|
||||
|
||||
{0x56C039B5,WrapI_CIUUU<sceKernelCreateVpl>, "sceKernelCreateVpl"},
|
||||
{0x89B3D48C,WrapI_I<sceKernelDeleteVpl>, "sceKernelDeleteVpl"},
|
||||
{0xBED27435,WrapI_IUUU<sceKernelAllocateVpl>, "sceKernelAllocateVpl"},
|
||||
{0xEC0A693F,WrapI_IUUU<sceKernelAllocateVplCB>, "sceKernelAllocateVplCB"},
|
||||
{0xBED27435,WrapI_IUUU<sceKernelAllocateVpl>, "sceKernelAllocateVpl", HLE_NOT_DISPATCH_SUSPENDED},
|
||||
{0xEC0A693F,WrapI_IUUU<sceKernelAllocateVplCB>, "sceKernelAllocateVplCB", HLE_NOT_DISPATCH_SUSPENDED},
|
||||
{0xAF36D708,WrapI_IUU<sceKernelTryAllocateVpl>, "sceKernelTryAllocateVpl"},
|
||||
{0xB736E9FF,WrapI_IU<sceKernelFreeVpl>, "sceKernelFreeVpl"},
|
||||
{0x1D371B8A,WrapI_IU<sceKernelCancelVpl>, "sceKernelCancelVpl"},
|
||||
@ -797,8 +797,8 @@ const HLEFunction ThreadManForUser[] =
|
||||
|
||||
{0xC07BB470,WrapI_CUUUUU<sceKernelCreateFpl>, "sceKernelCreateFpl"},
|
||||
{0xED1410E0,WrapI_I<sceKernelDeleteFpl>, "sceKernelDeleteFpl"},
|
||||
{0xD979E9BF,WrapI_IUU<sceKernelAllocateFpl>, "sceKernelAllocateFpl"},
|
||||
{0xE7282CB6,WrapI_IUU<sceKernelAllocateFplCB>, "sceKernelAllocateFplCB"},
|
||||
{0xD979E9BF,WrapI_IUU<sceKernelAllocateFpl>, "sceKernelAllocateFpl", HLE_NOT_DISPATCH_SUSPENDED},
|
||||
{0xE7282CB6,WrapI_IUU<sceKernelAllocateFplCB>, "sceKernelAllocateFplCB", HLE_NOT_DISPATCH_SUSPENDED},
|
||||
{0x623AE665,WrapI_IU<sceKernelTryAllocateFpl>, "sceKernelTryAllocateFpl"},
|
||||
{0xF6414A71,WrapI_IU<sceKernelFreeFpl>, "sceKernelFreeFpl"},
|
||||
{0xA8AA591F,WrapI_IU<sceKernelCancelFpl>, "sceKernelCancelFpl"},
|
||||
|
@ -1731,6 +1731,10 @@ int sceKernelAllocateTls(SceUID uid)
|
||||
{
|
||||
// TODO: Allocate downward if PSP_TLS_ATTR_HIGHMEM?
|
||||
DEBUG_LOG(HLE, "sceKernelAllocateTls(%08x)", uid);
|
||||
|
||||
if (!__KernelIsDispatchEnabled())
|
||||
return 0;
|
||||
|
||||
u32 error;
|
||||
TLS *tls = kernelObjects.Get<TLS>(uid, error);
|
||||
if (tls)
|
||||
|
@ -1512,9 +1512,9 @@ const HLEFunction ModuleMgrForUser[] =
|
||||
{
|
||||
{0x977DE386,&WrapU_CUU<sceKernelLoadModule>,"sceKernelLoadModule"},
|
||||
{0xb7f46618,&WrapU_UUU<sceKernelLoadModuleByID>,"sceKernelLoadModuleByID"},
|
||||
{0x50F0C1EC,&WrapV_UUUUU<sceKernelStartModule>,"sceKernelStartModule"},
|
||||
{0x50F0C1EC,&WrapV_UUUUU<sceKernelStartModule>,"sceKernelStartModule", HLE_NOT_DISPATCH_SUSPENDED},
|
||||
{0xD675EBB8,&sceKernelExitGame,"sceKernelSelfStopUnloadModule"}, //HACK
|
||||
{0xd1ff982a,&WrapU_UUUUU<sceKernelStopModule>,"sceKernelStopModule"},
|
||||
{0xd1ff982a,&WrapU_UUUUU<sceKernelStopModule>,"sceKernelStopModule", HLE_NOT_DISPATCH_SUSPENDED},
|
||||
{0x2e0911aa,WrapU_U<sceKernelUnloadModule>,"sceKernelUnloadModule"},
|
||||
{0x710F61B5,0,"sceKernelLoadModuleMs"},
|
||||
{0xF9275D98,0,"sceKernelLoadModuleBufferUsbWlan"}, ///???
|
||||
|
@ -427,11 +427,8 @@ int sceKernelDeleteMsgPipe(SceUID uid)
|
||||
return kernelObjects.Destroy<MsgPipe>(uid);
|
||||
}
|
||||
|
||||
int __KernelSendMsgPipe(MsgPipe *m, u32 sendBufAddr, u32 sendSize, int waitMode, u32 resultAddr, u32 timeoutPtr, bool cbEnabled, bool poll)
|
||||
int __KernelValidateSendMsgPipe(SceUID uid, u32 sendBufAddr, u32 sendSize, int waitMode, u32 resultAddr)
|
||||
{
|
||||
u32 curSendAddr = sendBufAddr;
|
||||
SceUID uid = m->GetUID();
|
||||
|
||||
if (sendSize & 0x80000000)
|
||||
{
|
||||
ERROR_LOG(HLE, "__KernelSendMsgPipe(%d): illegal size %d", uid, sendSize);
|
||||
@ -450,6 +447,20 @@ int __KernelSendMsgPipe(MsgPipe *m, u32 sendBufAddr, u32 sendSize, int waitMode,
|
||||
return SCE_KERNEL_ERROR_ILLEGAL_MODE;
|
||||
}
|
||||
|
||||
if (!__KernelIsDispatchEnabled())
|
||||
{
|
||||
WARN_LOG(HLE, "__KernelSendMsgPipe(%d): dispatch disabled", uid, waitMode);
|
||||
return SCE_KERNEL_ERROR_CAN_NOT_WAIT;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __KernelSendMsgPipe(MsgPipe *m, u32 sendBufAddr, u32 sendSize, int waitMode, u32 resultAddr, u32 timeoutPtr, bool cbEnabled, bool poll)
|
||||
{
|
||||
u32 curSendAddr = sendBufAddr;
|
||||
SceUID uid = m->GetUID();
|
||||
|
||||
// If the buffer size is 0, nothing is buffered and all operations wait.
|
||||
if (m->nmp.bufSize == 0)
|
||||
{
|
||||
@ -551,7 +562,10 @@ int __KernelSendMsgPipe(MsgPipe *m, u32 sendBufAddr, u32 sendSize, int waitMode,
|
||||
|
||||
int sceKernelSendMsgPipe(SceUID uid, u32 sendBufAddr, u32 sendSize, u32 waitMode, u32 resultAddr, u32 timeoutPtr)
|
||||
{
|
||||
u32 error;
|
||||
u32 error = __KernelValidateSendMsgPipe(uid, sendBufAddr, sendSize, waitMode, resultAddr);
|
||||
if (error != 0) {
|
||||
return error;
|
||||
}
|
||||
MsgPipe *m = kernelObjects.Get<MsgPipe>(uid, error);
|
||||
if (!m) {
|
||||
ERROR_LOG(HLE, "sceKernelSendMsgPipe(%i) - ERROR %08x", uid, error);
|
||||
@ -564,7 +578,10 @@ int sceKernelSendMsgPipe(SceUID uid, u32 sendBufAddr, u32 sendSize, u32 waitMode
|
||||
|
||||
int sceKernelSendMsgPipeCB(SceUID uid, u32 sendBufAddr, u32 sendSize, u32 waitMode, u32 resultAddr, u32 timeoutPtr)
|
||||
{
|
||||
u32 error;
|
||||
u32 error = __KernelValidateSendMsgPipe(uid, sendBufAddr, sendSize, waitMode, resultAddr);
|
||||
if (error != 0) {
|
||||
return error;
|
||||
}
|
||||
MsgPipe *m = kernelObjects.Get<MsgPipe>(uid, error);
|
||||
if (!m) {
|
||||
ERROR_LOG(HLE, "sceKernelSendMsgPipeCB(%i) - ERROR %08x", uid, error);
|
||||
@ -579,7 +596,10 @@ int sceKernelSendMsgPipeCB(SceUID uid, u32 sendBufAddr, u32 sendSize, u32 waitMo
|
||||
|
||||
int sceKernelTrySendMsgPipe(SceUID uid, u32 sendBufAddr, u32 sendSize, u32 waitMode, u32 resultAddr)
|
||||
{
|
||||
u32 error;
|
||||
u32 error = __KernelValidateSendMsgPipe(uid, sendBufAddr, sendSize, waitMode, resultAddr);
|
||||
if (error != 0) {
|
||||
return error;
|
||||
}
|
||||
MsgPipe *m = kernelObjects.Get<MsgPipe>(uid, error);
|
||||
if (!m) {
|
||||
ERROR_LOG(HLE, "sceKernelTrySendMsgPipe(%i) - ERROR %08x", uid, error);
|
||||
@ -590,11 +610,8 @@ int sceKernelTrySendMsgPipe(SceUID uid, u32 sendBufAddr, u32 sendSize, u32 waitM
|
||||
return __KernelSendMsgPipe(m, sendBufAddr, sendSize, waitMode, resultAddr, 0, false, true);
|
||||
}
|
||||
|
||||
int __KernelReceiveMsgPipe(MsgPipe *m, u32 receiveBufAddr, u32 receiveSize, int waitMode, u32 resultAddr, u32 timeoutPtr, bool cbEnabled, bool poll)
|
||||
int __KernelValidateReceiveMsgPipe(SceUID uid, u32 receiveBufAddr, u32 receiveSize, int waitMode, u32 resultAddr)
|
||||
{
|
||||
u32 curReceiveAddr = receiveBufAddr;
|
||||
SceUID uid = m->GetUID();
|
||||
|
||||
if (receiveSize & 0x80000000)
|
||||
{
|
||||
ERROR_LOG(HLE, "__KernelReceiveMsgPipe(%d): illegal size %d", uid, receiveSize);
|
||||
@ -613,6 +630,20 @@ int __KernelReceiveMsgPipe(MsgPipe *m, u32 receiveBufAddr, u32 receiveSize, int
|
||||
return SCE_KERNEL_ERROR_ILLEGAL_MODE;
|
||||
}
|
||||
|
||||
if (!__KernelIsDispatchEnabled())
|
||||
{
|
||||
WARN_LOG(HLE, "__KernelReceiveMsgPipe(%d): dispatch disabled", uid, waitMode);
|
||||
return SCE_KERNEL_ERROR_CAN_NOT_WAIT;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __KernelReceiveMsgPipe(MsgPipe *m, u32 receiveBufAddr, u32 receiveSize, int waitMode, u32 resultAddr, u32 timeoutPtr, bool cbEnabled, bool poll)
|
||||
{
|
||||
u32 curReceiveAddr = receiveBufAddr;
|
||||
SceUID uid = m->GetUID();
|
||||
|
||||
// MsgPipe buffer size is 0, receiving directly from waiting send threads
|
||||
if (m->nmp.bufSize == 0)
|
||||
{
|
||||
@ -712,7 +743,10 @@ int __KernelReceiveMsgPipe(MsgPipe *m, u32 receiveBufAddr, u32 receiveSize, int
|
||||
|
||||
int sceKernelReceiveMsgPipe(SceUID uid, u32 receiveBufAddr, u32 receiveSize, u32 waitMode, u32 resultAddr, u32 timeoutPtr)
|
||||
{
|
||||
u32 error;
|
||||
u32 error = __KernelValidateReceiveMsgPipe(uid, receiveBufAddr, receiveSize, waitMode, resultAddr);
|
||||
if (error != 0) {
|
||||
return error;
|
||||
}
|
||||
MsgPipe *m = kernelObjects.Get<MsgPipe>(uid, error);
|
||||
if (!m) {
|
||||
ERROR_LOG(HLE, "sceKernelReceiveMsgPipe(%i) - ERROR %08x", uid, error);
|
||||
@ -725,7 +759,10 @@ int sceKernelReceiveMsgPipe(SceUID uid, u32 receiveBufAddr, u32 receiveSize, u32
|
||||
|
||||
int sceKernelReceiveMsgPipeCB(SceUID uid, u32 receiveBufAddr, u32 receiveSize, u32 waitMode, u32 resultAddr, u32 timeoutPtr)
|
||||
{
|
||||
u32 error;
|
||||
u32 error = __KernelValidateReceiveMsgPipe(uid, receiveBufAddr, receiveSize, waitMode, resultAddr);
|
||||
if (error != 0) {
|
||||
return error;
|
||||
}
|
||||
MsgPipe *m = kernelObjects.Get<MsgPipe>(uid, error);
|
||||
if (!m) {
|
||||
ERROR_LOG(HLE, "sceKernelReceiveMsgPipeCB(%i) - ERROR %08x", uid, error);
|
||||
@ -740,7 +777,10 @@ int sceKernelReceiveMsgPipeCB(SceUID uid, u32 receiveBufAddr, u32 receiveSize, u
|
||||
|
||||
int sceKernelTryReceiveMsgPipe(SceUID uid, u32 receiveBufAddr, u32 receiveSize, u32 waitMode, u32 resultAddr)
|
||||
{
|
||||
u32 error;
|
||||
u32 error = __KernelValidateReceiveMsgPipe(uid, receiveBufAddr, receiveSize, waitMode, resultAddr);
|
||||
if (error != 0) {
|
||||
return error;
|
||||
}
|
||||
MsgPipe *m = kernelObjects.Get<MsgPipe>(uid, error);
|
||||
if (!m) {
|
||||
ERROR_LOG(HLE, "sceKernelTryReceiveMsgPipe(%i) - ERROR %08x", uid, error);
|
||||
|
@ -2541,6 +2541,9 @@ int sceKernelWaitThreadEnd(SceUID threadID, u32 timeoutPtr)
|
||||
if (threadID == 0 || threadID == currentThread)
|
||||
return SCE_KERNEL_ERROR_ILLEGAL_THID;
|
||||
|
||||
if (!__KernelIsDispatchEnabled())
|
||||
return SCE_KERNEL_ERROR_CAN_NOT_WAIT;
|
||||
|
||||
u32 error;
|
||||
Thread *t = kernelObjects.Get<Thread>(threadID, error);
|
||||
if (t)
|
||||
@ -2567,6 +2570,9 @@ int sceKernelWaitThreadEndCB(SceUID threadID, u32 timeoutPtr)
|
||||
if (threadID == 0 || threadID == currentThread)
|
||||
return SCE_KERNEL_ERROR_ILLEGAL_THID;
|
||||
|
||||
if (!__KernelIsDispatchEnabled())
|
||||
return SCE_KERNEL_ERROR_CAN_NOT_WAIT;
|
||||
|
||||
u32 error;
|
||||
Thread *t = kernelObjects.Get<Thread>(threadID, error);
|
||||
if (t)
|
||||
|
Loading…
Reference in New Issue
Block a user