# HLE versus LLE, frankly ## What a PSP game is - A game is an **encrypted module**. Every Redump UMD image and PSN image checked tonight (9 of 9, the smallest of each set) has a `PSP_GAME/SYSDIR/EBOOT.BIN` that begins `~PSP`, the encrypted container, not `\x7fELF` (census.md; MEASURED by reading the ISO9660 directory inside the zip, nothing extracted). Decrypting it takes keys that live in Sony's firmware and in KIRK's silicon (Copetti, "KIRK"). - Once decrypted it is a relocatable ELF (PRX) that **imports functions by NID** from libraries the kernel provides: pspsdk's stubs alone name 3,151 functions in 101 libraries (counted 2026-11-26 from `src/**/*.S` `IMPORT_FUNC` lines), and commercial games use more (Sony's user libraries in flash0: ATRAC3+, MPEG/PSMF, SAS, fonts, the save and dialog utilities). At load time the kernel replaces each stub with a SYSCALL or a jump into a module (YAPSPD 4.3.2: SCCode, the syscall table). - Games run in **user mode**, among kernel threads, with the kernel handling interrupts, the vblank wait, file I/O, memory partitions, module loading and the ME's codecs (Copetti, "Games"; "Kernel/IPL"). The firmware version a game asks for is in its PARAM.SFO (`PSP_SYSTEM_VER`: 1.00, 3.11, 6.20, 6.30 among the 9 checked). So "the game's behaviour" is the behaviour of **hardware plus a specific firmware**. ## What existing emulators do (OBSERVED; closed boxes, never read) PPSSPP (GPL-2.0+) and JPCSP (GPL-3.0) replace the kernel and Sony's libraries with their own implementations of each NID (high-level emulation), interpret or recompile the game's own code, emulate the GE at the display-list level, and do not run the Media Engine's CPU: its codecs are replaced by host decoders. Both can also load some of Sony's own firmware modules from a player's dump (PPSSPP's AGENTS.md index names a `--disable-hle` mode "that need[s] the real firmware modules" and a VSH boot "against a real firmware dump"; read for its index only). No emulator we know boots the PSP from its boot ROM. ## What "the specification" means when games call the OS The charter has the answer already, in axis B: a **functional** model is the right level for firmware ("firmware and BIOS (the Super Game Boy's SNES program)"), and "a functional model is a modelling choice judged against a lower-level run where one exists". For the PSP that splits the specification in two, each with its own evidence: 1. **The hardware specification**: the Allegrex, caches, memory, the GE, display, audio output, DMA, interrupts. Judges: pspautotests' hardware-facing tests (CPU, FPU, VFPU, GE `gpu/exact` CRCs and frame captures, display, intr, dmac), vfpu-docs' measurements. 2. **The firmware specification**: a functional model of Sony's kernel and libraries **as one firmware version behaves** (proposed: 6.61, the last; pspautotests records on custom firmware 6.60/6.61: its README "6.60 recommended"). Judges: pspautotests' OS-facing tests, recorded on real PSPs: threads 165 outputs, net 109, audio 78, video 37, utility 28, font 21, io 14, sysmem 10, intr 12, modules 12, umd 7, power 6, ... (census of `.expected` files, validation.md). This is **TEST ROM** evidence about the OS, the strongest we can get without running Sony's code ourselves. Every behaviour in (2) carries its tag like any other: an HLE function whose return value is shown by a recorded test is TEST ROM; one written from pspsdk's header comment is DOC; one guessed is HYPOTHESIS. **An HLE call's cost in cycles is never evidence**: it is a FITTED or HYPOTHESIS number, stated per function, and that is said in the README's claims. The tiers' proofs are unchanged: the HLE kernel is part of `psp-python`, transcribed by `psp-rust`, so "every bus cycle identical" still holds between tiers, including the syscalls' effects. "Matches the Python" stays distinct from "matches a PSP running 6.61". ## The honest problems with each choice **LLE (boot ROM -> IPL -> kernel -> game, all of Sony's code on our hardware model):** - It needs **Sony's firmware**, which the family never ships (charter, licences 9): the Pre-IPL ROM (inside Tachyon), the IPL and flash0 from NAND, the keys inside KIRK and SPOCK, and Lepton's 384 KB ROM (Copetti, "Lepton") if the UMD drive is low-level too. A player would have to dump all of it from their own PSP, and the KIRK keys are not in any dump: they are in silicon. - **Our clean evidence cannot carry it.** An LLE board must know every I/O block the kernel touches at register level (NAND controller, syscon serial protocol, the interrupt controller, DMA controllers, the ME's reset and mailbox, the LCD controller, KIRK's command set, the ATA bridge). That knowledge lives on the PSP Developer Wiki (set aside by its robots.txt) and in uOFW (a transcription of Sony's firmware, not read). YAPSPD (2006) has a partial register map. We would be building on sources we have set aside. - **Speed:** the kernel's own code then runs on the emulated Allegrex, and so does the Media Engine's (its codecs at up to 333 MHz): roughly **double the CPU need** of HLE (domains-and-speed.md), on a machine whose single CPU already exceeds the no-JIT budget on phones. - What it would buy: the firmware's exact behaviour, for free, in every library, and a judge for the HLE kernel. **HLE (the specification implements the kernel and Sony's libraries):** - It is large: a hundred libraries and thousands of functions, many with undocumented corners (thread scheduling order, callback delivery, error codes, the SDK-version checks the kernel makes to keep old games' behaviour: U3). - Its timing is invented where a real kernel would spend cycles (U4). - It still needs the **game's executable decrypted**: the HLE loader cannot run `~PSP` without Sony's keys. PPSSPP plays such images, so it must carry the means to decrypt them (HYPOTHESIS from its public behaviour; its source is not read, and we did not run it tonight). **We must not ship them** (Sony's secrets; the same rule as firmware). Decision P2. - Its codecs (ATRAC3/3+, AT3, MP3, AAC, H.264 AVC, PSMF demux) must be MIT-clean. H.264 has permissive decoders (Cisco's openh264, BSD-2-Clause: to be checked); **ATRAC3+ has no permissive implementation we know** (FFmpeg's is LGPL: a closed box). Decision P4. - What it buys: it runs without any of Sony's code except the game; it is the only way the CPU budget can be met on phones; its behaviour is judged by recorded tests. ## The boundary, recommended (decision P1) **HLE at the SYSCALL instruction and at Sony's library NIDs; low-level below them for everything a game touches directly.** - **Low level (the hardware specification):** the main Allegrex with the VFPU and caches; scratchpad, DDR, eDRAM/VRAM with its mirrors; **the GE at register and display-list level** (games build display lists in memory and the GE's DMA walks them: the sceGe calls only enqueue a list, move its stall address and wait; the list's meaning is hardware); display scan-out timing (vblank, hsync); the audio output stream (PCM channels and the SRC channel as the hardware's DMA output, at the kernel's sample granularity); interrupts as the HLE kernel sees them. - **Functional (the firmware specification, `psp_python.kernel` and `psp_python.libs`):** the module loader (decrypted PRX only, P2), threads and their scheduler, synchronisation objects, callbacks, memory partitions, the I/O file manager over the UMD's ISO9660 and a host directory as the Memory Stick, ctrl and power (the syscon's services as the kernel presents them), the utility dialogs (save, message, OSK: with a host-side presentation), the media libraries (decoders as host functions), SAS, fonts, networking stubbed (Wi-Fi is late). - **Not run at all under HLE:** the Media Engine's CPU, the VME, the AVC hardware, KIRK, SPOCK, Lepton, the NAND, the syscon MCU, the boot ROM. Their documents stay in this Phase 0 for the day an LLE row is built. - **Order of record:** the main CPU steps; at SYSCALL the HLE function runs to completion or blocks the thread, charges its stated cost, and the scheduler picks the next thread; the GE runs at its own channel points (list enqueue, stall update, finish/signal interrupts, CPU reads of VRAM); display and audio are producers (domains-and-speed.md). **LLE later, as a judge, not as the product (decision P5).** A `psp-lle` machine row that boots a player's own firmware dump on the same hardware model is worth building only after the HLE board runs games, only if the register-level evidence can be got from sources we may use, and then mainly to judge the HLE kernel against Sony's (the Super Game Boy precedent). The I/O blocks it needs are listed in memory-map.md with what we know of each.