From 02cba0100d08b84963bd6536e4b3239a8664970b Mon Sep 17 00:00:00 2001 From: raziel1000 Date: Sun, 14 Jul 2024 00:34:48 -0600 Subject: [PATCH] Some functions called by Stardew Valley --- src/core/libraries/kernel/file_system.cpp | 1 + src/core/libraries/kernel/libkernel.cpp | 5 ++++ .../libraries/kernel/thread_management.cpp | 25 +++++++++++++++++++ src/core/libraries/kernel/thread_management.h | 1 + 4 files changed, 32 insertions(+) diff --git a/src/core/libraries/kernel/file_system.cpp b/src/core/libraries/kernel/file_system.cpp index eb6248d0..466399e1 100644 --- a/src/core/libraries/kernel/file_system.cpp +++ b/src/core/libraries/kernel/file_system.cpp @@ -464,6 +464,7 @@ void fileSystemSymbolsRegister(Core::Loader::SymbolsResolver* sym) { LIB_FUNCTION("1G3lF1Gg1k8", "libkernel", 1, "libkernel", 1, 1, sceKernelOpen); LIB_FUNCTION("wuCroIGjt2g", "libScePosix", 1, "libkernel", 1, 1, posix_open); LIB_FUNCTION("UK2Tl2DWUns", "libkernel", 1, "libkernel", 1, 1, sceKernelClose); + LIB_FUNCTION("bY-PO6JhzhQ", "libkernel", 1, "libkernel", 1, 1, posix_close); LIB_FUNCTION("bY-PO6JhzhQ", "libScePosix", 1, "libkernel", 1, 1, posix_close); LIB_FUNCTION("4wSze92BhLI", "libkernel", 1, "libkernel", 1, 1, sceKernelWrite); diff --git a/src/core/libraries/kernel/libkernel.cpp b/src/core/libraries/kernel/libkernel.cpp index 9f57ff53..fbf86cdf 100644 --- a/src/core/libraries/kernel/libkernel.cpp +++ b/src/core/libraries/kernel/libkernel.cpp @@ -351,6 +351,10 @@ int PS4_SYSV_ABI _sigprocmask() { return ORBIS_OK; } +int PS4_SYSV_ABI posix_getpagesize() { + return 4096; +} + void LibKernel_Register(Core::Loader::SymbolsResolver* sym) { service_thread = std::jthread{KernelServiceThread}; @@ -414,6 +418,7 @@ void LibKernel_Register(Core::Loader::SymbolsResolver* sym) { LIB_FUNCTION("-o5uEDpN+oY", "libkernel", 1, "libkernel", 1, 1, sceKernelConvertUtcToLocaltime); LIB_FUNCTION("WB66evu8bsU", "libkernel", 1, "libkernel", 1, 1, sceKernelGetCompiledSdkVersion); LIB_FUNCTION("DRuBt2pvICk", "libkernel", 1, "libkernel", 1, 1, ps4__read); + LIB_FUNCTION("k+AXqu2-eBc", "libScePosix", 1, "libkernel", 1, 1, posix_getpagesize); Libraries::Kernel::fileSystemSymbolsRegister(sym); Libraries::Kernel::timeSymbolsRegister(sym); diff --git a/src/core/libraries/kernel/thread_management.cpp b/src/core/libraries/kernel/thread_management.cpp index b31e777d..a0e0e8f2 100644 --- a/src/core/libraries/kernel/thread_management.cpp +++ b/src/core/libraries/kernel/thread_management.cpp @@ -1331,6 +1331,26 @@ int PS4_SYSV_ABI scePthreadSetprio(ScePthread thread, int prio) { return ORBIS_OK; } +int PS4_SYSV_ABI posix_pthread_condattr_init(ScePthreadCondattr* attr) { + int result = scePthreadCondattrInit(attr); + LOG_INFO(Kernel_Pthread, + "posix_pthread_condattr_init redirect to scePthreadCondattrInit, result = {}", result); + return result; +} + +int PS4_SYSV_ABI posix_pthread_condattr_destroy(ScePthreadCondattr* attr) { + int result = scePthreadCondattrDestroy(attr); + LOG_INFO(Kernel_Pthread, + "posix_pthread_condattr_destroy redirect to scePthreadCondattrDestroy, result = {}", + result); + return result; +} + +int PS4_SYSV_ABI posix_pthread_condattr_setclock(ScePthreadCondattr* attr, clockid_t clock) { + (*attr)->clock = clock; + return SCE_OK; +} + void pthreadSymbolsRegister(Core::Loader::SymbolsResolver* sym) { LIB_FUNCTION("lZzFeSxPl08", "libScePosix", 1, "libkernel", 1, 1, posix_pthread_setcancelstate); LIB_FUNCTION("0TyVk4MSLt0", "libScePosix", 1, "libkernel", 1, 1, posix_pthread_cond_init); @@ -1418,6 +1438,11 @@ void pthreadSymbolsRegister(Core::Loader::SymbolsResolver* sym) { posix_pthread_mutexattr_setprotocol); LIB_FUNCTION("HF7lK46xzjY", "libScePosix", 1, "libkernel", 1, 1, posix_pthread_mutexattr_destroy); + LIB_FUNCTION("mKoTx03HRWA", "libScePosix", 1, "libkernel", 1, 1, posix_pthread_condattr_init); + LIB_FUNCTION("dJcuQVn6-Iw", "libScePosix", 1, "libkernel", 1, 1, + posix_pthread_condattr_destroy); + LIB_FUNCTION("EjllaAqAPZo", "libScePosix", 1, "libkernel", 1, 1, + posix_pthread_condattr_setclock); // openorbis weird functions LIB_FUNCTION("7H0iTOciTLo", "libkernel", 1, "libkernel", 1, 1, posix_pthread_mutex_lock); diff --git a/src/core/libraries/kernel/thread_management.h b/src/core/libraries/kernel/thread_management.h index 9926b379..8303c9ef 100644 --- a/src/core/libraries/kernel/thread_management.h +++ b/src/core/libraries/kernel/thread_management.h @@ -92,6 +92,7 @@ struct PthreadCondInternal { struct PthreadCondAttrInternal { u8 reserved[64]; pthread_condattr_t cond_attr; + clockid_t clock; }; struct PthreadRwLockAttrInternal {