Merge pull request #130 from shadps4-emu/kernel_stuff

Kernel stuff & others
This commit is contained in:
georgemoralis 2024-05-13 14:19:33 +03:00 committed by GitHub
commit 98316575fb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 426127 additions and 11238 deletions

View file

@ -45,7 +45,6 @@ jobs:
mkdir upload
move build/Release/shadps4.exe upload
move build/Release/zlib-ng2.dll upload
move build/Release/libwinpthread-1.dll upload
windeployqt --dir upload upload/shadps4.exe
- name: Upload executable

View file

@ -37,5 +37,4 @@ jobs:
# A file, directory or wildcard pattern that describes what to upload
path: |
${{github.workspace}}/build/Release/shadps4.exe
${{github.workspace}}/build/Release/SDL3.dll
${{github.workspace}}/build/Release/libwinpthread-1.dll
${{github.workspace}}/build/Release/SDL3.dll

10
.gitmodules vendored
View file

@ -6,10 +6,6 @@
path = third-party/zydis
url = https://github.com/zyantific/zydis.git
shallow = true
[submodule "third-party/winpthread"]
path = third-party/winpthread
url = https://github.com/shadps4/winpthread.git
branch = main
[submodule "third-party/toml11"]
path = third-party/toml11
url = https://github.com/ToruNiina/toml11
@ -18,9 +14,6 @@
path = third-party/xxHash
url = https://github.com/Cyan4973/xxHash.git
branch = dev
[submodule "third-party/vulkan"]
path = third-party/vulkan
url = https://github.com/GPUCode/vulkan
[submodule "externals/discord-rpc"]
path = externals/discord-rpc
url = https://github.com/shadps4-emu/ext-discord-rpc.git
@ -64,3 +57,6 @@
[submodule "externals/xbyak"]
path = externals/xbyak
url = https://github.com/herumi/xbyak
[submodule "externals/winpthreads"]
path = externals/winpthreads
url = https://github.com/shadps4-emu/winpthreads.git

View file

@ -403,7 +403,7 @@ if (ENABLE_QT_GUI)
endif()
if (WIN32)
target_link_libraries(shadps4 PRIVATE mincore winpthread clang_rt.builtins-x86_64.lib)
target_link_libraries(shadps4 PRIVATE mincore winpthreads clang_rt.builtins-x86_64.lib)
add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS)
add_definitions(-DNOMINMAX -DWIN32_LEAN_AND_MEAN)
if (MSVC)
@ -438,9 +438,3 @@ add_custom_command(TARGET shadps4 POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
$<TARGET_FILE:SDL3-shared>
$<TARGET_FILE_DIR:shadps4>)
if (WIN32)
add_custom_command(TARGET shadps4 POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${PROJECT_SOURCE_DIR}/third-party/winpthread/bin/libwinpthread-1.dll" $<TARGET_FILE_DIR:shadps4>)
endif()

View file

@ -66,3 +66,9 @@ add_subdirectory(robin-map EXCLUDE_FROM_ALL)
# Xbyak
add_subdirectory(xbyak EXCLUDE_FROM_ALL)
# Winpthreads
if (WIN32)
add_subdirectory(winpthreads EXCLUDE_FROM_ALL)
target_include_directories(winpthreads INTERFACE winpthreads/include)
endif()

2
externals/fmt vendored

@ -1 +1 @@
Subproject commit aa52eb765dec0eb67fab4b035a4a05b82346c8f5
Subproject commit d2473b7b73c0af2a3ed34c99e50ace0a1040581a

2
externals/glslang vendored

@ -1 +1 @@
Subproject commit 2db79056b418587e61122a8a820cd832b2abdf83
Subproject commit effcbf7893a177b756bc80bf74009a950c3073a1

2
externals/robin-map vendored

@ -1 +1 @@
Subproject commit 048eb1442a76ab81ecb3c4ab0495f15a68e54a6d
Subproject commit 1115dad3ffa0994e3f43b693d9b9cc99944c64c1

2
externals/sdl3 vendored

@ -1 +1 @@
Subproject commit cbb3c69cb0d771cdd221339aa1a064c55ec6e67d
Subproject commit bcbf09acdef71b550e837c8aaca67b08b6a38f0f

2
externals/vma vendored

@ -1 +1 @@
Subproject commit 5677097bafb8477097c6e3354ce68b7a44fd01a4
Subproject commit eaf8fc27eeadf6f21b11183651b829e897f01957

@ -1 +1 @@
Subproject commit cfebfc96b2b0bce93da7d12f2c14cc01793ae25c
Subproject commit 4bc77c26ff9ce89cf4a4f79e1c24a44604132d53

1
externals/winpthreads vendored Submodule

@ -0,0 +1 @@
Subproject commit d937b60055aaea313422672ebd5cc8bfa87a1682

2
externals/zlib-ng vendored

@ -1 +1 @@
Subproject commit 3f35bfccff2d1dacdfe9844712be1e042d028700
Subproject commit 1007e7a9c74148fe915384d7cc44921559500241

171520
scripts/aerolib.inl Normal file

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,7 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include <chrono>
#include <thread>
#include "common/assert.h"
#include "common/logging/log.h"
@ -16,7 +17,6 @@
#include "core/libraries/kernel/time_management.h"
#include "core/libraries/libs.h"
#include "core/linker.h"
#ifdef _WIN64
#include <io.h>
#include <windows.h>
@ -158,6 +158,27 @@ s64 PS4_SYSV_ABI ps4__write(int d, const void* buf, std::size_t nbytes) {
return ORBIS_OK;
}
int PS4_SYSV_ABI sceKernelConvertUtcToLocaltime(time_t time, time_t* local_time,
struct OrbisTimesec* st, unsigned long* dst_sec) {
LOG_TRACE(Kernel, "Called");
const auto* time_zone = std::chrono::current_zone();
auto info = time_zone->get_info(std::chrono::system_clock::now());
*local_time = info.offset.count() + info.save.count() * 60 + time;
if (st != nullptr) {
st->t = time;
st->west_sec = info.offset.count() * 60;
st->dst_sec = info.save.count() * 60;
}
if (dst_sec != nullptr) {
*dst_sec = info.save.count() * 60;
}
return ORBIS_OK;
}
void LibKernel_Register(Core::Loader::SymbolsResolver* sym) {
// obj
LIB_OBJ("f7uOxY9mM1U", "libkernel", 1, "libkernel", 1, 1, &g_stack_chk_guard);
@ -179,6 +200,7 @@ void LibKernel_Register(Core::Loader::SymbolsResolver* sym) {
LIB_FUNCTION("1jfXLRVzisc", "libkernel", 1, "libkernel", 1, 1, sceKernelUsleep);
LIB_FUNCTION("YSHRBRLn2pI", "libkernel", 1, "libkernel", 1, 1, _writev);
LIB_FUNCTION("959qrazPIrg", "libkernel", 1, "libkernel", 1, 1, sceKernelGetProcParam);
LIB_FUNCTION("-o5uEDpN+oY", "libkernel", 1, "libkernel", 1, 1, sceKernelConvertUtcToLocaltime);
Libraries::Kernel::fileSystemSymbolsRegister(sym);
Libraries::Kernel::timeSymbolsRegister(sym);

View file

@ -12,6 +12,12 @@ class SymbolsResolver;
namespace Libraries::Kernel {
struct OrbisTimesec {
time_t t;
u64 west_sec;
u64 dst_sec;
};
int32_t PS4_SYSV_ABI sceKernelReleaseDirectMemory(off_t start, size_t len);
int* PS4_SYSV_ABI __Error();

View file

@ -8,6 +8,9 @@
#include "core/libraries/error_codes.h"
#include "core/libraries/kernel/thread_management.h"
#include "core/libraries/libs.h"
#ifdef _WIN64
#include <windows.h>
#endif
namespace Libraries::Kernel {
@ -890,6 +893,12 @@ void PS4_SYSV_ABI scePthreadYield() {
sched_yield();
}
int PS4_SYSV_ABI scePthreadDetach(ScePthread thread) {
LOG_INFO(Kernel_Pthread, "thread create name = {}", thread->name);
thread->is_detached = true;
return ORBIS_OK;
}
void pthreadSymbolsRegister(Core::Loader::SymbolsResolver* sym) {
LIB_FUNCTION("4+h9EzwKF4I", "libkernel", 1, "libkernel", 1, 1, scePthreadAttrSetschedpolicy);
LIB_FUNCTION("-Wreprtu0Qs", "libkernel", 1, "libkernel", 1, 1, scePthreadAttrSetdetachstate);
@ -897,11 +906,13 @@ void pthreadSymbolsRegister(Core::Loader::SymbolsResolver* sym) {
LIB_FUNCTION("DzES9hQF4f4", "libkernel", 1, "libkernel", 1, 1, scePthreadAttrSetschedparam);
LIB_FUNCTION("nsYoNRywwNg", "libkernel", 1, "libkernel", 1, 1, scePthreadAttrInit);
LIB_FUNCTION("62KCwEMmzcM", "libkernel", 1, "libkernel", 1, 1, scePthreadAttrDestroy);
LIB_FUNCTION("4qGrR6eoP9Y", "libkernel", 1, "libkernel", 1, 1, scePthreadDetach);
LIB_FUNCTION("aI+OeCz8xrQ", "libkernel", 1, "libkernel", 1, 1, scePthreadSelf);
LIB_FUNCTION("3qxgM4ezETA", "libkernel", 1, "libkernel", 1, 1, scePthreadAttrSetaffinity);
LIB_FUNCTION("8+s5BzZjxSg", "libkernel", 1, "libkernel", 1, 1, scePthreadAttrGetaffinity);
LIB_FUNCTION("x1X76arYMxU", "libkernel", 1, "libkernel", 1, 1, scePthreadAttrGet);
LIB_FUNCTION("UTXzJbWhhTE", "libkernel", 1, "libkernel", 1, 1, scePthreadAttrSetstacksize);
LIB_FUNCTION("bt3CTBKmGyI", "libkernel", 1, "libkernel", 1, 1, scePthreadSetaffinity);
LIB_FUNCTION("6UgtwV+0zb4", "libkernel", 1, "libkernel", 1, 1, scePthreadCreate);
@ -928,6 +939,7 @@ void pthreadSymbolsRegister(Core::Loader::SymbolsResolver* sym) {
LIB_FUNCTION("QBi7HCK03hw", "libkernel", 1, "libkernel", 1, 1, sceKernelClockGettime);
LIB_FUNCTION("lLMT9vJAck0", "libkernel", 1, "libkernel", 1, 1, clock_gettime);
LIB_FUNCTION("lLMT9vJAck0", "libScePosix", 1, "libkernel", 1, 1, clock_gettime);
LIB_FUNCTION("yS8U2TGCe1A", "libScePosix", 1, "libkernel", 1, 1, nanosleep);
// openorbis weird functions

View file

@ -12,15 +12,6 @@ add_subdirectory(magic_enum EXCLUDE_FROM_ALL)
# Toml11
add_subdirectory(toml11 EXCLUDE_FROM_ALL)
# Vulkan
add_subdirectory(vulkan EXCLUDE_FROM_ALL)
# Winpthreads
if (WIN32)
add_subdirectory(winpthread EXCLUDE_FROM_ALL)
target_include_directories(winpthread INTERFACE winpthread/include)
endif()
# xxHash
add_library(xxhash INTERFACE)
target_include_directories(xxhash INTERFACE xxhash)

1
third-party/vulkan vendored

@ -1 +0,0 @@
Subproject commit 72b2e740754bc6b86b724fa5b2c90dca6f69462e

@ -1 +0,0 @@
Subproject commit 918de958b720c3ba7bc47f4988609c0109a0f75b