From 2c782721851ba4bb66ad5964944c4f6ee6f990f7 Mon Sep 17 00:00:00 2001 From: Stephen Miller <56742918+StevenMiller123@users.noreply.github.com> Date: Tue, 3 Jun 2025 00:02:51 -0500 Subject: [PATCH] Emulate libSceGnmDriver's init behavior (#3024) This time, perform it after the LoadSharedLibraries call, which places it after the various init memory mappings GFD engine titles perform. --- src/core/linker.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/core/linker.cpp b/src/core/linker.cpp index 3e6d8c22e..c50b03a8f 100644 --- a/src/core/linker.cpp +++ b/src/core/linker.cpp @@ -117,6 +117,18 @@ void Linker::Execute(const std::vector args) { Common::SetCurrentThreadName("GAME_MainThread"); LoadSharedLibraries(); + // Simulate libSceGnmDriver initialization, which maps a chunk of direct memory. + // Some games fail without accurately emulating this behavior. + s64 phys_addr{}; + s32 result = Libraries::Kernel::sceKernelAllocateDirectMemory( + 0, Libraries::Kernel::sceKernelGetDirectMemorySize(), 0x10000, 0x10000, 3, &phys_addr); + if (result == 0) { + void* addr{reinterpret_cast(0xfe0000000)}; + result = Libraries::Kernel::sceKernelMapNamedDirectMemory( + &addr, 0x10000, 0x13, 0, phys_addr, 0x10000, "SceGnmDriver"); + } + ASSERT_MSG(result == 0, "Unable to emulate libSceGnmDriver initialization"); + // Start main module. EntryParams params{}; params.argc = 1;