From a1b4a93cac1e82207c31ac238fcbc839acb6777a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 21 Oct 2026 02:28:10 +0200 Subject: [PATCH] HLE: Resolve the kernel sceKernelAllocateFpl It was left unresolved with the kernel mutex calls, as they all let the flash drivers reach the NAND controller during a VSH boot. It's the mutexes that do that: with only the FPL resolved, sceIdStorage_Service allocates from its pool and every firmware's VSH in 1.50-6.61 boots to the same XMB picture as without it. Resolving the mutexes still hangs on 0xbd101300. Co-Authored-By: Claude Opus 5.5 (1M context) --- Core/HLE/sceKernel.cpp | 21 ++++++++++++--------- docs/VSHBootInvestigation.md | 12 +++++++----- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/Core/HLE/sceKernel.cpp b/Core/HLE/sceKernel.cpp index edfe17bb94..037b1b3b80 100644 --- a/Core/HLE/sceKernel.cpp +++ b/Core/HLE/sceKernel.cpp @@ -1014,15 +1014,18 @@ const HLEFunction ThreadManForKernel[] = {0x5F32BEAA, &WrapU_IU, "sceKernelReferVTimerStatus", 'x', "ix", HLE_KERNEL_SYSCALL }, // Yabause-PSP's me.prx. {0x30FD48F0, &WrapI_IUUU, "sceKernelPollEventFlag", 'i', "ixxp", HLE_KERNEL_SYSCALL }, - // NOT added on purpose, even though we implement all four for user mode already: - // sceKernelCreateMutex (0xB7D098C6), sceKernelLockMutex (0xB011B11F), sceKernelUnlockMutex - // (0x6B30100F) and sceKernelAllocateFpl (0xD979E9BF). They are what the real flash0 NAND and - // ID storage drivers use to set themselves up while booting the VSH, and leaving them - // unresolved is load-bearing: the drivers fail their init early and the boot moves on. Resolve - // them and the drivers instead get all the way through to talking to the NAND controller, which - // we don't emulate - sceIdStorage_Service then polls 0xbd101300 forever, no plugin module ever - // starts, and the boot is dead where it used to reach the shell. Adding these needs NAND MMIO - // (or HLE'ing sceIdStorage/sceNand above the driver) to land first. + {0XD979E9BF, &WrapI_IUU, "sceKernelAllocateFpl", 'i', "ixx", HLE_NOT_IN_INTERRUPT | HLE_NOT_DISPATCH_SUSPENDED | HLE_KERNEL_SYSCALL }, + // HACK WARNING! + // + // NOT added on purpose, even though we implement all three for user mode already: + // sceKernelCreateMutex (0xB7D098C6), sceKernelLockMutex (0xB011B11F) and sceKernelUnlockMutex + // (0x6B30100F). They are what the real flash0 NAND and ID storage drivers use to set themselves + // up while booting the VSH, and leaving them unresolved is load-bearing: the drivers fail their + // init early and the boot moves on. Resolve them and the drivers instead get all the way through + // to talking to the NAND controller, which we don't emulate - sceIdStorage_Service then polls + // 0xbd101300 forever, no plugin module ever starts, and the boot is dead where it used to reach + // the shell. Adding these needs NAND MMIO (or HLE'ing sceIdStorage/sceNand above the driver) to + // land first. sceKernelAllocateFpl (below) was in this list, but the boot reaches the XMB with it. }; void Register_ThreadManForUser() diff --git a/docs/VSHBootInvestigation.md b/docs/VSHBootInvestigation.md index 245c11c8ee..8f6f9feadd 100644 --- a/docs/VSHBootInvestigation.md +++ b/docs/VSHBootInvestigation.md @@ -379,11 +379,13 @@ boot *worse*, because a correct implementation lets a real flash0 driver finish on into hardware PPSSPP does not emulate. Leaving the import unresolved makes the driver fail early and the boot continues. All three are commented in the source at the point where they'd be added: -- **`ThreadManForKernel` mutex/fpl NIDs** (`0xB7D098C6` `sceKernelCreateMutex`, `0xB011B11F` - `sceKernelLockMutex`, `0x6B30100F` `sceKernelUnlockMutex`, `0xD979E9BF` `sceKernelAllocateFpl`) - - we implement all four for user mode already. Resolve them and the NAND and ID storage drivers - init successfully, then `sceIdStorage_Service` polls the NAND controller at `0xbd101300` forever. - No module starts. +- **`ThreadManForKernel` mutex NIDs** (`0xB7D098C6` `sceKernelCreateMutex`, `0xB011B11F` + `sceKernelLockMutex`, `0x6B30100F` `sceKernelUnlockMutex`) - we implement all three for user + mode already. Resolve them and the NAND and ID storage drivers init successfully, then + `sceIdStorage_Service` polls the NAND controller at `0xbd101300` forever (470k reads in 25 + emulated seconds), and only 4 modules start. `sceKernelAllocateFpl` (`0xD979E9BF`) used to be on + this list, but it's the mutexes that do it: with only the FPL resolved, `sceIdStorage_Service` + allocates from its pool and the boot still reaches the XMB. - **`InterruptManagerForKernel` interrupt registration** (`0x58DD8978`, `0xF987B1F0`, `0x4D6E7305`, `0xD774BA45`) - JPCSP can honour these because it emulates the interrupt controller as MMIO. We dispatch the few interrupts we emulate ourselves (`__RegisterIntrHandler`), so success is a lie