diff --git a/src/common/path_util.cpp b/src/common/path_util.cpp index 293ee1b74..243bc15b4 100644 --- a/src/common/path_util.cpp +++ b/src/common/path_util.cpp @@ -34,6 +34,8 @@ static auto UserPaths = [] { create_path(PathType::ShaderDir, user_dir / SHADER_DIR); create_path(PathType::PM4Dir, user_dir / PM4_DIR); create_path(PathType::SaveDataDir, user_dir / SAVEDATA_DIR); + create_path(PathType::GameDataDir, user_dir / GAMEDATA_DIR); + create_path(PathType::TempDataDir, user_dir / TEMPDATA_DIR); create_path(PathType::SysModuleDir, user_dir / SYSMODULES_DIR); return paths; diff --git a/src/common/path_util.h b/src/common/path_util.h index d7664871c..57a9a73fa 100644 --- a/src/common/path_util.h +++ b/src/common/path_util.h @@ -15,6 +15,8 @@ enum class PathType { ShaderDir, // Where shaders are stored. PM4Dir, // Where command lists are stored. SaveDataDir, // Where guest save data is stored. + TempDataDir, // Where game temp data is stored. + GameDataDir, // Where game data is stored. SysModuleDir, // Where system modules are stored. }; @@ -26,6 +28,8 @@ constexpr auto SCREENSHOTS_DIR = "screenshots"; constexpr auto SHADER_DIR = "shader"; constexpr auto PM4_DIR = "pm4"; constexpr auto SAVEDATA_DIR = "savedata"; +constexpr auto GAMEDATA_DIR = "data"; +constexpr auto TEMPDATA_DIR = "temp"; constexpr auto SYSMODULES_DIR = "sys_modules"; // Filenames diff --git a/src/core/libraries/app_content/app_content.cpp b/src/core/libraries/app_content/app_content.cpp index b05ac1b4c..fc7139c28 100644 --- a/src/core/libraries/app_content/app_content.cpp +++ b/src/core/libraries/app_content/app_content.cpp @@ -3,7 +3,12 @@ // Generated By moduleGenerator #include +#include +#include +#include +#include #include "app_content.h" +#include "common/io_file.h" #include "common/logging/log.h" #include "core/libraries/error_codes.h" #include "core/libraries/libs.h" @@ -157,8 +162,15 @@ int PS4_SYSV_ABI sceAppContentTemporaryDataMount() { return ORBIS_OK; } -int PS4_SYSV_ABI sceAppContentTemporaryDataMount2() { - LOG_ERROR(Lib_AppContent, "(STUBBED) called"); +int PS4_SYSV_ABI sceAppContentTemporaryDataMount2(OrbisAppContentTemporaryDataOption option, + OrbisAppContentMountPoint* mountPoint) { + auto* param_sfo = Common::Singleton::Instance(); + std::string id(param_sfo->GetString("CONTENT_ID"), 7, 9); + const auto& mount_dir = Common::FS::GetUserPath(Common::FS::PathType::TempDataDir) / id; + auto* mnt = Common::Singleton::Instance(); + mnt->Mount(mount_dir, mountPoint->data); + LOG_INFO(Lib_AppContent, "sceAppContentTemporaryDataMount2: option = {}, mountPoint = {}", + (option & 1), mountPoint->data); return ORBIS_OK; } diff --git a/src/core/libraries/app_content/app_content.h b/src/core/libraries/app_content/app_content.h index f2c05fba5..30a8e1c26 100644 --- a/src/core/libraries/app_content/app_content.h +++ b/src/core/libraries/app_content/app_content.h @@ -21,6 +21,13 @@ struct OrbisAppContentBootParam { char reserved2[32]; }; +typedef u32 OrbisAppContentTemporaryDataOption; +constexpr int ORBIS_APP_CONTENT_MOUNTPOINT_DATA_MAXSIZE = 16; +typedef struct OrbisAppContentMountPoint { + + char data[ORBIS_APP_CONTENT_MOUNTPOINT_DATA_MAXSIZE]; +} OrbisAppContentMountPoint; + int PS4_SYSV_ABI _Z5dummyv(); int PS4_SYSV_ABI sceAppContentAddcontDelete(); int PS4_SYSV_ABI sceAppContentAddcontEnqueueDownload(); @@ -51,7 +58,8 @@ int PS4_SYSV_ABI sceAppContentSmallSharedDataUnmount(); int PS4_SYSV_ABI sceAppContentTemporaryDataFormat(); int PS4_SYSV_ABI sceAppContentTemporaryDataGetAvailableSpaceKb(); int PS4_SYSV_ABI sceAppContentTemporaryDataMount(); -int PS4_SYSV_ABI sceAppContentTemporaryDataMount2(); +int PS4_SYSV_ABI sceAppContentTemporaryDataMount2(OrbisAppContentTemporaryDataOption option, + OrbisAppContentMountPoint* mountPoint); int PS4_SYSV_ABI sceAppContentTemporaryDataUnmount(); int PS4_SYSV_ABI sceAppContentGetPftFlag(); int PS4_SYSV_ABI Func_C59A36FF8D7C59DA(); diff --git a/src/core/libraries/kernel/thread_management.cpp b/src/core/libraries/kernel/thread_management.cpp index 41b2e5a6d..997d52891 100644 --- a/src/core/libraries/kernel/thread_management.cpp +++ b/src/core/libraries/kernel/thread_management.cpp @@ -1147,7 +1147,7 @@ int PS4_SYSV_ABI posix_sched_get_priority_min() { int PS4_SYSV_ABI posix_pthread_mutex_trylock(ScePthreadMutex* mutex) { int result = scePthreadMutexTrylock(mutex); if (result < 0) { - UNREACHABLE(); + LOG_INFO(Kernel_Pthread, "posix_pthread_mutex_trylock: result = {}", result); } return result; } diff --git a/src/emulator.cpp b/src/emulator.cpp index 562a88cda..d1338f0c1 100644 --- a/src/emulator.cpp +++ b/src/emulator.cpp @@ -56,13 +56,14 @@ void Emulator::Run(const std::filesystem::path& file) { mnt->Mount(file.parent_path(), "/app0"); // Loading param.sfo file if exists + std::string id; std::filesystem::path sce_sys_folder = file.parent_path() / "sce_sys"; if (std::filesystem::is_directory(sce_sys_folder)) { for (const auto& entry : std::filesystem::directory_iterator(sce_sys_folder)) { if (entry.path().filename() == "param.sfo") { auto* param_sfo = Common::Singleton::Instance(); param_sfo->open(sce_sys_folder.string() + "/param.sfo", {}); - std::string id(param_sfo->GetString("CONTENT_ID"), 7, 9); + id = std::string(param_sfo->GetString("CONTENT_ID"), 7, 9); std::string title(param_sfo->GetString("TITLE")); LOG_INFO(Loader, "Game id: {} Title: {}", id, title); u32 fw_version = param_sfo->GetInteger("SYSTEM_VER"); @@ -81,6 +82,14 @@ void Emulator::Run(const std::filesystem::path& file) { } } + const auto& mount_data_dir = Common::FS::GetUserPath(Common::FS::PathType::GameDataDir) / id; + if (!std::filesystem::exists(mount_data_dir)) { + std::filesystem::create_directory(mount_data_dir); + } + mnt->Mount(mount_data_dir, "/data"); // should just exist, manually create with game serial + const auto& mount_temp_dir = Common::FS::GetUserPath(Common::FS::PathType::TempDataDir) / id; + mnt->Mount(mount_temp_dir, "/temp0"); // called in app_content ==> stat/mkdir + // Load the module with the linker linker->LoadModule(file);