Skip to content

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

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
babyhuey:feat/libkernel-socid-cpumode
Oct 12, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
babyhuey:feat/libkernel-socid-cpumode

Conversation

@babyhuey

@babyhuey babyhuey commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

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.

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

@github-actions

Copy link
Copy Markdown

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

@github-actions

Copy link
Copy Markdown

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

@oneandonlydean
oneandonlydean merged commit 60f4c71 into boykopovar:main Oct 12, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants