Merge pull request #130 from shadps4-emu/kernel_stuff

Kernel stuff & others
This commit is contained in:
georgemoralis authored and GitHub committed 2024-05-13 14:19:33 +03:00
commit 98316575fb
22 files changed
+426127 -11238

No files matched your search

-1
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
+1 -2
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
+3 -7
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
+1 -7
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()
+6
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()
+1 -1
+1 -1
+1 -1
Vendored Submodule
+1
Submodule externals/winpthreads added at d937b60055.
+171520
View File
File diff suppressed because it is too large. Load diff
+94254 -11201
View File
File diff suppressed because it is too large. Load diff
+160293 -1
View File
File diff suppressed because it is too large. Load diff
+23 -1
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);
+6
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();
@@ -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
-9
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)
Submodule third-party/vulkan deleted from 72b2e74075.
Submodule third-party/winpthread deleted from 918de958b7.