feat(libSceAjmi): submit packed batches through native AJM #21535

Closed
Mcm190 wants to merge 1 commit from upstream-pr/21535 into main
Mcm190 commented 2026-11-16 11:13:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Mcm190 on 2026-11-16T11:13:36Z.


What

sceAjmiBatchStartBuffer currently throws for every call, even though the corresponding native AJM implementation can parse and execute supported packed batches. This change gives the export its six-argument native signature and forwards submission to libSceAjm.native. The returned batch handle belongs to the same backend used by native wait and cancel.

The firmware 13.42 symbol-table report in #15495 identifies sceAjmiBatchStartBuffer (9zA4YMlkR9M) as sharing an entry address with sceAjmBatchStartBuffer in libSceAjmi.sprx, SHA-256 ff0dc985c1f7a6b25a766904e3a535b55e44d0d4b8872329d2bd6c019491df0b. The module investigation at https://github.com/boykopovar/AnyPS5/pull/10563#issuecomment-6412138282 also records the CELT and SILK frontends calling this submission export before waiting; those PC runs stubbed AJM and do not establish its driver behavior or a complete prototype. The adapter inherits the existing native signature and behavior.

Jobs execute synchronously. Priority and inaccessible non-null batch/output memory are not generally validated by packed submission. Unsupported chunks and codec operations retain native exceptions; codec 23 accepts stream-only run flags. These limits are recorded in the debt fragment. The tests initialize the existing PCM backend and submit hand-built packed run jobs with known sample values; they establish host adapter execution and memory bounds, not console behavior or encoder compatibility.

The branch is based on main and builds independently of #21529, #21533 and #21182. It adds a separate export. Their common AJMI link/fixture and header areas overlap, and #21529/#21533 change the same debt entry, so the later merges need CMake/header and debt-fragment reconciliation.

This adds one implemented callable export: libSceAjmi 6/26 to 7/26 on this branch. Together with #21529 and #21533, libSceAjmi would reach 15/26. No title execution or startup improvement is claimed.

Tested

Fedora 45, AMD Ryzen 7 5800X, GCC 16.2.1, Release, bundled dependencies.

  • Built guest_ajmi_submission_tests, existing AJMI batch/guest-pointer tests, guest_ajm_tests and guest_ajm_vibration_tests.
  • 14/14 focused CTest cases pass: six named/NID submission cases, existing AJMI and native AJM/vibration cases, and public_headers.
  • PCM jobs preserve exact s16 samples across 1, 2, 4 and 8 channels; tests check consumed/written sizes, sample counts, output guards, batch/error outputs, input batch preservation, wrong-context rejection, native cancellation and one-time wait consumption.
  • Malformed lengths and null arguments preserve the native results and refusal records; unsupported chunks retain the same exception and leave the caller batch and handle untouched.
  • REA 6.5.0 inspected the built NID-patched adapter, evidence ev_24a6ccdfc4f4dac1a4393e504f861087778b7a1dd48dcefa2e26e5c37a3d3eb1. Its export is a direct jump at 0x3420 to fFFkk0xfGWs@plt (sceAjmBatchStartBuffer). This is a build-artifact observation, not new firmware evidence. The complete disassembly observation was retained locally.
  • check_conventions.py --base origin/main passes; the new debt fragment applies independently.
  • No Windows runtime, console or title execution.

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 (see AGENTS.md)
  • 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
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5335930265 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/21535). Originally posted by [Mcm190](https://github.com/Mcm190) on 2026-11-16T11:13:36Z. --- ### What sceAjmiBatchStartBuffer currently throws for every call, even though the corresponding native AJM implementation can parse and execute supported packed batches. This change gives the export its six-argument native signature and forwards submission to libSceAjm.native. The returned batch handle belongs to the same backend used by native wait and cancel. The firmware 13.42 symbol-table report in #15495 identifies sceAjmiBatchStartBuffer (9zA4YMlkR9M) as sharing an entry address with sceAjmBatchStartBuffer in libSceAjmi.sprx, SHA-256 ff0dc985c1f7a6b25a766904e3a535b55e44d0d4b8872329d2bd6c019491df0b. The module investigation at https://github.com/boykopovar/AnyPS5/pull/10563#issuecomment-6412138282 also records the CELT and SILK frontends calling this submission export before waiting; those PC runs stubbed AJM and do not establish its driver behavior or a complete prototype. The adapter inherits the existing native signature and behavior. Jobs execute synchronously. Priority and inaccessible non-null batch/output memory are not generally validated by packed submission. Unsupported chunks and codec operations retain native exceptions; codec 23 accepts stream-only run flags. These limits are recorded in the debt fragment. The tests initialize the existing PCM backend and submit hand-built packed run jobs with known sample values; they establish host adapter execution and memory bounds, not console behavior or encoder compatibility. The branch is based on main and builds independently of #21529, #21533 and #21182. It adds a separate export. Their common AJMI link/fixture and header areas overlap, and #21529/#21533 change the same debt entry, so the later merges need CMake/header and debt-fragment reconciliation. This adds one implemented callable export: libSceAjmi 6/26 to 7/26 on this branch. Together with #21529 and #21533, libSceAjmi would reach 15/26. No title execution or startup improvement is claimed. ### Tested Fedora 45, AMD Ryzen 7 5800X, GCC 16.2.1, Release, bundled dependencies. - Built guest_ajmi_submission_tests, existing AJMI batch/guest-pointer tests, guest_ajm_tests and guest_ajm_vibration_tests. - 14/14 focused CTest cases pass: six named/NID submission cases, existing AJMI and native AJM/vibration cases, and public_headers. - PCM jobs preserve exact s16 samples across 1, 2, 4 and 8 channels; tests check consumed/written sizes, sample counts, output guards, batch/error outputs, input batch preservation, wrong-context rejection, native cancellation and one-time wait consumption. - Malformed lengths and null arguments preserve the native results and refusal records; unsupported chunks retain the same exception and leave the caller batch and handle untouched. - REA 6.5.0 inspected the built NID-patched adapter, evidence ev_24a6ccdfc4f4dac1a4393e504f861087778b7a1dd48dcefa2e26e5c37a3d3eb1. Its export is a direct jump at 0x3420 to fFFkk0xfGWs@plt (sceAjmBatchStartBuffer). This is a build-artifact observation, not new firmware evidence. The complete disassembly observation was retained locally. - check_conventions.py --base origin/main passes; the new debt fragment applies independently. - No Windows runtime, console or title execution. <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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) and the licence notice of code adapted from upstream (see AGENTS.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 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
PrivacyOnion commented 2026-11-16 11:15:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-16T11:15:48Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against a4c9a53a17:

  • Conventions: tools/check_conventions.py passed; git diff --check clean.
  • Build: guest_ajmi_submission_tests built cleanly.
  • CTest (guest_ajmi_submission_execute_unpatched, guest_ajmi_submission_errors_unpatched, guest_ajmi_submission_unsupported_unpatched, guest_ajmi_submission_execute_nid, guest_ajmi_submission_errors_nid, guest_ajmi_submission_unsupported_nid):
    1/6 Test #3270: guest_ajmi_submission_execute_unpatched .......   Passed    0.01 sec
    2/6 Test #3271: guest_ajmi_submission_errors_unpatched ........   Passed    0.01 sec
    3/6 Test #3272: guest_ajmi_submission_unsupported_unpatched ...   Passed    0.01 sec
    4/6 Test #3273: guest_ajmi_submission_execute_nid .............   Passed    0.01 sec
    5/6 Test #3274: guest_ajmi_submission_errors_nid ..............   Passed    0.01 sec
    6/6 Test #3275: guest_ajmi_submission_unsupported_nid .........   Passed    0.00 sec
    100% tests passed, 0 tests failed out of 6
    
  • Negative control: with core/libs/prx/libSceAjmi/Export.cpp, core/libs/prx/libSceAjmi/include/InventoryExports.hpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • core/libs/prx/libSceAjmi/Export.cpp:202: verified sceAjmiBatchStartBuffer takes the 6-argument signature (context, batch, batchSize, priority, error, batchId) and forwards directly to sceAjmBatchStartBuffer in libSceAjm.native.
    • core/libs/prx/libSceAjmi/include/InventoryExports.hpp:10: verified header declaration matches the Export.cpp definition and uses APS5_VABI.
    • core/libs/prx/libSceAjmi/CMakeLists.txt:3-67 and Submission.cmake:1-32: verified libSceAjmi links against libSceAjm.native, copies and NID-patches libSceAjm.native.prx into the alias test module directory, and configures both unpatched and nid test variants.
    • core/libs/tests/GuestAjmiSubmission.cpp:1-268: verified test harness exercises execute, errors (0x80930002, 0x80930004, 0x80930005, 0x80930011), and unsupported chunk handling against both unpatched and NID-patched exports with proper module cleanup.
    • docs/dev/debt/changes/ajmi-packed-batch-submission.md:1-9: verified technical debt fragment documents the shared symbol address from firmware 13.42, synchronous execution, and native delegation limits in accordance with AGENTS.md.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5919075791 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/21535#pullrequestreview-5919075791). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-16T11:15:48Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `a4c9a53a17`: - **Conventions**: `tools/check_conventions.py` passed; `git diff --check` clean. - **Build**: `guest_ajmi_submission_tests` built cleanly. - **CTest** (`guest_ajmi_submission_execute_unpatched`, `guest_ajmi_submission_errors_unpatched`, `guest_ajmi_submission_unsupported_unpatched`, `guest_ajmi_submission_execute_nid`, `guest_ajmi_submission_errors_nid`, `guest_ajmi_submission_unsupported_nid`): ``` 1/6 Test #3270: guest_ajmi_submission_execute_unpatched ....... Passed 0.01 sec 2/6 Test #3271: guest_ajmi_submission_errors_unpatched ........ Passed 0.01 sec 3/6 Test #3272: guest_ajmi_submission_unsupported_unpatched ... Passed 0.01 sec 4/6 Test #3273: guest_ajmi_submission_execute_nid ............. Passed 0.01 sec 5/6 Test #3274: guest_ajmi_submission_errors_nid .............. Passed 0.01 sec 6/6 Test #3275: guest_ajmi_submission_unsupported_nid ......... Passed 0.00 sec 100% tests passed, 0 tests failed out of 6 ``` - **Negative control**: with `core/libs/prx/libSceAjmi/Export.cpp`, `core/libs/prx/libSceAjmi/include/InventoryExports.hpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - core/libs/prx/libSceAjmi/Export.cpp:202: verified sceAjmiBatchStartBuffer takes the 6-argument signature (context, batch, batchSize, priority, error, batchId) and forwards directly to sceAjmBatchStartBuffer in libSceAjm.native. - core/libs/prx/libSceAjmi/include/InventoryExports.hpp:10: verified header declaration matches the Export.cpp definition and uses APS5_VABI. - core/libs/prx/libSceAjmi/CMakeLists.txt:3-67 and Submission.cmake:1-32: verified libSceAjmi links against libSceAjm.native, copies and NID-patches libSceAjm.native.prx into the alias test module directory, and configures both unpatched and nid test variants. - core/libs/tests/GuestAjmiSubmission.cpp:1-268: verified test harness exercises execute, errors (0x80930002, 0x80930004, 0x80930005, 0x80930011), and unsupported chunk handling against both unpatched and NID-patched exports with proper module cleanup. - docs/dev/debt/changes/ajmi-packed-batch-submission.md:1-9: verified technical debt fragment documents the shared symbol address from firmware 13.42, synchronous execution, and native delegation limits in accordance with AGENTS.md. Looks Good To Me

Pull request closed

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!21535
No description provided.