Dialog: Prevent reschedule on shutdown start.

This is a bit strange, but tests seem to suggest this is correct.
A worse priority thread won't run before savedata shutdown hits 0, but the
thread that initiated shutdown runs before shutdown completes.

Fixes Freakout Extreme Freeride loading savedata.
This commit is contained in:
Unknown W. Brackets 2021-08-14 20:15:34 -07:00
parent f01d4d697e
commit f530be0969
5 changed files with 10 additions and 6 deletions

View File

@ -122,7 +122,7 @@ void PSPDialog::ChangeStatusInit(int delayUs) {
void PSPDialog::ChangeStatusShutdown(int delayUs) {
// If we're doing shutdown right away and skipped start, we don't run the dialog thread.
bool skipDialogShutdown = status == SCE_UTILITY_STATUS_NONE;
bool skipDialogShutdown = status == SCE_UTILITY_STATUS_NONE && pendingStatus == SCE_UTILITY_STATUS_NONE;
ChangeStatus(SCE_UTILITY_STATUS_SHUTDOWN, 0);
auto params = GetCommonParam();

View File

@ -40,10 +40,6 @@
#include "GPU/GPUCommon.h"
#include "GPU/GPUState.h"
void __DisableInterrupts();
void __EnableInterrupts();
bool __InterruptsEnabled();
// Seems like some > 16 are taken but not available. Probably kernel only?
static const u32 PSP_NUMBER_SUBINTERRUPTS = 32;

View File

@ -128,6 +128,8 @@ private:
std::map<int, SubIntrHandler> subIntrHandlers;
};
void __DisableInterrupts();
void __EnableInterrupts();
bool __InterruptsEnabled();
bool __IsInInterrupt();
void __InterruptsInit();

View File

@ -2063,7 +2063,8 @@ int __KernelStartThread(SceUID threadToStartID, int argSize, u32 argBlockPtr, bo
Core_ExecException(startThread->context.pc, currentMIPS->pc, ExecExceptionType::THREAD);
}
__KernelChangeReadyState(cur, currentThread, true);
hleReSchedule("thread started");
if (__InterruptsEnabled())
hleReSchedule("thread started");
}
// Starting a thread automatically resumes the dispatch thread if the new thread has worse priority.

View File

@ -35,6 +35,7 @@
#include "Core/System.h"
#include "Core/HLE/sceKernel.h"
#include "Core/HLE/sceKernelInterrupt.h"
#include "Core/HLE/sceKernelMemory.h"
#include "Core/HLE/sceKernelThread.h"
#include "Core/HLE/scePower.h"
@ -325,8 +326,12 @@ void UtilityDialogShutdown(UtilityDialogType type, int delayUs, int priority) {
CleanupDialogThreads();
_assert_(accessThread == nullptr);
bool prevInterrupts = __InterruptsEnabled();
__DisableInterrupts();
accessThread = new HLEHelperThread("ScePafJob", insts, (uint32_t)ARRAY_SIZE(insts), priority, 0x200);
accessThread->Start(partDelay, 0);
if (prevInterrupts)
__EnableInterrupts();
}
static int UtilityWorkUs(int us) {