initial file system work

This commit is contained in:
georgemoralis 2023-10-16 13:27:37 +03:00
parent 675193fec3
commit 1fb53a5430
7 changed files with 58 additions and 1 deletions

View File

@ -43,6 +43,12 @@ set(SYSTEMSERVICE_SOURCES src/Emulator/HLE/Libraries/LibSystemService/system_ser
src/Emulator/HLE/Libraries/LibSystemService/system_service.h
)
set(FILESYSTEM_SOURCES src/Emulator/HLE/Libraries/LibKernel/FileSystem/file_system.cpp
src/Emulator/HLE/Libraries/LibKernel/FileSystem/file_system.h
src/Emulator/HLE/Libraries/LibKernel/FileSystem/posix_file_system.cpp
src/Emulator/HLE/Libraries/LibKernel/FileSystem/posix_file_system.h
)
set(UTIL_SOURCES src/Emulator/Util/singleton.h
)
@ -51,6 +57,7 @@ add_executable(shadps4
${USERSERVICE_SOURCES}
${PAD_SOURCES}
${SYSTEMSERVICE_SOURCES}
${FILESYSTEM_SOURCES}
${UTIL_SOURCES}
src/main.cpp
src/types.h
@ -86,7 +93,7 @@ add_executable(shadps4
src/Core/PS4/HLE/Kernel/cpu_management.cpp
src/Core/PS4/HLE/Kernel/cpu_management.h
"src/Util/Disassembler.cpp" "src/Util/Disassembler.h" "src/Core/PS4/Util/aerolib.h" "src/Core/PS4/Loader/SymbolsResolver.h" "src/Core/PS4/Loader/SymbolsResolver.cpp" "src/Core/PS4/HLE/Libs.cpp" "src/Core/PS4/HLE/Libs.h" "src/Core/PS4/HLE/LibC.cpp" "src/Core/PS4/HLE/LibC.h" "src/Lib/Timer.cpp" "src/Lib/Timer.h" "src/Core/PS4/HLE/LibKernel.cpp" "src/Core/PS4/HLE/LibKernel.h" "src/Core/PS4/HLE/LibSceGnmDriver.cpp" "src/Core/PS4/HLE/LibSceGnmDriver.h" "src/Core/PS4/HLE/Kernel/ThreadManagement.cpp" "src/Core/PS4/HLE/Kernel/ThreadManagement.h" "src/Core/PS4/HLE/ErrorCodes.h" "src/debug.h" "src/Core/PS4/HLE/Kernel/memory_management.cpp" "src/Core/PS4/HLE/Kernel/memory_management.h" "src/Core/PS4/GPU/gpu_memory.cpp" "src/Core/PS4/GPU/gpu_memory.h" "src/emulator.cpp" "src/emulator.h" "src/Core/PS4/HLE/Kernel/Objects/event_queue.h" "src/Core/PS4/HLE/Kernel/Objects/event_queue.cpp" "src/Core/PS4/HLE/Graphics/Objects/video_out_ctx.cpp" "src/Core/PS4/HLE/Graphics/Objects/video_out_ctx.h" "src/Core/PS4/HLE/Graphics/graphics_ctx.h" "src/vulkan_util.cpp" "src/vulkan_util.h" "src/Core/PS4/GPU/video_out_buffer.cpp" "src/Core/PS4/GPU/video_out_buffer.h" "src/Core/PS4/HLE/Graphics/graphics_render.cpp" "src/Core/PS4/HLE/Graphics/graphics_render.h" "src/Core/PS4/GPU/tile_manager.cpp" "src/Core/PS4/GPU/tile_manager.h" "src/version.h" "src/Emulator/HLE/Libraries/LibSystemService/system_service.cpp" "src/Emulator/HLE/Libraries/LibSystemService/system_service.h")
"src/Util/Disassembler.cpp" "src/Util/Disassembler.h" "src/Core/PS4/Util/aerolib.h" "src/Core/PS4/Loader/SymbolsResolver.h" "src/Core/PS4/Loader/SymbolsResolver.cpp" "src/Core/PS4/HLE/Libs.cpp" "src/Core/PS4/HLE/Libs.h" "src/Core/PS4/HLE/LibC.cpp" "src/Core/PS4/HLE/LibC.h" "src/Lib/Timer.cpp" "src/Lib/Timer.h" "src/Core/PS4/HLE/LibKernel.cpp" "src/Core/PS4/HLE/LibKernel.h" "src/Core/PS4/HLE/LibSceGnmDriver.cpp" "src/Core/PS4/HLE/LibSceGnmDriver.h" "src/Core/PS4/HLE/Kernel/ThreadManagement.cpp" "src/Core/PS4/HLE/Kernel/ThreadManagement.h" "src/Core/PS4/HLE/ErrorCodes.h" "src/debug.h" "src/Core/PS4/HLE/Kernel/memory_management.cpp" "src/Core/PS4/HLE/Kernel/memory_management.h" "src/Core/PS4/GPU/gpu_memory.cpp" "src/Core/PS4/GPU/gpu_memory.h" "src/emulator.cpp" "src/emulator.h" "src/Core/PS4/HLE/Kernel/Objects/event_queue.h" "src/Core/PS4/HLE/Kernel/Objects/event_queue.cpp" "src/Core/PS4/HLE/Graphics/Objects/video_out_ctx.cpp" "src/Core/PS4/HLE/Graphics/Objects/video_out_ctx.h" "src/Core/PS4/HLE/Graphics/graphics_ctx.h" "src/vulkan_util.cpp" "src/vulkan_util.h" "src/Core/PS4/GPU/video_out_buffer.cpp" "src/Core/PS4/GPU/video_out_buffer.h" "src/Core/PS4/HLE/Graphics/graphics_render.cpp" "src/Core/PS4/HLE/Graphics/graphics_render.h" "src/Core/PS4/GPU/tile_manager.cpp" "src/Core/PS4/GPU/tile_manager.h" "src/version.h" "src/Emulator/HLE/Libraries/LibSystemService/system_service.cpp" "src/Emulator/HLE/Libraries/LibSystemService/system_service.h" "src/Emulator/HLE/Libraries/LibKernel/FileSystem/file_system.cpp" "src/Emulator/HLE/Libraries/LibKernel/FileSystem/file_system.h" "src/Emulator/HLE/Libraries/LibKernel/FileSystem/posix_file_system.cpp" "src/Emulator/HLE/Libraries/LibKernel/FileSystem/posix_file_system.h")
find_package(OpenGL REQUIRED)
target_link_libraries(shadps4 PUBLIC fmt mincore spdlog IMGUI SDL3-shared ${OPENGL_LIBRARY} vulkan-1 spirv-tools-opt spirv-tools)

View File

@ -107,6 +107,9 @@ void PS4_SYSV_ABI qsort(void* ptr, size_t count,size_t size, int(PS4_SYSV_ABI* c
std::qsort(ptr, count, size, qsort_compair);
}
void* PS4_SYSV_ABI fopen(const char* filename, const char* mode) {
return std::fopen(filename, mode);
}
void LibC_Register(SymbolsResolver* sym) {
LIB_FUNCTION("bzQExy189ZI", "libc", 1, "libc", 1, 1, init_env);
@ -137,6 +140,7 @@ void LibC_Register(SymbolsResolver* sym) {
LIB_FUNCTION("eT2UsmTewbU", "libc", 1, "libc", 1, 1, _ZSt11_Xbad_allocv);
LIB_FUNCTION("tQIo+GIPklo", "libc", 1, "libc", 1, 1, _ZSt14_Xlength_errorPKc);
LIB_FUNCTION("fJnpuVVBbKk", "libc", 1, "libc", 1, 1, _Znwm);
LIB_FUNCTION("xeYO4u7uyJ0", "libc", 1, "libc", 1, 1, fopen);
}
}; // namespace HLE::Libs::LibC

View File

@ -10,6 +10,8 @@
#include "Kernel/event_queues.h"
#include "Kernel/memory_management.h"
#include "Libs.h"
#include "Emulator/HLE/Libraries/LibKernel/FileSystem/file_system.h"
#include "Emulator/HLE/Libraries/LibKernel/FileSystem/posix_file_system.h"
namespace HLE::Libs::LibKernel {
@ -44,6 +46,9 @@ void LibKernel_Register(SymbolsResolver* sym) {
LIB_FUNCTION("Ou3iL1abvng", "libkernel", 1, "libkernel", 1, 1, stack_chk_fail);
// time
LIB_FUNCTION("-2IRUCO--PM", "libkernel", 1, "libkernel", 1, 1, sceKernelReadTsc);
//fs
LIB_FUNCTION("1G3lF1Gg1k8", "libkernel", 1, "libkernel", 1, 1, Emulator::HLE::Libraries::LibKernel::FileSystem::sceKernelOpen);
LIB_FUNCTION("wuCroIGjt2g", "libScePosix", 1, "libkernel", 1, 1, Emulator::HLE::Libraries::LibKernel::FileSystem::POSIX::open);
}
}; // namespace HLE::Libs::LibKernel

View File

@ -0,0 +1,13 @@
#include "file_system.h"
#include <debug.h>
#include <Util/log.h>
namespace Emulator::HLE::Libraries::LibKernel::FileSystem {
constexpr bool log_file_fs = true; // disable it to disable logging
int PS4_SYSV_ABI sceKernelOpen(const char* path, int flags, u16 mode) {
LOG_INFO_IF(log_file_fs, "sceKernelOpen path = {} flags = {} mode = {}\n", path, log_hex_full(flags), log_hex_full(mode));
return 0;
}
} // namespace Emulator::HLE::Libraries::LibKernel::FileSystem

View File

@ -0,0 +1,7 @@
#pragma once
#include <types.h>
namespace Emulator::HLE::Libraries::LibKernel::FileSystem {
int PS4_SYSV_ABI sceKernelOpen(const char *path, int flags, /* SceKernelMode*/ u16 mode);
}

View File

@ -0,0 +1,15 @@
#include "posix_file_system.h"
#include <debug.h>
#include "file_system.h"
namespace Emulator::HLE::Libraries::LibKernel::FileSystem::POSIX {
int PS4_SYSV_ABI open(const char* path, int flags, /* SceKernelMode*/ u16 mode) {
int result = sceKernelOpen(path, flags, mode);
if (result < 0) {
BREAKPOINT(); // posix calls different only for their return values
}
return result;
}
} // namespace Emulator::HLE::Libraries::LibKernel::FileSystem::POSIX

View File

@ -0,0 +1,6 @@
#pragma once
#include "types.h"
namespace Emulator::HLE::Libraries::LibKernel::FileSystem::POSIX {
int PS4_SYSV_ABI open(const char *path, int flags, /* SceKernelMode*/ u16 mode);
}