loading libSceNgs2 from sceSysmoduleLoadModule instead of startup. This will prevent loading modules at startup that games not using . Still some work left but main idea is this for other modules as well

This commit is contained in:
georgemoralis 2024-09-27 07:21:59 +03:00
parent b9a3cd49a3
commit cdc5223f02
3 changed files with 19 additions and 3 deletions

View file

@ -36,6 +36,8 @@ int* PS4_SYSV_ABI __Error();
int PS4_SYSV_ABI sceKernelConvertUtcToLocaltime(time_t time, time_t* local_time,
struct OrbisTimesec* st, unsigned long* dst_sec);
int PS4_SYSV_ABI sceKernelGetCompiledSdkVersion(int* ver);
s32 PS4_SYSV_ABI sceKernelLoadStartModule(const char* moduleFileName, size_t args, const void* argp,
u32 flags, const void* pOpt, int* pRes);
void LibKernel_Register(Core::Loader::SymbolsResolver* sym);

View file

@ -9,6 +9,7 @@
#include "core/libraries/error_codes.h"
#include "core/libraries/libs.h"
#include "core/libraries/system/sysmodule.h"
#include "core/libraries//kernel/libkernel.h"
namespace Libraries::SysModule {
@ -45,6 +46,13 @@ int PS4_SYSV_ABI sceSysmoduleIsLoadedInternal() {
int PS4_SYSV_ABI sceSysmoduleLoadModule(OrbisSysModule id) {
auto color_name = magic_enum::enum_name(id);
LOG_ERROR(Lib_SysModule, "(DUMMY) called module = {}", magic_enum::enum_name(id));
//const auto& sys_module_path = Common::FS::GetUserPath(Common::FS::PathType::SysModuleDir);
switch (id) {
case OrbisSysModule::ORBIS_SYSMODULE_NGS2:
Libraries::Kernel::sceKernelLoadStartModule("/system/common/lib/libSceNgs2.sprx", 0, NULL, 0,
NULL, NULL);
break;
}
return ORBIS_OK;
}

View file

@ -191,6 +191,9 @@ void Emulator::Run(const std::filesystem::path& file) {
}
VideoCore::SetOutputDir(mount_captures_dir, id);
const auto& sys_module_path = Common::FS::GetUserPath(Common::FS::PathType::SysModuleDir);
mnt->Mount(sys_module_path, "/system/common/lib");
// Initialize kernel and library facilities.
Libraries::Kernel::init_pthreads();
Libraries::InitHLELibs(&linker->GetHLESymbols());
@ -222,8 +225,8 @@ void Emulator::Run(const std::filesystem::path& file) {
}
void Emulator::LoadSystemModules(const std::filesystem::path& file) {
constexpr std::array<SysModules, 13> ModulesToLoad{
{{"libSceNgs2.sprx", &Libraries::Ngs2::RegisterlibSceNgs2},
constexpr std::array<SysModules, 12> ModulesToLoad{
{/* {"libSceNgs2.sprx", &Libraries::Ngs2::RegisterlibSceNgs2},*/
{"libSceFiber.sprx", nullptr},
{"libSceUlt.sprx", nullptr},
{"libSceJson.sprx", nullptr},
@ -247,7 +250,10 @@ void Emulator::LoadSystemModules(const std::filesystem::path& file) {
found_modules, [&](const auto& path) { return path.filename() == module_name; });
if (it != found_modules.end()) {
LOG_INFO(Loader, "Loading {}", it->string());
linker->LoadModule(*it);
if (!(it->string() == "libSceNgs2.sprx")) {
linker->LoadModule(*it);
}
continue;
}
if (init_func) {