From 0fa7d5d02c5021cbeb20b11a46be0510b7d4a0a2 Mon Sep 17 00:00:00 2001 From: Younes Date: Sat, 15 Jun 2024 08:51:51 -0600 Subject: [PATCH] - sceKernelUuidCreate, sceAppContentAppParamGetInt, sceAppContentTemporaryDataMount2 (#199) - PlayGo - stub libusbd -added /temp0 and /data mounts at emu start. (Ghost Files: Memory of a Crime, Abyss: The Wraiths of Eden) - some posix functions --- CMakeLists.txt | 11 + src/common/logging/filter.cpp | 2 + src/common/logging/types.h | 2 + src/common/path_util.cpp | 2 + src/common/path_util.h | 4 + src/core/file_format/psf.cpp | 4 +- .../libraries/app_content/app_content.cpp | 46 +- src/core/libraries/app_content/app_content.h | 34 +- src/core/libraries/kernel/file_system.cpp | 15 +- src/core/libraries/kernel/libkernel.cpp | 19 + src/core/libraries/kernel/libkernel.h | 9 + .../libraries/kernel/thread_management.cpp | 18 + src/core/libraries/libs.cpp | 4 + src/core/libraries/playgo/playgo.cpp | 144 ++++++ src/core/libraries/playgo/playgo.h | 40 ++ src/core/libraries/playgo/playgo_types.h | 60 +++ src/core/libraries/usbd/usbd.cpp | 410 ++++++++++++++++++ src/core/libraries/usbd/usbd.h | 79 ++++ src/emulator.cpp | 11 +- 19 files changed, 900 insertions(+), 14 deletions(-) create mode 100644 src/core/libraries/playgo/playgo.cpp create mode 100644 src/core/libraries/playgo/playgo.h create mode 100644 src/core/libraries/playgo/playgo_types.h create mode 100644 src/core/libraries/usbd/usbd.cpp create mode 100644 src/core/libraries/usbd/usbd.h diff --git a/CMakeLists.txt b/CMakeLists.txt index d85e4da7..5df7ad33 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -196,6 +196,15 @@ set(PNG_LIB src/core/libraries/libpng/pngdec.cpp src/core/libraries/libpng/pngdec.h ) +set(PLAYGO_LIB src/core/libraries/playgo/playgo.cpp + src/core/libraries/playgo/playgo.h + src/core/libraries/playgo/playgo_types.h +) + +set(USBD_LIB src/core/libraries/usbd/usbd.cpp + src/core/libraries/usbd/usbd.h +) + set(NP_LIBS src/core/libraries/np_manager/np_manager.cpp src/core/libraries/np_manager/np_manager.h src/core/libraries/np_score/np_score.cpp @@ -297,6 +306,8 @@ set(CORE src/core/aerolib/stubs.cpp ${VIDEOOUT_LIB} ${NP_LIBS} ${PNG_LIB} + ${PLAYGO_LIB} + ${USBD_LIB} ${MISC_LIBS} src/core/linker.cpp src/core/linker.h diff --git a/src/common/logging/filter.cpp b/src/common/logging/filter.cpp index cda1b020..dc2e8f02 100644 --- a/src/common/logging/filter.cpp +++ b/src/common/logging/filter.cpp @@ -105,6 +105,8 @@ bool ParseFilterRule(Filter& instance, Iterator begin, Iterator end) { SUB(Lib, Rtc) \ SUB(Lib, DiscMap) \ SUB(Lib, Png) \ + SUB(Lib, PlayGo) \ + SUB(Lib, Usbd) \ CLS(Frontend) \ CLS(Render) \ SUB(Render, Vulkan) \ diff --git a/src/common/logging/types.h b/src/common/logging/types.h index 3dcfab12..687bcfce 100644 --- a/src/common/logging/types.h +++ b/src/common/logging/types.h @@ -72,6 +72,8 @@ enum class Class : u8 { Lib_Rtc, ///< The LibSceRtc implementation. Lib_DiscMap, ///< The LibSceDiscMap implementation. Lib_Png, ///< The LibScePng implementation. + Lib_PlayGo, ///< The LibScePlayGo implementation. + Lib_Usbd, ///< The LibSceUsbd implementation. Frontend, ///< Emulator UI Render, ///< Video Core Render_Vulkan, ///< Vulkan backend diff --git a/src/common/path_util.cpp b/src/common/path_util.cpp index 293ee1b7..243bc15b 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 d7664871..57a9a73f 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/file_format/psf.cpp b/src/core/file_format/psf.cpp index dd9da71a..c11dc05c 100644 --- a/src/core/file_format/psf.cpp +++ b/src/core/file_format/psf.cpp @@ -56,7 +56,7 @@ std::string PSF::GetString(const std::string& key) { u32 PSF::GetInteger(const std::string& key) { if (map_integers.find(key) != map_integers.end()) { - return map_integers.at(key); // TODO std::invalid_argument exception if it fails? + return map_integers.at(key); } - return 0; + return -1; } diff --git a/src/core/libraries/app_content/app_content.cpp b/src/core/libraries/app_content/app_content.cpp index b05ac1b4..d0184cfa 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" @@ -45,9 +50,29 @@ int PS4_SYSV_ABI sceAppContentAddcontUnmount() { return ORBIS_OK; } -int PS4_SYSV_ABI sceAppContentAppParamGetInt() { - LOG_ERROR(Lib_AppContent, "(STUBBED) called"); - return ORBIS_OK; +int PS4_SYSV_ABI sceAppContentAppParamGetInt(OrbisAppContentAppParamId paramId, s32* value) { + if (value == nullptr) + return 0x80D90002; + auto* param_sfo = Common::Singleton::Instance(); + switch (paramId) { + case ORBIS_APP_CONTENT_APPPARAM_ID_SKU_FLAG: + *value = ORBIS_APP_CONTENT_APPPARAM_SKU_FLAG_FULL; + break; + case ORBIS_APP_CONTENT_APPPARAM_ID_USER_DEFINED_PARAM_1: + *value = param_sfo->GetInteger("USER_DEFINED_PARAM_1"); + break; + case ORBIS_APP_CONTENT_APPPARAM_ID_USER_DEFINED_PARAM_2: + *value = param_sfo->GetInteger("USER_DEFINED_PARAM_2"); + break; + case ORBIS_APP_CONTENT_APPPARAM_ID_USER_DEFINED_PARAM_3: + *value = param_sfo->GetInteger("USER_DEFINED_PARAM_3"); + break; + case ORBIS_APP_CONTENT_APPPARAM_ID_USER_DEFINED_PARAM_4: + *value = param_sfo->GetInteger("USER_DEFINED_PARAM_4"); + break; + } + LOG_ERROR(Lib_AppContent, " paramId = {}, value = {}", paramId, *value); + return *value == -1 ? 0x80D90005 : ORBIS_OK; } int PS4_SYSV_ABI sceAppContentAppParamGetString() { @@ -147,8 +172,10 @@ int PS4_SYSV_ABI sceAppContentTemporaryDataFormat() { return ORBIS_OK; } -int PS4_SYSV_ABI sceAppContentTemporaryDataGetAvailableSpaceKb() { +int PS4_SYSV_ABI sceAppContentTemporaryDataGetAvailableSpaceKb( + const OrbisAppContentMountPoint* mountPoint, size_t* availableSpaceKb) { LOG_ERROR(Lib_AppContent, "(STUBBED) called"); + *availableSpaceKb = 1073741824; return ORBIS_OK; } @@ -157,8 +184,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, 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 f2c05fba..d566b25c 100644 --- a/src/core/libraries/app_content/app_content.h +++ b/src/core/libraries/app_content/app_content.h @@ -11,6 +11,15 @@ class SymbolsResolver; namespace Libraries::AppContent { +constexpr int ORBIS_APP_CONTENT_APPPARAM_ID_SKU_FLAG = 0; +constexpr int ORBIS_APP_CONTENT_APPPARAM_ID_USER_DEFINED_PARAM_1 = 1; +constexpr int ORBIS_APP_CONTENT_APPPARAM_ID_USER_DEFINED_PARAM_2 = 2; +constexpr int ORBIS_APP_CONTENT_APPPARAM_ID_USER_DEFINED_PARAM_3 = 3; +constexpr int ORBIS_APP_CONTENT_APPPARAM_ID_USER_DEFINED_PARAM_4 = 4; + +constexpr int ORBIS_APP_CONTENT_APPPARAM_SKU_FLAG_TRIAL = 1; +constexpr int ORBIS_APP_CONTENT_APPPARAM_SKU_FLAG_FULL = 3; + struct OrbisAppContentInitParam { char reserved[32]; }; @@ -21,6 +30,23 @@ 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; + +constexpr int ORBIS_APP_CONTENT_TEMPORARY_DATA_OPTION_NONE = 0; +constexpr int ORBIS_APP_CONTENT_TEMPORARY_DATA_OPTION_FORMAT = (1 << 0); +constexpr int ORBIS_NP_UNIFIED_ENTITLEMENT_LABEL_SIZE = 17; +typedef struct OrbisNpUnifiedEntitlementLabel { + + char data[ORBIS_NP_UNIFIED_ENTITLEMENT_LABEL_SIZE]; +} OrbisNpUnifiedEntitlementLabel; + +typedef u32 OrbisAppContentAppParamId; + int PS4_SYSV_ABI _Z5dummyv(); int PS4_SYSV_ABI sceAppContentAddcontDelete(); int PS4_SYSV_ABI sceAppContentAddcontEnqueueDownload(); @@ -28,7 +54,7 @@ int PS4_SYSV_ABI sceAppContentAddcontEnqueueDownloadSp(); int PS4_SYSV_ABI sceAppContentAddcontMount(); int PS4_SYSV_ABI sceAppContentAddcontShrink(); int PS4_SYSV_ABI sceAppContentAddcontUnmount(); -int PS4_SYSV_ABI sceAppContentAppParamGetInt(); +int PS4_SYSV_ABI sceAppContentAppParamGetInt(OrbisAppContentAppParamId paramId, s32* value); int PS4_SYSV_ABI sceAppContentAppParamGetString(); int PS4_SYSV_ABI sceAppContentDownload0Expand(); int PS4_SYSV_ABI sceAppContentDownload0Shrink(); @@ -49,9 +75,11 @@ int PS4_SYSV_ABI sceAppContentSmallSharedDataGetAvailableSpaceKb(); int PS4_SYSV_ABI sceAppContentSmallSharedDataMount(); int PS4_SYSV_ABI sceAppContentSmallSharedDataUnmount(); int PS4_SYSV_ABI sceAppContentTemporaryDataFormat(); -int PS4_SYSV_ABI sceAppContentTemporaryDataGetAvailableSpaceKb(); +int PS4_SYSV_ABI sceAppContentTemporaryDataGetAvailableSpaceKb( + const OrbisAppContentMountPoint* mountPoint, size_t* availableSpaceKb); 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/file_system.cpp b/src/core/libraries/kernel/file_system.cpp index 537f959b..bc9ff214 100644 --- a/src/core/libraries/kernel/file_system.cpp +++ b/src/core/libraries/kernel/file_system.cpp @@ -156,7 +156,7 @@ s64 PS4_SYSV_ABI sceKernelLseek(int d, s64 offset, int whence) { return pos; } -s64 PS4_SYSV_ABI lseek(int d, s64 offset, int whence) { +s64 PS4_SYSV_ABI posix_lseek(int d, s64 offset, int whence) { return sceKernelLseek(d, offset, whence); } @@ -176,6 +176,10 @@ s64 PS4_SYSV_ABI sceKernelRead(int d, void* buf, size_t nbytes) { return bytes_read; } +int PS4_SYSV_ABI posix_read(int d, void* buf, size_t nbytes) { + return sceKernelRead(d, buf, nbytes); +} + int PS4_SYSV_ABI sceKernelMkdir(const char* path, u16 mode) { LOG_INFO(Kernel_Fs, "path = {} mode = {}", path, mode); if (path == nullptr) { @@ -197,6 +201,10 @@ int PS4_SYSV_ABI sceKernelMkdir(const char* path, u16 mode) { return ORBIS_OK; } +int PS4_SYSV_ABI posix_mkdir(const char* path, u16 mode) { + return sceKernelMkdir(path, mode); +} + int PS4_SYSV_ABI sceKernelStat(const char* path, OrbisKernelStat* sb) { LOG_INFO(Kernel_Fs, "(PARTIAL) path = {}", path); auto* mnt = Common::Singleton::Instance(); @@ -310,10 +318,13 @@ void fileSystemSymbolsRegister(Core::Loader::SymbolsResolver* sym) { LIB_FUNCTION("4wSze92BhLI", "libkernel", 1, "libkernel", 1, 1, sceKernelWrite); LIB_FUNCTION("+WRlkKjZvag", "libkernel", 1, "libkernel", 1, 1, _readv); - LIB_FUNCTION("Oy6IpwgtYOk", "libkernel", 1, "libkernel", 1, 1, lseek); + LIB_FUNCTION("Oy6IpwgtYOk", "libkernel", 1, "libkernel", 1, 1, posix_lseek); + LIB_FUNCTION("Oy6IpwgtYOk", "libScePosix", 1, "libkernel", 1, 1, posix_lseek); LIB_FUNCTION("oib76F-12fk", "libkernel", 1, "libkernel", 1, 1, sceKernelLseek); LIB_FUNCTION("Cg4srZ6TKbU", "libkernel", 1, "libkernel", 1, 1, sceKernelRead); + LIB_FUNCTION("AqBioC2vF3I", "libScePosix", 1, "libkernel", 1, 1, posix_read); LIB_FUNCTION("1-LFLmRFxxM", "libkernel", 1, "libkernel", 1, 1, sceKernelMkdir); + LIB_FUNCTION("JGMio+21L4c", "libScePosix", 1, "libkernel", 1, 1, posix_mkdir); LIB_FUNCTION("eV9wAD2riIA", "libkernel", 1, "libkernel", 1, 1, sceKernelStat); LIB_FUNCTION("kBwCPsYX-m4", "libkernel", 1, "libkernel", 1, 1, sceKernelFStat); LIB_FUNCTION("mqQMh1zPPT8", "libScePosix", 1, "libkernel", 1, 1, posix_fstat); diff --git a/src/core/libraries/kernel/libkernel.cpp b/src/core/libraries/kernel/libkernel.cpp index 8b093d25..ef2f48f0 100644 --- a/src/core/libraries/kernel/libkernel.cpp +++ b/src/core/libraries/kernel/libkernel.cpp @@ -21,6 +21,7 @@ #include "core/memory.h" #ifdef _WIN64 #include +#include #include #else #include @@ -279,6 +280,24 @@ void PS4_SYSV_ABI sched_yield() { return std::this_thread::yield(); } +int PS4_SYSV_ABI sceKernelUuidCreate(OrbisKernelUuid* orbisUuid) { +#ifdef _WIN64 + UUID uuid; + UuidCreate(&uuid); + orbisUuid->timeLow = uuid.Data1; + orbisUuid->timeMid = uuid.Data2; + orbisUuid->timeHiAndVersion = uuid.Data3; + orbisUuid->clockSeqHiAndReserved = uuid.Data4[0]; + orbisUuid->clockSeqLow = uuid.Data4[1]; + for (int i = 0; i < 6; i++) { + orbisUuid->node[i] = uuid.Data4[2 + i]; + } +#else + LOG_ERROR(Kernel, "sceKernelUuidCreate: Add linux"); +#endif + return 0; +} + void LibKernel_Register(Core::Loader::SymbolsResolver* sym) { // obj LIB_OBJ("f7uOxY9mM1U", "libkernel", 1, "libkernel", 1, 1, &g_stack_chk_guard); diff --git a/src/core/libraries/kernel/libkernel.h b/src/core/libraries/kernel/libkernel.h index 0cc75777..0cc6b0b2 100644 --- a/src/core/libraries/kernel/libkernel.h +++ b/src/core/libraries/kernel/libkernel.h @@ -18,6 +18,15 @@ struct OrbisTimesec { u32 dst_sec; }; +typedef struct { + uint32_t timeLow; + uint16_t timeMid; + uint16_t timeHiAndVersion; + uint8_t clockSeqHiAndReserved; + uint8_t clockSeqLow; + uint8_t node[6]; +} OrbisKernelUuid; + int* PS4_SYSV_ABI __Error(); void LibKernel_Register(Core::Loader::SymbolsResolver* sym); diff --git a/src/core/libraries/kernel/thread_management.cpp b/src/core/libraries/kernel/thread_management.cpp index 946c248c..804e18c5 100644 --- a/src/core/libraries/kernel/thread_management.cpp +++ b/src/core/libraries/kernel/thread_management.cpp @@ -1212,6 +1212,22 @@ int PS4_SYSV_ABI posix_pthread_cond_init(ScePthreadCond* cond, const ScePthreadC return result; } +int PS4_SYSV_ABI posix_pthread_cond_signal(ScePthreadCond* cond) { + int result = scePthreadCondSignal(cond); + LOG_INFO(Kernel_Pthread, + "posix posix_pthread_cond_signal redirect to scePthreadCondSignal, result = {}", + result); + return result; +} + +int PS4_SYSV_ABI posix_pthread_cond_destroy(ScePthreadCond* cond) { + int result = scePthreadCondDestroy(cond); + LOG_INFO(Kernel_Pthread, + "posix posix_pthread_cond_destroy redirect to scePthreadCondDestroy, result = {}", + result); + return result; +} + int PS4_SYSV_ABI posix_pthread_setcancelstate(int state, int* oldstate) { return pthread_setcancelstate(state, oldstate); } @@ -1249,6 +1265,8 @@ int PS4_SYSV_ABI scePthreadOnce(int* once_control, void (*init_routine)(void)) { void pthreadSymbolsRegister(Core::Loader::SymbolsResolver* sym) { LIB_FUNCTION("lZzFeSxPl08", "libScePosix", 1, "libkernel", 1, 1, posix_pthread_setcancelstate); LIB_FUNCTION("0TyVk4MSLt0", "libScePosix", 1, "libkernel", 1, 1, posix_pthread_cond_init); + LIB_FUNCTION("2MOy+rUfuhQ", "libScePosix", 1, "libkernel", 1, 1, posix_pthread_cond_signal); + LIB_FUNCTION("RXXqi4CtF8w", "libScePosix", 1, "libkernel", 1, 1, posix_pthread_cond_destroy); LIB_FUNCTION("mqULNdimTn0", "libScePosix", 1, "libkernel", 1, 1, posix_pthread_key_create); LIB_FUNCTION("0-KXaS70xy4", "libScePosix", 1, "libkernel", 1, 1, posix_pthread_getspecific); LIB_FUNCTION("WrOLvHU0yQM", "libScePosix", 1, "libkernel", 1, 1, posix_pthread_setspecific); diff --git a/src/core/libraries/libs.cpp b/src/core/libraries/libs.cpp index 932943ad..b4c77f90 100644 --- a/src/core/libraries/libs.cpp +++ b/src/core/libraries/libs.cpp @@ -19,6 +19,7 @@ #include "core/libraries/np_score/np_score.h" #include "core/libraries/np_trophy/np_trophy.h" #include "core/libraries/pad/pad.h" +#include "core/libraries/playgo/playgo.h" #include "core/libraries/rtc/rtc.h" #include "core/libraries/save_data/savedata.h" #include "core/libraries/screenshot/screenshot.h" @@ -29,6 +30,7 @@ #include "core/libraries/system/sysmodule.h" #include "core/libraries/system/systemservice.h" #include "core/libraries/system/userservice.h" +#include "core/libraries/usbd/usbd.h" #include "core/libraries/videoout/video_out.h" #include "src/core/libraries/libpng/pngdec.h" @@ -67,6 +69,8 @@ void InitHLELibs(Core::Loader::SymbolsResolver* sym) { Libraries::Rtc::RegisterlibSceRtc(sym); Libraries::DiscMap::RegisterlibSceDiscMap(sym); Libraries::PngDec::RegisterlibScePngDec(sym); + Libraries::PlayGo::RegisterlibScePlayGo(sym); + Libraries::Usbd::RegisterlibSceUsbd(sym); } } // namespace Libraries diff --git a/src/core/libraries/playgo/playgo.cpp b/src/core/libraries/playgo/playgo.cpp new file mode 100644 index 00000000..1a335a2a --- /dev/null +++ b/src/core/libraries/playgo/playgo.cpp @@ -0,0 +1,144 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "common/logging/log.h" +#include "common/singleton.h" +#include "core/libraries/error_codes.h" +#include "core/libraries/libs.h" +#include "playgo.h" + +namespace Libraries::PlayGo { +// this lib is used to play as the game is being installed. +// can be skipped by just returning and assigning the correct values. + +s32 PS4_SYSV_ABI sceDbgPlayGoRequestNextChunk() { + LOG_ERROR(Lib_PlayGo, "(STUBBED)called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceDbgPlayGoSnapshot() { + LOG_ERROR(Lib_PlayGo, "(STUBBED)called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI scePlayGoClose() { + LOG_ERROR(Lib_PlayGo, "(STUBBED)called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI scePlayGoGetChunkId() { + LOG_ERROR(Lib_PlayGo, "(STUBBED)called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI scePlayGoGetEta() { + LOG_ERROR(Lib_PlayGo, "(STUBBED)called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI scePlayGoGetInstallSpeed() { + LOG_ERROR(Lib_PlayGo, "(STUBBED)called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI scePlayGoGetLanguageMask(OrbisPlayGoHandle handle, + OrbisPlayGoLanguageMask* languageMask) { + LOG_ERROR(Lib_PlayGo, "(STUBBED)called"); + *languageMask = 1; // En, todo; + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI scePlayGoGetLocus(OrbisPlayGoHandle handle, const OrbisPlayGoChunkId* chunkIds, + uint32_t numberOfEntries, OrbisPlayGoLocus* outLoci) { + LOG_ERROR(Lib_PlayGo, "(STUBBED)called handle = {}, chunkIds = {}, numberOfEntries = {}", + handle, *chunkIds, numberOfEntries); + // assign all now so that scePlayGoGetLocus is not called again for every single entry + std::fill(outLoci, outLoci + numberOfEntries, + OrbisPlayGoLocusValue::ORBIS_PLAYGO_LOCUS_LOCAL_FAST); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI scePlayGoGetProgress(OrbisPlayGoHandle handle, const OrbisPlayGoChunkId* chunkIds, + uint32_t numberOfEntries, OrbisPlayGoProgress* outProgress) { + LOG_ERROR(Lib_PlayGo, "(STUBBED)called handle = {}, chunkIds = {}, numberOfEntries = {}", + handle, *chunkIds, numberOfEntries); + outProgress->progressSize = 0x10000; // todo? + outProgress->totalSize = 0x10000; + return 0; +} + +s32 PS4_SYSV_ABI scePlayGoGetToDoList(OrbisPlayGoHandle handle, OrbisPlayGoToDo* outTodoList, + u32 numberOfEntries, u32* outEntries) { + LOG_ERROR(Lib_PlayGo, "(STUBBED)called"); + if (handle != shadMagic) + return ORBIS_PLAYGO_ERROR_BAD_HANDLE; + if (outTodoList == nullptr) + return ORBIS_PLAYGO_ERROR_BAD_POINTER; + *outEntries = 0; // nothing to do + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI scePlayGoInitialize(OrbisPlayGoInitParams* param) { + if (param->bufAddr == nullptr) + return ORBIS_PLAYGO_ERROR_BAD_POINTER; + if (param->bufSize < 0x200000) + return ORBIS_PLAYGO_ERROR_BAD_SIZE; + LOG_INFO(Lib_PlayGo, "(STUBBED)called, bufSize = {}", param->bufSize); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI scePlayGoOpen(OrbisPlayGoHandle* outHandle, const void* param) { + *outHandle = shadMagic; + LOG_INFO(Lib_PlayGo, "(STUBBED)called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI scePlayGoPrefetch() { + LOG_ERROR(Lib_PlayGo, "(STUBBED)called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI scePlayGoSetInstallSpeed() { + LOG_ERROR(Lib_PlayGo, "(STUBBED)called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI scePlayGoSetLanguageMask(OrbisPlayGoHandle handle, + OrbisPlayGoLanguageMask languageMask) { + LOG_ERROR(Lib_PlayGo, "(STUBBED)called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI scePlayGoSetToDoList(OrbisPlayGoHandle handle, const OrbisPlayGoToDo* todoList, + uint32_t numberOfEntries) { + LOG_ERROR(Lib_PlayGo, "(STUBBED)called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI scePlayGoTerminate() { + LOG_ERROR(Lib_PlayGo, "(STUBBED)called"); + return ORBIS_OK; +} + +void RegisterlibScePlayGo(Core::Loader::SymbolsResolver* sym) { + LIB_FUNCTION("uEqMfMITvEI", "libSceDbgPlayGo", 1, "libScePlayGo", 1, 0, + sceDbgPlayGoRequestNextChunk); + LIB_FUNCTION("vU+FqrH+pEY", "libSceDbgPlayGo", 1, "libScePlayGo", 1, 0, sceDbgPlayGoSnapshot); + LIB_FUNCTION("Uco1I0dlDi8", "libScePlayGo", 1, "libScePlayGo", 1, 0, scePlayGoClose); + LIB_FUNCTION("73fF1MFU8hA", "libScePlayGo", 1, "libScePlayGo", 1, 0, scePlayGoGetChunkId); + LIB_FUNCTION("v6EZ-YWRdMs", "libScePlayGo", 1, "libScePlayGo", 1, 0, scePlayGoGetEta); + LIB_FUNCTION("rvBSfTimejE", "libScePlayGo", 1, "libScePlayGo", 1, 0, scePlayGoGetInstallSpeed); + LIB_FUNCTION("3OMbYZBaa50", "libScePlayGo", 1, "libScePlayGo", 1, 0, scePlayGoGetLanguageMask); + LIB_FUNCTION("uWIYLFkkwqk", "libScePlayGo", 1, "libScePlayGo", 1, 0, scePlayGoGetLocus); + LIB_FUNCTION("-RJWNMK3fC8", "libScePlayGo", 1, "libScePlayGo", 1, 0, scePlayGoGetProgress); + LIB_FUNCTION("Nn7zKwnA5q0", "libScePlayGo", 1, "libScePlayGo", 1, 0, scePlayGoGetToDoList); + LIB_FUNCTION("ts6GlZOKRrE", "libScePlayGo", 1, "libScePlayGo", 1, 0, scePlayGoInitialize); + LIB_FUNCTION("M1Gma1ocrGE", "libScePlayGo", 1, "libScePlayGo", 1, 0, scePlayGoOpen); + LIB_FUNCTION("-Q1-u1a7p0g", "libScePlayGo", 1, "libScePlayGo", 1, 0, scePlayGoPrefetch); + LIB_FUNCTION("4AAcTU9R3XM", "libScePlayGo", 1, "libScePlayGo", 1, 0, scePlayGoSetInstallSpeed); + LIB_FUNCTION("LosLlHOpNqQ", "libScePlayGo", 1, "libScePlayGo", 1, 0, scePlayGoSetLanguageMask); + LIB_FUNCTION("gUPGiOQ1tmQ", "libScePlayGo", 1, "libScePlayGo", 1, 0, scePlayGoSetToDoList); + LIB_FUNCTION("MPe0EeBGM-E", "libScePlayGo", 1, "libScePlayGo", 1, 0, scePlayGoTerminate); +}; + +} // namespace Libraries::PlayGo \ No newline at end of file diff --git a/src/core/libraries/playgo/playgo.h b/src/core/libraries/playgo/playgo.h new file mode 100644 index 00000000..a6b8c91d --- /dev/null +++ b/src/core/libraries/playgo/playgo.h @@ -0,0 +1,40 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once +#include "common/types.h" +#include "playgo_types.h" + +namespace Core::Loader { +class SymbolsResolver; +} + +namespace Libraries::PlayGo { +constexpr int shadMagic = 0x53484144; + +s32 PS4_SYSV_ABI sceDbgPlayGoRequestNextChunk(); +s32 PS4_SYSV_ABI sceDbgPlayGoSnapshot(); +s32 PS4_SYSV_ABI scePlayGoClose(); +s32 PS4_SYSV_ABI scePlayGoGetChunkId(); +s32 PS4_SYSV_ABI scePlayGoGetEta(); +s32 PS4_SYSV_ABI scePlayGoGetInstallSpeed(); +s32 PS4_SYSV_ABI scePlayGoGetLanguageMask(OrbisPlayGoHandle handle, + OrbisPlayGoLanguageMask* outLanguageMask); +s32 PS4_SYSV_ABI scePlayGoGetLocus(OrbisPlayGoHandle handle, const OrbisPlayGoChunkId* chunkIds, + uint32_t numberOfEntries, OrbisPlayGoLocus* outLoci); +s32 PS4_SYSV_ABI scePlayGoGetProgress(OrbisPlayGoHandle handle, const OrbisPlayGoChunkId* chunkIds, + uint32_t numberOfEntries, OrbisPlayGoProgress* outProgress); +s32 PS4_SYSV_ABI scePlayGoGetToDoList(OrbisPlayGoHandle handle, OrbisPlayGoToDo* outTodoList, + u32 numberOfEntries, u32* outEntries); +s32 PS4_SYSV_ABI scePlayGoInitialize(OrbisPlayGoInitParams* param); +s32 PS4_SYSV_ABI scePlayGoOpen(OrbisPlayGoHandle* outHandle, const void* param); +s32 PS4_SYSV_ABI scePlayGoPrefetch(); +s32 PS4_SYSV_ABI scePlayGoSetInstallSpeed(); +s32 PS4_SYSV_ABI scePlayGoSetLanguageMask(OrbisPlayGoHandle handle, + OrbisPlayGoLanguageMask languageMask); +s32 PS4_SYSV_ABI scePlayGoSetToDoList(OrbisPlayGoHandle handle, const OrbisPlayGoToDo* todoList, + uint32_t numberOfEntries); +s32 PS4_SYSV_ABI scePlayGoTerminate(); + +void RegisterlibScePlayGo(Core::Loader::SymbolsResolver* sym); +} // namespace Libraries::PlayGo \ No newline at end of file diff --git a/src/core/libraries/playgo/playgo_types.h b/src/core/libraries/playgo/playgo_types.h new file mode 100644 index 00000000..62dea4f4 --- /dev/null +++ b/src/core/libraries/playgo/playgo_types.h @@ -0,0 +1,60 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "common/types.h" + +typedef u32 OrbisPlayGoHandle; +typedef u16 OrbisPlayGoChunkId; +typedef s8 OrbisPlayGoLocus; +typedef s32 OrbisPlayGoInstallSpeed; +typedef s64 OrbisPlayGoEta; +typedef u64 OrbisPlayGoLanguageMask; + +typedef struct OrbisPlayGoInitParams { + const void* bufAddr; + u32 bufSize; + u32 reserved; +} OrbisPlayGoInitParams; + +typedef struct OrbisPlayGoToDo { + OrbisPlayGoChunkId chunkId; + OrbisPlayGoLocus locus; + s8 reserved; +} OrbisPlayGoToDo; + +typedef struct OrbisPlayGoProgress { + uint64_t progressSize; + uint64_t totalSize; +} OrbisPlayGoProgress; + +typedef enum OrbisPlayGoLocusValue { + ORBIS_PLAYGO_LOCUS_NOT_DOWNLOADED = 0, + ORBIS_PLAYGO_LOCUS_LOCAL_SLOW = 2, + ORBIS_PLAYGO_LOCUS_LOCAL_FAST = 3 +} OrbisPlayGoLocusValue; + +typedef enum OrbisPlayGoInstallSpeedValue { + ORBIS_PLAYGO_INSTALL_SPEED_SUSPENDED = 0, + ORBIS_PLAYGO_INSTALL_SPEED_TRICKLE = 1, + ORBIS_PLAYGO_INSTALL_SPEED_FULL = 2 +} OrbisPlayGoInstallSpeedValue; + +constexpr int ORBIS_PLAYGO_ERROR_UNKNOWN = -2135818239; /* 0x80B20001 */ +constexpr int ORBIS_PLAYGO_ERROR_FATAL = -2135818238; /* 0x80B20002 */ +constexpr int ORBIS_PLAYGO_ERROR_NO_MEMORY = -2135818237; /* 0x80B20003 */ +constexpr int ORBIS_PLAYGO_ERROR_INVALID_ARGUMENT = -2135818236; /* 0x80B20004 */ +constexpr int ORBIS_PLAYGO_ERROR_NOT_INITIALIZED = -2135818235; /* 0x80B20005 */ +constexpr int ORBIS_PLAYGO_ERROR_ALREADY_INITIALIZED = -2135818234; /* 0x80B20006 */ +constexpr int ORBIS_PLAYGO_ERROR_ALREADY_STARTED = -2135818233; /* 0x80B20007 */ +constexpr int ORBIS_PLAYGO_ERROR_NOT_STARTED = -2135818232; /* 0x80B20008 */ +constexpr int ORBIS_PLAYGO_ERROR_BAD_HANDLE = -2135818231; /* 0x80B20009 */ +constexpr int ORBIS_PLAYGO_ERROR_BAD_POINTER = -2135818230; /* 0x80B2000A */ +constexpr int ORBIS_PLAYGO_ERROR_BAD_SIZE = -2135818229; /* 0x80B2000B */ +constexpr int ORBIS_PLAYGO_ERROR_BAD_CHUNK_ID = -2135818228; /* 0x80B2000C */ +constexpr int ORBIS_PLAYGO_ERROR_BAD_SPEED = -2135818227; /* 0x80B2000D */ +constexpr int ORBIS_PLAYGO_ERROR_NOT_SUPPORT_PLAYGO = -2135818226; /* 0x80B2000E */ +constexpr int ORBIS_PLAYGO_ERROR_EPERM = -2135818225; /* 0x80B2000F */ +constexpr int ORBIS_PLAYGO_ERROR_BAD_LOCUS = -2135818224; /* 0x80B20010 */ +constexpr int ORBIS_PLAYGO_ERROR_NEED_DATA_DISC = -2135818223; /* 0x80B20011 */ diff --git a/src/core/libraries/usbd/usbd.cpp b/src/core/libraries/usbd/usbd.cpp new file mode 100644 index 00000000..533f976e --- /dev/null +++ b/src/core/libraries/usbd/usbd.cpp @@ -0,0 +1,410 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +// Generated By moduleGenerator +#include "common/logging/log.h" +#include "common/singleton.h" +#include "core/libraries/error_codes.h" +#include "core/libraries/libs.h" +#include "usbd.h" + +namespace Libraries::Usbd { + +int PS4_SYSV_ABI sceUsbdAllocTransfer() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceUsbdAttachKernelDriver() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceUsbdBulkTransfer() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceUsbdCancelTransfer() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceUsbdCheckConnected() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceUsbdClaimInterface() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceUsbdClearHalt() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceUsbdClose() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceUsbdControlTransfer() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceUsbdControlTransferGetData() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceUsbdControlTransferGetSetup() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceUsbdDetachKernelDriver() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceUsbdEventHandlerActive() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceUsbdEventHandlingOk() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceUsbdExit() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceUsbdFillBulkTransfer() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceUsbdFillControlSetup() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceUsbdFillControlTransfer() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceUsbdFillInterruptTransfer() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceUsbdFillIsoTransfer() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceUsbdFreeConfigDescriptor() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceUsbdFreeDeviceList() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceUsbdFreeTransfer() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceUsbdGetActiveConfigDescriptor() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceUsbdGetBusNumber() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceUsbdGetConfigDescriptor() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceUsbdGetConfigDescriptorByValue() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceUsbdGetConfiguration() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceUsbdGetDescriptor() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceUsbdGetDevice() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceUsbdGetDeviceAddress() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceUsbdGetDeviceDescriptor() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceUsbdGetDeviceList() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceUsbdGetDeviceSpeed() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceUsbdGetIsoPacketBuffer() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceUsbdGetMaxIsoPacketSize() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceUsbdGetMaxPacketSize() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceUsbdGetStringDescriptor() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceUsbdGetStringDescriptorAscii() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceUsbdHandleEvents() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceUsbdHandleEventsLocked() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceUsbdHandleEventsTimeout() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceUsbdInit() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return 0x80240005; // Skip +} + +int PS4_SYSV_ABI sceUsbdInterruptTransfer() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceUsbdKernelDriverActive() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceUsbdLockEvents() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceUsbdLockEventWaiters() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceUsbdOpen() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceUsbdOpenDeviceWithVidPid() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceUsbdRefDevice() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceUsbdReleaseInterface() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceUsbdResetDevice() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceUsbdSetConfiguration() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceUsbdSetInterfaceAltSetting() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceUsbdSetIsoPacketLengths() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceUsbdSubmitTransfer() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceUsbdTryLockEvents() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceUsbdUnlockEvents() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceUsbdUnlockEventWaiters() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceUsbdUnrefDevice() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceUsbdWaitForEvent() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI Func_65F6EF33E38FFF50() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI Func_97F056BAD90AADE7() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI Func_C55104A33B35B264() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +int PS4_SYSV_ABI Func_D56B43060720B1E0() { + LOG_ERROR(Lib_Usbd, "(STUBBED)called"); + return ORBIS_OK; +} + +void RegisterlibSceUsbd(Core::Loader::SymbolsResolver* sym) { + LIB_FUNCTION("0ktE1PhzGFU", "libSceUsbd", 1, "libSceUsbd", 1, 1, sceUsbdAllocTransfer); + LIB_FUNCTION("BKMEGvfCPyU", "libSceUsbd", 1, "libSceUsbd", 1, 1, sceUsbdAttachKernelDriver); + LIB_FUNCTION("fotb7DzeHYw", "libSceUsbd", 1, "libSceUsbd", 1, 1, sceUsbdBulkTransfer); + LIB_FUNCTION("-KNh1VFIzlM", "libSceUsbd", 1, "libSceUsbd", 1, 1, sceUsbdCancelTransfer); + LIB_FUNCTION("MlW6deWfPp0", "libSceUsbd", 1, "libSceUsbd", 1, 1, sceUsbdCheckConnected); + LIB_FUNCTION("AE+mHBHneyk", "libSceUsbd", 1, "libSceUsbd", 1, 1, sceUsbdClaimInterface); + LIB_FUNCTION("3tPPMo4QRdY", "libSceUsbd", 1, "libSceUsbd", 1, 1, sceUsbdClearHalt); + LIB_FUNCTION("HarYYlaFGJY", "libSceUsbd", 1, "libSceUsbd", 1, 1, sceUsbdClose); + LIB_FUNCTION("RRKFcKQ1Ka4", "libSceUsbd", 1, "libSceUsbd", 1, 1, sceUsbdControlTransfer); + LIB_FUNCTION("XUWtxI31YEY", "libSceUsbd", 1, "libSceUsbd", 1, 1, sceUsbdControlTransferGetData); + LIB_FUNCTION("SEdQo8CFmus", "libSceUsbd", 1, "libSceUsbd", 1, 1, + sceUsbdControlTransferGetSetup); + LIB_FUNCTION("Y5go+ha6eDs", "libSceUsbd", 1, "libSceUsbd", 1, 1, sceUsbdDetachKernelDriver); + LIB_FUNCTION("Vw8Hg1CN028", "libSceUsbd", 1, "libSceUsbd", 1, 1, sceUsbdEventHandlerActive); + LIB_FUNCTION("e7gp1xhu6RI", "libSceUsbd", 1, "libSceUsbd", 1, 1, sceUsbdEventHandlingOk); + LIB_FUNCTION("Fq6+0Fm55xU", "libSceUsbd", 1, "libSceUsbd", 1, 1, sceUsbdExit); + LIB_FUNCTION("oHCade-0qQ0", "libSceUsbd", 1, "libSceUsbd", 1, 1, sceUsbdFillBulkTransfer); + LIB_FUNCTION("8KrqbaaPkE0", "libSceUsbd", 1, "libSceUsbd", 1, 1, sceUsbdFillControlSetup); + LIB_FUNCTION("7VGfMerK6m0", "libSceUsbd", 1, "libSceUsbd", 1, 1, sceUsbdFillControlTransfer); + LIB_FUNCTION("t3J5pXxhJlI", "libSceUsbd", 1, "libSceUsbd", 1, 1, sceUsbdFillInterruptTransfer); + LIB_FUNCTION("xqmkjHCEOSY", "libSceUsbd", 1, "libSceUsbd", 1, 1, sceUsbdFillIsoTransfer); + LIB_FUNCTION("Hvd3S--n25w", "libSceUsbd", 1, "libSceUsbd", 1, 1, sceUsbdFreeConfigDescriptor); + LIB_FUNCTION("EQ6SCLMqzkM", "libSceUsbd", 1, "libSceUsbd", 1, 1, sceUsbdFreeDeviceList); + LIB_FUNCTION("-sgi7EeLSO8", "libSceUsbd", 1, "libSceUsbd", 1, 1, sceUsbdFreeTransfer); + LIB_FUNCTION("S1o1C6yOt5g", "libSceUsbd", 1, "libSceUsbd", 1, 1, + sceUsbdGetActiveConfigDescriptor); + LIB_FUNCTION("t7WE9mb1TB8", "libSceUsbd", 1, "libSceUsbd", 1, 1, sceUsbdGetBusNumber); + LIB_FUNCTION("Dkm5qe8j3XE", "libSceUsbd", 1, "libSceUsbd", 1, 1, sceUsbdGetConfigDescriptor); + LIB_FUNCTION("GQsAVJuy8gM", "libSceUsbd", 1, "libSceUsbd", 1, 1, + sceUsbdGetConfigDescriptorByValue); + LIB_FUNCTION("L7FoTZp3bZs", "libSceUsbd", 1, "libSceUsbd", 1, 1, sceUsbdGetConfiguration); + LIB_FUNCTION("-JBoEtvTxvA", "libSceUsbd", 1, "libSceUsbd", 1, 1, sceUsbdGetDescriptor); + LIB_FUNCTION("rsl9KQ-agyA", "libSceUsbd", 1, "libSceUsbd", 1, 1, sceUsbdGetDevice); + LIB_FUNCTION("GjlCrU4GcIY", "libSceUsbd", 1, "libSceUsbd", 1, 1, sceUsbdGetDeviceAddress); + LIB_FUNCTION("bhomgbiQgeo", "libSceUsbd", 1, "libSceUsbd", 1, 1, sceUsbdGetDeviceDescriptor); + LIB_FUNCTION("8qB9Ar4P5nc", "libSceUsbd", 1, "libSceUsbd", 1, 1, sceUsbdGetDeviceList); + LIB_FUNCTION("e1UWb8cWPJM", "libSceUsbd", 1, "libSceUsbd", 1, 1, sceUsbdGetDeviceSpeed); + LIB_FUNCTION("vokkJ0aDf54", "libSceUsbd", 1, "libSceUsbd", 1, 1, sceUsbdGetIsoPacketBuffer); + LIB_FUNCTION("nuIRlpbxauM", "libSceUsbd", 1, "libSceUsbd", 1, 1, sceUsbdGetMaxIsoPacketSize); + LIB_FUNCTION("YJ0cMAlLuxQ", "libSceUsbd", 1, "libSceUsbd", 1, 1, sceUsbdGetMaxPacketSize); + LIB_FUNCTION("g2oYm1DitDg", "libSceUsbd", 1, "libSceUsbd", 1, 1, sceUsbdGetStringDescriptor); + LIB_FUNCTION("t4gUfGsjk+g", "libSceUsbd", 1, "libSceUsbd", 1, 1, + sceUsbdGetStringDescriptorAscii); + LIB_FUNCTION("EkqGLxWC-S0", "libSceUsbd", 1, "libSceUsbd", 1, 1, sceUsbdHandleEvents); + LIB_FUNCTION("rt-WeUGibfg", "libSceUsbd", 1, "libSceUsbd", 1, 1, sceUsbdHandleEventsLocked); + LIB_FUNCTION("+wU6CGuZcWk", "libSceUsbd", 1, "libSceUsbd", 1, 1, sceUsbdHandleEventsTimeout); + LIB_FUNCTION("TOhg7P6kTH4", "libSceUsbd", 1, "libSceUsbd", 1, 1, sceUsbdInit); + LIB_FUNCTION("rxi1nCOKWc8", "libSceUsbd", 1, "libSceUsbd", 1, 1, sceUsbdInterruptTransfer); + LIB_FUNCTION("RLf56F-WjKQ", "libSceUsbd", 1, "libSceUsbd", 1, 1, sceUsbdKernelDriverActive); + LIB_FUNCTION("u9yKks02-rA", "libSceUsbd", 1, "libSceUsbd", 1, 1, sceUsbdLockEvents); + LIB_FUNCTION("AeGaY8JrAV4", "libSceUsbd", 1, "libSceUsbd", 1, 1, sceUsbdLockEventWaiters); + LIB_FUNCTION("VJ6oMq-Di2U", "libSceUsbd", 1, "libSceUsbd", 1, 1, sceUsbdOpen); + LIB_FUNCTION("vrQXYRo1Gwk", "libSceUsbd", 1, "libSceUsbd", 1, 1, sceUsbdOpenDeviceWithVidPid); + LIB_FUNCTION("U1t1SoJvV-A", "libSceUsbd", 1, "libSceUsbd", 1, 1, sceUsbdRefDevice); + LIB_FUNCTION("REfUTmTchMw", "libSceUsbd", 1, "libSceUsbd", 1, 1, sceUsbdReleaseInterface); + LIB_FUNCTION("hvMn0QJXj5g", "libSceUsbd", 1, "libSceUsbd", 1, 1, sceUsbdResetDevice); + LIB_FUNCTION("FhU9oYrbXoA", "libSceUsbd", 1, "libSceUsbd", 1, 1, sceUsbdSetConfiguration); + LIB_FUNCTION("DVCQW9o+ki0", "libSceUsbd", 1, "libSceUsbd", 1, 1, sceUsbdSetInterfaceAltSetting); + LIB_FUNCTION("dJxro8Nzcjk", "libSceUsbd", 1, "libSceUsbd", 1, 1, sceUsbdSetIsoPacketLengths); + LIB_FUNCTION("L0EHgZZNVas", "libSceUsbd", 1, "libSceUsbd", 1, 1, sceUsbdSubmitTransfer); + LIB_FUNCTION("TcXVGc-LPbQ", "libSceUsbd", 1, "libSceUsbd", 1, 1, sceUsbdTryLockEvents); + LIB_FUNCTION("RA2D9rFH-Uw", "libSceUsbd", 1, "libSceUsbd", 1, 1, sceUsbdUnlockEvents); + LIB_FUNCTION("1DkGvUQYFKI", "libSceUsbd", 1, "libSceUsbd", 1, 1, sceUsbdUnlockEventWaiters); + LIB_FUNCTION("OULgIo1zAsA", "libSceUsbd", 1, "libSceUsbd", 1, 1, sceUsbdUnrefDevice); + LIB_FUNCTION("ys2e9VRBPrY", "libSceUsbd", 1, "libSceUsbd", 1, 1, sceUsbdWaitForEvent); + LIB_FUNCTION("ZfbvM+OP-1A", "libSceUsbd", 1, "libSceUsbd", 1, 1, Func_65F6EF33E38FFF50); + LIB_FUNCTION("l-BWutkKrec", "libSceUsbd", 1, "libSceUsbd", 1, 1, Func_97F056BAD90AADE7); + LIB_FUNCTION("xVEEozs1smQ", "libSceUsbd", 1, "libSceUsbd", 1, 1, Func_C55104A33B35B264); + LIB_FUNCTION("1WtDBgcgseA", "libSceUsbd", 1, "libSceUsbd", 1, 1, Func_D56B43060720B1E0); +}; + +} // namespace Libraries::Usbd \ No newline at end of file diff --git a/src/core/libraries/usbd/usbd.h b/src/core/libraries/usbd/usbd.h new file mode 100644 index 00000000..6aad31eb --- /dev/null +++ b/src/core/libraries/usbd/usbd.h @@ -0,0 +1,79 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once +#include "common/types.h" + +namespace Core::Loader { +class SymbolsResolver; +} +namespace Libraries::Usbd { + +int PS4_SYSV_ABI sceUsbdAllocTransfer(); +int PS4_SYSV_ABI sceUsbdAttachKernelDriver(); +int PS4_SYSV_ABI sceUsbdBulkTransfer(); +int PS4_SYSV_ABI sceUsbdCancelTransfer(); +int PS4_SYSV_ABI sceUsbdCheckConnected(); +int PS4_SYSV_ABI sceUsbdClaimInterface(); +int PS4_SYSV_ABI sceUsbdClearHalt(); +int PS4_SYSV_ABI sceUsbdClose(); +int PS4_SYSV_ABI sceUsbdControlTransfer(); +int PS4_SYSV_ABI sceUsbdControlTransferGetData(); +int PS4_SYSV_ABI sceUsbdControlTransferGetSetup(); +int PS4_SYSV_ABI sceUsbdDetachKernelDriver(); +int PS4_SYSV_ABI sceUsbdEventHandlerActive(); +int PS4_SYSV_ABI sceUsbdEventHandlingOk(); +int PS4_SYSV_ABI sceUsbdExit(); +int PS4_SYSV_ABI sceUsbdFillBulkTransfer(); +int PS4_SYSV_ABI sceUsbdFillControlSetup(); +int PS4_SYSV_ABI sceUsbdFillControlTransfer(); +int PS4_SYSV_ABI sceUsbdFillInterruptTransfer(); +int PS4_SYSV_ABI sceUsbdFillIsoTransfer(); +int PS4_SYSV_ABI sceUsbdFreeConfigDescriptor(); +int PS4_SYSV_ABI sceUsbdFreeDeviceList(); +int PS4_SYSV_ABI sceUsbdFreeTransfer(); +int PS4_SYSV_ABI sceUsbdGetActiveConfigDescriptor(); +int PS4_SYSV_ABI sceUsbdGetBusNumber(); +int PS4_SYSV_ABI sceUsbdGetConfigDescriptor(); +int PS4_SYSV_ABI sceUsbdGetConfigDescriptorByValue(); +int PS4_SYSV_ABI sceUsbdGetConfiguration(); +int PS4_SYSV_ABI sceUsbdGetDescriptor(); +int PS4_SYSV_ABI sceUsbdGetDevice(); +int PS4_SYSV_ABI sceUsbdGetDeviceAddress(); +int PS4_SYSV_ABI sceUsbdGetDeviceDescriptor(); +int PS4_SYSV_ABI sceUsbdGetDeviceList(); +int PS4_SYSV_ABI sceUsbdGetDeviceSpeed(); +int PS4_SYSV_ABI sceUsbdGetIsoPacketBuffer(); +int PS4_SYSV_ABI sceUsbdGetMaxIsoPacketSize(); +int PS4_SYSV_ABI sceUsbdGetMaxPacketSize(); +int PS4_SYSV_ABI sceUsbdGetStringDescriptor(); +int PS4_SYSV_ABI sceUsbdGetStringDescriptorAscii(); +int PS4_SYSV_ABI sceUsbdHandleEvents(); +int PS4_SYSV_ABI sceUsbdHandleEventsLocked(); +int PS4_SYSV_ABI sceUsbdHandleEventsTimeout(); +int PS4_SYSV_ABI sceUsbdInit(); +int PS4_SYSV_ABI sceUsbdInterruptTransfer(); +int PS4_SYSV_ABI sceUsbdKernelDriverActive(); +int PS4_SYSV_ABI sceUsbdLockEvents(); +int PS4_SYSV_ABI sceUsbdLockEventWaiters(); +int PS4_SYSV_ABI sceUsbdOpen(); +int PS4_SYSV_ABI sceUsbdOpenDeviceWithVidPid(); +int PS4_SYSV_ABI sceUsbdRefDevice(); +int PS4_SYSV_ABI sceUsbdReleaseInterface(); +int PS4_SYSV_ABI sceUsbdResetDevice(); +int PS4_SYSV_ABI sceUsbdSetConfiguration(); +int PS4_SYSV_ABI sceUsbdSetInterfaceAltSetting(); +int PS4_SYSV_ABI sceUsbdSetIsoPacketLengths(); +int PS4_SYSV_ABI sceUsbdSubmitTransfer(); +int PS4_SYSV_ABI sceUsbdTryLockEvents(); +int PS4_SYSV_ABI sceUsbdUnlockEvents(); +int PS4_SYSV_ABI sceUsbdUnlockEventWaiters(); +int PS4_SYSV_ABI sceUsbdUnrefDevice(); +int PS4_SYSV_ABI sceUsbdWaitForEvent(); +int PS4_SYSV_ABI Func_65F6EF33E38FFF50(); +int PS4_SYSV_ABI Func_97F056BAD90AADE7(); +int PS4_SYSV_ABI Func_C55104A33B35B264(); +int PS4_SYSV_ABI Func_D56B43060720B1E0(); + +void RegisterlibSceUsbd(Core::Loader::SymbolsResolver* sym); +} // namespace Libraries::Usbd \ No newline at end of file diff --git a/src/emulator.cpp b/src/emulator.cpp index 95fbbfa8..d43fabbe 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);