fix(kernel): use SCE kernel error codes in equeue, direct memory and mutex #26

Merged
QDarkRex merged 2 commits from upstream-pr/26 into main 2026-09-28 08:18:15 +00:00
QDarkRex commented 2026-09-27 06:22:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by QDarkRex on 2026-09-27T06:22:17Z.


Summary

SCE kernel error codes are 0x80020000 + FreeBSD errno (e.g. EINVAL = 0x80020016, ETIMEDOUT = 0x8002003C). Pthread and Semaphore already follow this. The constants in Equeue.hpp and DirectMemory.hpp used an unrelated 0x8001xxxx range, and their low bits don't match their names:

Constant Before After
EQUEUE_ERROR_ETIMEDOUT 0x80010023 0x8002003C
EQUEUE_ERROR_EBADF 0x80010016 0x80020009
EQUEUE_ERROR_ENOENT 0x80010011 0x80020002
EQUEUE_ERROR_EINVAL / SCE_KERNEL_ERROR_EINVAL (DirectMemory) 0x80010005 0x80020016
EQUEUE_ERROR_EFAULT / SCE_KERNEL_ERROR_EFAULT (DirectMemory) 0x80010009 0x8002000E
SCE_KERNEL_ERROR_EAGAIN (DirectMemory) 0x80010002 0x80020023
SCE_KERNEL_ERROR_ENOMEM (DirectMemory) 0x80010007 0x8002000C
SCE_KERNEL_ERROR_EACCES (DirectMemory) 0x80010004 0x8002000D
SCE_KERNEL_ERROR_EDEADLK (Mutex.cpp) 0x80020023 (= EAGAIN) 0x8002000B

The most visible effect: a guest waiting on sceKernelWaitEqueue with a timeout and checking for SCE_KERNEL_ERROR_ETIMEDOUT saw an unexpected error on an ordinary timeout. Values were cross-checked against shadPS4's orbis_error.h.

Tests

  • New guest_kernel_errors test covers:
    • equeue timeout, EFAULT, EINVAL, ENOENT and EBADF after delete
    • error-check mutex relock returns EDEADLK
  • I confirmed it aborts with the old constants and passes with the new ones.
  • Windows, MinGW-w64 GCC 15.2.0: 32/32 (31 existing + 1 new).

Independent of #25 and merges cleanly with it (checked locally).

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4652074787 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/26). Originally posted by [QDarkRex](https://github.com/QDarkRex) on 2026-09-27T06:22:17Z. --- ## Summary SCE kernel error codes are `0x80020000 + FreeBSD errno` (e.g. `EINVAL` = `0x80020016`, `ETIMEDOUT` = `0x8002003C`). `Pthread` and `Semaphore` already follow this. The constants in `Equeue.hpp` and `DirectMemory.hpp` used an unrelated `0x8001xxxx` range, and their low bits don't match their names: | Constant | Before | After | |---|---|---| | `EQUEUE_ERROR_ETIMEDOUT` | `0x80010023` | `0x8002003C` | | `EQUEUE_ERROR_EBADF` | `0x80010016` | `0x80020009` | | `EQUEUE_ERROR_ENOENT` | `0x80010011` | `0x80020002` | | `EQUEUE_ERROR_EINVAL` / `SCE_KERNEL_ERROR_EINVAL` (DirectMemory) | `0x80010005` | `0x80020016` | | `EQUEUE_ERROR_EFAULT` / `SCE_KERNEL_ERROR_EFAULT` (DirectMemory) | `0x80010009` | `0x8002000E` | | `SCE_KERNEL_ERROR_EAGAIN` (DirectMemory) | `0x80010002` | `0x80020023` | | `SCE_KERNEL_ERROR_ENOMEM` (DirectMemory) | `0x80010007` | `0x8002000C` | | `SCE_KERNEL_ERROR_EACCES` (DirectMemory) | `0x80010004` | `0x8002000D` | | `SCE_KERNEL_ERROR_EDEADLK` (Mutex.cpp) | `0x80020023` (= EAGAIN) | `0x8002000B` | The most visible effect: a guest waiting on `sceKernelWaitEqueue` with a timeout and checking for `SCE_KERNEL_ERROR_ETIMEDOUT` saw an unexpected error on an ordinary timeout. Values were cross-checked against shadPS4's `orbis_error.h`. ## Tests - New `guest_kernel_errors` test covers: - equeue timeout, `EFAULT`, `EINVAL`, `ENOENT` and `EBADF` after delete - error-check mutex relock returns `EDEADLK` - I confirmed it aborts with the old constants and passes with the new ones. - Windows, MinGW-w64 GCC 15.2.0: **32/32** (31 existing + 1 new). Independent of #25 and merges cleanly with it (checked locally). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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!26
No description provided.