feat(libkernel): export sceKernelGetSocPowerConsumption #5605

Merged
babyhuey merged 1 commit from upstream-pr/5605 into main 2026-10-14 12:51:37 +00:00
babyhuey commented 2026-10-14 00:54:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-14T00:54:15Z.


What

sceKernelGetSocPowerConsumption (CA5jcDb2vYI, libkernel) was absent. It is now exported next to sceKernelGetCpuTemperature and sceKernelGetSocSensorTemperature in ThermalSensors.cpp. It returns EFAULT for a null pointer. Otherwise it returns EINVAL and writes nothing, which is what those two return when the host has no sensor.

The host's package power isn't read. On Linux the RAPL counters (/sys/class/powercap/*/energy_uj) are readable by root only, and Windows has no general source for it. This is listed under Silent stubs in docs/dev/debt/libkernel.md.

The prototype isn't documented. PS5LM Plus calls it with a zeroed 128-byte buffer at guest 0x6117C. On a 0 return it reads the first 32-bit word as milliwatts and accepts 1000 to 350000; otherwise it shows 0 W. So the parameter is a void*, and nothing about the layout is assumed beyond not writing to it.

Tested

On the PR head 31abd1a2 (on main 520ee1a2), Linux (Ubuntu 24.04, GCC 13) and Windows 11 (MinGW-w64 GCC 15.2 from WinLibs), Release:

  • guest_thermal_sensors passes 5/5 (--repeat until-fail:5) on both. The new check covers the null pointer and the EINVAL return with the buffer left untouched.
  • No warnings in ThermalSensors.cpp or GuestThermalSensors.cpp.

PS5LM Plus (PPSA99581, catalog release 0.8.3):

  • On main feddf7f4 it doesn't load. Its only absent import is CA5jcDb2vYI: symbol lookup error on Linux, FAIL: unresolved ELF import on Windows.
  • With this PR every import resolves and it starts. Then it stops on a host standard-output failure, a separate issue (discussion #5601): FileStream: closed stream on Linux, and on Windows UCRT invalid parameter then Formatted output write failed.

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 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 (PS5LM Plus stops here on main)
  • Unblocks: PPSA99581 #5601
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4851410230 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5605). Originally posted by [babyhuey](https://github.com/babyhuey) on 2026-10-14T00:54:15Z. --- ### What `sceKernelGetSocPowerConsumption` (`CA5jcDb2vYI`, libkernel) was absent. It is now exported next to `sceKernelGetCpuTemperature` and `sceKernelGetSocSensorTemperature` in `ThermalSensors.cpp`. It returns `EFAULT` for a null pointer. Otherwise it returns `EINVAL` and writes nothing, which is what those two return when the host has no sensor. The host's package power isn't read. On Linux the RAPL counters (`/sys/class/powercap/*/energy_uj`) are readable by root only, and Windows has no general source for it. This is listed under Silent stubs in `docs/dev/debt/libkernel.md`. The prototype isn't documented. PS5LM Plus calls it with a zeroed 128-byte buffer at guest 0x6117C. On a 0 return it reads the first 32-bit word as milliwatts and accepts 1000 to 350000; otherwise it shows 0 W. So the parameter is a `void*`, and nothing about the layout is assumed beyond not writing to it. ### Tested On the PR head 31abd1a2 (on `main` 520ee1a2), Linux (Ubuntu 24.04, GCC 13) and Windows 11 (MinGW-w64 GCC 15.2 from WinLibs), Release: - `guest_thermal_sensors` passes 5/5 (`--repeat until-fail:5`) on both. The new check covers the null pointer and the `EINVAL` return with the buffer left untouched. - No warnings in `ThermalSensors.cpp` or `GuestThermalSensors.cpp`. PS5LM Plus (PPSA99581, catalog release 0.8.3): - On `main` feddf7f4 it doesn't load. Its only absent import is `CA5jcDb2vYI`: `symbol lookup error` on Linux, `FAIL: unresolved ELF import` on Windows. - With this PR every import resolves and it starts. Then it stops on a host standard-output failure, a separate issue (discussion #5601): `FileStream: closed stream` on Linux, and on Windows `UCRT invalid parameter` then `Formatted output write failed`. `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 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 (PS5LM Plus stops here on `main`) - [x] Unblocks: PPSA99581 #5601 - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-14 00:54:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-14T00:54:58Z.


Progress report (0dea07a → 31abd1a)

📈 System libraries: 88.19% (+0.01%, +1 implemented functions)

✅ 1 implemented
Library Name
libkernel sceKernelGetSocPowerConsumption
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6158435264 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5605#issuecomment-6158435264). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-14T00:54:58Z. --- <!-- progress-report --> ### Progress report (0dea07a → 31abd1a) 📈 **System libraries**: 88.19% (+0.01%, +1 implemented functions) <details> <summary>✅ 1 implemented</summary> | Library | Name | | - | - | | libkernel | `sceKernelGetSocPowerConsumption` | </details>
adriadam10 commented 2026-10-14 12:33:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T12:33:07Z.


Checked the build and ctest on the PR merged onto main: guest_thermal_sensors passes 5/5, and without the change the test fails (the symbol is missing). The null pointer returns EFAULT, otherwise EINVAL with the buffer untouched, and the Silent stubs line in docs/dev/debt/libkernel.md is accurate; merging once the full Build is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6168429589 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5605#issuecomment-6168429589). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-14T12:33:07Z. --- Checked the build and ctest on the PR merged onto main: `guest_thermal_sensors` passes 5/5, and without the change the test fails (the symbol is missing). The null pointer returns `EFAULT`, otherwise `EINVAL` with the buffer untouched, and the Silent stubs line in `docs/dev/debt/libkernel.md` is accurate; merging once the full Build is green.
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!5605
No description provided.