Skip to content

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

Closed
semirkabir wants to merge 3 commits into
boykopovar:mainfrom
semirkabir:feat/usbd-transfer-helpers
Closed

semirkabir wants to merge 3 commits into
boykopovar:mainfrom
semirkabir:feat/usbd-transfer-helpers

Conversation

@semirkabir

Copy link
Copy Markdown
Contributor

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

@github-actions

Copy link
Copy Markdown

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

@semirkabir

Copy link
Copy Markdown
Contributor Author

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.

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 12, 2026

@adriadam10 adriadam10 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

#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

Copy link
Copy Markdown
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build docs needs rebase Conflicts with main, rebase needed prx

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants