feat(kernel): implement Aio request lifecycle #102

Merged
asimplestray merged 1 commit from upstream-pr/102 into main 2026-09-29 08:07:11 +00:00
asimplestray commented 2026-09-28 20:39:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by asimplestray on 2026-09-28T20:39:45Z.


What

Implements the 7 declared sceKernelAio* entry points in libkernel/Aio (previously NotImplemented_nid_no_patch):

  • SubmitReadCommands / SubmitWriteCommands: positional read/write loop over the batch via native pread/pwrite (duplicated fd + lseek on Windows, where no native positional IO exists), filling each KernelAioResult (COMPLETED/ABORTED) and allocating one queue id per batch (ids cycle 1..511, 0 reserved).
  • WaitRequest: polls every 10us until the queue leaves PROCESSING; null/zero timeout waits forever, expiry returns ETIMEDOUT.
  • PollRequest: corrected signature to (id, state) (was a no-arg placeholder in Unimplemented.cpp) and implemented.
  • DeleteRequest: invalidates the queue id.
  • InitializeImpl: success (subsystem needs no init); InitializeParam: validates the param pointer.

Request states follow the Sony ABI (SUBMITTED=1, PROCESSING=2, COMPLETED=3, ABORTED=4), checked against the shadPS4 reference implementation of the same API family. Error style follows the repo: EFAULT/EINVAL/ETIMEDOUT returns for bad arguments, throw only for programmer errors.

Scope notes: submits execute synchronously (same as the reference); true overlapped async IO is a follow-up once boot-through works. AioPollRequest batch variants (PollRequests/WaitRequests/Cancel*/Multiple) are not declared in this repo yet, so they are out of scope.

Tested

Linux (GCC 16, BUILD_TESTING=ON): full build, ctest 57/57 pass, including the new guest_aio test (2-request read batch with content verification, write batch verified on disk, plus EFAULT/EINVAL argument checks). libkernel progress 295/377 -> 302/377.

Checklist

  • Based on current main; no other open PR implements the same functions (checked #77-86, #98: none touch Aio)
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (sceKernelPread/pwrite remain throwing stubs on Windows; no new silent stubs)
  • 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 (none added)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4669038161 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/102). Originally posted by [asimplestray](https://github.com/asimplestray) on 2026-09-28T20:39:45Z. --- ### What Implements the 7 declared `sceKernelAio*` entry points in `libkernel/Aio` (previously `NotImplemented_nid_no_patch`): - `SubmitReadCommands` / `SubmitWriteCommands`: positional read/write loop over the batch via native `pread`/`pwrite` (duplicated fd + `lseek` on Windows, where no native positional IO exists), filling each `KernelAioResult` (`COMPLETED`/`ABORTED`) and allocating one queue id per batch (ids cycle 1..511, 0 reserved). - `WaitRequest`: polls every 10us until the queue leaves `PROCESSING`; null/zero timeout waits forever, expiry returns `ETIMEDOUT`. - `PollRequest`: corrected signature to `(id, state)` (was a no-arg placeholder in `Unimplemented.cpp`) and implemented. - `DeleteRequest`: invalidates the queue id. - `InitializeImpl`: success (subsystem needs no init); `InitializeParam`: validates the param pointer. Request states follow the Sony ABI (`SUBMITTED=1, PROCESSING=2, COMPLETED=3, ABORTED=4`), checked against the shadPS4 reference implementation of the same API family. Error style follows the repo: `EFAULT`/`EINVAL`/`ETIMEDOUT` returns for bad arguments, `throw` only for programmer errors. Scope notes: submits execute synchronously (same as the reference); true overlapped async IO is a follow-up once boot-through works. `AioPollRequest` batch variants (`PollRequests`/`WaitRequests`/`Cancel*`/`Multiple`) are not declared in this repo yet, so they are out of scope. ### Tested Linux (GCC 16, `BUILD_TESTING=ON`): full build, `ctest` 57/57 pass, including the new `guest_aio` test (2-request read batch with content verification, write batch verified on disk, plus `EFAULT`/`EINVAL` argument checks). `libkernel` progress 295/377 -> 302/377. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions (checked #77-86, #98: none touch Aio) - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw (`sceKernelPread`/`pwrite` remain throwing stubs on Windows; no new 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 (none added) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes
github-actions[bot] commented 2026-09-29 08:01:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-09-29T08:01:21Z.


Progress report (49a7819 → c25c543)

📈 System libraries: 65.41% (+0.25%, +7 implemented functions)

✅ 7 implemented
Library Name
libkernel sceKernelAioDeleteRequest
libkernel sceKernelAioInitializeImpl
libkernel sceKernelAioInitializeParam
libkernel sceKernelAioPollRequest
libkernel sceKernelAioSubmitReadCommands
libkernel sceKernelAioSubmitWriteCommands
libkernel sceKernelAioWaitRequest
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5886147223 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/102#issuecomment-5886147223). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-09-29T08:01:21Z. --- <!-- progress-report --> ### Progress report (49a7819 → c25c543) 📈 **System libraries**: 65.41% (+0.25%, +7 implemented functions) <details> <summary>✅ 7 implemented</summary> | Library | Name | | - | - | | libkernel | `sceKernelAioDeleteRequest` | | libkernel | `sceKernelAioInitializeImpl` | | libkernel | `sceKernelAioInitializeParam` | | libkernel | `sceKernelAioPollRequest` | | libkernel | `sceKernelAioSubmitReadCommands` | | libkernel | `sceKernelAioSubmitWriteCommands` | | libkernel | `sceKernelAioWaitRequest` | </details>
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!102
No description provided.