From a2a6303a22cff91a2307fbf0b8a07b32027cc5d3 Mon Sep 17 00:00:00 2001 From: Eladash Date: Thu, 12 May 2022 08:08:36 +0300 Subject: [PATCH] PPU LLVM: Precompile system-internal executables if booting a dev_flash's program --- rpcs3/Emu/Cell/PPUThread.cpp | 23 ++++++++++++++++++++--- rpcs3/rpcs3qt/main_window.cpp | 2 +- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/rpcs3/Emu/Cell/PPUThread.cpp b/rpcs3/Emu/Cell/PPUThread.cpp index 87413ced6a..49f6aea5d4 100644 --- a/rpcs3/Emu/Cell/PPUThread.cpp +++ b/rpcs3/Emu/Cell/PPUThread.cpp @@ -2343,7 +2343,7 @@ extern void ppu_finalize(const ppu_module& info) // Get PPU cache location cache_path = fs::get_cache_dir() + "cache/"; - const std::string dev_flash = vfs::get("/dev_flash/"); + const std::string dev_flash = vfs::get("/dev_flash/sys/"); if (info.path.starts_with(dev_flash) || Emu.GetCat() == "1P") { @@ -2699,9 +2699,26 @@ extern void ppu_initialize() std::vector dir_queue; - if (compile_fw) + const std::string mount_point = vfs::get("/dev_flash/"); + + bool dev_flash_located = Emu.GetCat().back() != 'P' && Emu.IsPathInsideDir(Emu.GetBoot(), mount_point); + + if (compile_fw || dev_flash_located) { - const std::string firmware_sprx_path = vfs::get("/dev_flash/sys/external/"); + if (dev_flash_located) + { + const std::string eseibrd = mount_point + "/vsh/module/eseibrd.sprx"; + + if (auto prx = ppu_load_prx(ppu_prx_object{decrypt_self(fs::file{eseibrd})}, eseibrd, 0)) + { + // Check if cache exists for this infinitesimally small prx + dev_flash_located = ppu_initialize(*prx, true); + idm::remove(idm::last_id()); + ppu_unload_prx(*prx); + } + } + + const std::string firmware_sprx_path = vfs::get(dev_flash_located ? "/dev_flash/"sv : "/dev_flash/sys/"sv); dir_queue.emplace_back(firmware_sprx_path); } diff --git a/rpcs3/rpcs3qt/main_window.cpp b/rpcs3/rpcs3qt/main_window.cpp index 58e719a2de..abfff5b343 100644 --- a/rpcs3/rpcs3qt/main_window.cpp +++ b/rpcs3/rpcs3qt/main_window.cpp @@ -2666,7 +2666,7 @@ void main_window::CreateFirmwareCache() Emu.GracefulShutdown(false); Emu.SetForceBoot(true); - if (const game_boot_result error = Emu.BootGame(g_cfg_vfs.get_dev_flash(), "", true); + if (const game_boot_result error = Emu.BootGame(g_cfg_vfs.get_dev_flash() + "sys", "", true); error != game_boot_result::no_errors) { gui_log.error("Creating firmware cache failed: reason: %s", error);