feat(libkernel): implement preadv and pwritev #3005

Merged
babyhuey merged 1 commit from upstream-pr/3005 into main 2026-10-10 21:52:58 +00:00
babyhuey commented 2026-10-10 20:23:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-10T20:23:29Z.


What

Implements preadv (ZaRzaapAZwM) and pwritev (FCcmRZhWtOk) in libkernel as POSIX wrappers over the existing sceKernelPreadv and sceKernelPwritev (#806): the byte count on success, and -1 with the guest errno (EINVAL, EFAULT, EBADF) instead of the SCE error code on failure.

Prospero Explorer (PPSA99109), Prospero Multi Tools (PPSA99110) and Prospero Vibrate (PPSA99920) stop at preadv on main 56fb1b3b and at pwritev right after it (catalog builds, eboot.bin and sce_module/libc.prx unwrapped as #2605 requires; tracked in #1578):

  • main, Linux: app.elf: symbol lookup error: app.elf: undefined symbol: ZaRzaapAZwM
  • preadv alone, Linux: app.elf: symbol lookup error: app.elf: undefined symbol: FCcmRZhWtOk (pwritev)
  • with this PR, Linux: Explorer YeU23Szo3BM (sceKernelGetAllowedSdkVersionOnSystem), Multi Tools aML18Z0J0t0 (sceKernelGetProsperoSystemSwVersion), Vibrate Y2OqwJQ3lr8 (sync)

Tested

Linux (Ubuntu 24.04, GCC 13, Release) on 56fb1b3b: guest_file_vector passes 5/5 (--repeat until-fail:5). The new cases read and write at an offset through both wrappers, check the file contents and that the file position doesn't move, check 0 at end of file, and check -1 with EINVAL for a negative offset or count and EFAULT for a null vector. check_conventions.py passes. Windows 11 (MinGW-w64 GCC 15.2 from WinLibs, Release), which has its own TransferIovecs path: guest_file_vector 5/5 with no warnings, main stops at FAIL: unresolved ELF import ZaRzaapAZwM (preadv) from libkernel.prx for all three, and with this PR they reach the same next stops as on Linux (for example FAIL: unresolved ELF import Y2OqwJQ3lr8 (sync) from libkernel.prx for Vibrate).

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: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4814191620 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3005). Originally posted by [babyhuey](https://github.com/babyhuey) on 2026-10-10T20:23:29Z. --- ### What Implements `preadv` (`ZaRzaapAZwM`) and `pwritev` (`FCcmRZhWtOk`) in libkernel as POSIX wrappers over the existing `sceKernelPreadv` and `sceKernelPwritev` (#806): the byte count on success, and -1 with the guest errno (`EINVAL`, `EFAULT`, `EBADF`) instead of the SCE error code on failure. Prospero Explorer (PPSA99109), Prospero Multi Tools (PPSA99110) and Prospero Vibrate (PPSA99920) stop at `preadv` on `main` 56fb1b3b and at `pwritev` right after it (catalog builds, `eboot.bin` and `sce_module/libc.prx` unwrapped as #2605 requires; tracked in #1578): - `main`, Linux: `app.elf: symbol lookup error: app.elf: undefined symbol: ZaRzaapAZwM` - `preadv` alone, Linux: `app.elf: symbol lookup error: app.elf: undefined symbol: FCcmRZhWtOk` (`pwritev`) - with this PR, Linux: Explorer `YeU23Szo3BM` (`sceKernelGetAllowedSdkVersionOnSystem`), Multi Tools `aML18Z0J0t0` (`sceKernelGetProsperoSystemSwVersion`), Vibrate `Y2OqwJQ3lr8` (`sync`) ### Tested Linux (Ubuntu 24.04, GCC 13, Release) on 56fb1b3b: `guest_file_vector` passes 5/5 (`--repeat until-fail:5`). The new cases read and write at an offset through both wrappers, check the file contents and that the file position doesn't move, check 0 at end of file, and check -1 with `EINVAL` for a negative offset or count and `EFAULT` for a null vector. `check_conventions.py` passes. Windows 11 (MinGW-w64 GCC 15.2 from WinLibs, Release), which has its own `TransferIovecs` path: `guest_file_vector` 5/5 with no warnings, `main` stops at `FAIL: unresolved ELF import ZaRzaapAZwM (preadv) from libkernel.prx` for all three, and with this PR they reach the same next stops as on Linux (for example `FAIL: unresolved ELF import Y2OqwJQ3lr8 (sync) from libkernel.prx` for Vibrate). ### 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: none - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-10 20:23:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-10T20:23:50Z.


Progress report (56fb1b3 → 0c2d852)

📈 System libraries: 84.45% (+0.01%, +2 implemented functions)

✅ 2 implemented
Library Name
libkernel preadv_nid_postfix
libkernel pwritev_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6101816276 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3005#issuecomment-6101816276). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-10T20:23:50Z. --- <!-- progress-report --> ### Progress report (56fb1b3 → 0c2d852) 📈 **System libraries**: 84.45% (+0.01%, +2 implemented functions) <details> <summary>✅ 2 implemented</summary> | Library | Name | | - | - | | libkernel | `preadv_nid_postfix` | | libkernel | `pwritev_nid_postfix` | </details>
babyhuey commented 2026-10-10 20:39:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-10T20:39:17Z.


With this PR and sync (Y2OqwJQ3lr8, Vibrate's next stop above; ready on babyhuey:feat/libkernel-sync 1d2cd9ae, a wrapper over sceKernelSync), Prospero Vibrate (PPSA99920) resolves every import and runs on Windows 11 (MinGW-w64 GCC 15.2, Release, main 56fb1b3b, RTX 3080):

  • It creates its Vulkan device and swapchain (Swapchain created extent=1484x835 images=2), opens a window titled Prospero Vibrate | FPS: 14.38 (419) and stays up until killed (still running after 60 s, and again after 30 s on a second launch).
  • The window shows the app's UI: the "Prospero Vibrate - Haptics that move You" header, the Live, Presets, Custom, Timer and Settings tabs, the Large and Small motor sliders, and the "State: Idle" footer.
  • The last calls it logs are sceFontOpenFontSet and sceKernelOpen on /dev/urandom and /data/prospero-vibrate/patterns; no controller was attached, so the motors were not exercised.

On Linux the same build runs until DisplayWindow finds no Vulkan display in the headless test container. I'll open sync as its own PR once this one is in, since it's only Vibrate's next stop after it.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6101947039 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3005#issuecomment-6101947039). Originally posted by [babyhuey](https://github.com/babyhuey) on 2026-10-10T20:39:17Z. --- With this PR and `sync` (`Y2OqwJQ3lr8`, Vibrate's next stop above; ready on babyhuey:feat/libkernel-sync 1d2cd9ae, a wrapper over `sceKernelSync`), Prospero Vibrate (PPSA99920) resolves every import and runs on Windows 11 (MinGW-w64 GCC 15.2, Release, `main` 56fb1b3b, RTX 3080): - It creates its Vulkan device and swapchain (`Swapchain created extent=1484x835 images=2`), opens a window titled `Prospero Vibrate | FPS: 14.38 (419)` and stays up until killed (still running after 60 s, and again after 30 s on a second launch). - The window shows the app's UI: the "Prospero Vibrate - Haptics that move You" header, the Live, Presets, Custom, Timer and Settings tabs, the Large and Small motor sliders, and the "State: Idle" footer. - The last calls it logs are `sceFontOpenFontSet` and `sceKernelOpen` on `/dev/urandom` and `/data/prospero-vibrate/patterns`; no controller was attached, so the motors were not exercised. On Linux the same build runs until `DisplayWindow` finds no Vulkan display in the headless test container. I'll open `sync` as its own PR once this one is in, since it's only Vibrate's next stop after it.
adriadam10 commented 2026-10-10 21:52:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T21:52:55Z.


Checked the build and guest_file_vector on Linux; the new cases fail without the change (the wrappers don't exist) and pass with it. Wrappers follow the existing PosixFailure pattern, errno values match the tests; merging once CI is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6102566871 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3005#issuecomment-6102566871). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-10T21:52:55Z. --- Checked the build and `guest_file_vector` on Linux; the new cases fail without the change (the wrappers don't exist) and pass with it. Wrappers follow the existing `PosixFailure` pattern, errno values match the tests; merging once CI is green.
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!3005
No description provided.