mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-14 18:19:36 +01:00
A lot of log cleanup. It's quite useful as a forcing function to find missing logs.
This commit is contained in:
1 parent
41e3591c8a
commit
cb180bf781
4 files changed
+105
-181
No files matched your search
+1
-1
@@ -292,7 +292,7 @@ inline R hleCallImpl(std::string_view module, std::string_view funcName, F func,
|
||||
// called by them. Use regular ERROR_LOG etc for those.
|
||||
|
||||
#define hleLogReturnHelper(convert, t, level, res, ...) \
|
||||
(((int)level <= MAX_LOGLEVEL) ? hleDoLog<true, convert>(t, level, (res), __FILE__, __LINE__, nullptr, ##__VA_ARGS__) : (res))
|
||||
(((int)level <= MAX_LOGLEVEL) ? hleDoLog<true, convert>(t, level, (res), __FILE__, __LINE__, nullptr, ##__VA_ARGS__) : hleNoLog(res))
|
||||
|
||||
#define hleLogError(t, res, ...) hleLogReturnHelper(false, t, LogLevel::LERROR, res, ##__VA_ARGS__)
|
||||
#define hleLogWarning(t, res, ...) hleLogReturnHelper(false, t, LogLevel::LWARNING, res, ##__VA_ARGS__)
|
||||
|
||||
+18
-26
@@ -676,23 +676,19 @@ int sceKernelReferMutexStatus(SceUID id, u32 infoAddr) {
|
||||
return hleLogDebug(Log::sceKernel, 0);
|
||||
}
|
||||
|
||||
int sceKernelCreateLwMutex(u32 workareaPtr, const char *name, u32 attr, int initialCount, u32 optionsPtr)
|
||||
{
|
||||
if (!name)
|
||||
{
|
||||
WARN_LOG_REPORT(Log::sceKernel, "%08x=sceKernelCreateLwMutex(): invalid name", SCE_KERNEL_ERROR_ERROR);
|
||||
return SCE_KERNEL_ERROR_ERROR;
|
||||
int sceKernelCreateLwMutex(u32 workareaPtr, const char *name, u32 attr, int initialCount, u32 optionsPtr) {
|
||||
if (!name) {
|
||||
return hleLogError(Log::sceKernel, SCE_KERNEL_ERROR_ERROR, "invalid name");
|
||||
}
|
||||
if (attr >= 0x400)
|
||||
{
|
||||
WARN_LOG_REPORT(Log::sceKernel, "%08x=sceKernelCreateLwMutex(): invalid attr parameter: %08x", SCE_KERNEL_ERROR_ILLEGAL_ATTR, attr);
|
||||
return SCE_KERNEL_ERROR_ILLEGAL_ATTR;
|
||||
if (attr >= 0x400) {
|
||||
return hleReportError(Log::sceKernel, SCE_KERNEL_ERROR_ILLEGAL_ATTR, "invalid attr parameter: %08x", attr);
|
||||
}
|
||||
if (initialCount < 0) {
|
||||
return hleLogError(Log::sceKernel, SCE_KERNEL_ERROR_ILLEGAL_COUNT);
|
||||
}
|
||||
if ((attr & PSP_MUTEX_ATTR_ALLOW_RECURSIVE) == 0 && initialCount > 1) {
|
||||
return hleLogError(Log::sceKernel, SCE_KERNEL_ERROR_ILLEGAL_COUNT);
|
||||
}
|
||||
|
||||
if (initialCount < 0)
|
||||
return SCE_KERNEL_ERROR_ILLEGAL_COUNT;
|
||||
if ((attr & PSP_MUTEX_ATTR_ALLOW_RECURSIVE) == 0 && initialCount > 1)
|
||||
return SCE_KERNEL_ERROR_ILLEGAL_COUNT;
|
||||
|
||||
LwMutex *mutex = new LwMutex();
|
||||
SceUID id = kernelObjects.Create(mutex);
|
||||
@@ -713,8 +709,6 @@ int sceKernelCreateLwMutex(u32 workareaPtr, const char *name, u32 attr, int init
|
||||
workarea->attr = attr;
|
||||
workarea->uid = id;
|
||||
|
||||
DEBUG_LOG(Log::sceKernel, "sceKernelCreateLwMutex(%08x, %s, %08x, %d, %08x)", workareaPtr, name, attr, initialCount, optionsPtr);
|
||||
|
||||
if (optionsPtr != 0)
|
||||
{
|
||||
u32 size = Memory::Read_U32(optionsPtr);
|
||||
@@ -724,7 +718,7 @@ int sceKernelCreateLwMutex(u32 workareaPtr, const char *name, u32 attr, int init
|
||||
if ((attr & ~PSP_MUTEX_ATTR_KNOWN) != 0)
|
||||
WARN_LOG_REPORT(Log::sceKernel, "sceKernelCreateLwMutex(%s) unsupported attr parameter: %08x", name, attr);
|
||||
|
||||
return 0;
|
||||
return hleLogDebug(Log::sceKernel, 0);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@@ -752,19 +746,19 @@ bool __KernelUnlockLwMutexForThread(LwMutex *mutex, T workarea, SceUID threadID,
|
||||
return true;
|
||||
}
|
||||
|
||||
int sceKernelDeleteLwMutex(u32 workareaPtr)
|
||||
{
|
||||
int sceKernelDeleteLwMutex(u32 workareaPtr) {
|
||||
DEBUG_LOG(Log::sceKernel, "sceKernelDeleteLwMutex(%08x)", workareaPtr);
|
||||
|
||||
if (!workareaPtr || !Memory::IsValidAddress(workareaPtr))
|
||||
return SCE_KERNEL_ERROR_ILLEGAL_ADDR;
|
||||
return hleLogError(Log::sceKernel, SCE_KERNEL_ERROR_ILLEGAL_ADDR);
|
||||
|
||||
auto workarea = PSPPointer<NativeLwMutexWorkarea>::Create(workareaPtr);
|
||||
|
||||
u32 error;
|
||||
LwMutex *mutex = kernelObjects.Get<LwMutex>(workarea->uid, error);
|
||||
if (mutex)
|
||||
{
|
||||
if (!mutex) {
|
||||
return hleLogError(Log::sceKernel, error);
|
||||
} else {
|
||||
bool wokeThreads = false;
|
||||
std::vector<SceUID>::iterator iter, end;
|
||||
for (iter = mutex->waitingThreads.begin(), end = mutex->waitingThreads.end(); iter != end; ++iter)
|
||||
@@ -776,10 +770,8 @@ int sceKernelDeleteLwMutex(u32 workareaPtr)
|
||||
if (wokeThreads)
|
||||
hleReSchedule("lwmutex deleted");
|
||||
|
||||
return kernelObjects.Destroy<LwMutex>(mutex->GetUID());
|
||||
return hleLogDebugOrError(Log::sceKernel, kernelObjects.Destroy<LwMutex>(mutex->GetUID()));
|
||||
}
|
||||
else
|
||||
return error;
|
||||
}
|
||||
|
||||
static bool __KernelLockLwMutex(NativeLwMutexWorkarea *workarea, int count, u32 &error)
|
||||
|
||||
@@ -276,31 +276,26 @@ int sceKernelReferSemaStatus(SceUID id, u32 infoPtr) {
|
||||
}
|
||||
}
|
||||
|
||||
int sceKernelSignalSema(SceUID id, int signal)
|
||||
{
|
||||
int sceKernelSignalSema(SceUID id, int signal) {
|
||||
u32 error;
|
||||
PSPSemaphore *s = kernelObjects.Get<PSPSemaphore>(id, error);
|
||||
if (s)
|
||||
{
|
||||
if (s->ns.currentCount + signal - (int) s->waitingThreads.size() > s->ns.maxCount)
|
||||
{
|
||||
VERBOSE_LOG(Log::sceKernel, "sceKernelSignalSema(%i, %i): overflow (at %i)", id, signal, s->ns.currentCount);
|
||||
return SCE_KERNEL_ERROR_SEMA_OVF;
|
||||
if (!s) {
|
||||
return hleLogError(Log::sceKernel, error);
|
||||
} else {
|
||||
if (s->ns.currentCount + signal - (int) s->waitingThreads.size() > s->ns.maxCount) {
|
||||
return hleLogDebug(Log::sceKernel, SCE_KERNEL_ERROR_SEMA_OVF, "overflow at %d", s->ns.currentCount);
|
||||
}
|
||||
|
||||
int oldval = s->ns.currentCount;
|
||||
s->ns.currentCount += signal;
|
||||
DEBUG_LOG(Log::sceKernel, "sceKernelSignalSema(%i, %i) (count: %i -> %i)", id, signal, oldval, s->ns.currentCount);
|
||||
|
||||
if ((s->ns.attr & PSP_SEMA_ATTR_PRIORITY) != 0)
|
||||
std::stable_sort(s->waitingThreads.begin(), s->waitingThreads.end(), __KernelThreadSortPriority);
|
||||
|
||||
bool wokeThreads = false;
|
||||
retry:
|
||||
for (auto iter = s->waitingThreads.begin(), end = s->waitingThreads.end(); iter != end; ++iter)
|
||||
{
|
||||
if (__KernelUnlockSemaForThread(s, *iter, error, 0, wokeThreads))
|
||||
{
|
||||
for (auto iter = s->waitingThreads.begin(), end = s->waitingThreads.end(); iter != end; ++iter) {
|
||||
if (__KernelUnlockSemaForThread(s, *iter, error, 0, wokeThreads)) {
|
||||
s->waitingThreads.erase(iter);
|
||||
goto retry;
|
||||
}
|
||||
@@ -310,17 +305,11 @@ retry:
|
||||
hleReSchedule("semaphore signaled");
|
||||
|
||||
hleEatCycles(900);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_LOG(Log::sceKernel, "sceKernelSignalSema(%i, %i): invalid semaphore", id, signal);
|
||||
return error;
|
||||
return hleLogDebug(Log::sceKernel, 0, "sceKernelSignalSema(%i, %i) (count: %i -> %i)", id, signal, oldval, s->ns.currentCount);
|
||||
}
|
||||
}
|
||||
|
||||
void __KernelSemaTimeout(u64 userdata, int cycleslate)
|
||||
{
|
||||
void __KernelSemaTimeout(u64 userdata, int cycleslate) {
|
||||
SceUID threadID = (SceUID)userdata;
|
||||
u32 error;
|
||||
SceUID uid = __KernelGetWaitID(threadID, WAITTYPE_SEMA, error);
|
||||
@@ -356,8 +345,7 @@ static void __KernelSetSemaTimeout(PSPSemaphore *s, u32 timeoutPtr) {
|
||||
CoreTiming::ScheduleEvent(usToCycles(micro), semaWaitTimer, __KernelGetCurThread());
|
||||
}
|
||||
|
||||
static int __KernelWaitSema(SceUID id, int wantedCount, u32 timeoutPtr, bool processCallbacks)
|
||||
{
|
||||
static int __KernelWaitSema(SceUID id, int wantedCount, u32 timeoutPtr, bool processCallbacks) {
|
||||
hleEatCycles(900);
|
||||
|
||||
if (wantedCount <= 0)
|
||||
@@ -392,59 +380,33 @@ static int __KernelWaitSema(SceUID id, int wantedCount, u32 timeoutPtr, bool pro
|
||||
return error;
|
||||
}
|
||||
|
||||
int sceKernelWaitSema(SceUID id, int wantedCount, u32 timeoutPtr)
|
||||
{
|
||||
int sceKernelWaitSema(SceUID id, int wantedCount, u32 timeoutPtr) {
|
||||
int result = __KernelWaitSema(id, wantedCount, timeoutPtr, false);
|
||||
if (result == (int)SCE_KERNEL_ERROR_ILLEGAL_COUNT)
|
||||
DEBUG_LOG(Log::sceKernel, "SCE_KERNEL_ERROR_ILLEGAL_COUNT=sceKernelWaitSema(%i, %i, %i)", id, wantedCount, timeoutPtr);
|
||||
else if (result == 0)
|
||||
DEBUG_LOG(Log::sceKernel, "0=sceKernelWaitSema(%i, %i, %i)", id, wantedCount, timeoutPtr);
|
||||
else
|
||||
DEBUG_LOG(Log::sceKernel, "%08x=sceKernelWaitSema(%i, %i, %i)", result, id, wantedCount, timeoutPtr);
|
||||
return result;
|
||||
return hleLogDebugOrError(Log::sceKernel, result);
|
||||
}
|
||||
|
||||
int sceKernelWaitSemaCB(SceUID id, int wantedCount, u32 timeoutPtr)
|
||||
{
|
||||
int sceKernelWaitSemaCB(SceUID id, int wantedCount, u32 timeoutPtr) {
|
||||
int result = __KernelWaitSema(id, wantedCount, timeoutPtr, true);
|
||||
if (result == (int)SCE_KERNEL_ERROR_ILLEGAL_COUNT)
|
||||
DEBUG_LOG(Log::sceKernel, "SCE_KERNEL_ERROR_ILLEGAL_COUNT=sceKernelWaitSemaCB(%i, %i, %i)", id, wantedCount, timeoutPtr);
|
||||
else if (result == 0)
|
||||
DEBUG_LOG(Log::sceKernel, "0=sceKernelWaitSemaCB(%i, %i, %i)", id, wantedCount, timeoutPtr);
|
||||
else
|
||||
DEBUG_LOG(Log::sceKernel, "%08x=sceKernelWaitSemaCB(%i, %i, %i)", result, id, wantedCount, timeoutPtr);
|
||||
return result;
|
||||
return hleLogDebugOrError(Log::sceKernel, result);
|
||||
}
|
||||
|
||||
// Should be same as WaitSema but without the wait, instead returning SCE_KERNEL_ERROR_SEMA_ZERO
|
||||
int sceKernelPollSema(SceUID id, int wantedCount)
|
||||
{
|
||||
if (wantedCount <= 0)
|
||||
{
|
||||
DEBUG_LOG(Log::sceKernel, "SCE_KERNEL_ERROR_ILLEGAL_COUNT=sceKernelPollSema(%i, %i)", id, wantedCount);
|
||||
return (int)SCE_KERNEL_ERROR_ILLEGAL_COUNT;
|
||||
int sceKernelPollSema(SceUID id, int wantedCount) {
|
||||
if (wantedCount <= 0) {
|
||||
return hleLogError(Log::sceKernel, SCE_KERNEL_ERROR_ILLEGAL_COUNT);
|
||||
}
|
||||
|
||||
u32 error;
|
||||
PSPSemaphore *s = kernelObjects.Get<PSPSemaphore>(id, error);
|
||||
if (s)
|
||||
{
|
||||
if (s->ns.currentCount >= wantedCount && s->waitingThreads.size() == 0)
|
||||
{
|
||||
DEBUG_LOG(Log::sceKernel, "0=sceKernelPollSema(%i, %i)", id, wantedCount);
|
||||
s->ns.currentCount -= wantedCount;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_LOG(Log::sceKernel, "SCE_KERNEL_ERROR_SEMA_ZERO=sceKernelPollSema(%i, %i)", id, wantedCount);
|
||||
return SCE_KERNEL_ERROR_SEMA_ZERO;
|
||||
}
|
||||
if (!s) {
|
||||
return hleLogError(Log::sceKernel, error, "invalid semaphore");
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_LOG(Log::sceKernel, "sceKernelPollSema(%i, %i): invalid semaphore", id, wantedCount);
|
||||
return error;
|
||||
|
||||
if (s->ns.currentCount >= wantedCount && s->waitingThreads.size() == 0) {
|
||||
s->ns.currentCount -= wantedCount;
|
||||
return hleLogDebug(Log::sceKernel, 0);
|
||||
} else {
|
||||
return hleLogError(Log::sceKernel, SCE_KERNEL_ERROR_SEMA_ZERO);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -452,23 +414,21 @@ int sceKernelPollSema(SceUID id, int wantedCount)
|
||||
// exposed through the confusingly named "sceUtilsBufferCopyWithRange" name, which Sony placed in the
|
||||
// not-at-all-suspicious "semaphore" library, which has nothing to do with semaphores.
|
||||
|
||||
static u32 sceUtilsBufferCopyWithRange(u32 outAddr, int outSize, u32 inAddr, int inSize, int cmd)
|
||||
{
|
||||
static u32 sceUtilsBufferCopyWithRange(u32 outAddr, int outSize, u32 inAddr, int inSize, int cmd) {
|
||||
u8 *outAddress = Memory::IsValidRange(outAddr, outSize) ? Memory::GetPointerWriteUnchecked(outAddr) : nullptr;
|
||||
const u8 *inAddress = Memory::IsValidRange(inAddr, inSize) ? Memory::GetPointerUnchecked(inAddr) : nullptr;
|
||||
int temp = kirk_sceUtilsBufferCopyWithRange(outAddress, outSize, inAddress, inSize, cmd);
|
||||
if (temp != 0) {
|
||||
ERROR_LOG(Log::sceKernel, "hleUtilsBufferCopyWithRange: Failed with %d", temp);
|
||||
}
|
||||
return 0;
|
||||
return hleNoLog(0);
|
||||
}
|
||||
|
||||
// Note sure what difference there is between this and sceUtilsBufferCopyWithRange.
|
||||
static int sceUtilsBufferCopyByPollingWithRange(u32 outAddr, int outSize, u32 inAddr, int inSize, int cmd)
|
||||
{
|
||||
static int sceUtilsBufferCopyByPollingWithRange(u32 outAddr, int outSize, u32 inAddr, int inSize, int cmd) {
|
||||
u8 *outAddress = Memory::IsValidRange(outAddr, outSize) ? Memory::GetPointerWriteUnchecked(outAddr) : nullptr;
|
||||
const u8 *inAddress = Memory::IsValidRange(inAddr, inSize) ? Memory::GetPointerUnchecked(inAddr) : nullptr;
|
||||
return kirk_sceUtilsBufferCopyWithRange(outAddress, outSize, inAddress, inSize, cmd);
|
||||
return hleNoLog(kirk_sceUtilsBufferCopyWithRange(outAddress, outSize, inAddress, inSize, cmd));
|
||||
}
|
||||
|
||||
const HLEFunction semaphore[] = {
|
||||
|
||||
@@ -380,10 +380,10 @@ public:
|
||||
void GetQuickInfo(char *ptr, int size) override {
|
||||
snprintf(ptr, size, "pc= %08x sp= %08x %s %s %s %s %s %s (wt=%i wid=%i wv= %08x )",
|
||||
context.pc, context.r[MIPS_REG_SP],
|
||||
(nt.status & THREADSTATUS_RUNNING) ? "RUN" : "",
|
||||
(nt.status & THREADSTATUS_READY) ? "READY" : "",
|
||||
(nt.status & THREADSTATUS_WAIT) ? "WAIT" : "",
|
||||
(nt.status & THREADSTATUS_SUSPEND) ? "SUSPEND" : "",
|
||||
(nt.status & THREADSTATUS_RUNNING) ? "RUN" : "",
|
||||
(nt.status & THREADSTATUS_READY) ? "READY" : "",
|
||||
(nt.status & THREADSTATUS_WAIT) ? "WAIT" : "",
|
||||
(nt.status & THREADSTATUS_SUSPEND) ? "SUSPEND" : "",
|
||||
(nt.status & THREADSTATUS_DORMANT) ? "DORMANT" : "",
|
||||
(nt.status & THREADSTATUS_DEAD) ? "DEAD" : "",
|
||||
(int)nt.waitType,
|
||||
@@ -1904,7 +1904,7 @@ PSPThread *__KernelCreateThreadObject(SceUID &id, SceUID moduleId, const char *n
|
||||
return t;
|
||||
}
|
||||
|
||||
SceUID __KernelSetupRootThread(SceUID moduleID, int args, const char *argp, int prio, int stacksize, int attr)
|
||||
SceUID __KernelSetupRootThread(SceUID moduleID, int args, const char *argp, int prio, int stacksize, int attr)
|
||||
{
|
||||
//grab mips regs
|
||||
SceUID id;
|
||||
@@ -1985,7 +1985,7 @@ int __KernelCreateThread(const char *threadName, SceUID moduleID, u32 entry, u32
|
||||
if ((attr & PSP_THREAD_ATTR_KERNEL) == 0) {
|
||||
if (allowKernel && (attr & PSP_THREAD_ATTR_USER) == 0) {
|
||||
attr |= PSP_THREAD_ATTR_KERNEL;
|
||||
} else {
|
||||
} else {
|
||||
attr |= PSP_THREAD_ATTR_USER;
|
||||
}
|
||||
}
|
||||
@@ -2663,21 +2663,20 @@ int sceKernelSleepThreadCB() {
|
||||
return __KernelSleepThread(true);
|
||||
}
|
||||
|
||||
int sceKernelWaitThreadEnd(SceUID threadID, u32 timeoutPtr)
|
||||
{
|
||||
DEBUG_LOG(Log::sceKernel, "sceKernelWaitThreadEnd(%i, %08x)", threadID, timeoutPtr);
|
||||
int sceKernelWaitThreadEnd(SceUID threadID, u32 timeoutPtr) {
|
||||
if (threadID == 0 || threadID == currentThread)
|
||||
return SCE_KERNEL_ERROR_ILLEGAL_THID;
|
||||
return hleLogError(Log::sceKernel, SCE_KERNEL_ERROR_ILLEGAL_THID);
|
||||
|
||||
if (!__KernelIsDispatchEnabled())
|
||||
return SCE_KERNEL_ERROR_CAN_NOT_WAIT;
|
||||
return hleLogError(Log::sceKernel, SCE_KERNEL_ERROR_CAN_NOT_WAIT);
|
||||
if (__IsInInterrupt())
|
||||
return SCE_KERNEL_ERROR_ILLEGAL_CONTEXT;
|
||||
return hleLogError(Log::sceKernel, SCE_KERNEL_ERROR_ILLEGAL_CONTEXT);
|
||||
|
||||
u32 error;
|
||||
PSPThread *t = kernelObjects.Get<PSPThread>(threadID, error);
|
||||
if (t)
|
||||
{
|
||||
if (!t) {
|
||||
return hleLogError(Log::sceKernel, error, "bad thread ID");
|
||||
} else {
|
||||
if (t->nt.status != THREADSTATUS_DORMANT)
|
||||
{
|
||||
if (Memory::IsValidAddress(timeoutPtr))
|
||||
@@ -2687,30 +2686,24 @@ int sceKernelWaitThreadEnd(SceUID threadID, u32 timeoutPtr)
|
||||
__KernelWaitCurThread(WAITTYPE_THREADEND, threadID, 0, timeoutPtr, false, "thread wait end");
|
||||
}
|
||||
|
||||
return t->nt.exitStatus;
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR_LOG(Log::sceKernel, "sceKernelWaitThreadEnd - bad thread %i", threadID);
|
||||
return error;
|
||||
return hleLogDebug(Log::sceKernel, t->nt.exitStatus);
|
||||
}
|
||||
}
|
||||
|
||||
int sceKernelWaitThreadEndCB(SceUID threadID, u32 timeoutPtr)
|
||||
{
|
||||
DEBUG_LOG(Log::sceKernel, "sceKernelWaitThreadEndCB(%i, 0x%X)", threadID, timeoutPtr);
|
||||
int sceKernelWaitThreadEndCB(SceUID threadID, u32 timeoutPtr) {
|
||||
if (threadID == 0 || threadID == currentThread)
|
||||
return SCE_KERNEL_ERROR_ILLEGAL_THID;
|
||||
return hleLogError(Log::sceKernel, SCE_KERNEL_ERROR_ILLEGAL_THID);
|
||||
|
||||
if (!__KernelIsDispatchEnabled())
|
||||
return SCE_KERNEL_ERROR_CAN_NOT_WAIT;
|
||||
return hleLogError(Log::sceKernel, SCE_KERNEL_ERROR_CAN_NOT_WAIT);
|
||||
if (__IsInInterrupt())
|
||||
return SCE_KERNEL_ERROR_ILLEGAL_CONTEXT;
|
||||
return hleLogError(Log::sceKernel, SCE_KERNEL_ERROR_ILLEGAL_CONTEXT);
|
||||
|
||||
u32 error;
|
||||
PSPThread *t = kernelObjects.Get<PSPThread>(threadID, error);
|
||||
if (t)
|
||||
{
|
||||
if (!t) {
|
||||
return hleLogError(Log::sceKernel, error, "bad thread ID");
|
||||
} else {
|
||||
if (t->nt.status != THREADSTATUS_DORMANT)
|
||||
{
|
||||
if (Memory::IsValidAddress(timeoutPtr))
|
||||
@@ -2724,84 +2717,61 @@ int sceKernelWaitThreadEndCB(SceUID threadID, u32 timeoutPtr)
|
||||
|
||||
return t->nt.exitStatus;
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR_LOG(Log::sceKernel, "sceKernelWaitThreadEndCB - bad thread %i", threadID);
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
int sceKernelReleaseWaitThread(SceUID threadID)
|
||||
{
|
||||
DEBUG_LOG(Log::sceKernel, "sceKernelReleaseWaitThread(%i)", threadID);
|
||||
int sceKernelReleaseWaitThread(SceUID threadID) {
|
||||
if (__KernelInCallback())
|
||||
WARN_LOG_REPORT(Log::sceKernel, "UNTESTED sceKernelReleaseWaitThread() might not do the right thing in a callback");
|
||||
|
||||
if (threadID == 0 || threadID == currentThread)
|
||||
return SCE_KERNEL_ERROR_ILLEGAL_THID;
|
||||
return hleLogError(Log::sceKernel, SCE_KERNEL_ERROR_ILLEGAL_THID);
|
||||
|
||||
u32 error;
|
||||
PSPThread *t = kernelObjects.Get<PSPThread>(threadID, error);
|
||||
if (t)
|
||||
{
|
||||
if (!t) {
|
||||
return hleLogError(Log::sceKernel, error, "bad thread ID");
|
||||
} else {
|
||||
if (!t->isWaiting())
|
||||
return SCE_KERNEL_ERROR_NOT_WAIT;
|
||||
return hleLogError(Log::sceKernel, SCE_KERNEL_ERROR_NOT_WAIT);
|
||||
if (t->nt.waitType == WAITTYPE_HLEDELAY)
|
||||
{
|
||||
WARN_LOG_REPORT_ONCE(rwt_delay, Log::sceKernel, "sceKernelReleaseWaitThread(): Refusing to wake HLE-delayed thread, right thing to do?");
|
||||
return SCE_KERNEL_ERROR_NOT_WAIT;
|
||||
return hleNoLog(SCE_KERNEL_ERROR_NOT_WAIT);
|
||||
}
|
||||
if (t->nt.waitType == WAITTYPE_MODULE)
|
||||
{
|
||||
WARN_LOG_REPORT_ONCE(rwt_sm, Log::sceKernel, "sceKernelReleaseWaitThread(): Refusing to wake start_module thread, right thing to do?");
|
||||
return SCE_KERNEL_ERROR_NOT_WAIT;
|
||||
return hleNoLog(SCE_KERNEL_ERROR_NOT_WAIT);
|
||||
}
|
||||
|
||||
__KernelResumeThreadFromWait(threadID, SCE_KERNEL_ERROR_RELEASE_WAIT);
|
||||
hleReSchedule("thread released from wait");
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR_LOG(Log::sceKernel, "sceKernelReleaseWaitThread - bad thread %i", threadID);
|
||||
return error;
|
||||
return hleLogDebug(Log::sceKernel, 0);
|
||||
}
|
||||
}
|
||||
|
||||
int sceKernelSuspendThread(SceUID threadID)
|
||||
{
|
||||
int sceKernelSuspendThread(SceUID threadID) {
|
||||
// TODO: What about interrupts/callbacks?
|
||||
if (threadID == 0 || threadID == currentThread)
|
||||
{
|
||||
ERROR_LOG(Log::sceKernel, "sceKernelSuspendThread(%d): cannot suspend current thread", threadID);
|
||||
return SCE_KERNEL_ERROR_ILLEGAL_THID;
|
||||
if (threadID == 0 || threadID == currentThread) {
|
||||
return hleLogError(Log::sceKernel, SCE_KERNEL_ERROR_ILLEGAL_THID, "cannot suspend current thread");
|
||||
}
|
||||
|
||||
u32 error;
|
||||
PSPThread *t = kernelObjects.Get<PSPThread>(threadID, error);
|
||||
if (t)
|
||||
{
|
||||
if (t->isStopped())
|
||||
{
|
||||
ERROR_LOG(Log::sceKernel, "sceKernelSuspendThread(%d): thread not running", threadID);
|
||||
return SCE_KERNEL_ERROR_DORMANT;
|
||||
if (!t) {
|
||||
return hleLogError(Log::sceKernel, error, "bad thread ID");
|
||||
} else {
|
||||
if (t->isStopped()) {
|
||||
return hleLogError(Log::sceKernel, SCE_KERNEL_ERROR_DORMANT, "thread not running");
|
||||
}
|
||||
if (t->isSuspended())
|
||||
{
|
||||
ERROR_LOG(Log::sceKernel, "sceKernelSuspendThread(%d): thread already suspended", threadID);
|
||||
return SCE_KERNEL_ERROR_SUSPEND;
|
||||
if (t->isSuspended()) {
|
||||
return hleLogError(Log::sceKernel, SCE_KERNEL_ERROR_SUSPEND, "thread already suspended");
|
||||
}
|
||||
|
||||
DEBUG_LOG(Log::sceKernel, "sceKernelSuspendThread(%d)", threadID);
|
||||
if (t->isReady())
|
||||
__KernelChangeReadyState(t, threadID, false);
|
||||
t->nt.status = (t->nt.status & ~THREADSTATUS_READY) | THREADSTATUS_SUSPEND;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR_LOG(Log::sceKernel, "sceKernelSuspendThread(%d): bad thread", threadID);
|
||||
return error;
|
||||
return hleLogDebug(Log::sceKernel, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2814,7 +2784,7 @@ int sceKernelResumeThread(SceUID threadID) {
|
||||
u32 error;
|
||||
PSPThread *t = kernelObjects.Get<PSPThread>(threadID, error);
|
||||
if (!t) {
|
||||
return hleLogError(Log::sceKernel, error, "bad thread");
|
||||
return hleLogError(Log::sceKernel, error, "bad thread ID");
|
||||
} else {
|
||||
if (!t->isSuspended()) {
|
||||
return hleLogError(Log::sceKernel, SCE_KERNEL_ERROR_NOT_SUSPEND, "sceKernelResumeThread(%d): thread not suspended", threadID);
|
||||
@@ -2973,6 +2943,7 @@ void __KernelReturnFromExtendStack()
|
||||
if (!thread)
|
||||
{
|
||||
ERROR_LOG_REPORT(Log::sceKernel, "__KernelReturnFromExtendStack() - not on a thread?");
|
||||
hleNoLogVoid();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2995,6 +2966,7 @@ void __KernelReturnFromExtendStack()
|
||||
currentMIPS->pc = restorePC;
|
||||
|
||||
// We retain whatever is in v0/v1, it gets passed on to the caller of sceKernelExtendThreadStack().
|
||||
hleNoLogVoid();
|
||||
}
|
||||
|
||||
void ActionAfterMipsCall::run(MipsCall &call) {
|
||||
@@ -3286,15 +3258,13 @@ bool __KernelExecuteMipsCallOnCurrentThread(u32 callId, bool reschedAfter)
|
||||
return true;
|
||||
}
|
||||
|
||||
void __KernelReturnFromMipsCall()
|
||||
{
|
||||
void __KernelReturnFromMipsCall() {
|
||||
hleSkipDeadbeef();
|
||||
|
||||
PSPThread *cur = __GetCurrentThread();
|
||||
if (cur == NULL)
|
||||
{
|
||||
if (!cur) {
|
||||
ERROR_LOG(Log::sceKernel, "__KernelReturnFromMipsCall(): Bad current thread");
|
||||
return;
|
||||
return hleNoLogVoid();
|
||||
}
|
||||
|
||||
u32 callId = cur->currentMipscallId;
|
||||
@@ -3360,6 +3330,7 @@ void __KernelReturnFromMipsCall()
|
||||
}
|
||||
|
||||
delete call;
|
||||
hleNoLogVoid();
|
||||
}
|
||||
|
||||
// First arg must be current thread, passed to avoid perf cost of a lookup.
|
||||
@@ -3389,6 +3360,7 @@ static void __KernelRunCallbackOnThread(SceUID cbId, PSPThread *thread, bool res
|
||||
PSPCallback *cb = kernelObjects.Get<PSPCallback>(cbId, error);
|
||||
if (!cb) {
|
||||
ERROR_LOG(Log::sceKernel, "__KernelRunCallbackOnThread: Bad cbId %i", cbId);
|
||||
hleNoLogVoid();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -3410,6 +3382,7 @@ static void __KernelRunCallbackOnThread(SceUID cbId, PSPThread *thread, bool res
|
||||
ERROR_LOG(Log::sceKernel, "Something went wrong creating a restore action for a callback.");
|
||||
|
||||
__KernelCallAddress(thread, cb->nc.entrypoint, action, args, 3, reschedAfter, cbId);
|
||||
hleNoLogVoid();
|
||||
}
|
||||
|
||||
void ActionAfterCallback::run(MipsCall &call) {
|
||||
@@ -3502,8 +3475,7 @@ bool __KernelCheckCallbacks() {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool __KernelForceCallbacks()
|
||||
{
|
||||
bool __KernelForceCallbacks() {
|
||||
// Let's not check every thread all the time, callbacks are fairly uncommon.
|
||||
if (readyCallbacksCount == 0) {
|
||||
return false;
|
||||
@@ -3522,8 +3494,7 @@ bool __KernelForceCallbacks()
|
||||
}
|
||||
|
||||
// Not wrapped because it has special return logic.
|
||||
void sceKernelCheckCallback()
|
||||
{
|
||||
void sceKernelCheckCallback() {
|
||||
// Start with yes.
|
||||
RETURN(1);
|
||||
|
||||
@@ -3536,6 +3507,7 @@ void sceKernelCheckCallback()
|
||||
RETURN(0);
|
||||
}
|
||||
hleEatCycles(230);
|
||||
hleNoLogVoid();
|
||||
}
|
||||
|
||||
bool __KernelInCallback()
|
||||
@@ -3629,8 +3601,8 @@ int sceKernelRegisterExitCallback(SceUID cbId)
|
||||
{
|
||||
WARN_LOG(Log::sceKernel, "sceKernelRegisterExitCallback(%i): invalid callback id", cbId);
|
||||
if (sceKernelGetCompiledSdkVersion() >= 0x3090500)
|
||||
return SCE_KERNEL_ERROR_ILLEGAL_ARGUMENT;
|
||||
return 0;
|
||||
return hleLogError(Log::sceKernel, SCE_KERNEL_ERROR_ILLEGAL_ARGUMENT);
|
||||
return hleNoLog(0);
|
||||
}
|
||||
|
||||
registeredExitCbId = cbId;
|
||||
@@ -3657,7 +3629,7 @@ int LoadExecForUser_362A956B()
|
||||
if (!Memory::IsValidAddress(parameterArea)) {
|
||||
return hleLogWarning(Log::sceKernel, SCE_KERNEL_ERROR_ILLEGAL_ADDR, "invalid address for parameterArea on userMemory (0x%08X)", parameterArea);
|
||||
}
|
||||
|
||||
|
||||
u32 size = Memory::Read_U32(parameterArea);
|
||||
if (size < 12) {
|
||||
return hleLogWarning(Log::sceKernel, SCE_KERNEL_ERROR_ILLEGAL_SIZE, "invalid parameterArea size %d", size);
|
||||
|
||||
Reference in new issue
Block a user