From 9ad749566175921e6ea9a4b661913ecf2679c197 Mon Sep 17 00:00:00 2001 From: psucien Date: Fri, 17 May 2024 23:29:10 +0200 Subject: [PATCH] kernel: user event and data functions --- src/core/libraries/kernel/event_queues.cpp | 30 +++++++++++++++++++--- src/core/libraries/kernel/event_queues.h | 2 ++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/core/libraries/kernel/event_queues.cpp b/src/core/libraries/kernel/event_queues.cpp index 4e239784..d8d3bfdf 100644 --- a/src/core/libraries/kernel/event_queues.cpp +++ b/src/core/libraries/kernel/event_queues.cpp @@ -34,7 +34,7 @@ int PS4_SYSV_ABI sceKernelCreateEqueue(SceKernelEqueue* eq, const char* name) { int PS4_SYSV_ABI sceKernelDeleteEqueue(SceKernelEqueue eq) { if (eq == nullptr) { - return SCE_KERNEL_ERROR_EBADF; + return ORBIS_KERNEL_ERROR_EBADF; } delete eq; @@ -46,7 +46,7 @@ int PS4_SYSV_ABI sceKernelWaitEqueue(SceKernelEqueue eq, SceKernelEvent* ev, int LOG_INFO(Kernel_Event, "num = {}", num); if (eq == nullptr) { - return SCE_KERNEL_ERROR_EBADF; + return ORBIS_KERNEL_ERROR_EBADF; } if (ev == nullptr) { @@ -71,7 +71,31 @@ int PS4_SYSV_ABI sceKernelWaitEqueue(SceKernelEqueue eq, SceKernelEvent* ev, int } } - return SCE_OK; + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceKernelAddUserEvent(SceKernelEqueue eq, int id) { + if (eq == nullptr) { + return ORBIS_KERNEL_ERROR_EBADF; + } + + Kernel::EqueueEvent event{}; + event.isTriggered = false; + event.event.ident = id; + event.event.filter = Kernel::EVFILT_USER; + event.event.udata = 0; + event.event.fflags = 0; + event.event.data = 0; + + return eq->addEvent(event); +} + +void* PS4_SYSV_ABI sceKernelGetEventUserData(const SceKernelEvent* ev) { + if (!ev) { + return nullptr; + } + + return ev->udata; } } // namespace Libraries::Kernel diff --git a/src/core/libraries/kernel/event_queues.h b/src/core/libraries/kernel/event_queues.h index df78f9ce..3c08ed5f 100644 --- a/src/core/libraries/kernel/event_queues.h +++ b/src/core/libraries/kernel/event_queues.h @@ -14,5 +14,7 @@ int PS4_SYSV_ABI sceKernelCreateEqueue(SceKernelEqueue* eq, const char* name); int PS4_SYSV_ABI sceKernelDeleteEqueue(SceKernelEqueue eq); int PS4_SYSV_ABI sceKernelWaitEqueue(SceKernelEqueue eq, SceKernelEvent* ev, int num, int* out, SceKernelUseconds* timo); +void* PS4_SYSV_ABI sceKernelGetEventUserData(const SceKernelEvent* ev); +int PS4_SYSV_ABI sceKernelAddUserEvent(SceKernelEqueue eq, int id); } // namespace Libraries::Kernel