some more HLE functions
This commit is contained in:
parent
830542e870
commit
67da986e19
|
@ -23,7 +23,18 @@ add_subdirectory("third-party")
|
|||
#=================== EXAMPLE ===================
|
||||
include_directories(src)
|
||||
|
||||
set(LIBC_SOURCES src/Emulator/HLE/Libraries/LibC/Libc.cpp
|
||||
src/Emulator/HLE/Libraries/LibC/Libc.h
|
||||
src/Emulator/HLE/Libraries/LibC/printf.h
|
||||
src/Emulator/HLE/Libraries/LibC/va_ctx.h
|
||||
)
|
||||
set(USERSERVICE_SOURCES src/Emulator/HLE/Libraries/LibUserService/user_service.cpp
|
||||
src/Emulator/HLE/Libraries/LibUserService/user_service.h
|
||||
)
|
||||
|
||||
add_executable(shadps4
|
||||
${LIBC_SOURCES}
|
||||
${USERSERVICE_SOURCES}
|
||||
src/main.cpp
|
||||
src/types.h
|
||||
src/Core/FsFile.cpp
|
||||
|
@ -55,7 +66,7 @@ add_executable(shadps4
|
|||
src/Core/PS4/HLE/Kernel/cpu_management.cpp
|
||||
src/Core/PS4/HLE/Kernel/cpu_management.h
|
||||
|
||||
"src/Util/Singleton.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/LibC/printf.h" "src/Emulator/HLE/Libraries/LibC/va_ctx.h" "src/Emulator/HLE/Libraries/LibC/libc.cpp" "src/Emulator/HLE/Libraries/LibC/libc.h")
|
||||
"src/Util/Singleton.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")
|
||||
|
||||
find_package(OpenGL REQUIRED)
|
||||
target_link_libraries(shadps4 PUBLIC fmt mincore spdlog IMGUI SDL3-shared ${OPENGL_LIBRARY} vulkan-1 spirv-tools-opt spirv-tools)
|
||||
|
|
|
@ -292,6 +292,7 @@ s32 PS4_SYSV_ABI sceVideoOutOpen(SceUserServiceUserId userId, s32 busType, s32 i
|
|||
|
||||
return handle;
|
||||
}
|
||||
s32 PS4_SYSV_ABI sceVideoOutUnregisterBuffers(s32 handle, s32 attributeIndex) { BREAKPOINT(); }
|
||||
|
||||
void videoOutRegisterLib(SymbolsResolver* sym) {
|
||||
LIB_FUNCTION("SbU3dwp80lQ", "libSceVideoOut", 1, "libSceVideoOut", 0, 0, sceVideoOutGetFlipStatus);
|
||||
|
@ -303,5 +304,6 @@ void videoOutRegisterLib(SymbolsResolver* sym) {
|
|||
LIB_FUNCTION("6kPnj51T62Y", "libSceVideoOut", 1, "libSceVideoOut", 0, 0, sceVideoOutGetResolutionStatus);
|
||||
LIB_FUNCTION("Up36PTk687E", "libSceVideoOut", 1, "libSceVideoOut", 0, 0, sceVideoOutOpen);
|
||||
LIB_FUNCTION("zgXifHT9ErY", "libSceVideoOut", 1, "libSceVideoOut", 0, 0, sceVideoOutIsFlipPending);
|
||||
LIB_FUNCTION("N5KDtkIjjJ4", "libSceVideoOut", 1, "libSceVideoOut", 0, 0, sceVideoOutUnregisterBuffers);
|
||||
}
|
||||
} // namespace HLE::Libs::Graphics::VideoOut
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
#include <Core/PS4/GPU/gpu_memory.h>
|
||||
#include <Core/virtual_memory.h>
|
||||
#include <Util/log.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <bit>
|
||||
#include <magic_enum.hpp>
|
||||
|
||||
#include <Util/log.h>
|
||||
#include "../../../../Util/Singleton.h"
|
||||
#include "../ErrorCodes.h"
|
||||
#include "../Libs.h"
|
||||
|
@ -92,6 +92,7 @@ int PS4_SYSV_ABI sceKernelMapDirectMemory(void** addr, u64 len, int prot, int fl
|
|||
GPU::MemoryMode gpu_mode = GPU::MemoryMode::NoAccess;
|
||||
|
||||
switch (prot) {
|
||||
case 0x32:
|
||||
case 0x33: // SCE_KERNEL_PROT_CPU_READ|SCE_KERNEL_PROT_CPU_WRITE|SCE_KERNEL_PROT_GPU_READ|SCE_KERNEL_PROT_GPU_ALL
|
||||
cpu_mode = VirtualMemory::MemoryMode::ReadWrite;
|
||||
gpu_mode = GPU::MemoryMode::ReadWrite;
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "../Loader/Elf.h"
|
||||
#include "Libs.h"
|
||||
#include "Emulator/HLE/Libraries/LibC/libc.h"
|
||||
#include "ErrorCodes.h"
|
||||
|
||||
|
||||
namespace HLE::Libs::LibC {
|
||||
|
@ -79,18 +80,24 @@ static PS4_SYSV_ABI void catchReturnFromMain(int status) {
|
|||
|
||||
static PS4_SYSV_ABI void _Assert() { BREAKPOINT(); }
|
||||
|
||||
PS4_SYSV_ABI int puts(const char* s) {
|
||||
std::puts(s);
|
||||
return SCE_OK;
|
||||
}
|
||||
|
||||
void LibC_Register(SymbolsResolver* sym) {
|
||||
LIB_FUNCTION("bzQExy189ZI", "libc", 1, "libc", 1, 1, init_env);
|
||||
LIB_FUNCTION("3GPpjQdAMTw", "libc", 1, "libc", 1, 1, __cxa_guard_acquire);
|
||||
LIB_FUNCTION("9rAeANT2tyE", "libc", 1, "libc", 1, 1, __cxa_guard_release);
|
||||
LIB_FUNCTION("DfivPArhucg", "libc", 1, "libc", 1, 1, Emulator::HLE::Libraries::LibC::memcmp);
|
||||
LIB_FUNCTION("Q3VBxCXhUHs", "libc", 1, "libc", 1, 1, Emulator::HLE::Libraries::LibC::memcpy);
|
||||
LIB_FUNCTION("8zTFvBIAIN8", "libc", 1, "libc", 1, 1, Emulator::HLE::Libraries::LibC::memset);
|
||||
LIB_FUNCTION("XKRegsFpEpk", "libc", 1, "libc", 1, 1, catchReturnFromMain);
|
||||
LIB_FUNCTION("uMei1W9uyNo", "libc", 1, "libc", 1, 1, Emulator::HLE::Libraries::LibC::exit);
|
||||
LIB_FUNCTION("8G2LB+A3rzg", "libc", 1, "libc", 1, 1, Emulator::HLE::Libraries::LibC::atexit);
|
||||
LIB_FUNCTION("-QgqOT5u2Vk", "libc", 1, "libc", 1, 1, _Assert);
|
||||
LIB_FUNCTION("hcuQgD53UxM", "libc", 1, "libc", 1, 1, Emulator::HLE::Libraries::LibC::printf);
|
||||
|
||||
LIB_FUNCTION("YQ0navp+YIc", "libc", 1, "libc", 1, 1, puts);
|
||||
LIB_OBJ("P330P3dFF68", "libc", 1, "libc", 1, 1, &HLE::Libs::LibC::g_need_sceLibc);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
#include "../Loader/Elf.h"
|
||||
#include "LibKernel.h"
|
||||
#include "Libs.h"
|
||||
#include <debug.h>
|
||||
|
||||
#include <Util/log.h>
|
||||
#include "Kernel/memory_management.h"
|
||||
#include <debug.h>
|
||||
|
||||
#include "../../../Util/Singleton.h"
|
||||
#include "../Loader/Elf.h"
|
||||
#include "Kernel/Objects/physical_memory.h"
|
||||
#include "Kernel/cpu_management.h"
|
||||
#include "Kernel/event_queues.h"
|
||||
#include "Kernel/memory_management.h"
|
||||
#include "Libs.h"
|
||||
|
||||
namespace HLE::Libs::LibKernel {
|
||||
|
||||
|
@ -18,14 +20,13 @@ namespace HLE::Libs::LibKernel {
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static PS4_SYSV_ABI void stack_chk_fail() { BREAKPOINT();
|
||||
}
|
||||
static PS4_SYSV_ABI void stack_chk_fail() { BREAKPOINT(); }
|
||||
u64 PS4_SYSV_ABI sceKernelReadTsc() {
|
||||
LARGE_INTEGER c;
|
||||
QueryPerformanceCounter(&c);
|
||||
return c.QuadPart;
|
||||
}
|
||||
int PS4_SYSV_ABI sceKernelMunmap(void* addr, size_t len) { BREAKPOINT(); }
|
||||
void LibKernel_Register(SymbolsResolver* sym) {
|
||||
// obj
|
||||
LIB_OBJ("f7uOxY9mM1U", "libkernel", 1, "libkernel", 1, 1, &HLE::Libs::LibKernel::g_stack_chk_guard);
|
||||
|
@ -34,6 +35,7 @@ namespace HLE::Libs::LibKernel {
|
|||
LIB_FUNCTION("pO96TwzOm5E", "libkernel", 1, "libkernel", 1, 1, MemoryManagement::sceKernelGetDirectMemorySize);
|
||||
LIB_FUNCTION("L-Q3LEjIbgA", "libkernel", 1, "libkernel", 1, 1, MemoryManagement::sceKernelMapDirectMemory);
|
||||
LIB_FUNCTION("MBuItvba6z8", "libkernel", 1, "libkernel", 1, 1, sceKernelReleaseDirectMemory);
|
||||
LIB_FUNCTION("cQke9UuBQOk", "libkernel", 1, "libkernel", 1, 1, sceKernelMunmap);
|
||||
// equeue
|
||||
LIB_FUNCTION("D0OdFMjp46I", "libkernel", 1, "libkernel", 1, 1, EventQueues::sceKernelCreateEqueue);
|
||||
LIB_FUNCTION("fzyMKs9kim0", "libkernel", 1, "libkernel", 1, 1, EventQueues::sceKernelWaitEqueue);
|
||||
|
@ -44,4 +46,4 @@ namespace HLE::Libs::LibKernel {
|
|||
LIB_FUNCTION("-2IRUCO--PM", "libkernel", 1, "libkernel", 1, 1, sceKernelReadTsc);
|
||||
}
|
||||
|
||||
};
|
||||
}; // namespace HLE::Libs::LibKernel
|
|
@ -26,4 +26,6 @@ int PS4_SYSV_ABI memcmp(const void* s1, const void* s2, size_t n) { return std::
|
|||
|
||||
void* PS4_SYSV_ABI memcpy(void* dest, const void* src, size_t n) { return std::memcpy(dest, src, n); }
|
||||
|
||||
void* PS4_SYSV_ABI memset(void* s, int c, size_t n) { return std::memset(s, c, n); }
|
||||
|
||||
}; // namespace Emulator::HLE::Libraries::LibC
|
|
@ -12,4 +12,5 @@ PS4_SYSV_ABI void exit(int code);
|
|||
PS4_SYSV_ABI int atexit(void (*func)());
|
||||
int PS4_SYSV_ABI memcmp(const void* s1, const void* s2, size_t n);
|
||||
void* PS4_SYSV_ABI memcpy(void* dest, const void* src, size_t n);
|
||||
void* PS4_SYSV_ABI memset(void* s, int c, size_t n);
|
||||
} // namespace Emulator::HLE::Libraries::LibC
|
|
@ -0,0 +1,5 @@
|
|||
#include "user_service.h"
|
||||
|
||||
namespace Emulator::HLE::Libraries::LibUserService {
|
||||
void libUserService_Register(SymbolsResolver* sym) {}
|
||||
}; // namespace Emulator::HLE::Libraries::LibUserService
|
|
@ -0,0 +1,6 @@
|
|||
#pragma once
|
||||
#include "Core/PS4/Loader/SymbolsResolver.h"
|
||||
|
||||
namespace Emulator::HLE::Libraries::LibUserService {
|
||||
void libUserService_Register(SymbolsResolver* sym);
|
||||
};
|
Loading…
Reference in New Issue