feat(libkernel): implement sceKernelGetEventError #950

Closed
CnRJay wants to merge 3 commits from upstream-pr/950 into main
CnRJay commented 2026-10-06 20:11:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-10-06T20:11:48Z.


What

Implements sceKernelGetEventError (Uu-iDFC9aUc), which threw before.

  • Returns the event's data when EV_ERROR is set in flags, otherwise 0.

  • The references disagree:

    Reference Behaviour
    KytyPS5 (src/kernel/eventQueue.cpp:663, PS5) data under EV_ERROR, otherwise 0; 0 for a null event
    fpPS4 (kernel/ps4_queue.pas, PS4) fflags + 0x80020000 when fflags is nonzero
    prosper constant 0
    shadPS4 stub only
  • This follows KytyPS5, for three reasons:

    • It targets PS5 titles.
    • FreeBSD kevent puts the errno in data under EV_ERROR, and the Orbis/Prospero kernel derives from FreeBSD.
    • fpPS4's own header contradicts its accessor: it comments EV_ERROR as "data contains errno".
  • I could not check the console libkernel body, so the semantics are recorded under "Unknown function info" in TechnicalDebt: which field carries the error, and whether it is the raw errno or an SCE code (fpPS4's 0x80020000 mapping).

  • A null event throws, like the other sceKernelGetEvent* accessors (KytyPS5 returns 0).

Tested

Windows 11 (winlibs GCC): guest_equeue_events passes. It fails on main because the stub throws. It checks:

  • A triggered user event reports 0.
  • An event with data = -5 and no EV_ERROR reports 0.
  • An event with flags = EV_ADD | EV_ERROR and data = 22 reports 22, with a nonzero fflags that must be ignored.
  • The same event with data = 0 reports 0.
  • A null event throws.

tools/progress.py: libraries +1. No title run.

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

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4764105571 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/950). Originally posted by [CnRJay](https://github.com/CnRJay) on 2026-10-06T20:11:48Z. --- ### What Implements `sceKernelGetEventError` (`Uu-iDFC9aUc`), which threw before. - Returns the event's `data` when `EV_ERROR` is set in `flags`, otherwise 0. - The references disagree: | Reference | Behaviour | |---|---| | KytyPS5 (`src/kernel/eventQueue.cpp:663`, PS5) | `data` under `EV_ERROR`, otherwise 0; 0 for a null event | | fpPS4 (`kernel/ps4_queue.pas`, PS4) | `fflags + 0x80020000` when `fflags` is nonzero | | prosper | constant 0 | | shadPS4 | stub only | - This follows KytyPS5, for three reasons: - It targets PS5 titles. - FreeBSD kevent puts the errno in `data` under `EV_ERROR`, and the Orbis/Prospero kernel derives from FreeBSD. - fpPS4's own header contradicts its accessor: it comments `EV_ERROR` as "data contains errno". - I could not check the console `libkernel` body, so the semantics are recorded under "Unknown function info" in TechnicalDebt: which field carries the error, and whether it is the raw errno or an SCE code (fpPS4's `0x80020000` mapping). - A null event throws, like the other `sceKernelGetEvent*` accessors (KytyPS5 returns 0). ### Tested Windows 11 (winlibs GCC): `guest_equeue_events` passes. It fails on `main` because the stub throws. It checks: - A triggered user event reports 0. - An event with `data = -5` and no `EV_ERROR` reports 0. - An event with `flags = EV_ADD | EV_ERROR` and `data = 22` reports 22, with a nonzero `fflags` that must be ignored. - The same event with `data = 0` reports 0. - A null event throws. `tools/progress.py`: libraries +1. No title run. ### 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 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-actions[bot] commented 2026-10-06 20:12:12 +00:00 (Migrated from github.com)

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


Progress report (4ddbf04 → f0e7c93)

📈 System libraries: 84.79% (+0.03%, +1 implemented functions)

✅ 1 implemented
Library Name
libkernel sceKernelGetEventError
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6024579566 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/950#issuecomment-6024579566). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-06T20:12:12Z. --- <!-- progress-report --> ### Progress report (4ddbf04 → f0e7c93) 📈 **System libraries**: 84.79% (+0.03%, +1 implemented functions) <details> <summary>✅ 1 implemented</summary> | Library | Name | | - | - | | libkernel | `sceKernelGetEventError` | </details>
adriadam10 commented 2026-10-08 05:22:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-08T05:22:04Z.

Review: CHANGES_REQUESTED


Thanks for the PR. Two things to fix before this can merge:

  • The description says KytyPS5 has no body for sceKernelGetEventError, but it does: src/kernel/eventQueue.cpp:660 returns static_cast<int>(ev->data) when ev->flags & EV_ERROR, otherwise 0 (and returns 0 for a null event). prosper returns a constant 0 (hle_kernel_time.cpp:2488); shadPS4 is a bare stub.
  • So the references disagree: fpPS4 (PS4) maps fflags + 0x80020000, KytyPS5 (PS5 titles) reports data under EV_ERROR. The PR follows fpPS4 only, and the test builds rawEvent.fflags = 22 by hand with no EV_ERROR, so it pins fpPS4's behaviour and nothing else. Please state which reference you follow and why, ideally backed by the real library (e.g. the sceKernelGetEventError body in a title's libkernel), and make the test reflect the real event shape (an event with EV_ERROR set).
  • Add a line to TechnicalDebt under "Unknown function info" for the inferred semantics (which field carries the error, the 0x80020000 mapping).

Happy to re-review once updated.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5451868923 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/950#pullrequestreview-5451868923). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-08T05:22:04Z. **Review:** CHANGES_REQUESTED --- Thanks for the PR. Two things to fix before this can merge: - The description says KytyPS5 has no body for `sceKernelGetEventError`, but it does: `src/kernel/eventQueue.cpp:660` returns `static_cast<int>(ev->data)` when `ev->flags & EV_ERROR`, otherwise 0 (and returns 0 for a null event). prosper returns a constant 0 (`hle_kernel_time.cpp:2488`); shadPS4 is a bare stub. - So the references disagree: fpPS4 (PS4) maps `fflags` + `0x80020000`, KytyPS5 (PS5 titles) reports `data` under `EV_ERROR`. The PR follows fpPS4 only, and the test builds `rawEvent.fflags = 22` by hand with no `EV_ERROR`, so it pins fpPS4's behaviour and nothing else. Please state which reference you follow and why, ideally backed by the real library (e.g. the `sceKernelGetEventError` body in a title's `libkernel`), and make the test reflect the real event shape (an event with `EV_ERROR` set). - Add a line to TechnicalDebt under "Unknown function info" for the inferred semantics (which field carries the error, the `0x80020000` mapping). Happy to re-review once updated.
CnRJay commented 2026-10-08 18:29:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-10-08T18:29:59Z.


Thanks, you're right: I missed KytyPS5's body. Updated in f0e7c93a:

  • I now follow KytyPS5: data under EV_ERROR, otherwise 0. It targets PS5, it matches FreeBSD kevent (errno in data under EV_ERROR), and fpPS4's own header comments EV_ERROR as "data contains errno", which contradicts its fflags accessor. I don't have a console libkernel to disassemble, so this stays an inference.
  • The test builds an event with EV_ADD | EV_ERROR and data = 22, plus a nonzero fflags that must be ignored. It also checks that data without EV_ERROR gives 0.
  • Added a TechnicalDebt line under "Unknown function info" covering the field choice, the unknown raw-errno vs SCE-code question (fpPS4's 0x80020000), and the null-event difference from KytyPS5.
  • The description now lists all four references accurately.

🤖 Addressed by Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6066464130 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/950#issuecomment-6066464130). Originally posted by [CnRJay](https://github.com/CnRJay) on 2026-10-08T18:29:59Z. --- Thanks, you're right: I missed KytyPS5's body. Updated in f0e7c93a: - I now follow KytyPS5: `data` under `EV_ERROR`, otherwise 0. It targets PS5, it matches FreeBSD kevent (errno in `data` under `EV_ERROR`), and fpPS4's own header comments `EV_ERROR` as "data contains errno", which contradicts its `fflags` accessor. I don't have a console `libkernel` to disassemble, so this stays an inference. - The test builds an event with `EV_ADD | EV_ERROR` and `data = 22`, plus a nonzero `fflags` that must be ignored. It also checks that `data` without `EV_ERROR` gives 0. - Added a TechnicalDebt line under "Unknown function info" covering the field choice, the unknown raw-errno vs SCE-code question (fpPS4's `0x80020000`), and the null-event difference from KytyPS5. - The description now lists all four references accurately. _🤖 Addressed by [Claude Code](https://claude.com/claude-code)_
WifeInLantern commented 2026-10-09 07:50:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by WifeInLantern on 2026-10-09T07:50:09Z.


Windows 11 (26200), WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON, #950 merged onto current main (clean). guest_equeue_events passes; reverting only EventAccessors.cpp to main makes it abort, so the test covers the change. check_conventions.py --base origin/main passes.

#1464 and #2003 implement the same one-line behaviour (data under EV_ERROR, else 0). #950 is the oldest, has CI and a review, and its debt entry is the most complete, so it looks like the one to keep. One check from #2003 is missing here: an event with every flag bit except EV_ERROR set must report 0.

Nothing in the project currently sets EV_ERROR on a delivered event (grep of core outside tests), so this reports 0 for every real event until something does. Not verified against the console library.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6076783046 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/950#issuecomment-6076783046). Originally posted by [WifeInLantern](https://github.com/WifeInLantern) on 2026-10-09T07:50:09Z. --- Windows 11 (26200), WinLibs GCC 15.2.0 r7, Release, `BUILD_TESTING=ON`, #950 merged onto current main (clean). `guest_equeue_events` passes; reverting only `EventAccessors.cpp` to main makes it abort, so the test covers the change. `check_conventions.py --base origin/main` passes. #1464 and #2003 implement the same one-line behaviour (`data` under `EV_ERROR`, else 0). #950 is the oldest, has CI and a review, and its debt entry is the most complete, so it looks like the one to keep. One check from #2003 is missing here: an event with every flag bit except `EV_ERROR` set must report 0. Nothing in the project currently sets `EV_ERROR` on a delivered event (grep of `core` outside tests), so this reports 0 for every real event until something does. Not verified against the console library.
oneandonlydean commented 2026-10-09 09:21:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T09:21:48Z.


Which title reaches sceKernelGetEventError on main? Same question as on #1205: with the ID and the log line this can go in; otherwise I'll close it until one does.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6078113115 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/950#issuecomment-6078113115). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-09T09:21:48Z. --- Which title reaches `sceKernelGetEventError` on main? Same question as on #1205: with the ID and the log line this can go in; otherwise I'll close it until one does.
CnRJay commented 2026-10-09 18:43:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-10-09T18:43:45Z.


Closing: no title on hand that reaches sceKernelGetEventError on main. Will reopen with a title ID and log line if one turns up.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6087105061 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/950#issuecomment-6087105061). Originally posted by [CnRJay](https://github.com/CnRJay) on 2026-10-09T18:43:45Z. --- Closing: no title on hand that reaches sceKernelGetEventError on main. Will reopen with a title ID and log line if one turns up.

Pull request closed

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!950
No description provided.