mirror of
https://github.com/libretro/ppsspp.git
synced 2024-11-29 19:30:48 +00:00
Simplify the API for HLE funcs to do callbacks.
__KernelWaitCurThread() already (ultimately) calls __KernelCheckCallbacks.
This commit is contained in:
parent
ff7e1d7be9
commit
fda41752e8
@ -337,21 +337,18 @@ void sceDisplayWaitVblankCB()
|
||||
{
|
||||
DEBUG_LOG(HLE,"sceDisplayWaitVblankCB()");
|
||||
__KernelWaitCurThread(WAITTYPE_VBLANK, 0, 0, 0, true);
|
||||
__KernelCheckCallbacks();
|
||||
}
|
||||
|
||||
void sceDisplayWaitVblankStartCB()
|
||||
{
|
||||
DEBUG_LOG(HLE,"sceDisplayWaitVblankStartCB()");
|
||||
__KernelWaitCurThread(WAITTYPE_VBLANK, 0, 0, 0, true);
|
||||
__KernelCheckCallbacks();
|
||||
}
|
||||
|
||||
void sceDisplayWaitVblankStartMultiCB()
|
||||
{
|
||||
DEBUG_LOG(HLE,"sceDisplayWaitVblankStartMultiCB()");
|
||||
__KernelWaitCurThread(WAITTYPE_VBLANK, 0, 0, 0, true);
|
||||
__KernelCheckCallbacks();
|
||||
}
|
||||
|
||||
void sceDisplayGetVcount()
|
||||
|
@ -232,7 +232,6 @@ void sceKernelWaitEventFlagCB(SceUID id, u32 bits, u32 wait, u32 outBitsPtr, u32
|
||||
timeout = Memory::Read_U32(timeoutPtr);
|
||||
|
||||
__KernelWaitCurThread(WAITTYPE_EVENTFLAG, id, 0, 0, true); // sets RETURN
|
||||
__KernelCheckCallbacks();
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -430,9 +430,7 @@ void sceKernelLockMutexCB(SceUID id, int count, u32 timeoutPtr)
|
||||
if (__KernelLockMutex(mutex, count, error))
|
||||
{
|
||||
RETURN(0);
|
||||
bool callbacksProcessed = __KernelForceCallbacks();
|
||||
if (callbacksProcessed)
|
||||
__KernelExecutePendingMipsCalls();
|
||||
__KernelForceCallbacks();
|
||||
}
|
||||
else if (error)
|
||||
RETURN(error);
|
||||
@ -441,7 +439,6 @@ void sceKernelLockMutexCB(SceUID id, int count, u32 timeoutPtr)
|
||||
mutex->waitingThreads.push_back(__KernelGetCurThread());
|
||||
__KernelWaitMutex(mutex, timeoutPtr);
|
||||
__KernelWaitCurThread(WAITTYPE_MUTEX, id, count, timeoutPtr, true);
|
||||
__KernelCheckCallbacks();
|
||||
}
|
||||
}
|
||||
|
||||
@ -792,9 +789,7 @@ void sceKernelLockLwMutexCB(u32 workareaPtr, int count, u32 timeoutPtr)
|
||||
{
|
||||
Memory::WriteStruct(workareaPtr, &workarea);
|
||||
RETURN(0);
|
||||
bool callbacksProcessed = __KernelForceCallbacks();
|
||||
if (callbacksProcessed)
|
||||
__KernelExecutePendingMipsCalls();
|
||||
__KernelForceCallbacks();
|
||||
}
|
||||
else if (error)
|
||||
RETURN(error);
|
||||
@ -806,7 +801,6 @@ void sceKernelLockLwMutexCB(u32 workareaPtr, int count, u32 timeoutPtr)
|
||||
mutex->waitingThreads.push_back(__KernelGetCurThread());
|
||||
__KernelWaitLwMutex(mutex, timeoutPtr);
|
||||
__KernelWaitCurThread(WAITTYPE_LWMUTEX, workarea.uid, count, timeoutPtr, true);
|
||||
__KernelCheckCallbacks();
|
||||
}
|
||||
else
|
||||
RETURN(error);
|
||||
|
@ -356,11 +356,7 @@ void __KernelWaitSema(SceUID id, int wantedCount, u32 timeoutPtr, const char *ba
|
||||
{
|
||||
s->ns.currentCount -= wantedCount;
|
||||
if (processCallbacks)
|
||||
{
|
||||
bool callbacksProcessed = __KernelForceCallbacks();
|
||||
if (callbacksProcessed)
|
||||
__KernelExecutePendingMipsCalls();
|
||||
}
|
||||
__KernelForceCallbacks();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -368,8 +364,6 @@ void __KernelWaitSema(SceUID id, int wantedCount, u32 timeoutPtr, const char *ba
|
||||
s->waitingThreads.push_back(__KernelGetCurThread());
|
||||
__KernelSetSemaTimeout(s, timeoutPtr);
|
||||
__KernelWaitCurThread(WAITTYPE_SEMA, id, wantedCount, timeoutPtr, processCallbacks);
|
||||
if (processCallbacks)
|
||||
__KernelCheckCallbacks();
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -959,7 +959,6 @@ void sceKernelStartThread(SceUID threadToStartID, u32 argSize, u32 argBlockPtr)
|
||||
|
||||
if (startThread->nt.status != THREADSTATUS_DORMANT)
|
||||
{
|
||||
printf("NOT DORMANT\n");
|
||||
//Not dormant, WTF?
|
||||
RETURN(ERROR_KERNEL_THREAD_IS_NOT_DORMANT);
|
||||
return;
|
||||
@ -1276,8 +1275,6 @@ void sceKernelDelayThreadCB()
|
||||
SceUID curThread = __KernelGetCurThread();
|
||||
__KernelScheduleWakeup(curThread, usec);
|
||||
__KernelWaitCurThread(WAITTYPE_DELAY, curThread, 0, 0, true);
|
||||
if (__KernelCheckCallbacks())
|
||||
__KernelExecutePendingMipsCalls();
|
||||
}
|
||||
|
||||
void sceKernelDelayThread()
|
||||
@ -1364,7 +1361,6 @@ void sceKernelSleepThreadCB()
|
||||
DEBUG_LOG(HLE, "sceKernelSleepThreadCB()");
|
||||
__KernelSleepThread(true);
|
||||
__KernelCheckCallbacks();
|
||||
__KernelExecutePendingMipsCalls();
|
||||
}
|
||||
|
||||
void sceKernelWaitThreadEnd()
|
||||
@ -1758,8 +1754,7 @@ void __KernelReturnFromMipsCall()
|
||||
g_inCbCount--;
|
||||
|
||||
// yeah! back in the real world, let's keep going. Should we process more callbacks?
|
||||
__KernelCheckCallbacks();
|
||||
if (!__KernelExecutePendingMipsCalls())
|
||||
if (!__KernelCheckCallbacks())
|
||||
{
|
||||
// We should definitely reschedule as we might still be asleep. - except if we came from checkcallbacks?
|
||||
__KernelReSchedule("return from callback");
|
||||
@ -1872,6 +1867,9 @@ bool __KernelCheckCallbacks() {
|
||||
}
|
||||
}
|
||||
// } while (processed && currentThread == __KernelGetCurThread());
|
||||
|
||||
if (processed)
|
||||
return __KernelExecutePendingMipsCalls();
|
||||
return processed;
|
||||
}
|
||||
|
||||
@ -1880,19 +1878,21 @@ bool __KernelForceCallbacks()
|
||||
Thread *curThread = __GetCurrentThread();
|
||||
|
||||
bool callbacksProcessed = __KernelCheckThreadCallbacks(curThread, true);
|
||||
if (callbacksProcessed)
|
||||
__KernelExecutePendingMipsCalls();
|
||||
|
||||
return callbacksProcessed;
|
||||
}
|
||||
|
||||
void sceKernelCheckCallback() {
|
||||
Thread *curThread = __GetCurrentThread();
|
||||
void sceKernelCheckCallback()
|
||||
{
|
||||
// Start with yes.
|
||||
RETURN(1);
|
||||
|
||||
bool callbacksProcessed = __KernelForceCallbacks();
|
||||
|
||||
if (callbacksProcessed) {
|
||||
curThread->setReturnValue(1);
|
||||
ERROR_LOG(HLE,"sceKernelCheckCallback() - processed a callback.");
|
||||
__KernelExecutePendingMipsCalls();
|
||||
} else {
|
||||
RETURN(0);
|
||||
}
|
||||
|
@ -268,9 +268,7 @@ void sceUmdWaitDriveStatCB(u32 stat, u32 timeout)
|
||||
{
|
||||
DEBUG_LOG(HLE,"0=sceUmdWaitDriveStatCB(stat = %08x, timeout = %d)", stat, timeout);
|
||||
|
||||
bool callbacksProcessed = __KernelForceCallbacks();
|
||||
if (callbacksProcessed)
|
||||
__KernelExecutePendingMipsCalls();
|
||||
__KernelForceCallbacks();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -284,7 +282,6 @@ void sceUmdWaitDriveStatCB(u32 stat, u32 timeout)
|
||||
|
||||
__UmdWaitStat(timeout);
|
||||
__KernelWaitCurThread(WAITTYPE_UMD, 1, stat, 0, true);
|
||||
__KernelCheckCallbacks();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user