mirror of
https://github.com/libretro/ppsspp.git
synced 2025-01-19 15:13:10 +00:00
Correct sceKernelGetThreadStackFreeSize().
It was always returning 0.
This commit is contained in:
parent
0f7ac377cd
commit
b898e397aa
@ -717,7 +717,7 @@ const HLEFunction ThreadManForUser[] =
|
||||
{0x94aa61ee,sceKernelGetThreadCurrentPriority,"sceKernelGetThreadCurrentPriority"},
|
||||
{0x293b45b8,WrapI_V<sceKernelGetThreadId>,"sceKernelGetThreadId"},
|
||||
{0x3B183E26,WrapI_I<sceKernelGetThreadExitStatus>,"sceKernelGetThreadExitStatus"},
|
||||
{0x52089CA1,sceKernelGetThreadStackFreeSize,"sceKernelGetThreadStackFreeSize"},
|
||||
{0x52089CA1,WrapI_I<sceKernelGetThreadStackFreeSize>, "sceKernelGetThreadStackFreeSize"},
|
||||
{0xFFC36A14,WrapU_UU<sceKernelReferThreadRunStatus>,"sceKernelReferThreadRunStatus"},
|
||||
{0x17c1684e,WrapU_UU<sceKernelReferThreadStatus>,"sceKernelReferThreadStatus"},
|
||||
{0x2C34E053,WrapI_I<sceKernelReleaseWaitThread>,"sceKernelReleaseWaitThread"},
|
||||
|
@ -389,7 +389,7 @@ int sceKernelDcacheWritebackAll();
|
||||
int sceKernelDcacheWritebackRange(u32 addr, int size);
|
||||
int sceKernelDcacheWritebackInvalidateRange(u32 addr, int size);
|
||||
int sceKernelDcacheWritebackInvalidateAll();
|
||||
void sceKernelGetThreadStackFreeSize();
|
||||
int sceKernelGetThreadStackFreeSize(SceUID threadID);
|
||||
u32 sceKernelIcacheInvalidateAll();
|
||||
u32 sceKernelIcacheClearAll();
|
||||
int sceKernelIcacheInvalidateRange(u32 addr, int size);
|
||||
|
@ -1852,7 +1852,7 @@ int sceKernelCheckThreadStack()
|
||||
Thread *t = kernelObjects.Get<Thread>(__KernelGetCurThread(), error);
|
||||
if (t) {
|
||||
u32 diff = labs((long)((s64)currentMIPS->r[MIPS_REG_SP] - (s64)t->currentStack.start));
|
||||
WARN_LOG(SCEKERNEL, "%i=sceKernelCheckThreadStack()", diff);
|
||||
DEBUG_LOG(SCEKERNEL, "%i=sceKernelCheckThreadStack()", diff);
|
||||
return diff;
|
||||
} else {
|
||||
ERROR_LOG_REPORT(SCEKERNEL, "sceKernelCheckThreadStack() - not on thread");
|
||||
@ -2148,37 +2148,32 @@ int sceKernelStartThread(SceUID threadToStartID, int argSize, u32 argBlockPtr)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void sceKernelGetThreadStackFreeSize()
|
||||
int sceKernelGetThreadStackFreeSize(SceUID threadID)
|
||||
{
|
||||
SceUID threadID = PARAM(0);
|
||||
Thread *thread;
|
||||
|
||||
INFO_LOG(SCEKERNEL,"sceKernelGetThreadStackFreeSize(%i)", threadID);
|
||||
DEBUG_LOG(SCEKERNEL, "sceKernelGetThreadStackFreeSize(%i)", threadID);
|
||||
|
||||
if (threadID == 0)
|
||||
thread = __GetCurrentThread();
|
||||
else
|
||||
threadID = currentThread;
|
||||
|
||||
u32 error;
|
||||
Thread *thread = kernelObjects.Get<Thread>(threadID, error);
|
||||
if (thread == 0)
|
||||
{
|
||||
u32 error;
|
||||
thread = kernelObjects.Get<Thread>(threadID, error);
|
||||
if (thread == 0)
|
||||
{
|
||||
ERROR_LOG(SCEKERNEL,"sceKernelGetThreadStackFreeSize: invalid thread id %i", threadID);
|
||||
RETURN(error);
|
||||
return;
|
||||
}
|
||||
ERROR_LOG(SCEKERNEL, "sceKernelGetThreadStackFreeSize: invalid thread id %i", threadID);
|
||||
return error;
|
||||
}
|
||||
|
||||
// Scan the stack for 0xFF
|
||||
// Scan the stack for 0xFF, starting after 0x10 (the thread id is written there.)
|
||||
// Obviously this doesn't work great if PSP_THREAD_ATTR_NO_FILLSTACK is used.
|
||||
int sz = 0;
|
||||
for (u32 addr = thread->currentStack.start; addr < thread->currentStack.start + thread->nt.stackSize; addr++)
|
||||
for (u32 offset = 0x10; offset < thread->nt.stackSize; ++offset)
|
||||
{
|
||||
if (Memory::Read_U8(addr) != 0xFF)
|
||||
if (Memory::Read_U8(thread->currentStack.start + offset) != 0xFF)
|
||||
break;
|
||||
sz++;
|
||||
}
|
||||
|
||||
RETURN(sz & ~3);
|
||||
return sz & ~3;
|
||||
}
|
||||
|
||||
void __KernelReturnFromThread()
|
||||
|
@ -319,7 +319,7 @@ int sceKernelVolatileMemLock(int type, u32 paddr, u32 psize) {
|
||||
|
||||
case SCE_KERNEL_ERROR_ILLEGAL_CONTEXT:
|
||||
{
|
||||
WARN_LOG(HLE, "sceKernelVolatileMemLock(%i, %08x, %08x): dispatch disabled", type, paddr, psize);
|
||||
WARN_LOG(HLE, "sceKernelVolatileMemLock(%i, %08x, %08x): in interrupt", type, paddr, psize);
|
||||
Memory::Write_U32(0x08400000, paddr);
|
||||
Memory::Write_U32(0x00400000, psize);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user