Skip to main content
Print

PSP Asynchronous I/O and Callback-Aware Completion

Type: REFERENCE   Status: MAINTAINED   Scope: Asynchronous file operations, per-descriptor request state, poll/wait/callback completion, cancellation, and close lifetime.   Last reviewed: 2026-08-11

Asynchronous I/O is a state machine attached to a guest file descriptor. It is not equivalent to “run a host read on another thread and later report success.” The descriptor, request, output result, callback, cancellation, and close path remain observable guest state.

Exact public API evidence

The maintained PSPSDK File IO reference lists sceIoReadAsync, sceIoWriteAsync, sceIoWaitAsync, sceIoWaitAsyncCB, sceIoPollAsync, sceIoGetAsyncStat, sceIoCancel, sceIoSetAsyncCallback, and priority changes. The exact pspiofilemgr.h source is the smallest citation for the signatures and the SceInt64 result pointer. The API surface establishes distinct poll, wait, callback-aware wait, status, and cancel operations.

open fd -> IDLE<br>async submit -> PENDING(request, buffer, size, callback)<br>poll/status -> PENDING or COMPLETE(result)<br>wait / wait-CB -> completion, timeout/error, optional callback execution<br>cancel -> CANCELLED (request-specific result)<br>close -> resolve request lifetime before descriptor reuse
Source-owned async request state machine. Descriptor identity and request state are deliberately separate.

Descriptor identity is not request identity

One open descriptor may have one active asynchronous action while the host has a separate worker or event object. Track the guest FD, request generation, operation kind, guest input/output spans, result width, callback UID/argument, and completion reason. A stale completion must not write into a reused descriptor or a freed guest buffer.

Validate complete guest spans before submission and before completion writes. Preserve short reads/writes, negative result values, and cancellation outcomes as distinct fields. A synchronous byte count followed by a later status report is not automatically equivalent to a synchronous call.

Callbacks and scheduler integration

sceIoWaitAsyncCB shares the callback-aware shape seen in ThreadMan: callback code may run while the guest would otherwise be waiting, and the original wait can resume or complete. Do not invoke a host callback that bypasses the guest CPU state. Route completion through the guest scheduler so priority, wake order, and callback context remain observable.

Nakagawa’s current file/HLE boundaries are represented by hle.c and iso.c. The public filesystem and I/O model remains the broader context; these commit-pinned files are the implementation-specific citations.

Safe regression matrix

Use a deterministic synthetic device: submit a read, poll before completion, wait, wait-CB, cancel before completion, cancel after completion, close with a pending request, and reuse the FD. Assert scheduler state, callback sequence, result pointer bytes, short-count behavior, and descriptor generation. Keep device-specific or retail-path observations private unless the evidence is cleared for publication.

Sources

Table of Contents