feat(libkernel): implement sceKernelHasTrinityMode for a base PS5 #13769

Merged
Flamefusion merged 2 commits from upstream-pr/13769 into main 2026-10-31 23:54:51 +00:00
Flamefusion commented 2026-10-31 05:11:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Flamefusion on 2026-10-31T05:11:39Z.


What

sceKernelHasTrinityMode threw: it existed only as a parameterless placeholder in the libkernel_sys inventory. It now returns 0, a base PS5's answer, from libkernel next to sceKernelIsTrinityMode, which already returns 0.

  • Behaviour. Two public readings of firmware libkernel:
    • Backport FINDINGS.md L246 (firmware 11.00 to 12.70) says it reads the sysctl hw.sce_main_socid. The masked comparison stated there is for sceKernelIsTrinityMode.
    • OpenAGC driver_prospero.c L333-L340 (firmware 11.60) gives the test for sceKernelHasTrinityMode: the four-byte id with its low five bits cleared, compared with 0x840fc0.
    • The base PS5 SoC id recorded in the sceKernelGetMainSocId debt entry (0x840f80, CFI-2014, firmware 13.60) fails that test.
    • Not measured on a console, and I did not read the module myself. A PS5 Pro is not modelled, as for sceKernelIsTrinityMode.
  • Prototype. int (void) comes from the 23 calls in RuneScape: Dragonwilds (PPSA34114 01.000.005), for example 0x8837e3, 0x67db227 and 0x78dfa9e. Each one sets up a function-local static:
    call __cxa_guard_acquire ; test eax,eax ; je ...
    call sceKernelHasTrinityMode      ; no argument register set
    test eax,eax
    setne byte [static]
    call __cxa_guard_release
    
  • Library. That title imports it from libkernel (yu17wG8L5FI#4#J). Before this change only libkernel_sys exported it, which import_audit.py reports as a library_mismatch. The placeholder, its inventory row and the inventory counts are set to what AdditionalExports.cpp holds: 325 entries, 165 named and 160 NID aliases. Since #13129 merged, main has said 326 in the first paragraph and still 328 and 168 in the identity paragraph; both now give the counted values.

Overlap: pr_overlap.py finds no conflicting lines or shared exports. Of the PRs it could not compare (they conflict with main), I checked those touching the changed code files by hand (#5021, #7804, #9242, #9297, #9302, #11215, #11628, #11661, #11689, #11698, #11939, #12925); none touches sceKernelHasTrinityMode or sceKernelIsTrinityMode.

Tested

Windows 11 (build 26300), WinLibs GCC 15.2.0, Release, on main 18f5949788 (rebased; the first runs were on d3118d1946).

  • guest_operation_mode checks sceKernelHasTrinityMode() == 0 and passes. On d3118d1946 all 91 guest_kernel_sys*, guest_current_cpu and guest_operation_mode tests passed. After the rebase onto 18f5949788, guest_operation_mode, guest_current_cpu, guest_kernel_sys, guest_kernel_sys_neo_mode, guest_kernel_sys_cpumode, guest_kernel_sys_constants and the 65 public_headers tests pass (71/71).
  • RuneScape: Dragonwilds (PPSA34114 01.000.005) on an RTX 3050 Laptop GPU (driver 621.01). On main it aborts about 7 s after start with sceKernelHasTrinityMode not implemented. With this change it gets past that point, creates the Vulkan device, compiles about 900 shaders and mounts save data. It then stops 26 s in at sceHttp2SetRedirectCallback not implemented, which #11575 implements.
  • check_conventions.py --base upstream/main passes.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: PPSA34114 #13768
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5094785614 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13769). Originally posted by [Flamefusion](https://github.com/Flamefusion) on 2026-10-31T05:11:39Z. --- ### What `sceKernelHasTrinityMode` threw: it existed only as a parameterless placeholder in the `libkernel_sys` inventory. It now returns 0, a base PS5's answer, from libkernel next to `sceKernelIsTrinityMode`, which already returns 0. - **Behaviour.** Two public readings of firmware `libkernel`: - [Backport `FINDINGS.md` L246](https://github.com/danthespal/Backport/blob/5ba843c5ea51caad30ac05e830302bc1b8707f3c/FINDINGS.md?plain=1#L246) (firmware 11.00 to 12.70) says it reads the sysctl `hw.sce_main_socid`. The masked comparison stated there is for `sceKernelIsTrinityMode`. - [OpenAGC `driver_prospero.c` L333-L340](https://github.com/OpenAGC/OpenAGC/blob/03484809c29fee4dc9fc3a4d61743749899ef5ca/src/driver_prospero.c#L333-L340) (firmware 11.60) gives the test for `sceKernelHasTrinityMode`: the four-byte id with its low five bits cleared, compared with 0x840fc0. - The base PS5 SoC id recorded in the `sceKernelGetMainSocId` debt entry (0x840f80, CFI-2014, firmware 13.60) fails that test. - Not measured on a console, and I did not read the module myself. A PS5 Pro is not modelled, as for `sceKernelIsTrinityMode`. - **Prototype.** `int (void)` comes from the 23 calls in RuneScape: Dragonwilds (PPSA34114 01.000.005), for example 0x8837e3, 0x67db227 and 0x78dfa9e. Each one sets up a function-local static: ``` call __cxa_guard_acquire ; test eax,eax ; je ... call sceKernelHasTrinityMode ; no argument register set test eax,eax setne byte [static] call __cxa_guard_release ``` - **Library.** That title imports it from `libkernel` (`yu17wG8L5FI#4#J`). Before this change only `libkernel_sys` exported it, which `import_audit.py` reports as a `library_mismatch`. The placeholder, its inventory row and the inventory counts are set to what `AdditionalExports.cpp` holds: 325 entries, 165 named and 160 NID aliases. Since #13129 merged, `main` has said 326 in the first paragraph and still 328 and 168 in the identity paragraph; both now give the counted values. Overlap: `pr_overlap.py` finds no conflicting lines or shared exports. Of the PRs it could not compare (they conflict with `main`), I checked those touching the changed code files by hand (#5021, #7804, #9242, #9297, #9302, #11215, #11628, #11661, #11689, #11698, #11939, #12925); none touches `sceKernelHasTrinityMode` or `sceKernelIsTrinityMode`. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Windows 11 (build 26300), WinLibs GCC 15.2.0, Release, on `main` `18f5949788` (rebased; the first runs were on `d3118d1946`). - `guest_operation_mode` checks `sceKernelHasTrinityMode() == 0` and passes. On `d3118d1946` all 91 `guest_kernel_sys*`, `guest_current_cpu` and `guest_operation_mode` tests passed. After the rebase onto `18f5949788`, `guest_operation_mode`, `guest_current_cpu`, `guest_kernel_sys`, `guest_kernel_sys_neo_mode`, `guest_kernel_sys_cpumode`, `guest_kernel_sys_constants` and the 65 `public_headers` tests pass (71/71). - RuneScape: Dragonwilds (PPSA34114 01.000.005) on an RTX 3050 Laptop GPU (driver 621.01). On `main` it aborts about 7 s after start with `sceKernelHasTrinityMode not implemented`. With this change it gets past that point, creates the Vulkan device, compiles about 900 shaders and mounts save data. It then stops 26 s in at `sceHttp2SetRedirectCallback not implemented`, which #11575 implements. - `check_conventions.py --base upstream/main` passes. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: PPSA34114 #13768 - [x] GPUs tested: n/a - [x] AI-assisted: yes
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!13769
No description provided.