Skip to content

feat(libSceDipsw): implement retail-state queries and switch table - #22858

Closed
Xaviel wants to merge 1 commit into
boykopovar:mainfrom
Xaviel:feat/libscedipsw-retail-queries
Closed

Xaviel wants to merge 1 commit into
boykopovar:mainfrom
Xaviel:feat/libscedipsw-retail-queries

Conversation

@Xaviel

@Xaviel Xaviel commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

What

implements 8 of 10 libscedipsw exports. four arg-less queries return the retail-unit values documented across the ps4 and ps5 scene baselines (shadps4, kyty, openorbis): sceKernelIsAssistMode, sceKernelIsDevelopmentMode, sceKernelIsDisableRazor and sceKernelGetDiableBinaryVersionCheckValue. sceKernelInitializeDipsw returns 0 as a no-op. sceKernelCheckDipsw, sceKernelSetDipsw and sceKernelUnsetDipsw take a uint16_t bit index and operate on an in-memory 65536-bit switch block under a mutex, so a set is visible to the next check. sceKernelReadDipswData and sceKernelWriteDipswData keep throwing until their buffer shape is settled across public sources. debt fragment updates the existing debt entry.

Tested

not tested. convention check and debt_fold --check pass on the working tree. no full build on this machine.

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 and the licence notice of code adapted from upstream
  • 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
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

implements eight of ten exports. sceKernelInitializeDipsw, sceKernelIsAssistMode, sceKernelIsDevelopmentMode, sceKernelIsDisableRazor and sceKernelGetDiableBinaryVersionCheckValue return the retail-unit values documented across the ps4 and ps5 scene baselines (shadps4, kyty, openorbis). sceKernelCheckDipsw, sceKernelSetDipsw and sceKernelUnsetDipsw take a uint16_t bit index and operate on an in-memory 65536-bit switch block under a mutex. sceKernelReadDipswData and sceKernelWriteDipswData keep throwing until their buffer shape is settled.
@github-actions

Copy link
Copy Markdown

Progress report (41bb4ae → 4e1d4b5)

📈 System libraries: 43.04% (+0.02%, +8 implemented functions)

✅ 8 implemented
Library Name
libSceDipsw sceKernelCheckDipsw
libSceDipsw sceKernelGetDiableBinaryVersionCheckValue
libSceDipsw sceKernelInitializeDipsw
libSceDipsw sceKernelIsAssistMode
libSceDipsw sceKernelIsDevelopmentMode
libSceDipsw sceKernelIsDisableRazor
libSceDipsw sceKernelSetDipsw
libSceDipsw sceKernelUnsetDipsw
⚪ 5 behaviourally empty (constant return or throw)
Library Name
libSceDipsw sceKernelGetDiableBinaryVersionCheckValue
libSceDipsw sceKernelInitializeDipsw
libSceDipsw sceKernelIsAssistMode
libSceDipsw sceKernelIsDevelopmentMode
libSceDipsw sceKernelIsDisableRazor

Changed libraries (implemented exports)

Library Before After Change
libSceDipsw 0/10 (0.00%) 8/10 (80.00%) +80.00%

@edubox

edubox commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Checked the decrypted 13.40 module (libSceDipsw.sprx, /system/common/lib) against the switch-block model here; four details differ:

  • Size and bounds. The module's table is 32 bytes at 0xc020 (the second ioctl, 0x8010880a, copies 0x20 bytes), so 256 bits, and sceKernelCheckDipsw refuses everything from 0x100 on: cmp $0x100, %bx; jb at 0x37d and mov $0x16, %edi; jmp sceKernelError at 0x391, i.e. sceKernelError(EINVAL) = 0x80020016. It compares the id's low 16 bits, so a uint16_t index over a 65536-bit block accepts ids the console rejects and never returns that error.
  • No device. When open("/dev/dipsw", 2) fails, the module still answers bit id from the same table, which is .bss and therefore zero (0x3f1 to 0x434). A console without the device answers 0, not an error, and the table never receives a set value because the write path goes through the device.
  • sceKernelInitializeDipsw is not a no-op. It is 0xd0, 232 bytes: open("/dev/dipsw", 2), ioctl 0x20008800, ioctl 0x8010880a with {buffer 0xc020, size 0x20}, close, and it answers sceKernelError(errno) when the open or either ioctl fails and 0 on success.
  • The ids the wrappers pass, which confirms the four answers: sceKernelIsDevelopmentMode 0, sceKernelIsAssistMode 2, sceKernelIsDisableRazor 0x18 and sceKernelGetDiableBinaryVersionCheckValue 0x1e (0x760 to 0x790, 7 to 10 bytes each, each mov edi, N; jmp sceKernelCheckDipsw).

If the goal is to reproduce the module, answering 0 for ids 0 to 255 and 0x80020016 from 0x100 is enough; Set/Unset only have a console-visible effect through /dev/dipsw, which is absent here. I had prepared that reading, with the debt entry recording the device fallback, but I am not opening a PR because this one already covers the library.

This was referenced Nov 21, 2026
@kiwe147

kiwe147 commented Nov 21, 2026

Copy link
Copy Markdown

Tested head 4e1d4b5135, applied with git apply on main fd4aeed483 together with the other 26 PRs of one batch (#24498, #24665, #17297, #21499, #21726, #22534, #12900, #17843, #22051, #22075, #23087, #23206, #23222, #23227, #13147, #17482, #21935, #17477, #18272, #22929, #23028, #23295, #23916, #24179, #24706, #12619). All applied without conflicts and the whole tree built.

Setup: Windows 11 Pro 10.0.26200, Ryzen 7 9800X3D, WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON. GPUs: NVIDIA GeForce RTX 3080 (driver 621.24) and the AMD Radeon iGPU of the CPU (gfx1036, driver 32.0.21036.18). No validation layer. iGPU run: ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 ANYPS5_GPU="AMD Radeon", agc_/video tests only.

tests RTX 3080 iGPU
none: no test of its own in this PR - -

Whole batch: the full ctest -j 12 (6525 tests) on the RTX 3080 has 8 failing tests; the 4 that also fail on main fd4aeed483 are agc_driver_stencil_plane_memory, agc_driver_msaa_dcc_unwatch, agc_storage_write_back_host_retile, and pr_overlap_names, which needs a newer Python than my 3.10. Intermittent in this run (pass when rerun alone, or known flaky): agc_driver_store_over_untracked. Traced to other PRs of the batch, each by reverting it and testing again: #18272 (guest_audio_out), #12900 (guest_user_service_initial_user_bounds); none is in this PR's area. Failing tests I could not trace to a single PR (reverting the likely candidates did not clear them): guest_content_search. The 2125 agc_/video tests on the iGPU have 2 failing: agc_driver_stencil_plane_memory, agc_driver_store_over_untracked (agc_driver_stencil_plane_memory also fails on main).

This is one combined tree, not a run of this PR alone.

AI-assisted: yes (Claude Code)

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — no blocking findings

Nothing blocks this change; the review is incomplete because the existing debt record conflicts with the new ABI claims.

What I ran

Reviewed head 4e1d4b513546e0677ed1eb83a76bb1c20c13e114 using repo_read.py to inspect the prepared diff, changed files, and targeted references. No tests or build were run; the PR description reports none.

Results

Check Result Note
Diff and changed files passed All three changed files read
Targeted caller search passed No other references found
Build and tests not run No execution performed

Findings

Blocking

None.

Non-blocking

  • The existing docs/dev/debt/libSceDipsw.md still says the switch functions have no credible prototypes, that their declarations are parameterless placeholders, and that callers must not call them. This contradicts the newly documented uint16_t signatures and implementations. Please update the existing debt entry alongside this change. The discrepancy is evidenced by docs/dev/debt/changes/libscedipsw-retail-state-queries.md:7.

Not verified

  • No build, tests, or console behavior were run. The author reports that convention and debt-fold checks pass, but those results were not independently verified.
  • Read: core/libs/prx/libSceDipsw/Export.cpp, core/libs/prx/libSceDipsw/include/Api.hpp, docs/dev/debt/changes/libscedipsw-retail-state-queries.md, and docs/dev/debt/libSceDipsw.md. The latter was targeted context, not listed as changed. No changed files were excluded; files.json was not available through the reader.

To get this to a good state

Nothing is required. Optional: update the existing debt record to reflect the new signatures and behavior.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

@Xaviel, I am closing this one. The Dipsw query answers come from other projects' defaults rather than a console measurement, there are no tests, and no title we know of imports these queries, so it would not change what any game does. If you find a title that calls them, or measure the retail answers on a PS5, please reopen with that and it goes to review.

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.

5 participants