diff --git a/CMakeLists.txt b/CMakeLists.txt index a967c540..657b7c5b 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -276,6 +276,7 @@ set(SYSTEM_LIBS src/core/libraries/system/commondialog.cpp src/core/libraries/save_data/dialog/savedatadialog_ui.h src/core/libraries/system/sysmodule.cpp src/core/libraries/system/sysmodule.h + src/core/libraries/system/system_error.h src/core/libraries/system/systemservice.cpp src/core/libraries/system/systemservice.h src/core/libraries/system/userservice.cpp diff --git a/src/core/libraries/system/sysmodule.cpp b/src/core/libraries/system/sysmodule.cpp index d37c375b..8ea61e17 100644 --- a/src/core/libraries/system/sysmodule.cpp +++ b/src/core/libraries/system/sysmodule.cpp @@ -9,6 +9,7 @@ #include "core/libraries/error_codes.h" #include "core/libraries/libs.h" #include "core/libraries/system/sysmodule.h" +#include "core/libraries/system/system_error.h" namespace Libraries::SysModule { @@ -34,11 +35,23 @@ int PS4_SYSV_ABI sceSysmoduleIsCameraPreloaded() { int PS4_SYSV_ABI sceSysmoduleIsLoaded(OrbisSysModule id) { LOG_ERROR(Lib_SysModule, "(DUMMY) called module = {}", magic_enum::enum_name(id)); + if (static_cast(id) == 0) { + LOG_ERROR(Lib_SysModule, "Invalid sysmodule ID: {:#x}", static_cast(id)); + return ORBIS_SYSMODULE_INVALID_ID; + } return ORBIS_OK; } -int PS4_SYSV_ABI sceSysmoduleIsLoadedInternal() { - LOG_ERROR(Lib_SysModule, "(STUBBED) called"); +int PS4_SYSV_ABI sceSysmoduleIsLoadedInternal(OrbisSysModuleInternal id) { + LOG_ERROR(Lib_SysModule, "(DUMMY) called module = {:#x}", static_cast(id)); + if ((static_cast(id) & 0x7FFFFFFF) == 0) { + LOG_ERROR(Lib_SysModule, "Invalid internal sysmodule ID: {:#x}", static_cast(id)); + return ORBIS_SYSMODULE_INVALID_ID; + } + if (id == OrbisSysModuleInternal::ORBIS_SYSMODULE_INTERNAL_RAZOR_CPU) { + // Internal debugging library, report as not loaded so it won't be used. + return ORBIS_SYSMODULE_NOT_LOADED; + } return ORBIS_OK; } diff --git a/src/core/libraries/system/sysmodule.h b/src/core/libraries/system/sysmodule.h index c9ec97ce..3630fb58 100644 --- a/src/core/libraries/system/sysmodule.h +++ b/src/core/libraries/system/sysmodule.h @@ -147,12 +147,16 @@ enum class OrbisSysModule : u16 { ORBIS_SYSMODULE_KEYBOARD = 0x0106, }; +enum class OrbisSysModuleInternal : u32 { + ORBIS_SYSMODULE_INTERNAL_RAZOR_CPU = 0x80000019, // libSceRazorCpu.sprx +}; + int PS4_SYSV_ABI sceSysmoduleGetModuleHandleInternal(); int PS4_SYSV_ABI sceSysmoduleGetModuleInfoForUnwind(); int PS4_SYSV_ABI sceSysmoduleIsCalledFromSysModule(); int PS4_SYSV_ABI sceSysmoduleIsCameraPreloaded(); int PS4_SYSV_ABI sceSysmoduleIsLoaded(OrbisSysModule id); -int PS4_SYSV_ABI sceSysmoduleIsLoadedInternal(); +int PS4_SYSV_ABI sceSysmoduleIsLoadedInternal(OrbisSysModuleInternal id); int PS4_SYSV_ABI sceSysmoduleLoadModule(OrbisSysModule id); int PS4_SYSV_ABI sceSysmoduleLoadModuleByNameInternal(); int PS4_SYSV_ABI sceSysmoduleLoadModuleInternal(); diff --git a/src/core/libraries/system/system_error.h b/src/core/libraries/system/system_error.h new file mode 100644 index 00000000..615e4cd5 --- /dev/null +++ b/src/core/libraries/system/system_error.h @@ -0,0 +1,8 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +constexpr int ORBIS_SYSMODULE_INVALID_ID = 0x805A1000; +constexpr int ORBIS_SYSMODULE_NOT_LOADED = 0x805A1001; +constexpr int ORBIS_SYSMODULE_LOCK_FAILED = 0x805A10FF; \ No newline at end of file diff --git a/src/emulator.cpp b/src/emulator.cpp index c0b01229..27291707 100644 --- a/src/emulator.cpp +++ b/src/emulator.cpp @@ -269,7 +269,7 @@ void Emulator::Run(const std::filesystem::path& file) { } void Emulator::LoadSystemModules(const std::filesystem::path& file, std::string game_serial) { - constexpr std::array ModulesToLoad{ + constexpr std::array ModulesToLoad{ {{"libSceNgs2.sprx", &Libraries::Ngs2::RegisterlibSceNgs2}, {"libSceFiber.sprx", &Libraries::Fiber::RegisterlibSceFiber}, {"libSceUlt.sprx", nullptr}, @@ -279,7 +279,6 @@ void Emulator::LoadSystemModules(const std::filesystem::path& file, std::string {"libSceDiscMap.sprx", &Libraries::DiscMap::RegisterlibSceDiscMap}, {"libSceRtc.sprx", &Libraries::Rtc::RegisterlibSceRtc}, {"libSceJpegEnc.sprx", nullptr}, - {"libSceRazorCpu.sprx", nullptr}, {"libSceCesCs.sprx", nullptr}}}; std::vector found_modules;