feat(libkernel): export sceKernelGetMainSocId, sceKernelGetCpumode and sceKernelGetCpuFrequency #4466

Merged
babyhuey merged 1 commit from upstream-pr/4466 into main 2026-10-12 18:27:29 +00:00
babyhuey commented 2026-10-12 12:35:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-12T12:35:41Z.


What

Exports three libkernel calls that PS5SX2 (PPSA99203) imports and only prints at start-up:

  • sceKernelGetMainSocId (0vTn5IDMU9A) and sceKernelGetCpumode (VOx8NGmHXTs) return 0. This is a silent stub, listed in TechnicalDebt.
    • The PS5's SoC id and CPU mode are not known.
    • shadPS4's PS4 values (0x710f10/0x740f30; 0, 2 or 5 from param.sfo) would be wrong for a PS5.
  • sceKernelGetCpuFrequency (iUohlUDiGac) returns the host TSC frequency already measured for sceKernelGetTscFrequency.
    • The signature long sceKernelGetCpuFrequency(void) is from the ps5-payload-dev SDK's samples/hwinfo.

The names are the ones tools/nid_names.py's aerolib list (zecoxao/sce_symbols@2883963) gives for these NIDs.

PS5SX2 calls them in one block:

  • sceKernelGetMainSocId(&id) on a zeroed int
  • sceKernelGetCpuFrequency()
  • sceKernelGetCpumode()

It then logs [console] main SoC id: result=%#x out=%#x and [console] CPU: %llu Hz, cpumode %d, and builds a status string from them. No branch depends on the values. The title then calibrates the TSC itself with rdtsc against a 50 ms wait.

PS5SX2 relinks only with --trap-sdk-syscall-stubs (#3804, see #2136), which the runs below use.

  • On main ffa19840 it stops at the first call:
    • Linux: undefined symbol: 0vTn5IDMU9A
    • Windows: FAIL: unresolved ELF import 0vTn5IDMU9A from libkernel.prx
  • With this PR, all three resolve and the next stop is setitimer (#4382, #3800) on both:
    • Linux: undefined symbol: hPWDGx8ioXQ (setitimer)
    • Windows: FAIL: unresolved ELF import hPWDGx8ioXQ (setitimer) from libkernel.prx

Tested

Linux (Ubuntu 24.04, GCC 13) and Windows 11 (MinGW-w64 GCC 15.2 from WinLibs), Release: guest_current_cpu passes 5/5 (--repeat until-fail:5) on both. No warnings in Process.cpp, Time.cpp or GuestCurrentCpu.cpp. The new checks:

  • the two stubs return 0
  • sceKernelGetCpuFrequency is positive and equal to sceKernelGetTscFrequency

check_conventions.py 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 in TechnicalDebt
  • 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
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4829491053 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4466). Originally posted by [babyhuey](https://github.com/babyhuey) on 2026-10-12T12:35:41Z. --- ### What Exports three libkernel calls that PS5SX2 (PPSA99203) imports and only prints at start-up: - `sceKernelGetMainSocId` (`0vTn5IDMU9A`) and `sceKernelGetCpumode` (`VOx8NGmHXTs`) return 0. This is a silent stub, listed in TechnicalDebt. - The PS5's SoC id and CPU mode are not known. - shadPS4's PS4 values (`0x710f10`/`0x740f30`; 0, 2 or 5 from param.sfo) would be wrong for a PS5. - `sceKernelGetCpuFrequency` (`iUohlUDiGac`) returns the host TSC frequency already measured for `sceKernelGetTscFrequency`. - The signature `long sceKernelGetCpuFrequency(void)` is from the ps5-payload-dev SDK's `samples/hwinfo`. The names are the ones `tools/nid_names.py`'s aerolib list (`zecoxao/sce_symbols@2883963`) gives for these NIDs. PS5SX2 calls them in one block: - `sceKernelGetMainSocId(&id)` on a zeroed `int` - `sceKernelGetCpuFrequency()` - `sceKernelGetCpumode()` It then logs `[console] main SoC id: result=%#x out=%#x` and `[console] CPU: %llu Hz, cpumode %d`, and builds a status string from them. No branch depends on the values. The title then calibrates the TSC itself with `rdtsc` against a 50 ms wait. PS5SX2 relinks only with `--trap-sdk-syscall-stubs` (#3804, see #2136), which the runs below use. - On `main` ffa19840 it stops at the first call: - Linux: `undefined symbol: 0vTn5IDMU9A` - Windows: `FAIL: unresolved ELF import 0vTn5IDMU9A from libkernel.prx` - With this PR, all three resolve and the next stop is `setitimer` (#4382, #3800) on both: - Linux: `undefined symbol: hPWDGx8ioXQ (setitimer)` - Windows: `FAIL: unresolved ELF import hPWDGx8ioXQ (setitimer) from libkernel.prx` ### Tested Linux (Ubuntu 24.04, GCC 13) and Windows 11 (MinGW-w64 GCC 15.2 from WinLibs), Release: `guest_current_cpu` passes 5/5 (`--repeat until-fail:5`) on both. No warnings in `Process.cpp`, `Time.cpp` or `GuestCurrentCpu.cpp`. The new checks: - the two stubs return 0 - `sceKernelGetCpuFrequency` is positive and equal to `sceKernelGetTscFrequency` `check_conventions.py` passes. ### Checklist - [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 in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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] AI-assisted: yes
github-actions[bot] commented 2026-10-12 12:36:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-12T12:36:05Z.


Progress report (0ef9dc9 → 4e3aa15)

📈 System libraries: 86.26% (+0.01%, +3 implemented functions)

✅ 3 implemented
Library Name
libkernel sceKernelGetCpuFrequency
libkernel sceKernelGetCpumode
libkernel sceKernelGetMainSocId
⚪ 2 behaviourally empty (constant return or throw)
Library Name
libkernel sceKernelGetCpumode
libkernel sceKernelGetMainSocId
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6124381949 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4466#issuecomment-6124381949). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-12T12:36:05Z. --- <!-- progress-report --> ### Progress report (0ef9dc9 → 4e3aa15) 📈 **System libraries**: 86.26% (+0.01%, +3 implemented functions) <details> <summary>✅ 3 implemented</summary> | Library | Name | | - | - | | libkernel | `sceKernelGetCpuFrequency` | | libkernel | `sceKernelGetCpumode` | | libkernel | `sceKernelGetMainSocId` | </details> <details> <summary>⚪ 2 behaviourally empty (constant return or throw)</summary> | Library | Name | | - | - | | libkernel | `sceKernelGetCpumode` | | libkernel | `sceKernelGetMainSocId` | </details>
github-actions[bot] commented 2026-10-12 16:40:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-12T16:40:29Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#4588 sceKernelGetCpuFrequency
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6128529661 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4466#issuecomment-6128529661). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-12T16:40:29Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #4588 | | `sceKernelGetCpuFrequency` | |
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!4466
No description provided.