initial sceKernelWaitEqueue implementation (WIP)

This commit is contained in:
georgemoralis 2023-09-08 08:28:01 +03:00
parent 5b6bbfc327
commit 98090ae42f
6 changed files with 37 additions and 10 deletions

View File

@ -1,6 +1,7 @@
#pragma once
constexpr int SCE_OK = 0;
constexpr int SCE_KERNEL_ERROR_EBADF = 0x80020009;
constexpr int SCE_KERNEL_ERROR_ENOMEM = 0x8002000c; // Insufficient memory
constexpr int SCE_KERNEL_ERROR_EFAULT = 0x8002000e; // Invalid address pointer
constexpr int SCE_KERNEL_ERROR_EINVAL = 0x80020016; // null or invalid states

View File

@ -38,7 +38,7 @@ using TriggerFunc = void (*)(EqueueEvent* event, void* trigger_data);
using ResetFunc = void (*)(EqueueEvent* event);
using DeleteFunc = void (*)(SceKernelEqueue eq, EqueueEvent* event);
struct Event {
struct SceKernelEvent {
u64 ident = 0; /* identifier for this event */
s16 filter = 0; /* filter for event */
u16 flags = 0;
@ -56,7 +56,7 @@ struct Filter {
struct EqueueEvent {
bool isTriggered = false;
Event event;
SceKernelEvent event;
Filter filter;
};

View File

@ -3,6 +3,7 @@
#include <Core/PS4/HLE/ErrorCodes.h>
#include <Core/PS4/HLE/Libs.h>
#include <Util/log.h>
#include <debug.h>
namespace HLE::Libs::LibKernel::EventQueues {
constexpr bool log_file_equeues = true; // disable it to disable logging
@ -34,4 +35,32 @@ int PS4_SYSV_ABI sceKernelCreateEqueue(SceKernelEqueue* eq, const char* name) {
LOG_INFO_IF(log_file_equeues, "sceKernelCreateEqueue created with name \"{}\"\n", name);
return SCE_OK;
}
int PS4_SYSV_ABI sceKernelWaitEqueue(SceKernelEqueue eq, HLE::Kernel::Objects::SceKernelEvent* ev, int num, int* out, SceKernelUseconds* timo) {
PRINT_FUNCTION_NAME();
if (eq == nullptr) {
return SCE_KERNEL_ERROR_EBADF;
}
if (ev == nullptr) {
return SCE_KERNEL_ERROR_EFAULT;
}
if (num < 1) {
return SCE_KERNEL_ERROR_EINVAL;
}
if (timo == nullptr) { // wait until an event arrives without timing out
// BREAKPOINT();//NOT supported yet TODO
}
if (timo != nullptr) {
if (*timo == 0) {//only events that have already arrived at the time of this function call can be received
BREAKPOINT();
} else { // wait until an event arrives with timing out
BREAKPOINT();
}
}
return SCE_OK;
}
}; // namespace HLE::Libs::LibKernel::EventQueues

View File

@ -1,10 +1,14 @@
#pragma once
#include <types.h>
#include "Objects/event_queue.h"
namespace HLE::Libs::LibKernel::EventQueues {
using SceKernelUseconds = u32;
using SceKernelEqueue = Kernel::Objects::EqueueInternal*;
int PS4_SYSV_ABI sceKernelCreateEqueue(SceKernelEqueue* eq, const char* name);
int PS4_SYSV_ABI sceKernelWaitEqueue(SceKernelEqueue eq, HLE::Kernel::Objects::SceKernelEvent* ev, int num, int* out, SceKernelUseconds *timo);
}; // namespace HLE::Libs::LibKernel::EventQueues

View File

@ -18,11 +18,6 @@ namespace HLE::Libs::LibKernel {
return 0;
}
int PS4_SYSV_ABI sceKernelWaitEqueue(/*SceKernelEqueue eq, SceKernelEvent* ev,*/ int num, int* out /*, SceKernelUseconds* timo*/)
{
PRINT_DUMMY_FUNCTION_NAME();
return 0;
}
static PS4_SYSV_ABI void stack_chk_fail() { BREAKPOINT();
}
@ -36,7 +31,7 @@ namespace HLE::Libs::LibKernel {
LIB_FUNCTION("MBuItvba6z8", "libkernel", 1, "libkernel", 1, 1, sceKernelReleaseDirectMemory);
//equeue
LIB_FUNCTION("D0OdFMjp46I", "libkernel", 1, "libkernel", 1, 1, EventQueues::sceKernelCreateEqueue);
LIB_FUNCTION("fzyMKs9kim0", "libkernel", 1, "libkernel", 1, 1, sceKernelWaitEqueue);
LIB_FUNCTION("fzyMKs9kim0", "libkernel", 1, "libkernel", 1, 1, EventQueues::sceKernelWaitEqueue);
//misc
LIB_FUNCTION("WslcK1FQcGI", "libkernel", 1, "libkernel", 1, 1, CPUManagement::sceKernelIsNeoMode);
LIB_FUNCTION("Ou3iL1abvng", "libkernel", 1, "libkernel", 1, 1, stack_chk_fail);

View File

@ -8,6 +8,4 @@ void LibKernel_Register(SymbolsResolver* sym);
int32_t PS4_SYSV_ABI sceKernelReleaseDirectMemory(off_t start, size_t len);
int PS4_SYSV_ABI sceKernelWaitEqueue(/*SceKernelEqueue eq, SceKernelEvent* ev,*/ int num, int* out /*, SceKernelUseconds* timo*/);
}; // namespace HLE::Libs::LibKernel