feat(libSceUsbd): add the transfer fill helpers and the synchronous bulk and interrupt transfers #3875

Closed
13hourstilliland wants to merge 2 commits from upstream-pr/3875 into main
13hourstilliland commented 2026-10-11 18:24:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by 13hourstilliland on 2026-10-11T18:24:32Z.


What

Adds the transfer helpers FreeType titles allocate and fill through, following libusb10_io.c field for field:

  • sceUsbdFillBulkTransfer, sceUsbdFillIsoTransfer and sceUsbdFillControlTransfer, and sceUsbdFillControlSetup with the little-endian setup bytes.
  • sceUsbdControlTransferGetData and sceUsbdControlTransferGetSetup.
  • sceUsbdSetIsoPacketLengths and sceUsbdGetIsoPacketBuffer, whose offsets sum the earlier packet lengths.
  • sceUsbdBulkTransfer and sceUsbdInterruptTransfer, passing through to libusb's synchronous calls; a null transferred output throws, which FreeBSD writes to.

Stacked on #3848; until that merges the diff shows both commits.

Tested

  • Windows (WinLibs MinGW GCC 15.2), Xbox 360 controller: guest_usbd device with APS5_USBD_DEVICE=3537:100f now does the control request through the new fill helpers and completes a synchronous interrupt read on endpoint 0x81 (15-byte input report) and an asynchronous one through the event loop.
  • Same run against three deliberately broken versions: an interrupt read sized 0, a swapped setup byte and wrong iso offset math. Each fails the test; the restored code passes.
  • Linux (no USB access): the no-device guest_usbd run passes, and check_conventions.py passes.
  • Bulk endpoints are untested on real hardware, since the controller has none; it is recorded in TechnicalDebt. Not tested with a title.

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: #3848
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4821296952 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3875). Originally posted by [13hourstilliland](https://github.com/13hourstilliland) on 2026-10-11T18:24:32Z. --- ### What Adds the transfer helpers FreeType titles allocate and fill through, following [libusb10_io.c](https://github.com/freebsd/freebsd-src/blob/d106002967eff712894ab8b5337bbbff106ce5e0/lib/libusb/libusb10_io.c) field for field: - `sceUsbdFillBulkTransfer`, `sceUsbdFillIsoTransfer` and `sceUsbdFillControlTransfer`, and `sceUsbdFillControlSetup` with the little-endian setup bytes. - `sceUsbdControlTransferGetData` and `sceUsbdControlTransferGetSetup`. - `sceUsbdSetIsoPacketLengths` and `sceUsbdGetIsoPacketBuffer`, whose offsets sum the earlier packet lengths. - `sceUsbdBulkTransfer` and `sceUsbdInterruptTransfer`, passing through to libusb's synchronous calls; a null transferred output throws, which FreeBSD writes to. Stacked on #3848; until that merges the diff shows both commits. ### Tested - Windows (WinLibs MinGW GCC 15.2), Xbox 360 controller: `guest_usbd device` with `APS5_USBD_DEVICE=3537:100f` now does the control request through the new fill helpers and completes a synchronous interrupt read on endpoint 0x81 (15-byte input report) and an asynchronous one through the event loop. - Same run against three deliberately broken versions: an interrupt read sized 0, a swapped setup byte and wrong iso offset math. Each fails the test; the restored code passes. - Linux (no USB access): the no-device `guest_usbd` run passes, and `check_conventions.py` passes. - Bulk endpoints are untested on real hardware, since the controller has none; it is recorded in TechnicalDebt. Not tested with a title. ### 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 in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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: #3848 - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-11 18:24:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-11T18:24:55Z.


Progress report (a11c8f7 → e91ec2b)

📈 System libraries: 86.41% (+0.6%, +29 implemented functions)

✅ 29 implemented
Library Name
libSceUsbd sceUsbdAttachKernelDriver
libSceUsbd sceUsbdBulkTransfer
libSceUsbd sceUsbdCheckConnected
libSceUsbd sceUsbdClaimInterface
libSceUsbd sceUsbdClose
libSceUsbd sceUsbdControlTransfer
libSceUsbd sceUsbdControlTransferGetData
libSceUsbd sceUsbdControlTransferGetSetup
libSceUsbd sceUsbdFillBulkTransfer
libSceUsbd sceUsbdFillControlSetup
libSceUsbd sceUsbdFillControlTransfer
libSceUsbd sceUsbdFillIsoTransfer
libSceUsbd sceUsbdGetActiveConfigDescriptor
libSceUsbd sceUsbdGetBusNumber
libSceUsbd sceUsbdGetConfigDescriptor
libSceUsbd sceUsbdGetDeviceAddress
libSceUsbd sceUsbdGetDeviceDescriptor
libSceUsbd sceUsbdGetIsoPacketBuffer
libSceUsbd sceUsbdGetStringDescriptor
libSceUsbd sceUsbdInterruptTransfer
libSceUsbd sceUsbdKernelDriverActive
libSceUsbd sceUsbdOpen
libSceUsbd sceUsbdRefDevice
libSceUsbd sceUsbdReleaseInterface
libSceUsbd sceUsbdResetDevice
libSceUsbd sceUsbdSetConfiguration
libSceUsbd sceUsbdSetIsoPacketLengths
libSceUsbd sceUsbdSubmitTransfer
libSceUsbd sceUsbdUnrefDevice
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6112223436 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3875#issuecomment-6112223436). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-11T18:24:55Z. --- <!-- progress-report --> ### Progress report (a11c8f7 → e91ec2b) 📈 **System libraries**: 86.41% (+0.6%, +29 implemented functions) <details> <summary>✅ 29 implemented</summary> | Library | Name | | - | - | | libSceUsbd | `sceUsbdAttachKernelDriver` | | libSceUsbd | `sceUsbdBulkTransfer` | | libSceUsbd | `sceUsbdCheckConnected` | | libSceUsbd | `sceUsbdClaimInterface` | | libSceUsbd | `sceUsbdClose` | | libSceUsbd | `sceUsbdControlTransfer` | | libSceUsbd | `sceUsbdControlTransferGetData` | | libSceUsbd | `sceUsbdControlTransferGetSetup` | | libSceUsbd | `sceUsbdFillBulkTransfer` | | libSceUsbd | `sceUsbdFillControlSetup` | | libSceUsbd | `sceUsbdFillControlTransfer` | | libSceUsbd | `sceUsbdFillIsoTransfer` | | libSceUsbd | `sceUsbdGetActiveConfigDescriptor` | | libSceUsbd | `sceUsbdGetBusNumber` | | libSceUsbd | `sceUsbdGetConfigDescriptor` | | libSceUsbd | `sceUsbdGetDeviceAddress` | | libSceUsbd | `sceUsbdGetDeviceDescriptor` | | libSceUsbd | `sceUsbdGetIsoPacketBuffer` | | libSceUsbd | `sceUsbdGetStringDescriptor` | | libSceUsbd | `sceUsbdInterruptTransfer` | | libSceUsbd | `sceUsbdKernelDriverActive` | | libSceUsbd | `sceUsbdOpen` | | libSceUsbd | `sceUsbdRefDevice` | | libSceUsbd | `sceUsbdReleaseInterface` | | libSceUsbd | `sceUsbdResetDevice` | | libSceUsbd | `sceUsbdSetConfiguration` | | libSceUsbd | `sceUsbdSetIsoPacketLengths` | | libSceUsbd | `sceUsbdSubmitTransfer` | | libSceUsbd | `sceUsbdUnrefDevice` | </details>
13hourstilliland commented 2026-10-11 19:29:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by 13hourstilliland on 2026-10-11T19:29:09Z.


The conflict against #1835 is textual only: both PRs append different submodule blocks to the same tail of .gitmodules after the libjpeg-turbo entry (3rdparty/libusb-cmake here, capstone/pyelftools/ps5link-sdk there), and git cannot auto-merge two different appends at the same anchor. I verified with a trial merge: CMakeLists.txt (the ANYPS5_NATIVE_AOT option hunk vs the libusb add_subdirectory hunk) and docs/dev/TechnicalDebt.md (their AOT entries at the top vs this PR's rewrite of the libSceUsbd entry) auto-merge cleanly, and there is no semantic interaction — the AOT path is behind an opt-in flag under core/aot, the libusb submodule builds unconditionally. Whichever PR merges second just keeps all four submodule blocks in .gitmodules; I will rebase after whichever lands first.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6112838127 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3875#issuecomment-6112838127). Originally posted by [13hourstilliland](https://github.com/13hourstilliland) on 2026-10-11T19:29:09Z. --- The conflict against #1835 is textual only: both PRs append different submodule blocks to the same tail of `.gitmodules` after the `libjpeg-turbo` entry (`3rdparty/libusb-cmake` here, capstone/pyelftools/ps5link-sdk there), and git cannot auto-merge two different appends at the same anchor. I verified with a trial merge: `CMakeLists.txt` (the `ANYPS5_NATIVE_AOT` option hunk vs the libusb `add_subdirectory` hunk) and `docs/dev/TechnicalDebt.md` (their AOT entries at the top vs this PR's rewrite of the libSceUsbd entry) auto-merge cleanly, and there is no semantic interaction — the AOT path is behind an opt-in flag under `core/aot`, the libusb submodule builds unconditionally. Whichever PR merges second just keeps all four submodule blocks in `.gitmodules`; I will rebase after whichever lands first.
adriadam10 commented 2026-10-12 21:01:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-12T21:01:41Z.

Review: CHANGES_REQUESTED


#3848 is merged now, but with different commits than the first commit of this branch (6073ac556): main has 98d594c9c plus faff4a645 (cancel under the state lock). The branch no longer merges cleanly: core/libs/prx/libSceUsbd/Export.cpp, core/libs/tests/GuestUsbd.cpp and docs/dev/TechnicalDebt.md conflict.

  • Please rebase onto current main and drop 6073ac556, so the PR contains only the transfer-helpers commit and the diff shows only that change.
  • Re-run guest_usbd after the rebase (the merged base changed the cancel path and the test file), and keep the TechnicalDebt line consistent with the version now on main.

I'll review the code once the diff is just this commit.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5495907091 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3875#pullrequestreview-5495907091). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-12T21:01:41Z. **Review:** CHANGES_REQUESTED --- #3848 is merged now, but with different commits than the first commit of this branch (`6073ac556`): main has `98d594c9c` plus `faff4a645` (cancel under the state lock). The branch no longer merges cleanly: `core/libs/prx/libSceUsbd/Export.cpp`, `core/libs/tests/GuestUsbd.cpp` and `docs/dev/TechnicalDebt.md` conflict. - Please rebase onto current `main` and drop `6073ac556`, so the PR contains only the transfer-helpers commit and the diff shows only that change. - Re-run `guest_usbd` after the rebase (the merged base changed the cancel path and the test file), and keep the TechnicalDebt line consistent with the version now on main. I'll review the code once the diff is just this commit.
oneandonlydean commented 2026-10-14 02:39:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T02:39:33Z.


Closing: no title is known to reach this. With the queue at 700+ open PRs, please hold off on new PRs that don't name a title needing the change until it's down. If a title stops on this on current main, reopen with the title ID and the log line.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6159664650 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3875#issuecomment-6159664650). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-14T02:39:33Z. --- Closing: no title is known to reach this. With the queue at 700+ open PRs, please hold off on new PRs that don't name a title needing the change until it's down. If a title stops on this on current main, reopen with the title ID and the log line.

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