Repository navigation
feat(padtracker): answer Init, Term, Calibrate and ReadState from the firmware checks - #22349
Conversation
… firmware checks Firmware 13.42 (issue boykopovar#21753): scePadTrackerInit(memA, memB, a, b) refuses memory that is null or not 16 KiB aligned and a outside 0-6 or b outside 0-7, then a second Init, and returns 0 after its tracker setup, whose result it ignores. Calibrate and Term answer 0x80c40001 before Init and 0 after. ReadState refuses a null state and returns 0x80c40004 for a handle no Update recorded, as none does here. Update answers 0x80c40001 before Init and otherwise still throws, since the tracker isn't implemented. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ilds on Windows
MinGW's PE/COFF objects cannot align a static object to more than 8192
bytes, so the two alignas(0x4000) buffers failed to compile on Windows
("requested alignment '16384' exceeds object file maximum 8192"). Take
both 0x4000-aligned blocks from one static array instead, rounding the
first up to 0x4000 at run time. Diagnosed and verified on Windows by my
test session.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PrivacyOnion
left a comment
There was a problem hiding this comment.
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 9350539044:
- Conventions:
tools/check_conventions.pypassed. - Build:
guest_pad_tracker_testsbuilt cleanly. - CTest (
guest_pad_tracker):1/1 Test #4767: guest_pad_tracker ................ Passed 0.02 sec 100% tests passed, 0 tests failed out of 1 - Negative control: with
core/libs/prx/libScePadTracker/Export.cpp,core/libs/prx/libScePadTracker/include/Api.hppreverted tomain, the new tests do not build/link without the change; restoring it makes them build and pass. - Code reading:
- Verified pointer validation and 16 KiB alignment checks in ValidMemory() using MemoryAlignment = 0x4000 across firstMemory and secondMemory in scePadTrackerInit.
- Verified bounds checks for integer arguments first in [0, 6] and second in [0, 7] returning PAD_TRACKER_ERROR_INVALID_ARG (0x80c40003).
- Verified mutex locking and state checks across scePadTrackerInit, scePadTrackerTerm, scePadTrackerCalibrate, scePadTrackerReadState, and scePadTrackerUpdate.
- Verified error codes 0x80c40001 (not initialized), 0x80c40002 (already initialized), 0x80c40003 (invalid arg), and 0x80c40004 (handle not found) against PS5 firmware 13.42 specifications.
- Verified debt documentation in docs/dev/debt/changes/feat-padtracker-lifecycle.md and verified full test lifecycle and cleanup in GuestPadTracker.cpp.
Looks Good To Me
Progress report (098c734 → 57fff40)📈 System libraries: 46.93% (+0.01%, +3 implemented functions) ✅ 3 implemented
Changed libraries (implemented exports)
|
|
The Windows run
The full run reports 5,087 tests, 2 failed. I have not rerun the 50-minute Windows job; the available evidence points to those unrelated LibreSSL3 failures rather than this PR's changed paths. |
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — looks good
Nothing blocks this change; the reviewed code implements the documented firmware checks and explicitly records the unimplemented tracker behavior.
What I ran
Reviewed head 9350539044ff338aab473901da5e4ecc8efdbfd6. No build or test commands were run. The author reports Windows and macOS test runs in the PR description; those results were not independently verified.
Results
| Check | Result | Note |
|---|---|---|
| Source review | passed | All four changed files read |
| Build and tests | not run | Author reports Windows and macOS runs |
Findings
Blocking
None.
Non-blocking
None.
Not verified
No builds or tests were run. Firmware behavior is based on the author's cited emulator research, not independently confirmed or measured on a console. review/files.json was not available through the reader, so exclusions were not verified; the manifest lists four changed files, all included and read.
To get this to a good state
Nothing is required.
|
@malekaifa thanks for going through that run. @MarcZX10 thanks for the review. AI-assisted: yes (Claude Code) |
What
scePadTrackerInit,Term,CalibrateandReadStateget their firmware 13.42 signatures and answers.scePadTrackerUpdateanswers beforeInit. Onmainall five throw.Source. @BunnyFl's reading and emulator runs of
libScePadTracker.sprx(13.42) on #21753 (comment). Not measured on a console.Init(void* memA, void* memB, int32_t a, int32_t b)0x80c40003for memory that is null or not 16 KiB aligned,aoutside 0–6 orboutside 0–7; then0x80c40002when initialized; then the tracker setup, whose result is ignored, and 0Term(void)0x80c40001beforeInit; otherwise it resets the light bars, tears down and returns 0Calibrate(void)0x80c40001beforeInit; otherwise 0, ignoring the calibration callReadState(int32_t handle, void* state)0x80c40001;0x80c40003for a nullstate;0x80c40004for a handleUpdatenever recordedUpdate0x80c40001beforeInit; then the trackerInitThe emulator runs confirmed the bad-argument rows, the second
Init,Termbefore and afterInit,CalibrateafterInit, andReadState(1, NULL)/ReadState(1, state)afterInit.Change (
Export.cpp,Api.hpp). An initialized flag under a mutex carries the checks above. Notes on the remaining pieces:Init, and nothing here tracks.Termdoesn't reset the pads' light bars as the console does, since that would need libScePad.ReadStatehandle 0: handle 0 throws, because the table's initial contents weren't read and 0 might match an empty slot.Update: it keeps its parameterless declaration, since only itsInitcheck is answered. Its 0x40-byte by-value record isn't implemented.Debt. Following the fragment rule, this adds
docs/dev/debt/changes/feat-padtracker-lifecycle.md. It splits the "no credible prototypes" entry into one forInit/Calibrate/Termand one forReadState/Update. Each states the answers and what isn't modelled. The fragment folds cleanly in isolation.Test (
GuestPadTracker.cpp, ctestguest_pad_tracker). New rows:Init:Term,Calibrate,ReadStateandUpdategive0x80c40001;Initrefuses each null or misaligned memory block and each out-of-rangeaandb, andTermstill gives0x80c40001;Init(…, 6, 7)returns 0; a secondInitgives0x80c40002, but bad memory is still refused first;Init:Calibratereturns 0;ReadStaterefuses a null state, gives0x80c40004for handle 1 and leaves the state untouched;Termreturns 0, then0x80c40001, and a freshInit/Termpair works.The two 16 KiB-aligned memory blocks are carved at run time from one static
0xC000-byte array. MinGW can't align a static object past 8192 bytes, soalignas(0x4000)doesn't build on Windows.Tested
BUILD_TESTING=ON, onmaincb28e72762.58eb2ce459, didn't build: "requested alignment '16384' exceeds object file maximum 8192" for the twoalignas(0x4000)buffers. The test session wrote the run-time alignment above.b32a7012db, the same diff as this head9350539044), it builds with no warnings in the test, andguest_pad_trackerpasses.main'sExport.cppwith the stubs given the branch's signatures, plus the branch's header and test. It aborts (0xc0000409) withscePadTrackerTerm not implemented.git merge-treefinds no conflict withmainor with any open PR that merges withmain.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)