Stub out SetGPO and GetGPI (#3135)

This commit is contained in:
kalaposfos13 2025-06-21 14:23:14 +02:00 committed by GitHub
parent 1fc95bf44b
commit 2d335f436c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 40 additions and 24 deletions

View file

@ -76,21 +76,21 @@ static PS4_SYSV_ABI void stack_chk_fail() {
UNREACHABLE(); UNREACHABLE();
} }
static thread_local int g_posix_errno = 0; static thread_local s32 g_posix_errno = 0;
int* PS4_SYSV_ABI __Error() { s32* PS4_SYSV_ABI __Error() {
return &g_posix_errno; return &g_posix_errno;
} }
void ErrSceToPosix(int error) { void ErrSceToPosix(s32 error) {
g_posix_errno = error - ORBIS_KERNEL_ERROR_UNKNOWN; g_posix_errno = error - ORBIS_KERNEL_ERROR_UNKNOWN;
} }
int ErrnoToSceKernelError(int error) { s32 ErrnoToSceKernelError(s32 error) {
return error + ORBIS_KERNEL_ERROR_UNKNOWN; return error + ORBIS_KERNEL_ERROR_UNKNOWN;
} }
void SetPosixErrno(int e) { void SetPosixErrno(s32 e) {
// Some error numbers are different between supported OSes // Some error numbers are different between supported OSes
switch (e) { switch (e) {
case EPERM: case EPERM:
@ -132,15 +132,15 @@ void SetPosixErrno(int e) {
} }
} }
static uint64_t g_mspace_atomic_id_mask = 0; static u64 g_mspace_atomic_id_mask = 0;
static uint64_t g_mstate_table[64] = {0}; static u64 g_mstate_table[64] = {0};
struct HeapInfoInfo { struct HeapInfoInfo {
uint64_t size = sizeof(HeapInfoInfo); u64 size = sizeof(HeapInfoInfo);
uint32_t flag; u32 flag;
uint32_t getSegmentInfo; u32 getSegmentInfo;
uint64_t* mspace_atomic_id_mask; u64* mspace_atomic_id_mask;
uint64_t* mstate_table; u64* mstate_table;
}; };
void PS4_SYSV_ABI sceLibcHeapGetTraceInfo(HeapInfoInfo* info) { void PS4_SYSV_ABI sceLibcHeapGetTraceInfo(HeapInfoInfo* info) {
@ -159,7 +159,7 @@ struct OrbisKernelUuid {
}; };
static_assert(sizeof(OrbisKernelUuid) == 0x10); static_assert(sizeof(OrbisKernelUuid) == 0x10);
int PS4_SYSV_ABI sceKernelUuidCreate(OrbisKernelUuid* orbisUuid) { s32 PS4_SYSV_ABI sceKernelUuidCreate(OrbisKernelUuid* orbisUuid) {
if (!orbisUuid) { if (!orbisUuid) {
return ORBIS_KERNEL_ERROR_EINVAL; return ORBIS_KERNEL_ERROR_EINVAL;
} }
@ -176,7 +176,7 @@ int PS4_SYSV_ABI sceKernelUuidCreate(OrbisKernelUuid* orbisUuid) {
return ORBIS_OK; return ORBIS_OK;
} }
int PS4_SYSV_ABI kernel_ioctl(int fd, u64 cmd, VA_ARGS) { s32 PS4_SYSV_ABI kernel_ioctl(s32 fd, u64 cmd, VA_ARGS) {
auto* h = Common::Singleton<Core::FileSys::HandleTable>::Instance(); auto* h = Common::Singleton<Core::FileSys::HandleTable>::Instance();
auto* file = h->GetFile(fd); auto* file = h->GetFile(fd);
if (file == nullptr) { if (file == nullptr) {
@ -190,7 +190,7 @@ int PS4_SYSV_ABI kernel_ioctl(int fd, u64 cmd, VA_ARGS) {
return -1; return -1;
} }
VA_CTX(ctx); VA_CTX(ctx);
int result = file->device->ioctl(cmd, &ctx); s32 result = file->device->ioctl(cmd, &ctx);
LOG_TRACE(Lib_Kernel, "ioctl: fd = {:X} cmd = {:X} result = {}", fd, cmd, result); LOG_TRACE(Lib_Kernel, "ioctl: fd = {:X} cmd = {:X} result = {}", fd, cmd, result);
if (result < 0) { if (result < 0) {
ErrSceToPosix(result); ErrSceToPosix(result);
@ -204,15 +204,15 @@ const char* PS4_SYSV_ABI sceKernelGetFsSandboxRandomWord() {
return path; return path;
} }
int PS4_SYSV_ABI _sigprocmask() { s32 PS4_SYSV_ABI _sigprocmask() {
return ORBIS_OK; return ORBIS_OK;
} }
int PS4_SYSV_ABI posix_getpagesize() { s32 PS4_SYSV_ABI posix_getpagesize() {
return 16_KB; return 16_KB;
} }
int PS4_SYSV_ABI posix_getsockname(Libraries::Net::OrbisNetId s, s32 PS4_SYSV_ABI posix_getsockname(Libraries::Net::OrbisNetId s,
Libraries::Net::OrbisNetSockaddr* addr, u32* paddrlen) { Libraries::Net::OrbisNetSockaddr* addr, u32* paddrlen) {
auto* netcall = Common::Singleton<Libraries::Net::NetInternal>::Instance(); auto* netcall = Common::Singleton<Libraries::Net::NetInternal>::Instance();
auto sock = netcall->FindSocket(s); auto sock = netcall->FindSocket(s);
@ -221,7 +221,7 @@ int PS4_SYSV_ABI posix_getsockname(Libraries::Net::OrbisNetId s,
LOG_ERROR(Lib_Net, "socket id is invalid = {}", s); LOG_ERROR(Lib_Net, "socket id is invalid = {}", s);
return -1; return -1;
} }
int returncode = sock->GetSocketAddress(addr, paddrlen); s32 returncode = sock->GetSocketAddress(addr, paddrlen);
if (returncode >= 0) { if (returncode >= 0) {
LOG_ERROR(Lib_Net, "return code : {:#x}", (u32)returncode); LOG_ERROR(Lib_Net, "return code : {:#x}", (u32)returncode);
return 0; return 0;
@ -230,6 +230,19 @@ int PS4_SYSV_ABI posix_getsockname(Libraries::Net::OrbisNetId s,
LOG_ERROR(Lib_Net, "error code returned : {:#x}", (u32)returncode); LOG_ERROR(Lib_Net, "error code returned : {:#x}", (u32)returncode);
return -1; return -1;
} }
// stubbed on non-devkit consoles
s32 PS4_SYSV_ABI sceKernelGetGPI() {
LOG_DEBUG(Kernel, "called");
return ORBIS_OK;
}
// stubbed on non-devkit consoles
s32 PS4_SYSV_ABI sceKernelSetGPO() {
LOG_DEBUG(Kernel, "called");
return ORBIS_OK;
}
void RegisterKernel(Core::Loader::SymbolsResolver* sym) { void RegisterKernel(Core::Loader::SymbolsResolver* sym) {
service_thread = std::jthread{KernelServiceThread}; service_thread = std::jthread{KernelServiceThread};
@ -277,6 +290,9 @@ void RegisterKernel(Core::Loader::SymbolsResolver* sym) {
LIB_FUNCTION("3e+4Iv7IJ8U", "libScePosix", 1, "libkernel", 1, 1, Libraries::Net::sys_accept); LIB_FUNCTION("3e+4Iv7IJ8U", "libScePosix", 1, "libkernel", 1, 1, Libraries::Net::sys_accept);
LIB_FUNCTION("aNeavPDNKzA", "libScePosix", 1, "libkernel", 1, 1, Libraries::Net::sys_sendmsg); LIB_FUNCTION("aNeavPDNKzA", "libScePosix", 1, "libkernel", 1, 1, Libraries::Net::sys_sendmsg);
LIB_FUNCTION("pxnCmagrtao", "libScePosix", 1, "libkernel", 1, 1, Libraries::Net::sys_listen); LIB_FUNCTION("pxnCmagrtao", "libScePosix", 1, "libkernel", 1, 1, Libraries::Net::sys_listen);
LIB_FUNCTION("4oXYe9Xmk0Q", "libkernel", 1, "libkernel", 1, 1, sceKernelGetGPI);
LIB_FUNCTION("ca7v6Cxulzs", "libkernel", 1, "libkernel", 1, 1, sceKernelSetGPO);
} }
} // namespace Libraries::Kernel } // namespace Libraries::Kernel

View file

@ -12,10 +12,10 @@ class SymbolsResolver;
namespace Libraries::Kernel { namespace Libraries::Kernel {
void ErrSceToPosix(int result); void ErrSceToPosix(s32 result);
int ErrnoToSceKernelError(int e); s32 ErrnoToSceKernelError(s32 e);
void SetPosixErrno(int e); void SetPosixErrno(s32 e);
int* PS4_SYSV_ABI __Error(); s32* PS4_SYSV_ABI __Error();
template <class F, F f> template <class F, F f>
struct OrbisWrapperImpl; struct OrbisWrapperImpl;
@ -33,7 +33,7 @@ struct OrbisWrapperImpl<PS4_SYSV_ABI R (*)(Args...), f> {
#define ORBIS(func) (Libraries::Kernel::OrbisWrapperImpl<decltype(&(func)), func>::wrap) #define ORBIS(func) (Libraries::Kernel::OrbisWrapperImpl<decltype(&(func)), func>::wrap)
int* PS4_SYSV_ABI __Error(); s32* PS4_SYSV_ABI __Error();
void RegisterKernel(Core::Loader::SymbolsResolver* sym); void RegisterKernel(Core::Loader::SymbolsResolver* sym);