diff --git a/Utilities/StrFmt.h b/Utilities/StrFmt.h index 845f673074..dafb7fa67a 100644 --- a/Utilities/StrFmt.h +++ b/Utilities/StrFmt.h @@ -39,7 +39,7 @@ struct fmt_unveil // This overload resolution takes the precedence static inline u64_wrapper get(T&& arg) { - return {std::move(arg)}; + return u64_wrapper{std::move(arg)}; } }; diff --git a/Utilities/types.h b/Utilities/types.h index d33a8d08db..6c0c7c76f0 100644 --- a/Utilities/types.h +++ b/Utilities/types.h @@ -818,7 +818,10 @@ static_assert(sizeof(cmd64) == 8 && std::is_pod::value, "Incorrect cmd64 template struct multicast : multicast { - constexpr multicast() = default; + constexpr multicast() + : multicast() + { + } // Implicit conversion to desired type constexpr operator T1() const @@ -868,14 +871,59 @@ public: } }; -enum class not_an_error_t : s32 +// Error code type (return type), implements error reporting +struct error_code { + // Use fixed s32 type for now (could be template argument) + s32 value; + + error_code() = default; + + // Must be implemented + static s32 error_report(const fmt_type_info* sup, u64 arg); + + // Helper type (TODO: use scoped enum when error code is widely used) + enum not_an_error : s32 + { + __not_an_error // SFINAE marker + }; + + // __not_an_error tester + template + struct is_error : std::integral_constant::value || std::is_integral::value> + { + }; + + template + struct is_error> : std::false_type + { + }; + + // Not an error constructor + template + error_code(const ET& value, int = 0) + : value(static_cast(value)) + { + } + + // Error constructor + template::value>> + error_code(const ET& value) + : value(error_report(fmt::get_type_info>(), fmt_unveil::get(value))) + { + } + + operator s32() const + { + return value; + } }; +// Helper function for error_code template -FORCE_INLINE not_an_error_t not_an_error(const T& value) +constexpr FORCE_INLINE error_code::not_an_error not_an_error(const T& value) { - return static_cast(static_cast(value)); + return static_cast(static_cast(value)); } template diff --git a/rpcs3/Emu/Cell/ErrorCodes.h b/rpcs3/Emu/Cell/ErrorCodes.h index 937919de58..5861d86dab 100644 --- a/rpcs3/Emu/Cell/ErrorCodes.h +++ b/rpcs3/Emu/Cell/ErrorCodes.h @@ -1,10 +1,18 @@ #pragma once -enum CellOk : s32 +struct CellOk { - CELL_OK = 0, + enum : s32 + { + __not_an_error, + + CELL_OK = 0 + }; }; +// Temporary workaround +constexpr auto CELL_OK = CellOk::CELL_OK; + enum CellError : u32 { CELL_EAGAIN = 0x80010001, // The resource is temporarily unavailable @@ -66,142 +74,3 @@ enum CellError : u32 CELL_ENOTMOUNTED = 0x8001003A, CELL_ENOTSDATA = 0x8001003B, }; - -// Special return type signaling on errors -struct ppu_error_code -{ - s32 value; - - // Print error message, error code is returned - static s32 report(s32 error, const char* text); - - // Must be specialized for specific tag type T - template - static const char* print(T code) - { - return nullptr; - } - - template - s32 error_check(T code) - { - if (const auto text = print(code)) - { - return report(code, text); - } - - return code; - } - - ppu_error_code() = default; - - // General error check - template::value>> - ppu_error_code(T value) - : value(error_check(value)) - { - } - - // Force error reporting with a message specified - ppu_error_code(s32 value, const char* text) - : value(report(value, text)) - { - } - - // Silence any error - constexpr ppu_error_code(not_an_error_t value) - : value(static_cast(value)) - { - } - - // Conversion - constexpr operator s32() const - { - return value; - } -}; - -template -struct ppu_gpr_cast_impl; - -template<> -struct ppu_gpr_cast_impl -{ - static inline u64 to(const ppu_error_code& code) - { - return code; - } - - static inline ppu_error_code from(const u64 reg) - { - return not_an_error(reg); - } -}; - -template<> -inline const char* ppu_error_code::print(CellError error) -{ - switch (error) - { - STR_CASE(CELL_EAGAIN); - STR_CASE(CELL_EINVAL); - STR_CASE(CELL_ENOSYS); - STR_CASE(CELL_ENOMEM); - STR_CASE(CELL_ESRCH); - STR_CASE(CELL_ENOENT); - STR_CASE(CELL_ENOEXEC); - STR_CASE(CELL_EDEADLK); - STR_CASE(CELL_EPERM); - STR_CASE(CELL_EBUSY); - STR_CASE(CELL_ETIMEDOUT); - STR_CASE(CELL_EABORT); - STR_CASE(CELL_EFAULT); - STR_CASE(CELL_ESTAT); - STR_CASE(CELL_EALIGN); - STR_CASE(CELL_EKRESOURCE); - STR_CASE(CELL_EISDIR); - STR_CASE(CELL_ECANCELED); - STR_CASE(CELL_EEXIST); - STR_CASE(CELL_EISCONN); - STR_CASE(CELL_ENOTCONN); - STR_CASE(CELL_EAUTHFAIL); - STR_CASE(CELL_ENOTMSELF); - STR_CASE(CELL_ESYSVER); - STR_CASE(CELL_EAUTHFATAL); - STR_CASE(CELL_EDOM); - STR_CASE(CELL_ERANGE); - STR_CASE(CELL_EILSEQ); - STR_CASE(CELL_EFPOS); - STR_CASE(CELL_EINTR); - STR_CASE(CELL_EFBIG); - STR_CASE(CELL_EMLINK); - STR_CASE(CELL_ENFILE); - STR_CASE(CELL_ENOSPC); - STR_CASE(CELL_ENOTTY); - STR_CASE(CELL_EPIPE); - STR_CASE(CELL_EROFS); - STR_CASE(CELL_ESPIPE); - STR_CASE(CELL_E2BIG); - STR_CASE(CELL_EACCES); - STR_CASE(CELL_EBADF); - STR_CASE(CELL_EIO); - STR_CASE(CELL_EMFILE); - STR_CASE(CELL_ENODEV); - STR_CASE(CELL_ENOTDIR); - STR_CASE(CELL_ENXIO); - STR_CASE(CELL_EXDEV); - STR_CASE(CELL_EBADMSG); - STR_CASE(CELL_EINPROGRESS); - STR_CASE(CELL_EMSGSIZE); - STR_CASE(CELL_ENAMETOOLONG); - STR_CASE(CELL_ENOLCK); - STR_CASE(CELL_ENOTEMPTY); - STR_CASE(CELL_ENOTSUP); - STR_CASE(CELL_EFSSPECIFIC); - STR_CASE(CELL_EOVERFLOW); - STR_CASE(CELL_ENOTMOUNTED); - STR_CASE(CELL_ENOTSDATA); - } - - return nullptr; -} diff --git a/rpcs3/Emu/Cell/Modules/cellFs.cpp b/rpcs3/Emu/Cell/Modules/cellFs.cpp index 5447a5c89a..5b634204da 100644 --- a/rpcs3/Emu/Cell/Modules/cellFs.cpp +++ b/rpcs3/Emu/Cell/Modules/cellFs.cpp @@ -262,7 +262,7 @@ s32 cellFsGetDirectoryEntries(u32 fd, vm::ptr entries, u32 return CELL_OK; } -ppu_error_code cellFsReadWithOffset(u32 fd, u64 offset, vm::ptr buf, u64 buffer_size, vm::ptr nread) +error_code cellFsReadWithOffset(u32 fd, u64 offset, vm::ptr buf, u64 buffer_size, vm::ptr nread) { cellFs.trace("cellFsReadWithOffset(fd=%d, offset=0x%llx, buf=*0x%x, buffer_size=0x%llx, nread=*0x%x)", fd, offset, buf, buffer_size, nread); @@ -291,7 +291,7 @@ ppu_error_code cellFsReadWithOffset(u32 fd, u64 offset, vm::ptr buf, u64 b return not_an_error(rc ? rc : arg->out_code.value()); } -ppu_error_code cellFsWriteWithOffset(u32 fd, u64 offset, vm::cptr buf, u64 data_size, vm::ptr nwrite) +error_code cellFsWriteWithOffset(u32 fd, u64 offset, vm::cptr buf, u64 data_size, vm::ptr nwrite) { cellFs.trace("cellFsWriteWithOffset(fd=%d, offset=0x%llx, buf=*0x%x, data_size=0x%llx, nwrite=*0x%x)", fd, offset, buf, data_size, nwrite); diff --git a/rpcs3/Emu/Cell/Modules/cellGame.cpp b/rpcs3/Emu/Cell/Modules/cellGame.cpp index 4821479aa5..b3b63badbe 100644 --- a/rpcs3/Emu/Cell/Modules/cellGame.cpp +++ b/rpcs3/Emu/Cell/Modules/cellGame.cpp @@ -14,6 +14,55 @@ logs::channel cellGame("cellGame", logs::level::notice); +template<> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](auto error) + { + switch (error) + { + STR_CASE(CELL_GAME_ERROR_NOTFOUND); + STR_CASE(CELL_GAME_ERROR_BROKEN); + STR_CASE(CELL_GAME_ERROR_INTERNAL); + STR_CASE(CELL_GAME_ERROR_PARAM); + STR_CASE(CELL_GAME_ERROR_NOAPP); + STR_CASE(CELL_GAME_ERROR_ACCESS_ERROR); + STR_CASE(CELL_GAME_ERROR_NOSPACE); + STR_CASE(CELL_GAME_ERROR_NOTSUPPORTED); + STR_CASE(CELL_GAME_ERROR_FAILURE); + STR_CASE(CELL_GAME_ERROR_BUSY); + STR_CASE(CELL_GAME_ERROR_IN_SHUTDOWN); + STR_CASE(CELL_GAME_ERROR_INVALID_ID); + STR_CASE(CELL_GAME_ERROR_EXIST); + STR_CASE(CELL_GAME_ERROR_NOTPATCH); + STR_CASE(CELL_GAME_ERROR_INVALID_THEME_FILE); + STR_CASE(CELL_GAME_ERROR_BOOTPATH); + } + + return unknown; + }); +} + +template<> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](auto error) + { + switch (error) + { + STR_CASE(CELL_GAMEDATA_ERROR_CBRESULT); + STR_CASE(CELL_GAMEDATA_ERROR_ACCESS_ERROR); + STR_CASE(CELL_GAMEDATA_ERROR_INTERNAL); + STR_CASE(CELL_GAMEDATA_ERROR_PARAM); + STR_CASE(CELL_GAMEDATA_ERROR_NOSPACE); + STR_CASE(CELL_GAMEDATA_ERROR_BROKEN); + STR_CASE(CELL_GAMEDATA_ERROR_FAILURE); + } + + return unknown; + }); +} + // Normal content directory (if is_temporary is not involved): // contentInfo = dir // usrdir = dir + "/USRDIR" @@ -153,7 +202,7 @@ s32 cellGameDataExitBroken() } -ppu_error_code cellGameBootCheck(vm::ptr type, vm::ptr attributes, vm::ptr size, vm::ptr dirName) +error_code cellGameBootCheck(vm::ptr type, vm::ptr attributes, vm::ptr size, vm::ptr dirName) { cellGame.warning("cellGameBootCheck(type=*0x%x, attributes=*0x%x, size=*0x%x, dirName=*0x%x)", type, attributes, size, dirName); @@ -214,10 +263,10 @@ ppu_error_code cellGameBootCheck(vm::ptr type, vm::ptr attributes, vm: cellGame.error("cellGameBootCheck(): Unknown CATEGORY: %s", category); } - return CELL_GAME_RET_OK; + return CELL_OK; } -ppu_error_code cellGamePatchCheck(vm::ptr size, vm::ptr reserved) +error_code cellGamePatchCheck(vm::ptr size, vm::ptr reserved) { cellGame.warning("cellGamePatchCheck(size=*0x%x, reserved=*0x%x)", size, reserved); @@ -246,7 +295,7 @@ ppu_error_code cellGamePatchCheck(vm::ptr size, vm::ptr dirName, vm::ptr size) +error_code cellGameDataCheck(u32 type, vm::cptr dirName, vm::ptr size) { cellGame.warning("cellGameDataCheck(type=%d, dirName=%s, size=*0x%x)", type, dirName, size); @@ -271,7 +320,7 @@ ppu_error_code cellGameDataCheck(u32 type, vm::cptr dirName, vm::ptr(std::move(dir), psf::load_object(fs::file(vfs::get(dir + "/PARAM.SFO"))), false)) @@ -279,10 +328,10 @@ ppu_error_code cellGameDataCheck(u32 type, vm::cptr dirName, vm::ptr contentInfoPath, vm::ptr usrdirPath) +error_code cellGameContentPermit(vm::ptr contentInfoPath, vm::ptr usrdirPath) { cellGame.warning("cellGameContentPermit(contentInfoPath=*0x%x, usrdirPath=*0x%x)", contentInfoPath, usrdirPath); @@ -330,7 +379,7 @@ ppu_error_code cellGameContentPermit(vm::ptr contentIn return CELL_OK; } -ppu_error_code cellGameDataCheckCreate2(ppu_thread& ppu, u32 version, vm::cptr dirName, u32 errDialog, vm::ptr funcStat, u32 container) +error_code cellGameDataCheckCreate2(ppu_thread& ppu, u32 version, vm::cptr dirName, u32 errDialog, vm::ptr funcStat, u32 container) { cellGame.error("cellGameDataCheckCreate2(version=0x%x, dirName=%s, errDialog=0x%x, funcStat=*0x%x, container=%d)", version, dirName, errDialog, funcStat, container); @@ -347,7 +396,7 @@ ppu_error_code cellGameDataCheckCreate2(ppu_thread& ppu, u32 version, vm::cptr cbResult; @@ -394,7 +443,7 @@ ppu_error_code cellGameDataCheckCreate2(ppu_thread& ppu, u32 version, vm::cptr dirName return cellGameDataCheckCreate2(ppu, version, dirName, errDialog, funcStat, container); } -ppu_error_code cellGameCreateGameData(vm::ptr init, vm::ptr tmp_contentInfoPath, vm::ptr tmp_usrdirPath) +error_code cellGameCreateGameData(vm::ptr init, vm::ptr tmp_contentInfoPath, vm::ptr tmp_usrdirPath) { cellGame.error("cellGameCreateGameData(init=*0x%x, tmp_contentInfoPath=*0x%x, tmp_usrdirPath=*0x%x)", init, tmp_contentInfoPath, tmp_usrdirPath); @@ -476,7 +525,7 @@ s32 cellGameDeleteGameData() return CELL_OK; } -ppu_error_code cellGameGetParamInt(s32 id, vm::ptr value) +error_code cellGameGetParamInt(s32 id, vm::ptr value) { cellGame.warning("cellGameGetParamInt(id=%d, value=*0x%x)", id, value); @@ -539,7 +588,7 @@ static const char* get_param_string_key(s32 id) return nullptr; } -ppu_error_code cellGameGetParamString(s32 id, vm::ptr buf, u32 bufsize) +error_code cellGameGetParamString(s32 id, vm::ptr buf, u32 bufsize) { cellGame.warning("cellGameGetParamString(id=%d, buf=*0x%x, bufsize=%d)", id, buf, bufsize); @@ -565,7 +614,7 @@ ppu_error_code cellGameGetParamString(s32 id, vm::ptr buf, u32 bufsize) return CELL_OK; } -ppu_error_code cellGameSetParamString(s32 id, vm::cptr buf) +error_code cellGameSetParamString(s32 id, vm::cptr buf) { cellGame.warning("cellGameSetParamString(id=%d, buf=*0x%x)", id, buf); @@ -616,7 +665,7 @@ s32 cellGameGetLocalWebContentPath() return CELL_OK; } -ppu_error_code cellGameContentErrorDialog(s32 type, s32 errNeedSizeKB, vm::cptr dirName) +error_code cellGameContentErrorDialog(s32 type, s32 errNeedSizeKB, vm::cptr dirName) { cellGame.warning("cellGameContentErrorDialog(type=%d, errNeedSizeKB=%d, dirName=%s)", type, errNeedSizeKB, dirName); diff --git a/rpcs3/Emu/Cell/Modules/cellGame.h b/rpcs3/Emu/Cell/Modules/cellGame.h index eee3b71c5a..7eef52de10 100644 --- a/rpcs3/Emu/Cell/Modules/cellGame.h +++ b/rpcs3/Emu/Cell/Modules/cellGame.h @@ -32,31 +32,16 @@ enum CellGameError : u32 CELL_GAME_ERROR_BOOTPATH = 0x8002cb50, }; -template<> -inline const char* ppu_error_code::print(CellGameError error) +enum CellGameDataError : u32 { - switch (error) - { - STR_CASE(CELL_GAME_ERROR_NOTFOUND); - STR_CASE(CELL_GAME_ERROR_BROKEN); - STR_CASE(CELL_GAME_ERROR_INTERNAL); - STR_CASE(CELL_GAME_ERROR_PARAM); - STR_CASE(CELL_GAME_ERROR_NOAPP); - STR_CASE(CELL_GAME_ERROR_ACCESS_ERROR); - STR_CASE(CELL_GAME_ERROR_NOSPACE); - STR_CASE(CELL_GAME_ERROR_NOTSUPPORTED); - STR_CASE(CELL_GAME_ERROR_FAILURE); - STR_CASE(CELL_GAME_ERROR_BUSY); - STR_CASE(CELL_GAME_ERROR_IN_SHUTDOWN); - STR_CASE(CELL_GAME_ERROR_INVALID_ID); - STR_CASE(CELL_GAME_ERROR_EXIST); - STR_CASE(CELL_GAME_ERROR_NOTPATCH); - STR_CASE(CELL_GAME_ERROR_INVALID_THEME_FILE); - STR_CASE(CELL_GAME_ERROR_BOOTPATH); - } - - return nullptr; -} + CELL_GAMEDATA_ERROR_CBRESULT = 0x8002b601, + CELL_GAMEDATA_ERROR_ACCESS_ERROR = 0x8002b602, + CELL_GAMEDATA_ERROR_INTERNAL = 0x8002b603, + CELL_GAMEDATA_ERROR_PARAM = 0x8002b604, + CELL_GAMEDATA_ERROR_NOSPACE = 0x8002b605, + CELL_GAMEDATA_ERROR_BROKEN = 0x8002b606, + CELL_GAMEDATA_ERROR_FAILURE = 0x8002b607, +}; // Definitions enum @@ -174,16 +159,6 @@ enum // old consts CELL_GAMEDATA_RET_OK = 0, CELL_GAMEDATA_RET_CANCEL = 1, - CELL_GAMEDATA_ERROR_CBRESULT = 0x8002b601, - CELL_GAMEDATA_ERROR_ACCESS_ERROR = 0x8002b602, - CELL_GAMEDATA_ERROR_INTERNAL = 0x8002b603, - - CELL_GAMEDATA_ERROR_PARAM = 0x8002b604, - CELL_GAMEDATA_ERROR_NOSPACE = 0x8002b605, - CELL_GAMEDATA_ERROR_BROKEN = 0x8002b606, - - CELL_GAMEDATA_ERROR_FAILURE = 0x8002b607, - CELL_GAMEDATA_ATTR_NORMAL = 0, CELL_GAMEDATA_VERSION_CURRENT = 0, diff --git a/rpcs3/Emu/Cell/Modules/cellSpurs.cpp b/rpcs3/Emu/Cell/Modules/cellSpurs.cpp index b8c6392e69..8c9cc83eff 100644 --- a/rpcs3/Emu/Cell/Modules/cellSpurs.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSpurs.cpp @@ -3196,7 +3196,7 @@ s32 cellSpursEventFlagGetTasksetAddress(vm::ptr eventFlag, v return CELL_OK; } -static inline s32 SyncErrorToSpursError(const ppu_error_code& res) +static inline s32 SyncErrorToSpursError(const error_code& res) { return res.value < 0 ? 0x80410900 | (res.value & 0xff) : res.value; } diff --git a/rpcs3/Emu/Cell/Modules/cellSync.cpp b/rpcs3/Emu/Cell/Modules/cellSync.cpp index ce39bfbc1d..c3a0773035 100644 --- a/rpcs3/Emu/Cell/Modules/cellSync.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSync.cpp @@ -12,6 +12,38 @@ logs::channel cellSync("cellSync", logs::level::notice); +template<> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](auto error) + { + switch (error) + { + STR_CASE(CELL_SYNC_ERROR_AGAIN); + STR_CASE(CELL_SYNC_ERROR_INVAL); + STR_CASE(CELL_SYNC_ERROR_NOSYS); + STR_CASE(CELL_SYNC_ERROR_NOMEM); + STR_CASE(CELL_SYNC_ERROR_SRCH); + STR_CASE(CELL_SYNC_ERROR_NOENT); + STR_CASE(CELL_SYNC_ERROR_NOEXEC); + STR_CASE(CELL_SYNC_ERROR_DEADLK); + STR_CASE(CELL_SYNC_ERROR_PERM); + STR_CASE(CELL_SYNC_ERROR_BUSY); + STR_CASE(CELL_SYNC_ERROR_ABORT); + STR_CASE(CELL_SYNC_ERROR_FAULT); + STR_CASE(CELL_SYNC_ERROR_CHILD); + STR_CASE(CELL_SYNC_ERROR_STAT); + STR_CASE(CELL_SYNC_ERROR_ALIGN); + STR_CASE(CELL_SYNC_ERROR_NULL_POINTER); + STR_CASE(CELL_SYNC_ERROR_NOT_SUPPORTED_THREAD); + STR_CASE(CELL_SYNC_ERROR_NO_NOTIFIER); + STR_CASE(CELL_SYNC_ERROR_NO_SPU_CONTEXT_STORAGE); + } + + return unknown; + }); +} + namespace _sync { static inline be_t mutex_acquire(mutex& ctrl) @@ -30,7 +62,7 @@ namespace _sync } } -ppu_error_code cellSyncMutexInitialize(vm::ptr mutex) +error_code cellSyncMutexInitialize(vm::ptr mutex) { cellSync.trace("cellSyncMutexInitialize(mutex=*0x%x)", mutex); @@ -49,7 +81,7 @@ ppu_error_code cellSyncMutexInitialize(vm::ptr mutex) return CELL_OK; } -ppu_error_code cellSyncMutexLock(vm::ptr mutex) +error_code cellSyncMutexLock(vm::ptr mutex) { cellSync.trace("cellSyncMutexLock(mutex=*0x%x)", mutex); @@ -74,7 +106,7 @@ ppu_error_code cellSyncMutexLock(vm::ptr mutex) return CELL_OK; } -ppu_error_code cellSyncMutexTryLock(vm::ptr mutex) +error_code cellSyncMutexTryLock(vm::ptr mutex) { cellSync.trace("cellSyncMutexTryLock(mutex=*0x%x)", mutex); @@ -96,7 +128,7 @@ ppu_error_code cellSyncMutexTryLock(vm::ptr mutex) return CELL_OK; } -ppu_error_code cellSyncMutexUnlock(vm::ptr mutex) +error_code cellSyncMutexUnlock(vm::ptr mutex) { cellSync.trace("cellSyncMutexUnlock(mutex=*0x%x)", mutex); @@ -117,7 +149,7 @@ ppu_error_code cellSyncMutexUnlock(vm::ptr mutex) return CELL_OK; } -ppu_error_code cellSyncBarrierInitialize(vm::ptr barrier, u16 total_count) +error_code cellSyncBarrierInitialize(vm::ptr barrier, u16 total_count) { cellSync.trace("cellSyncBarrierInitialize(barrier=*0x%x, total_count=%d)", barrier, total_count); @@ -142,7 +174,7 @@ ppu_error_code cellSyncBarrierInitialize(vm::ptr barrier, u16 t return CELL_OK; } -ppu_error_code cellSyncBarrierNotify(vm::ptr barrier) +error_code cellSyncBarrierNotify(vm::ptr barrier) { cellSync.trace("cellSyncBarrierNotify(barrier=*0x%x)", barrier); @@ -163,7 +195,7 @@ ppu_error_code cellSyncBarrierNotify(vm::ptr barrier) return CELL_OK; } -ppu_error_code cellSyncBarrierTryNotify(vm::ptr barrier) +error_code cellSyncBarrierTryNotify(vm::ptr barrier) { cellSync.trace("cellSyncBarrierTryNotify(barrier=*0x%x)", barrier); @@ -189,7 +221,7 @@ ppu_error_code cellSyncBarrierTryNotify(vm::ptr barrier) return CELL_OK; } -ppu_error_code cellSyncBarrierWait(vm::ptr barrier) +error_code cellSyncBarrierWait(vm::ptr barrier) { cellSync.trace("cellSyncBarrierWait(barrier=*0x%x)", barrier); @@ -212,7 +244,7 @@ ppu_error_code cellSyncBarrierWait(vm::ptr barrier) return CELL_OK; } -ppu_error_code cellSyncBarrierTryWait(vm::ptr barrier) +error_code cellSyncBarrierTryWait(vm::ptr barrier) { cellSync.trace("cellSyncBarrierTryWait(barrier=*0x%x)", barrier); @@ -238,7 +270,7 @@ ppu_error_code cellSyncBarrierTryWait(vm::ptr barrier) return CELL_OK; } -ppu_error_code cellSyncRwmInitialize(vm::ptr rwm, vm::ptr buffer, u32 buffer_size) +error_code cellSyncRwmInitialize(vm::ptr rwm, vm::ptr buffer, u32 buffer_size) { cellSync.trace("cellSyncRwmInitialize(rwm=*0x%x, buffer=*0x%x, buffer_size=0x%x)", rwm, buffer, buffer_size); @@ -267,7 +299,7 @@ ppu_error_code cellSyncRwmInitialize(vm::ptr rwm, vm::ptr buf return CELL_OK; } -ppu_error_code cellSyncRwmRead(vm::ptr rwm, vm::ptr buffer) +error_code cellSyncRwmRead(vm::ptr rwm, vm::ptr buffer) { cellSync.trace("cellSyncRwmRead(rwm=*0x%x, buffer=*0x%x)", rwm, buffer); @@ -298,7 +330,7 @@ ppu_error_code cellSyncRwmRead(vm::ptr rwm, vm::ptr buffer) return CELL_OK; } -ppu_error_code cellSyncRwmTryRead(vm::ptr rwm, vm::ptr buffer) +error_code cellSyncRwmTryRead(vm::ptr rwm, vm::ptr buffer) { cellSync.trace("cellSyncRwmTryRead(rwm=*0x%x, buffer=*0x%x)", rwm, buffer); @@ -332,7 +364,7 @@ ppu_error_code cellSyncRwmTryRead(vm::ptr rwm, vm::ptr buffer return CELL_OK; } -ppu_error_code cellSyncRwmWrite(vm::ptr rwm, vm::cptr buffer) +error_code cellSyncRwmWrite(vm::ptr rwm, vm::cptr buffer) { cellSync.trace("cellSyncRwmWrite(rwm=*0x%x, buffer=*0x%x)", rwm, buffer); @@ -363,7 +395,7 @@ ppu_error_code cellSyncRwmWrite(vm::ptr rwm, vm::cptr buffer) return CELL_OK; } -ppu_error_code cellSyncRwmTryWrite(vm::ptr rwm, vm::cptr buffer) +error_code cellSyncRwmTryWrite(vm::ptr rwm, vm::cptr buffer) { cellSync.trace("cellSyncRwmTryWrite(rwm=*0x%x, buffer=*0x%x)", rwm, buffer); @@ -394,7 +426,7 @@ ppu_error_code cellSyncRwmTryWrite(vm::ptr rwm, vm::cptr buff return CELL_OK; } -ppu_error_code cellSyncQueueInitialize(vm::ptr queue, vm::ptr buffer, u32 size, u32 depth) +error_code cellSyncQueueInitialize(vm::ptr queue, vm::ptr buffer, u32 size, u32 depth) { cellSync.trace("cellSyncQueueInitialize(queue=*0x%x, buffer=*0x%x, size=0x%x, depth=0x%x)", queue, buffer, size, depth); @@ -429,7 +461,7 @@ ppu_error_code cellSyncQueueInitialize(vm::ptr queue, vm::ptr return CELL_OK; } -ppu_error_code cellSyncQueuePush(vm::ptr queue, vm::cptr buffer) +error_code cellSyncQueuePush(vm::ptr queue, vm::cptr buffer) { cellSync.trace("cellSyncQueuePush(queue=*0x%x, buffer=*0x%x)", queue, buffer); @@ -460,7 +492,7 @@ ppu_error_code cellSyncQueuePush(vm::ptr queue, vm::cptr bu return CELL_OK; } -ppu_error_code cellSyncQueueTryPush(vm::ptr queue, vm::cptr buffer) +error_code cellSyncQueueTryPush(vm::ptr queue, vm::cptr buffer) { cellSync.trace("cellSyncQueueTryPush(queue=*0x%x, buffer=*0x%x)", queue, buffer); @@ -494,7 +526,7 @@ ppu_error_code cellSyncQueueTryPush(vm::ptr queue, vm::cptr return CELL_OK; } -ppu_error_code cellSyncQueuePop(vm::ptr queue, vm::ptr buffer) +error_code cellSyncQueuePop(vm::ptr queue, vm::ptr buffer) { cellSync.trace("cellSyncQueuePop(queue=*0x%x, buffer=*0x%x)", queue, buffer); @@ -525,7 +557,7 @@ ppu_error_code cellSyncQueuePop(vm::ptr queue, vm::ptr buff return CELL_OK; } -ppu_error_code cellSyncQueueTryPop(vm::ptr queue, vm::ptr buffer) +error_code cellSyncQueueTryPop(vm::ptr queue, vm::ptr buffer) { cellSync.trace("cellSyncQueueTryPop(queue=*0x%x, buffer=*0x%x)", queue, buffer); @@ -559,7 +591,7 @@ ppu_error_code cellSyncQueueTryPop(vm::ptr queue, vm::ptr b return CELL_OK; } -ppu_error_code cellSyncQueuePeek(vm::ptr queue, vm::ptr buffer) +error_code cellSyncQueuePeek(vm::ptr queue, vm::ptr buffer) { cellSync.trace("cellSyncQueuePeek(queue=*0x%x, buffer=*0x%x)", queue, buffer); @@ -590,7 +622,7 @@ ppu_error_code cellSyncQueuePeek(vm::ptr queue, vm::ptr buf return CELL_OK; } -ppu_error_code cellSyncQueueTryPeek(vm::ptr queue, vm::ptr buffer) +error_code cellSyncQueueTryPeek(vm::ptr queue, vm::ptr buffer) { cellSync.trace("cellSyncQueueTryPeek(queue=*0x%x, buffer=*0x%x)", queue, buffer); @@ -624,7 +656,7 @@ ppu_error_code cellSyncQueueTryPeek(vm::ptr queue, vm::ptr return CELL_OK; } -ppu_error_code cellSyncQueueSize(vm::ptr queue) +error_code cellSyncQueueSize(vm::ptr queue) { cellSync.trace("cellSyncQueueSize(queue=*0x%x)", queue); @@ -643,7 +675,7 @@ ppu_error_code cellSyncQueueSize(vm::ptr queue) return not_an_error(queue->ctrl.load().count & 0xffffff); } -ppu_error_code cellSyncQueueClear(vm::ptr queue) +error_code cellSyncQueueClear(vm::ptr queue) { cellSync.trace("cellSyncQueueClear(queue=*0x%x)", queue); @@ -711,7 +743,7 @@ void syncLFQueueInitialize(vm::ptr queue, vm::cptr buffer queue->m_eq_id = 0; } -ppu_error_code cellSyncLFQueueInitialize(vm::ptr queue, vm::cptr buffer, u32 size, u32 depth, u32 direction, vm::ptr eaSignal) +error_code cellSyncLFQueueInitialize(vm::ptr queue, vm::cptr buffer, u32 size, u32 depth, u32 direction, vm::ptr eaSignal) { cellSync.warning("cellSyncLFQueueInitialize(queue=*0x%x, buffer=*0x%x, size=0x%x, depth=0x%x, direction=%d, eaSignal=*0x%x)", queue, buffer, size, depth, direction, eaSignal); @@ -820,7 +852,7 @@ ppu_error_code cellSyncLFQueueInitialize(vm::ptr queue, vm::cpt return CELL_OK; } -ppu_error_code _cellSyncLFQueueGetPushPointer(ppu_thread& ppu, vm::ptr queue, vm::ptr pointer, u32 isBlocking, u32 useEventQueue) +error_code _cellSyncLFQueueGetPushPointer(ppu_thread& ppu, vm::ptr queue, vm::ptr pointer, u32 isBlocking, u32 useEventQueue) { cellSync.warning("_cellSyncLFQueueGetPushPointer(queue=*0x%x, pointer=*0x%x, isBlocking=%d, useEventQueue=%d)", queue, pointer, isBlocking, useEventQueue); @@ -913,7 +945,7 @@ ppu_error_code _cellSyncLFQueueGetPushPointer(ppu_thread& ppu, vm::ptr queue, vm::ptr pointer, u32 isBlocking, u32 useEventQueue) +error_code _cellSyncLFQueueGetPushPointer2(ppu_thread& ppu, vm::ptr queue, vm::ptr pointer, u32 isBlocking, u32 useEventQueue) { // arguments copied from _cellSyncLFQueueGetPushPointer cellSync.todo("_cellSyncLFQueueGetPushPointer2(queue=*0x%x, pointer=*0x%x, isBlocking=%d, useEventQueue=%d)", queue, pointer, isBlocking, useEventQueue); @@ -921,7 +953,7 @@ ppu_error_code _cellSyncLFQueueGetPushPointer2(ppu_thread& ppu, vm::ptr queue, s32 pointer, vm::ptr fpSendSignal) +error_code _cellSyncLFQueueCompletePushPointer(ppu_thread& ppu, vm::ptr queue, s32 pointer, vm::ptr fpSendSignal) { cellSync.warning("_cellSyncLFQueueCompletePushPointer(queue=*0x%x, pointer=%d, fpSendSignal=*0x%x)", queue, pointer, fpSendSignal); @@ -1053,7 +1085,7 @@ ppu_error_code _cellSyncLFQueueCompletePushPointer(ppu_thread& ppu, vm::ptr queue, s32 pointer, vm::ptr fpSendSignal) +error_code _cellSyncLFQueueCompletePushPointer2(ppu_thread& ppu, vm::ptr queue, s32 pointer, vm::ptr fpSendSignal) { // arguments copied from _cellSyncLFQueueCompletePushPointer cellSync.todo("_cellSyncLFQueueCompletePushPointer2(queue=*0x%x, pointer=%d, fpSendSignal=*0x%x)", queue, pointer, fpSendSignal); @@ -1061,7 +1093,7 @@ ppu_error_code _cellSyncLFQueueCompletePushPointer2(ppu_thread& ppu, vm::ptr queue, vm::cptr buffer, u32 isBlocking) +error_code _cellSyncLFQueuePushBody(ppu_thread& ppu, vm::ptr queue, vm::cptr buffer, u32 isBlocking) { // cellSyncLFQueuePush has 1 in isBlocking param, cellSyncLFQueueTryPush has 0 cellSync.warning("_cellSyncLFQueuePushBody(queue=*0x%x, buffer=*0x%x, isBlocking=%d)", queue, buffer, isBlocking); @@ -1119,7 +1151,7 @@ ppu_error_code _cellSyncLFQueuePushBody(ppu_thread& ppu, vm::ptr queue, vm::ptr pointer, u32 isBlocking, u32 arg4, u32 useEventQueue) +error_code _cellSyncLFQueueGetPopPointer(ppu_thread& ppu, vm::ptr queue, vm::ptr pointer, u32 isBlocking, u32 arg4, u32 useEventQueue) { cellSync.warning("_cellSyncLFQueueGetPopPointer(queue=*0x%x, pointer=*0x%x, isBlocking=%d, arg4=%d, useEventQueue=%d)", queue, pointer, isBlocking, arg4, useEventQueue); @@ -1212,7 +1244,7 @@ ppu_error_code _cellSyncLFQueueGetPopPointer(ppu_thread& ppu, vm::ptr queue, vm::ptr pointer, u32 isBlocking, u32 useEventQueue) +error_code _cellSyncLFQueueGetPopPointer2(ppu_thread& ppu, vm::ptr queue, vm::ptr pointer, u32 isBlocking, u32 useEventQueue) { // arguments copied from _cellSyncLFQueueGetPopPointer cellSync.todo("_cellSyncLFQueueGetPopPointer2(queue=*0x%x, pointer=*0x%x, isBlocking=%d, useEventQueue=%d)", queue, pointer, isBlocking, useEventQueue); @@ -1220,7 +1252,7 @@ ppu_error_code _cellSyncLFQueueGetPopPointer2(ppu_thread& ppu, vm::ptr queue, s32 pointer, vm::ptr fpSendSignal, u32 noQueueFull) +error_code _cellSyncLFQueueCompletePopPointer(ppu_thread& ppu, vm::ptr queue, s32 pointer, vm::ptr fpSendSignal, u32 noQueueFull) { // arguments copied from _cellSyncLFQueueCompletePushPointer + unknown argument (noQueueFull taken from LFQueue2CompletePopPointer) cellSync.warning("_cellSyncLFQueueCompletePopPointer(queue=*0x%x, pointer=%d, fpSendSignal=*0x%x, noQueueFull=%d)", queue, pointer, fpSendSignal, noQueueFull); @@ -1352,7 +1384,7 @@ ppu_error_code _cellSyncLFQueueCompletePopPointer(ppu_thread& ppu, vm::ptr queue, s32 pointer, vm::ptr fpSendSignal, u32 noQueueFull) +error_code _cellSyncLFQueueCompletePopPointer2(ppu_thread& ppu, vm::ptr queue, s32 pointer, vm::ptr fpSendSignal, u32 noQueueFull) { // arguments copied from _cellSyncLFQueueCompletePopPointer cellSync.todo("_cellSyncLFQueueCompletePopPointer2(queue=*0x%x, pointer=%d, fpSendSignal=*0x%x, noQueueFull=%d)", queue, pointer, fpSendSignal, noQueueFull); @@ -1360,7 +1392,7 @@ ppu_error_code _cellSyncLFQueueCompletePopPointer2(ppu_thread& ppu, vm::ptr queue, vm::ptr buffer, u32 isBlocking) +error_code _cellSyncLFQueuePopBody(ppu_thread& ppu, vm::ptr queue, vm::ptr buffer, u32 isBlocking) { // cellSyncLFQueuePop has 1 in isBlocking param, cellSyncLFQueueTryPop has 0 cellSync.warning("_cellSyncLFQueuePopBody(queue=*0x%x, buffer=*0x%x, isBlocking=%d)", queue, buffer, isBlocking); @@ -1418,7 +1450,7 @@ ppu_error_code _cellSyncLFQueuePopBody(ppu_thread& ppu, vm::ptr } } -ppu_error_code cellSyncLFQueueClear(vm::ptr queue) +error_code cellSyncLFQueueClear(vm::ptr queue) { cellSync.warning("cellSyncLFQueueClear(queue=*0x%x)", queue); @@ -1469,7 +1501,7 @@ ppu_error_code cellSyncLFQueueClear(vm::ptr queue) return CELL_OK; } -ppu_error_code cellSyncLFQueueSize(vm::ptr queue, vm::ptr size) +error_code cellSyncLFQueueSize(vm::ptr queue, vm::ptr size) { cellSync.warning("cellSyncLFQueueSize(queue=*0x%x, size=*0x%x)", queue, size); @@ -1506,7 +1538,7 @@ ppu_error_code cellSyncLFQueueSize(vm::ptr queue, vm::ptr } } -ppu_error_code cellSyncLFQueueDepth(vm::ptr queue, vm::ptr depth) +error_code cellSyncLFQueueDepth(vm::ptr queue, vm::ptr depth) { cellSync.trace("cellSyncLFQueueDepth(queue=*0x%x, depth=*0x%x)", queue, depth); @@ -1525,7 +1557,7 @@ ppu_error_code cellSyncLFQueueDepth(vm::ptr queue, vm::ptr return CELL_OK; } -ppu_error_code _cellSyncLFQueueGetSignalAddress(vm::cptr queue, vm::pptr ppSignal) +error_code _cellSyncLFQueueGetSignalAddress(vm::cptr queue, vm::pptr ppSignal) { cellSync.trace("_cellSyncLFQueueGetSignalAddress(queue=*0x%x, ppSignal=**0x%x)", queue, ppSignal); @@ -1544,7 +1576,7 @@ ppu_error_code _cellSyncLFQueueGetSignalAddress(vm::cptr queue, return CELL_OK; } -ppu_error_code cellSyncLFQueueGetDirection(vm::cptr queue, vm::ptr direction) +error_code cellSyncLFQueueGetDirection(vm::cptr queue, vm::ptr direction) { cellSync.trace("cellSyncLFQueueGetDirection(queue=*0x%x, direction=*0x%x)", queue, direction); @@ -1563,7 +1595,7 @@ ppu_error_code cellSyncLFQueueGetDirection(vm::cptr queue, vm:: return CELL_OK; } -ppu_error_code cellSyncLFQueueGetEntrySize(vm::cptr queue, vm::ptr entry_size) +error_code cellSyncLFQueueGetEntrySize(vm::cptr queue, vm::ptr entry_size) { cellSync.trace("cellSyncLFQueueGetEntrySize(queue=*0x%x, entry_size=*0x%x)", queue, entry_size); @@ -1582,14 +1614,14 @@ ppu_error_code cellSyncLFQueueGetEntrySize(vm::cptr queue, vm:: return CELL_OK; } -ppu_error_code _cellSyncLFQueueAttachLv2EventQueue(vm::ptr spus, u32 num, vm::ptr queue) +error_code _cellSyncLFQueueAttachLv2EventQueue(vm::ptr spus, u32 num, vm::ptr queue) { cellSync.todo("_cellSyncLFQueueAttachLv2EventQueue(spus=*0x%x, num=%d, queue=*0x%x)", spus, num, queue); fmt::throw_exception("Unimplemented" HERE); } -ppu_error_code _cellSyncLFQueueDetachLv2EventQueue(vm::ptr spus, u32 num, vm::ptr queue) +error_code _cellSyncLFQueueDetachLv2EventQueue(vm::ptr spus, u32 num, vm::ptr queue) { cellSync.todo("_cellSyncLFQueueDetachLv2EventQueue(spus=*0x%x, num=%d, queue=*0x%x)", spus, num, queue); diff --git a/rpcs3/Emu/Cell/Modules/cellSync.h b/rpcs3/Emu/Cell/Modules/cellSync.h index b4da3340e0..8e3151d91a 100644 --- a/rpcs3/Emu/Cell/Modules/cellSync.h +++ b/rpcs3/Emu/Cell/Modules/cellSync.h @@ -34,47 +34,6 @@ enum CellSyncError1 : u32 CELL_SYNC_ERROR_UNKNOWNKEY = 0x80410113, }; -template<> -inline const char* ppu_error_code::print(CellSyncError error) -{ - switch (error) - { - STR_CASE(CELL_SYNC_ERROR_AGAIN); - STR_CASE(CELL_SYNC_ERROR_INVAL); - STR_CASE(CELL_SYNC_ERROR_NOSYS); - STR_CASE(CELL_SYNC_ERROR_NOMEM); - STR_CASE(CELL_SYNC_ERROR_SRCH); - STR_CASE(CELL_SYNC_ERROR_NOENT); - STR_CASE(CELL_SYNC_ERROR_NOEXEC); - STR_CASE(CELL_SYNC_ERROR_DEADLK); - STR_CASE(CELL_SYNC_ERROR_PERM); - STR_CASE(CELL_SYNC_ERROR_BUSY); - STR_CASE(CELL_SYNC_ERROR_ABORT); - STR_CASE(CELL_SYNC_ERROR_FAULT); - STR_CASE(CELL_SYNC_ERROR_CHILD); - STR_CASE(CELL_SYNC_ERROR_STAT); - STR_CASE(CELL_SYNC_ERROR_ALIGN); - STR_CASE(CELL_SYNC_ERROR_NULL_POINTER); - STR_CASE(CELL_SYNC_ERROR_NOT_SUPPORTED_THREAD); - STR_CASE(CELL_SYNC_ERROR_NO_NOTIFIER); - STR_CASE(CELL_SYNC_ERROR_NO_SPU_CONTEXT_STORAGE); - } - - return nullptr; -} - -template<> -inline const char* ppu_error_code::print(CellSyncError1 error) -{ - switch (error) - { - STR_CASE(CELL_SYNC_ERROR_SHOTAGE); - STR_CASE(CELL_SYNC_ERROR_UNKNOWNKEY); - } - - return nullptr; -} - namespace _sync { struct alignas(4) mutex // CellSyncMutex control variable @@ -381,4 +340,4 @@ struct alignas(128) CellSyncLFQueue CHECK_SIZE_ALIGN(CellSyncLFQueue, 128, 128); // Prototypes -ppu_error_code cellSyncLFQueueInitialize(vm::ptr queue, vm::cptr buffer, u32 size, u32 depth, u32 direction, vm::ptr eaSignal); +error_code cellSyncLFQueueInitialize(vm::ptr queue, vm::cptr buffer, u32 size, u32 depth, u32 direction, vm::ptr eaSignal); diff --git a/rpcs3/Emu/Cell/Modules/cellUserInfo.cpp b/rpcs3/Emu/Cell/Modules/cellUserInfo.cpp index 94a7118349..8f53f60af0 100644 --- a/rpcs3/Emu/Cell/Modules/cellUserInfo.cpp +++ b/rpcs3/Emu/Cell/Modules/cellUserInfo.cpp @@ -8,6 +8,23 @@ logs::channel cellUserInfo("cellUserInfo", logs::level::notice); +template<> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](auto error) + { + switch (error) + { + STR_CASE(CELL_USERINFO_ERROR_BUSY); + STR_CASE(CELL_USERINFO_ERROR_INTERNAL); + STR_CASE(CELL_USERINFO_ERROR_PARAM); + STR_CASE(CELL_USERINFO_ERROR_NOUSER); + } + + return unknown; + }); +} + s32 cellUserInfoGetStat(u32 id, vm::ptr stat) { cellUserInfo.warning("cellUserInfoGetStat(id=%d, stat=*0x%x)", id, stat); @@ -63,7 +80,7 @@ s32 cellUserInfoEnableOverlay() return CELL_OK; } -ppu_error_code cellUserInfoGetList(vm::ptr listNum, vm::ptr listBuf, vm::ptr currentUserId) +error_code cellUserInfoGetList(vm::ptr listNum, vm::ptr listBuf, vm::ptr currentUserId) { cellUserInfo.todo("cellUserInfoGetList(listNum=*0x%x, listBuf=*0x%x, currentUserId=*0x%x)", listNum, listBuf, currentUserId); diff --git a/rpcs3/Emu/Cell/Modules/cellUserInfo.h b/rpcs3/Emu/Cell/Modules/cellUserInfo.h index 43bb8fd038..021f65cccb 100644 --- a/rpcs3/Emu/Cell/Modules/cellUserInfo.h +++ b/rpcs3/Emu/Cell/Modules/cellUserInfo.h @@ -3,30 +3,21 @@ namespace vm { using namespace ps3; } // Return Codes -enum CellUserInfoError : u32 +enum { CELL_USERINFO_RET_OK = 0, CELL_USERINFO_RET_CANCEL = 1, +}; + +// Error Codes +enum CellUserInfoError : u32 +{ CELL_USERINFO_ERROR_BUSY = 0x8002c301, CELL_USERINFO_ERROR_INTERNAL = 0x8002c302, CELL_USERINFO_ERROR_PARAM = 0x8002c303, CELL_USERINFO_ERROR_NOUSER = 0x8002c304, }; -template<> -inline const char* ppu_error_code::print(CellUserInfoError error) -{ - switch (error) - { - STR_CASE(CELL_USERINFO_ERROR_BUSY); - STR_CASE(CELL_USERINFO_ERROR_INTERNAL); - STR_CASE(CELL_USERINFO_ERROR_PARAM); - STR_CASE(CELL_USERINFO_ERROR_NOUSER); - } - - return nullptr; -} - // Enums enum CellUserInfoParamSize { diff --git a/rpcs3/Emu/Cell/Modules/cellVideoOut.cpp b/rpcs3/Emu/Cell/Modules/cellVideoOut.cpp index b823e24a09..68206d3f96 100644 --- a/rpcs3/Emu/Cell/Modules/cellVideoOut.cpp +++ b/rpcs3/Emu/Cell/Modules/cellVideoOut.cpp @@ -37,7 +37,29 @@ const extern std::unordered_map> g_video_out_resolution_ { CELL_VIDEO_OUT_RESOLUTION_960x1080, { 960, 1080 } }, }; -ppu_error_code cellVideoOutGetState(u32 videoOut, u32 deviceIndex, vm::ptr state) +template<> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](auto error) + { + switch (error) + { + STR_CASE(CELL_VIDEO_OUT_ERROR_NOT_IMPLEMENTED); + STR_CASE(CELL_VIDEO_OUT_ERROR_ILLEGAL_CONFIGURATION); + STR_CASE(CELL_VIDEO_OUT_ERROR_ILLEGAL_PARAMETER); + STR_CASE(CELL_VIDEO_OUT_ERROR_PARAMETER_OUT_OF_RANGE); + STR_CASE(CELL_VIDEO_OUT_ERROR_DEVICE_NOT_FOUND); + STR_CASE(CELL_VIDEO_OUT_ERROR_UNSUPPORTED_VIDEO_OUT); + STR_CASE(CELL_VIDEO_OUT_ERROR_UNSUPPORTED_DISPLAY_MODE); + STR_CASE(CELL_VIDEO_OUT_ERROR_CONDITION_BUSY); + STR_CASE(CELL_VIDEO_OUT_ERROR_VALUE_IS_NOT_SET); + } + + return unknown; + }); +} + +error_code cellVideoOutGetState(u32 videoOut, u32 deviceIndex, vm::ptr state) { cellSysutil.trace("cellVideoOutGetState(videoOut=%d, deviceIndex=%d, state=*0x%x)", videoOut, deviceIndex, state); @@ -63,7 +85,7 @@ ppu_error_code cellVideoOutGetState(u32 videoOut, u32 deviceIndex, vm::ptr resolution) +error_code cellVideoOutGetResolution(u32 resolutionId, vm::ptr resolution) { cellSysutil.trace("cellVideoOutGetResolution(resolutionId=0x%x, resolution=*0x%x)", resolutionId, resolution); @@ -104,7 +126,7 @@ ppu_error_code cellVideoOutGetResolution(u32 resolutionId, vm::ptr config, vm::ptr option, u32 waitForEvent) +error_code cellVideoOutConfigure(u32 videoOut, vm::ptr config, vm::ptr option, u32 waitForEvent) { cellSysutil.warning("cellVideoOutConfigure(videoOut=%d, config=*0x%x, option=*0x%x, waitForEvent=%d)", videoOut, config, option, waitForEvent); @@ -121,7 +143,7 @@ ppu_error_code cellVideoOutConfigure(u32 videoOut, vm::ptr config, vm::ptr option) +error_code cellVideoOutGetConfiguration(u32 videoOut, vm::ptr config, vm::ptr option) { cellSysutil.warning("cellVideoOutGetConfiguration(videoOut=%d, config=*0x%x, option=*0x%x)", videoOut, config, option); @@ -146,7 +168,7 @@ ppu_error_code cellVideoOutGetConfiguration(u32 videoOut, vm::ptr info) +error_code cellVideoOutGetDeviceInfo(u32 videoOut, u32 deviceIndex, vm::ptr info) { cellSysutil.warning("cellVideoOutGetDeviceInfo(videoOut=%d, deviceIndex=%d, info=*0x%x)", videoOut, deviceIndex, info); @@ -177,7 +199,7 @@ ppu_error_code cellVideoOutGetDeviceInfo(u32 videoOut, u32 deviceIndex, vm::ptr< return CELL_OK; } -ppu_error_code cellVideoOutGetNumberOfDevice(u32 videoOut) +error_code cellVideoOutGetNumberOfDevice(u32 videoOut) { cellSysutil.warning("cellVideoOutGetNumberOfDevice(videoOut=%d)", videoOut); @@ -190,7 +212,7 @@ ppu_error_code cellVideoOutGetNumberOfDevice(u32 videoOut) return CELL_VIDEO_OUT_ERROR_UNSUPPORTED_VIDEO_OUT; } -ppu_error_code cellVideoOutGetResolutionAvailability(u32 videoOut, u32 resolutionId, u32 aspect, u32 option) +error_code cellVideoOutGetResolutionAvailability(u32 videoOut, u32 resolutionId, u32 aspect, u32 option) { cellSysutil.warning("cellVideoOutGetResolutionAvailability(videoOut=%d, resolutionId=0x%x, aspect=%d, option=%d)", videoOut, resolutionId, aspect, option); diff --git a/rpcs3/Emu/Cell/Modules/cellVideoOut.h b/rpcs3/Emu/Cell/Modules/cellVideoOut.h index f1d6ea787c..e1df00a26e 100644 --- a/rpcs3/Emu/Cell/Modules/cellVideoOut.h +++ b/rpcs3/Emu/Cell/Modules/cellVideoOut.h @@ -18,25 +18,6 @@ enum CellVideoOutError : u32 CELL_VIDEO_OUT_ERROR_VALUE_IS_NOT_SET = 0x8002b228, }; -template<> -inline const char* ppu_error_code::print(CellVideoOutError error) -{ - switch (error) - { - STR_CASE(CELL_VIDEO_OUT_ERROR_NOT_IMPLEMENTED); - STR_CASE(CELL_VIDEO_OUT_ERROR_ILLEGAL_CONFIGURATION); - STR_CASE(CELL_VIDEO_OUT_ERROR_ILLEGAL_PARAMETER); - STR_CASE(CELL_VIDEO_OUT_ERROR_PARAMETER_OUT_OF_RANGE); - STR_CASE(CELL_VIDEO_OUT_ERROR_DEVICE_NOT_FOUND); - STR_CASE(CELL_VIDEO_OUT_ERROR_UNSUPPORTED_VIDEO_OUT); - STR_CASE(CELL_VIDEO_OUT_ERROR_UNSUPPORTED_DISPLAY_MODE); - STR_CASE(CELL_VIDEO_OUT_ERROR_CONDITION_BUSY); - STR_CASE(CELL_VIDEO_OUT_ERROR_VALUE_IS_NOT_SET); - } - - return nullptr; -} - enum CellVideoOut : s32 { CELL_VIDEO_OUT_PRIMARY = 0, diff --git a/rpcs3/Emu/Cell/Modules/sys_net.cpp b/rpcs3/Emu/Cell/Modules/sys_net.cpp index a559ff9430..6cf91947f3 100644 --- a/rpcs3/Emu/Cell/Modules/sys_net.cpp +++ b/rpcs3/Emu/Cell/Modules/sys_net.cpp @@ -199,7 +199,7 @@ namespace sys_net if (name && result != SYS_NET_EWOULDBLOCK) { - ppu_error_code::report(result, name); + libnet.error("Socket error %s", name); } return result; diff --git a/rpcs3/Emu/Cell/PPUFunction.cpp b/rpcs3/Emu/Cell/PPUFunction.cpp index c91ea73bc4..3f6dbb3348 100644 --- a/rpcs3/Emu/Cell/PPUFunction.cpp +++ b/rpcs3/Emu/Cell/PPUFunction.cpp @@ -2355,29 +2355,6 @@ extern std::string ppu_get_variable_name(const std::string& module, u32 vnid) return fmt::format("0x%08X", vnid); } -s32 ppu_error_code::report(s32 error, const char* text) -{ - if (auto thread = get_current_cpu_thread()) - { - if (thread->id >= ppu_thread::id_min) - { - if (auto func = static_cast(thread)->last_function) - { - LOG_ERROR(PPU, "'%s' failed with 0x%08x : %s", func, error, text); - } - else - { - LOG_ERROR(PPU, "Unknown function failed with 0x%08x : %s", error, text); - } - - return error; - } - } - - LOG_ERROR(PPU, "Illegal call to ppu_error_code::report(0x%x, '%s')!"); - return error; -} - std::vector& ppu_function_manager::access() { static std::vector list diff --git a/rpcs3/Emu/Cell/PPUThread.h b/rpcs3/Emu/Cell/PPUThread.h index 18a239279b..fa05e6cdee 100644 --- a/rpcs3/Emu/Cell/PPUThread.h +++ b/rpcs3/Emu/Cell/PPUThread.h @@ -192,6 +192,20 @@ struct ppu_gpr_cast_impl } }; +template<> +struct ppu_gpr_cast_impl +{ + static inline u64 to(const error_code& code) + { + return code; + } + + static inline error_code from(const u64 reg) + { + return not_an_error(reg); + } +}; + template struct ppu_gpr_cast_impl, void> { diff --git a/rpcs3/Emu/Cell/lv2/lv2.cpp b/rpcs3/Emu/Cell/lv2/lv2.cpp index da32ca7563..3b39b21c56 100644 --- a/rpcs3/Emu/Cell/lv2/lv2.cpp +++ b/rpcs3/Emu/Cell/lv2/lv2.cpp @@ -908,6 +908,77 @@ std::array g_ppu_syscall_table null_func, null_func, null_func, null_func, //1023 UNS }; +template<> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](auto error) + { + switch (error) + { + STR_CASE(CELL_EAGAIN); + STR_CASE(CELL_EINVAL); + STR_CASE(CELL_ENOSYS); + STR_CASE(CELL_ENOMEM); + STR_CASE(CELL_ESRCH); + STR_CASE(CELL_ENOENT); + STR_CASE(CELL_ENOEXEC); + STR_CASE(CELL_EDEADLK); + STR_CASE(CELL_EPERM); + STR_CASE(CELL_EBUSY); + STR_CASE(CELL_ETIMEDOUT); + STR_CASE(CELL_EABORT); + STR_CASE(CELL_EFAULT); + STR_CASE(CELL_ESTAT); + STR_CASE(CELL_EALIGN); + STR_CASE(CELL_EKRESOURCE); + STR_CASE(CELL_EISDIR); + STR_CASE(CELL_ECANCELED); + STR_CASE(CELL_EEXIST); + STR_CASE(CELL_EISCONN); + STR_CASE(CELL_ENOTCONN); + STR_CASE(CELL_EAUTHFAIL); + STR_CASE(CELL_ENOTMSELF); + STR_CASE(CELL_ESYSVER); + STR_CASE(CELL_EAUTHFATAL); + STR_CASE(CELL_EDOM); + STR_CASE(CELL_ERANGE); + STR_CASE(CELL_EILSEQ); + STR_CASE(CELL_EFPOS); + STR_CASE(CELL_EINTR); + STR_CASE(CELL_EFBIG); + STR_CASE(CELL_EMLINK); + STR_CASE(CELL_ENFILE); + STR_CASE(CELL_ENOSPC); + STR_CASE(CELL_ENOTTY); + STR_CASE(CELL_EPIPE); + STR_CASE(CELL_EROFS); + STR_CASE(CELL_ESPIPE); + STR_CASE(CELL_E2BIG); + STR_CASE(CELL_EACCES); + STR_CASE(CELL_EBADF); + STR_CASE(CELL_EIO); + STR_CASE(CELL_EMFILE); + STR_CASE(CELL_ENODEV); + STR_CASE(CELL_ENOTDIR); + STR_CASE(CELL_ENXIO); + STR_CASE(CELL_EXDEV); + STR_CASE(CELL_EBADMSG); + STR_CASE(CELL_EINPROGRESS); + STR_CASE(CELL_EMSGSIZE); + STR_CASE(CELL_ENAMETOOLONG); + STR_CASE(CELL_ENOLCK); + STR_CASE(CELL_ENOTEMPTY); + STR_CASE(CELL_ENOTSUP); + STR_CASE(CELL_EFSSPECIFIC); + STR_CASE(CELL_EOVERFLOW); + STR_CASE(CELL_ENOTMOUNTED); + STR_CASE(CELL_ENOTSDATA); + } + + return unknown; + }); +} + extern void ppu_execute_syscall(ppu_thread& ppu, u64 code) { if (code < g_ppu_syscall_table.size()) diff --git a/rpcs3/Emu/Cell/lv2/sys_fs.cpp b/rpcs3/Emu/Cell/lv2/sys_fs.cpp index 6831cf1b21..e283e974fd 100644 --- a/rpcs3/Emu/Cell/lv2/sys_fs.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_fs.cpp @@ -45,14 +45,14 @@ u64 lv2_file::op_write(vm::ps3::cptr buf, u64 size) return file.write(local_buf.get(), size); } -ppu_error_code sys_fs_test(u32 arg1, u32 arg2, vm::ptr arg3, u32 arg4, vm::ptr arg5, u32 arg6) +error_code sys_fs_test(u32 arg1, u32 arg2, vm::ptr arg3, u32 arg4, vm::ptr arg5, u32 arg6) { sys_fs.todo("sys_fs_test(arg1=0x%x, arg2=0x%x, arg3=*0x%x, arg4=0x%x, arg5=*0x%x, arg6=0x%x) -> CELL_OK", arg1, arg2, arg3, arg4, arg5, arg6); return CELL_OK; } -ppu_error_code sys_fs_open(vm::cptr path, s32 flags, vm::ptr fd, s32 mode, vm::cptr arg, u64 size) +error_code sys_fs_open(vm::cptr path, s32 flags, vm::ptr fd, s32 mode, vm::cptr arg, u64 size) { sys_fs.warning("sys_fs_open(path=%s, flags=%#o, fd=*0x%x, mode=%#o, arg=*0x%x, size=0x%llx)", path, flags, fd, mode, arg, size); @@ -156,7 +156,7 @@ ppu_error_code sys_fs_open(vm::cptr path, s32 flags, vm::ptr fd, s32 return CELL_OK; } -ppu_error_code sys_fs_read(u32 fd, vm::ptr buf, u64 nbytes, vm::ptr nread) +error_code sys_fs_read(u32 fd, vm::ptr buf, u64 nbytes, vm::ptr nread) { sys_fs.trace("sys_fs_read(fd=%d, buf=*0x%x, nbytes=0x%llx, nread=*0x%x)", fd, buf, nbytes, nread); @@ -179,7 +179,7 @@ ppu_error_code sys_fs_read(u32 fd, vm::ptr buf, u64 nbytes, vm::ptr n return CELL_OK; } -ppu_error_code sys_fs_write(u32 fd, vm::cptr buf, u64 nbytes, vm::ptr nwrite) +error_code sys_fs_write(u32 fd, vm::cptr buf, u64 nbytes, vm::ptr nwrite) { sys_fs.trace("sys_fs_write(fd=%d, buf=*0x%x, nbytes=0x%llx, nwrite=*0x%x)", fd, buf, nbytes, nwrite); @@ -199,7 +199,7 @@ ppu_error_code sys_fs_write(u32 fd, vm::cptr buf, u64 nbytes, vm::ptr return CELL_OK; } -ppu_error_code sys_fs_close(u32 fd) +error_code sys_fs_close(u32 fd) { sys_fs.trace("sys_fs_close(fd=%d)", fd); @@ -217,7 +217,7 @@ ppu_error_code sys_fs_close(u32 fd) return CELL_OK; } -ppu_error_code sys_fs_opendir(vm::cptr path, vm::ptr fd) +error_code sys_fs_opendir(vm::cptr path, vm::ptr fd) { sys_fs.warning("sys_fs_opendir(path=%s, fd=*0x%x)", path, fd); @@ -258,7 +258,7 @@ ppu_error_code sys_fs_opendir(vm::cptr path, vm::ptr fd) return CELL_OK; } -ppu_error_code sys_fs_readdir(u32 fd, vm::ptr dir, vm::ptr nread) +error_code sys_fs_readdir(u32 fd, vm::ptr dir, vm::ptr nread) { sys_fs.warning("sys_fs_readdir(fd=%d, dir=*0x%x, nread=*0x%x)", fd, dir, nread); @@ -286,7 +286,7 @@ ppu_error_code sys_fs_readdir(u32 fd, vm::ptr dir, vm::ptr nr return CELL_OK; } -ppu_error_code sys_fs_closedir(u32 fd) +error_code sys_fs_closedir(u32 fd) { sys_fs.trace("sys_fs_closedir(fd=%d)", fd); @@ -302,7 +302,7 @@ ppu_error_code sys_fs_closedir(u32 fd) return CELL_OK; } -ppu_error_code sys_fs_stat(vm::cptr path, vm::ptr sb) +error_code sys_fs_stat(vm::cptr path, vm::ptr sb) { sys_fs.warning("sys_fs_stat(path=%s, sb=*0x%x)", path, sb); @@ -334,7 +334,7 @@ ppu_error_code sys_fs_stat(vm::cptr path, vm::ptr sb) return CELL_OK; } -ppu_error_code sys_fs_fstat(u32 fd, vm::ptr sb) +error_code sys_fs_fstat(u32 fd, vm::ptr sb) { sys_fs.warning("sys_fs_fstat(fd=%d, sb=*0x%x)", fd, sb); @@ -361,7 +361,7 @@ ppu_error_code sys_fs_fstat(u32 fd, vm::ptr sb) return CELL_OK; } -ppu_error_code sys_fs_mkdir(vm::cptr path, s32 mode) +error_code sys_fs_mkdir(vm::cptr path, s32 mode) { sys_fs.warning("sys_fs_mkdir(path=%s, mode=%#o)", path, mode); @@ -381,7 +381,7 @@ ppu_error_code sys_fs_mkdir(vm::cptr path, s32 mode) return CELL_OK; } -ppu_error_code sys_fs_rename(vm::cptr from, vm::cptr to) +error_code sys_fs_rename(vm::cptr from, vm::cptr to) { sys_fs.warning("sys_fs_rename(from=%s, to=%s)", from, to); @@ -394,7 +394,7 @@ ppu_error_code sys_fs_rename(vm::cptr from, vm::cptr to) return CELL_OK; } -ppu_error_code sys_fs_rmdir(vm::cptr path) +error_code sys_fs_rmdir(vm::cptr path) { sys_fs.warning("sys_fs_rmdir(path=%s)", path); @@ -413,7 +413,7 @@ ppu_error_code sys_fs_rmdir(vm::cptr path) return CELL_OK; } -ppu_error_code sys_fs_unlink(vm::cptr path) +error_code sys_fs_unlink(vm::cptr path) { sys_fs.warning("sys_fs_unlink(path=%s)", path); @@ -432,7 +432,7 @@ ppu_error_code sys_fs_unlink(vm::cptr path) return CELL_OK; } -ppu_error_code sys_fs_fcntl(u32 fd, u32 op, vm::ptr _arg, u32 _size) +error_code sys_fs_fcntl(u32 fd, u32 op, vm::ptr _arg, u32 _size) { sys_fs.trace("sys_fs_fcntl(fd=%d, op=0x%x, arg=*0x%x, size=0x%x)", fd, op, _arg, _size); @@ -489,7 +489,7 @@ ppu_error_code sys_fs_fcntl(u32 fd, u32 op, vm::ptr _arg, u32 _size) return CELL_OK; } -ppu_error_code sys_fs_lseek(u32 fd, s64 offset, s32 whence, vm::ptr pos) +error_code sys_fs_lseek(u32 fd, s64 offset, s32 whence, vm::ptr pos) { sys_fs.trace("sys_fs_lseek(fd=%d, offset=0x%llx, whence=0x%x, pos=*0x%x)", fd, offset, whence, pos); @@ -513,7 +513,7 @@ ppu_error_code sys_fs_lseek(u32 fd, s64 offset, s32 whence, vm::ptr pos) return CELL_OK; } -ppu_error_code sys_fs_fget_block_size(u32 fd, vm::ptr sector_size, vm::ptr block_size, vm::ptr arg4, vm::ptr arg5) +error_code sys_fs_fget_block_size(u32 fd, vm::ptr sector_size, vm::ptr block_size, vm::ptr arg4, vm::ptr arg5) { sys_fs.todo("sys_fs_fget_block_size(fd=%d, sector_size=*0x%x, block_size=*0x%x, arg4=*0x%x, arg5=*0x%x)", fd, sector_size, block_size, arg4, arg5); @@ -530,7 +530,7 @@ ppu_error_code sys_fs_fget_block_size(u32 fd, vm::ptr sector_size, vm::ptr< return CELL_OK; } -ppu_error_code sys_fs_get_block_size(vm::cptr path, vm::ptr sector_size, vm::ptr block_size, vm::ptr arg4) +error_code sys_fs_get_block_size(vm::cptr path, vm::ptr sector_size, vm::ptr block_size, vm::ptr arg4) { sys_fs.todo("sys_fs_get_block_size(path=%s, sector_size=*0x%x, block_size=*0x%x, arg4=*0x%x, arg5=*0x%x)", path, sector_size, block_size, arg4); @@ -540,7 +540,7 @@ ppu_error_code sys_fs_get_block_size(vm::cptr path, vm::ptr sector_si return CELL_OK; } -ppu_error_code sys_fs_truncate(vm::cptr path, u64 size) +error_code sys_fs_truncate(vm::cptr path, u64 size) { sys_fs.warning("sys_fs_truncate(path=%s, size=0x%llx)", path, size); @@ -558,7 +558,7 @@ ppu_error_code sys_fs_truncate(vm::cptr path, u64 size) return CELL_OK; } -ppu_error_code sys_fs_ftruncate(u32 fd, u64 size) +error_code sys_fs_ftruncate(u32 fd, u64 size) { sys_fs.warning("sys_fs_ftruncate(fd=%d, size=0x%llx)", fd, size); @@ -585,7 +585,7 @@ ppu_error_code sys_fs_ftruncate(u32 fd, u64 size) return CELL_OK; } -ppu_error_code sys_fs_chmod(vm::cptr path, s32 mode) +error_code sys_fs_chmod(vm::cptr path, s32 mode) { sys_fs.todo("sys_fs_chmod(path=%s, mode=%#o) -> CELL_OK", path, mode); diff --git a/rpcs3/Emu/Cell/lv2/sys_fs.h b/rpcs3/Emu/Cell/lv2/sys_fs.h index e3fea5aa6b..2c08c8a7fa 100644 --- a/rpcs3/Emu/Cell/lv2/sys_fs.h +++ b/rpcs3/Emu/Cell/lv2/sys_fs.h @@ -185,24 +185,24 @@ struct lv2_file_op_rw : lv2_file_op CHECK_SIZE(lv2_file_op_rw, 0x38); // SysCalls -ppu_error_code sys_fs_test(u32 arg1, u32 arg2, vm::ps3::ptr arg3, u32 arg4, vm::ps3::ptr arg5, u32 arg6); -ppu_error_code sys_fs_open(vm::ps3::cptr path, s32 flags, vm::ps3::ptr fd, s32 mode, vm::ps3::cptr arg, u64 size); -ppu_error_code sys_fs_read(u32 fd, vm::ps3::ptr buf, u64 nbytes, vm::ps3::ptr nread); -ppu_error_code sys_fs_write(u32 fd, vm::ps3::cptr buf, u64 nbytes, vm::ps3::ptr nwrite); -ppu_error_code sys_fs_close(u32 fd); -ppu_error_code sys_fs_opendir(vm::ps3::cptr path, vm::ps3::ptr fd); -ppu_error_code sys_fs_readdir(u32 fd, vm::ps3::ptr dir, vm::ps3::ptr nread); -ppu_error_code sys_fs_closedir(u32 fd); -ppu_error_code sys_fs_stat(vm::ps3::cptr path, vm::ps3::ptr sb); -ppu_error_code sys_fs_fstat(u32 fd, vm::ps3::ptr sb); -ppu_error_code sys_fs_mkdir(vm::ps3::cptr path, s32 mode); -ppu_error_code sys_fs_rename(vm::ps3::cptr from, vm::ps3::cptr to); -ppu_error_code sys_fs_rmdir(vm::ps3::cptr path); -ppu_error_code sys_fs_unlink(vm::ps3::cptr path); -ppu_error_code sys_fs_fcntl(u32 fd, u32 op, vm::ps3::ptr arg, u32 size); -ppu_error_code sys_fs_lseek(u32 fd, s64 offset, s32 whence, vm::ps3::ptr pos); -ppu_error_code sys_fs_fget_block_size(u32 fd, vm::ps3::ptr sector_size, vm::ps3::ptr block_size, vm::ps3::ptr arg4, vm::ps3::ptr arg5); -ppu_error_code sys_fs_get_block_size(vm::ps3::cptr path, vm::ps3::ptr sector_size, vm::ps3::ptr block_size, vm::ps3::ptr arg4); -ppu_error_code sys_fs_truncate(vm::ps3::cptr path, u64 size); -ppu_error_code sys_fs_ftruncate(u32 fd, u64 size); -ppu_error_code sys_fs_chmod(vm::ps3::cptr path, s32 mode); +error_code sys_fs_test(u32 arg1, u32 arg2, vm::ps3::ptr arg3, u32 arg4, vm::ps3::ptr arg5, u32 arg6); +error_code sys_fs_open(vm::ps3::cptr path, s32 flags, vm::ps3::ptr fd, s32 mode, vm::ps3::cptr arg, u64 size); +error_code sys_fs_read(u32 fd, vm::ps3::ptr buf, u64 nbytes, vm::ps3::ptr nread); +error_code sys_fs_write(u32 fd, vm::ps3::cptr buf, u64 nbytes, vm::ps3::ptr nwrite); +error_code sys_fs_close(u32 fd); +error_code sys_fs_opendir(vm::ps3::cptr path, vm::ps3::ptr fd); +error_code sys_fs_readdir(u32 fd, vm::ps3::ptr dir, vm::ps3::ptr nread); +error_code sys_fs_closedir(u32 fd); +error_code sys_fs_stat(vm::ps3::cptr path, vm::ps3::ptr sb); +error_code sys_fs_fstat(u32 fd, vm::ps3::ptr sb); +error_code sys_fs_mkdir(vm::ps3::cptr path, s32 mode); +error_code sys_fs_rename(vm::ps3::cptr from, vm::ps3::cptr to); +error_code sys_fs_rmdir(vm::ps3::cptr path); +error_code sys_fs_unlink(vm::ps3::cptr path); +error_code sys_fs_fcntl(u32 fd, u32 op, vm::ps3::ptr arg, u32 size); +error_code sys_fs_lseek(u32 fd, s64 offset, s32 whence, vm::ps3::ptr pos); +error_code sys_fs_fget_block_size(u32 fd, vm::ps3::ptr sector_size, vm::ps3::ptr block_size, vm::ps3::ptr arg4, vm::ps3::ptr arg5); +error_code sys_fs_get_block_size(vm::ps3::cptr path, vm::ps3::ptr sector_size, vm::ps3::ptr block_size, vm::ps3::ptr arg4); +error_code sys_fs_truncate(vm::ps3::cptr path, u64 size); +error_code sys_fs_ftruncate(u32 fd, u64 size); +error_code sys_fs_chmod(vm::ps3::cptr path, s32 mode); diff --git a/rpcs3/Emu/Cell/lv2/sys_memory.cpp b/rpcs3/Emu/Cell/lv2/sys_memory.cpp index b018c0c342..dfe4424579 100644 --- a/rpcs3/Emu/Cell/lv2/sys_memory.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_memory.cpp @@ -5,7 +5,7 @@ namespace vm { using namespace ps3; } logs::channel sys_memory("sys_memory", logs::level::notice); -ppu_error_code sys_memory_allocate(u32 size, u64 flags, vm::ptr alloc_addr) +error_code sys_memory_allocate(u32 size, u64 flags, vm::ptr alloc_addr) { sys_memory.warning("sys_memory_allocate(size=0x%x, flags=0x%llx, alloc_addr=*0x%x)", size, flags, alloc_addr); @@ -53,7 +53,7 @@ ppu_error_code sys_memory_allocate(u32 size, u64 flags, vm::ptr alloc_addr) return CELL_OK; } -ppu_error_code sys_memory_allocate_from_container(u32 size, u32 cid, u64 flags, vm::ptr alloc_addr) +error_code sys_memory_allocate_from_container(u32 size, u32 cid, u64 flags, vm::ptr alloc_addr) { sys_memory.warning("sys_memory_allocate_from_container(size=0x%x, cid=0x%x, flags=0x%llx, alloc_addr=*0x%x)", size, cid, flags, alloc_addr); @@ -86,7 +86,7 @@ ppu_error_code sys_memory_allocate_from_container(u32 size, u32 cid, u64 flags, } } - ppu_error_code result{}; + error_code result{}; const auto ct = idm::get(cid, [&](u32, lv2_memory_container& ct) { @@ -116,7 +116,7 @@ ppu_error_code sys_memory_allocate_from_container(u32 size, u32 cid, u64 flags, return CELL_OK; } -ppu_error_code sys_memory_free(u32 addr) +error_code sys_memory_free(u32 addr) { sys_memory.warning("sys_memory_free(addr=0x%x)", addr); @@ -145,7 +145,7 @@ ppu_error_code sys_memory_free(u32 addr) return CELL_OK; } -ppu_error_code sys_memory_get_page_attribute(u32 addr, vm::ptr attr) +error_code sys_memory_get_page_attribute(u32 addr, vm::ptr attr) { sys_memory.error("sys_memory_get_page_attribute(addr=0x%x, attr=*0x%x)", addr, attr); @@ -157,7 +157,7 @@ ppu_error_code sys_memory_get_page_attribute(u32 addr, vm::ptr return CELL_OK; } -ppu_error_code sys_memory_get_user_memory_size(vm::ptr mem_info) +error_code sys_memory_get_user_memory_size(vm::ptr mem_info) { sys_memory.warning("sys_memory_get_user_memory_size(mem_info=*0x%x)", mem_info); @@ -176,7 +176,7 @@ ppu_error_code sys_memory_get_user_memory_size(vm::ptr mem_in return CELL_OK; } -ppu_error_code sys_memory_container_create(vm::ptr cid, u32 size) +error_code sys_memory_container_create(vm::ptr cid, u32 size) { sys_memory.warning("sys_memory_container_create(cid=*0x%x, size=0x%x)", cid, size); @@ -202,11 +202,11 @@ ppu_error_code sys_memory_container_create(vm::ptr cid, u32 size) return CELL_OK; } -ppu_error_code sys_memory_container_destroy(u32 cid) +error_code sys_memory_container_destroy(u32 cid) { sys_memory.warning("sys_memory_container_destroy(cid=0x%x)", cid); - ppu_error_code result{}; + error_code result{}; const auto ct = idm::withdraw(cid, [&](u32, lv2_memory_container& ct) { @@ -236,7 +236,7 @@ ppu_error_code sys_memory_container_destroy(u32 cid) return CELL_OK; } -ppu_error_code sys_memory_container_get_size(vm::ptr mem_info, u32 cid) +error_code sys_memory_container_get_size(vm::ptr mem_info, u32 cid) { sys_memory.warning("sys_memory_container_get_size(mem_info=*0x%x, cid=0x%x)", mem_info, cid); diff --git a/rpcs3/Emu/Cell/lv2/sys_memory.h b/rpcs3/Emu/Cell/lv2/sys_memory.h index 896ebade8e..8b95a621a8 100644 --- a/rpcs3/Emu/Cell/lv2/sys_memory.h +++ b/rpcs3/Emu/Cell/lv2/sys_memory.h @@ -78,11 +78,11 @@ struct lv2_memory_container }; // SysCalls -ppu_error_code sys_memory_allocate(u32 size, u64 flags, vm::ps3::ptr alloc_addr); -ppu_error_code sys_memory_allocate_from_container(u32 size, u32 cid, u64 flags, vm::ps3::ptr alloc_addr); -ppu_error_code sys_memory_free(u32 start_addr); -ppu_error_code sys_memory_get_page_attribute(u32 addr, vm::ps3::ptr attr); -ppu_error_code sys_memory_get_user_memory_size(vm::ps3::ptr mem_info); -ppu_error_code sys_memory_container_create(vm::ps3::ptr cid, u32 size); -ppu_error_code sys_memory_container_destroy(u32 cid); -ppu_error_code sys_memory_container_get_size(vm::ps3::ptr mem_info, u32 cid); +error_code sys_memory_allocate(u32 size, u64 flags, vm::ps3::ptr alloc_addr); +error_code sys_memory_allocate_from_container(u32 size, u32 cid, u64 flags, vm::ps3::ptr alloc_addr); +error_code sys_memory_free(u32 start_addr); +error_code sys_memory_get_page_attribute(u32 addr, vm::ps3::ptr attr); +error_code sys_memory_get_user_memory_size(vm::ps3::ptr mem_info); +error_code sys_memory_container_create(vm::ps3::ptr cid, u32 size); +error_code sys_memory_container_destroy(u32 cid); +error_code sys_memory_container_get_size(vm::ps3::ptr mem_info, u32 cid); diff --git a/rpcs3/Emu/Cell/lv2/sys_mmapper.cpp b/rpcs3/Emu/Cell/lv2/sys_mmapper.cpp index 74bc73b4dd..5db37d58da 100644 --- a/rpcs3/Emu/Cell/lv2/sys_mmapper.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_mmapper.cpp @@ -5,7 +5,7 @@ namespace vm { using namespace ps3; } logs::channel sys_mmapper("sys_mmapper", logs::level::notice); -ppu_error_code sys_mmapper_allocate_address(u64 size, u64 flags, u64 alignment, vm::ptr alloc_addr) +error_code sys_mmapper_allocate_address(u64 size, u64 flags, u64 alignment, vm::ptr alloc_addr) { sys_mmapper.error("sys_mmapper_allocate_address(size=0x%llx, flags=0x%llx, alignment=0x%llx, alloc_addr=*0x%x)", size, flags, alignment, alloc_addr); @@ -49,7 +49,7 @@ ppu_error_code sys_mmapper_allocate_address(u64 size, u64 flags, u64 alignment, return CELL_EALIGN; } -ppu_error_code sys_mmapper_allocate_fixed_address() +error_code sys_mmapper_allocate_fixed_address() { sys_mmapper.error("sys_mmapper_allocate_fixed_address()"); @@ -61,7 +61,7 @@ ppu_error_code sys_mmapper_allocate_fixed_address() return CELL_OK; } -ppu_error_code sys_mmapper_allocate_shared_memory(u64 unk, u32 size, u64 flags, vm::ptr mem_id) +error_code sys_mmapper_allocate_shared_memory(u64 unk, u32 size, u64 flags, vm::ptr mem_id) { sys_mmapper.warning("sys_mmapper_allocate_shared_memory(0x%llx, size=0x%x, flags=0x%llx, mem_id=*0x%x)", unk, size, flags, mem_id); @@ -108,7 +108,7 @@ ppu_error_code sys_mmapper_allocate_shared_memory(u64 unk, u32 size, u64 flags, return CELL_OK; } -ppu_error_code sys_mmapper_allocate_shared_memory_from_container(u64 unk, u32 size, u32 cid, u64 flags, vm::ptr mem_id) +error_code sys_mmapper_allocate_shared_memory_from_container(u64 unk, u32 size, u32 cid, u64 flags, vm::ptr mem_id) { sys_mmapper.error("sys_mmapper_allocate_shared_memory_from_container(0x%llx, size=0x%x, cid=0x%x, flags=0x%llx, mem_id=*0x%x)", unk, size, cid, flags, mem_id); @@ -141,7 +141,7 @@ ppu_error_code sys_mmapper_allocate_shared_memory_from_container(u64 unk, u32 si } } - ppu_error_code result{}; + error_code result{}; const auto ct = idm::get(cid, [&](u32, lv2_memory_container& ct) { @@ -171,14 +171,14 @@ ppu_error_code sys_mmapper_allocate_shared_memory_from_container(u64 unk, u32 si return CELL_OK; } -ppu_error_code sys_mmapper_change_address_access_right(u32 addr, u64 flags) +error_code sys_mmapper_change_address_access_right(u32 addr, u64 flags) { sys_mmapper.todo("sys_mmapper_change_address_access_right(addr=0x%x, flags=0x%llx)", addr, flags); return CELL_OK; } -ppu_error_code sys_mmapper_free_address(u32 addr) +error_code sys_mmapper_free_address(u32 addr) { sys_mmapper.error("sys_mmapper_free_address(addr=0x%x)", addr); @@ -198,11 +198,11 @@ ppu_error_code sys_mmapper_free_address(u32 addr) return CELL_OK; } -ppu_error_code sys_mmapper_free_shared_memory(u32 mem_id) +error_code sys_mmapper_free_shared_memory(u32 mem_id) { sys_mmapper.warning("sys_mmapper_free_shared_memory(mem_id=0x%x)", mem_id); - ppu_error_code result{}; + error_code result{}; // Conditionally remove memory ID const auto mem = idm::withdraw(mem_id, [&](u32, lv2_memory& mem) @@ -232,7 +232,7 @@ ppu_error_code sys_mmapper_free_shared_memory(u32 mem_id) return CELL_OK; } -ppu_error_code sys_mmapper_map_shared_memory(u32 addr, u32 mem_id, u64 flags) +error_code sys_mmapper_map_shared_memory(u32 addr, u32 mem_id, u64 flags) { sys_mmapper.error("sys_mmapper_map_shared_memory(addr=0x%x, mem_id=0x%x, flags=0x%llx)", addr, mem_id, flags); @@ -271,7 +271,7 @@ ppu_error_code sys_mmapper_map_shared_memory(u32 addr, u32 mem_id, u64 flags) return CELL_OK; } -ppu_error_code sys_mmapper_search_and_map(u32 start_addr, u32 mem_id, u64 flags, vm::ptr alloc_addr) +error_code sys_mmapper_search_and_map(u32 start_addr, u32 mem_id, u64 flags, vm::ptr alloc_addr) { sys_mmapper.error("sys_mmapper_search_and_map(start_addr=0x%x, mem_id=0x%x, flags=0x%llx, alloc_addr=*0x%x)", start_addr, mem_id, flags, alloc_addr); @@ -307,7 +307,7 @@ ppu_error_code sys_mmapper_search_and_map(u32 start_addr, u32 mem_id, u64 flags, return CELL_OK; } -ppu_error_code sys_mmapper_unmap_shared_memory(u32 addr, vm::ptr mem_id) +error_code sys_mmapper_unmap_shared_memory(u32 addr, vm::ptr mem_id) { sys_mmapper.error("sys_mmapper_unmap_shared_memory(addr=0x%x, mem_id=*0x%x)", addr, mem_id); @@ -338,7 +338,7 @@ ppu_error_code sys_mmapper_unmap_shared_memory(u32 addr, vm::ptr mem_id) return CELL_OK; } -ppu_error_code sys_mmapper_enable_page_fault_notification(u32 addr, u32 eq) +error_code sys_mmapper_enable_page_fault_notification(u32 addr, u32 eq) { sys_mmapper.todo("sys_mmapper_enable_page_fault_notification(addr=0x%x, eq=0x%x)", addr, eq); diff --git a/rpcs3/Emu/Cell/lv2/sys_mmapper.h b/rpcs3/Emu/Cell/lv2/sys_mmapper.h index ac312841d1..aeafeb18df 100644 --- a/rpcs3/Emu/Cell/lv2/sys_mmapper.h +++ b/rpcs3/Emu/Cell/lv2/sys_mmapper.h @@ -21,14 +21,14 @@ struct lv2_memory }; // SysCalls -ppu_error_code sys_mmapper_allocate_address(u64 size, u64 flags, u64 alignment, vm::ps3::ptr alloc_addr); -ppu_error_code sys_mmapper_allocate_fixed_address(); -ppu_error_code sys_mmapper_allocate_shared_memory(u64 unk, u32 size, u64 flags, vm::ps3::ptr mem_id); -ppu_error_code sys_mmapper_allocate_shared_memory_from_container(u64 unk, u32 size, u32 cid, u64 flags, vm::ps3::ptr mem_id); -ppu_error_code sys_mmapper_change_address_access_right(u32 addr, u64 flags); -ppu_error_code sys_mmapper_free_address(u32 addr); -ppu_error_code sys_mmapper_free_shared_memory(u32 mem_id); -ppu_error_code sys_mmapper_map_shared_memory(u32 addr, u32 mem_id, u64 flags); -ppu_error_code sys_mmapper_search_and_map(u32 start_addr, u32 mem_id, u64 flags, vm::ps3::ptr alloc_addr); -ppu_error_code sys_mmapper_unmap_shared_memory(u32 addr, vm::ps3::ptr mem_id); -ppu_error_code sys_mmapper_enable_page_fault_notification(u32 addr, u32 eq); +error_code sys_mmapper_allocate_address(u64 size, u64 flags, u64 alignment, vm::ps3::ptr alloc_addr); +error_code sys_mmapper_allocate_fixed_address(); +error_code sys_mmapper_allocate_shared_memory(u64 unk, u32 size, u64 flags, vm::ps3::ptr mem_id); +error_code sys_mmapper_allocate_shared_memory_from_container(u64 unk, u32 size, u32 cid, u64 flags, vm::ps3::ptr mem_id); +error_code sys_mmapper_change_address_access_right(u32 addr, u64 flags); +error_code sys_mmapper_free_address(u32 addr); +error_code sys_mmapper_free_shared_memory(u32 mem_id); +error_code sys_mmapper_map_shared_memory(u32 addr, u32 mem_id, u64 flags); +error_code sys_mmapper_search_and_map(u32 start_addr, u32 mem_id, u64 flags, vm::ps3::ptr alloc_addr); +error_code sys_mmapper_unmap_shared_memory(u32 addr, vm::ps3::ptr mem_id); +error_code sys_mmapper_enable_page_fault_notification(u32 addr, u32 eq); diff --git a/rpcs3/Emu/Cell/lv2/sys_tty.cpp b/rpcs3/Emu/Cell/lv2/sys_tty.cpp index d7a427ab9b..18e122959b 100644 --- a/rpcs3/Emu/Cell/lv2/sys_tty.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_tty.cpp @@ -7,7 +7,7 @@ logs::channel sys_tty("sys_tty", logs::level::notice); extern fs::file g_tty; -ppu_error_code sys_tty_read(s32 ch, vm::ptr buf, u32 len, vm::ptr preadlen) +error_code sys_tty_read(s32 ch, vm::ptr buf, u32 len, vm::ptr preadlen) { sys_tty.fatal("sys_tty_read(ch=%d, buf=*0x%x, len=%d, preadlen=*0x%x)", ch, buf, len, preadlen); @@ -15,7 +15,7 @@ ppu_error_code sys_tty_read(s32 ch, vm::ptr buf, u32 len, vm::ptr pre fmt::throw_exception("Unimplemented" HERE); } -ppu_error_code sys_tty_write(s32 ch, vm::cptr buf, u32 len, vm::ptr pwritelen) +error_code sys_tty_write(s32 ch, vm::cptr buf, u32 len, vm::ptr pwritelen) { sys_tty.notice("sys_tty_write(ch=%d, buf=*0x%x, len=%d, pwritelen=*0x%x)", ch, buf, len, pwritelen); diff --git a/rpcs3/Emu/Cell/lv2/sys_tty.h b/rpcs3/Emu/Cell/lv2/sys_tty.h index 4eb8f092d8..3420408370 100644 --- a/rpcs3/Emu/Cell/lv2/sys_tty.h +++ b/rpcs3/Emu/Cell/lv2/sys_tty.h @@ -26,5 +26,5 @@ enum }; // SysCalls -ppu_error_code sys_tty_read(s32 ch, vm::ps3::ptr buf, u32 len, vm::ps3::ptr preadlen); -ppu_error_code sys_tty_write(s32 ch, vm::ps3::cptr buf, u32 len, vm::ps3::ptr pwritelen); +error_code sys_tty_read(s32 ch, vm::ps3::ptr buf, u32 len, vm::ps3::ptr preadlen); +error_code sys_tty_write(s32 ch, vm::ps3::cptr buf, u32 len, vm::ps3::ptr pwritelen); diff --git a/rpcs3/Emu/Cell/lv2/sys_vm.cpp b/rpcs3/Emu/Cell/lv2/sys_vm.cpp index 5473bf67ed..413c8927ea 100644 --- a/rpcs3/Emu/Cell/lv2/sys_vm.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_vm.cpp @@ -6,7 +6,7 @@ namespace vm { using namespace ps3; } logs::channel sys_vm("sys_vm", logs::level::notice); -ppu_error_code sys_vm_memory_map(u32 vsize, u32 psize, u32 cid, u64 flag, u64 policy, vm::ptr addr) +error_code sys_vm_memory_map(u32 vsize, u32 psize, u32 cid, u64 flag, u64 policy, vm::ptr addr) { sys_vm.error("sys_vm_memory_map(vsize=0x%x, psize=0x%x, cid=0x%x, flags=0x%llx, policy=0x%llx, addr=*0x%x)", vsize, psize, cid, flag, policy, addr); @@ -38,7 +38,7 @@ ppu_error_code sys_vm_memory_map(u32 vsize, u32 psize, u32 cid, u64 flag, u64 po return CELL_ENOMEM; } -ppu_error_code sys_vm_unmap(u32 addr) +error_code sys_vm_unmap(u32 addr) { sys_vm.warning("sys_vm_unmap(addr=0x%x)", addr); @@ -50,70 +50,70 @@ ppu_error_code sys_vm_unmap(u32 addr) return CELL_OK; } -ppu_error_code sys_vm_append_memory(u32 addr, u32 size) +error_code sys_vm_append_memory(u32 addr, u32 size) { sys_vm.warning("sys_vm_append_memory(addr=0x%x, size=0x%x)", addr, size); return CELL_OK; } -ppu_error_code sys_vm_return_memory(u32 addr, u32 size) +error_code sys_vm_return_memory(u32 addr, u32 size) { sys_vm.warning("sys_vm_return_memory(addr=0x%x, size=0x%x)", addr, size); return CELL_OK; } -ppu_error_code sys_vm_lock(u32 addr, u32 size) +error_code sys_vm_lock(u32 addr, u32 size) { sys_vm.warning("sys_vm_lock(addr=0x%x, size=0x%x)", addr, size); return CELL_OK; } -ppu_error_code sys_vm_unlock(u32 addr, u32 size) +error_code sys_vm_unlock(u32 addr, u32 size) { sys_vm.warning("sys_vm_unlock(addr=0x%x, size=0x%x)", addr, size); return CELL_OK; } -ppu_error_code sys_vm_touch(u32 addr, u32 size) +error_code sys_vm_touch(u32 addr, u32 size) { sys_vm.warning("sys_vm_touch(addr=0x%x, size=0x%x)", addr, size); return CELL_OK; } -ppu_error_code sys_vm_flush(u32 addr, u32 size) +error_code sys_vm_flush(u32 addr, u32 size) { sys_vm.warning("sys_vm_flush(addr=0x%x, size=0x%x)", addr, size); return CELL_OK; } -ppu_error_code sys_vm_invalidate(u32 addr, u32 size) +error_code sys_vm_invalidate(u32 addr, u32 size) { sys_vm.todo("sys_vm_invalidate(addr=0x%x, size=0x%x)", addr, size); return CELL_OK; } -ppu_error_code sys_vm_store(u32 addr, u32 size) +error_code sys_vm_store(u32 addr, u32 size) { sys_vm.warning("sys_vm_store(addr=0x%x, size=0x%x)", addr, size); return CELL_OK; } -ppu_error_code sys_vm_sync(u32 addr, u32 size) +error_code sys_vm_sync(u32 addr, u32 size) { sys_vm.warning("sys_vm_sync(addr=0x%x, size=0x%x)", addr, size); return CELL_OK; } -ppu_error_code sys_vm_test(u32 addr, u32 size, vm::ptr result) +error_code sys_vm_test(u32 addr, u32 size, vm::ptr result) { sys_vm.warning("sys_vm_test(addr=0x%x, size=0x%x, result=*0x%x)", addr, size, result); @@ -122,7 +122,7 @@ ppu_error_code sys_vm_test(u32 addr, u32 size, vm::ptr result) return CELL_OK; } -ppu_error_code sys_vm_get_statistics(u32 addr, vm::ptr stat) +error_code sys_vm_get_statistics(u32 addr, vm::ptr stat) { sys_vm.warning("sys_vm_get_statistics(addr=0x%x, stat=*0x%x)", addr, stat); diff --git a/rpcs3/Emu/Cell/lv2/sys_vm.h b/rpcs3/Emu/Cell/lv2/sys_vm.h index 84b2542b3c..527d455222 100644 --- a/rpcs3/Emu/Cell/lv2/sys_vm.h +++ b/rpcs3/Emu/Cell/lv2/sys_vm.h @@ -26,16 +26,16 @@ struct sys_vm_statistics_t }; // SysCalls -ppu_error_code sys_vm_memory_map(u32 vsize, u32 psize, u32 cid, u64 flag, u64 policy, vm::ps3::ptr addr); -ppu_error_code sys_vm_unmap(u32 addr); -ppu_error_code sys_vm_append_memory(u32 addr, u32 size); -ppu_error_code sys_vm_return_memory(u32 addr, u32 size); -ppu_error_code sys_vm_lock(u32 addr, u32 size); -ppu_error_code sys_vm_unlock(u32 addr, u32 size); -ppu_error_code sys_vm_touch(u32 addr, u32 size); -ppu_error_code sys_vm_flush(u32 addr, u32 size); -ppu_error_code sys_vm_invalidate(u32 addr, u32 size); -ppu_error_code sys_vm_store(u32 addr, u32 size); -ppu_error_code sys_vm_sync(u32 addr, u32 size); -ppu_error_code sys_vm_test(u32 addr, u32 size, vm::ps3::ptr result); -ppu_error_code sys_vm_get_statistics(u32 addr, vm::ps3::ptr stat); +error_code sys_vm_memory_map(u32 vsize, u32 psize, u32 cid, u64 flag, u64 policy, vm::ps3::ptr addr); +error_code sys_vm_unmap(u32 addr); +error_code sys_vm_append_memory(u32 addr, u32 size); +error_code sys_vm_return_memory(u32 addr, u32 size); +error_code sys_vm_lock(u32 addr, u32 size); +error_code sys_vm_unlock(u32 addr, u32 size); +error_code sys_vm_touch(u32 addr, u32 size); +error_code sys_vm_flush(u32 addr, u32 size); +error_code sys_vm_invalidate(u32 addr, u32 size); +error_code sys_vm_store(u32 addr, u32 size); +error_code sys_vm_sync(u32 addr, u32 size); +error_code sys_vm_test(u32 addr, u32 size, vm::ps3::ptr result); +error_code sys_vm_get_statistics(u32 addr, vm::ps3::ptr stat); diff --git a/rpcs3/Emu/PSP2/ARMv7Function.cpp b/rpcs3/Emu/PSP2/ARMv7Function.cpp index 6f33f39e03..8c4ecb48e1 100644 --- a/rpcs3/Emu/PSP2/ARMv7Function.cpp +++ b/rpcs3/Emu/PSP2/ARMv7Function.cpp @@ -35,26 +35,6 @@ extern std::string arm_get_variable_name(const std::string& module, u32 vnid) return fmt::format("0x%08X", vnid); } -s32 arm_error_code::report(s32 error, const char* text) -{ - if (auto thread = get_current_cpu_thread()) - { - if (auto func = static_cast(thread)->last_function) - { - LOG_ERROR(ARMv7, "Function '%s' failed with 0x%08x : %s", func, error, text); - } - else - { - LOG_ERROR(ARMv7, "Unknown function failed with 0x%08x : %s", error, text); - } - - return error; - } - - LOG_ERROR(ARMv7, "Illegal call to arm_report_error(0x%x, '%s')!"); - return error; -} - std::vector& arm_function_manager::access() { static std::vector list diff --git a/rpcs3/Emu/PSP2/ARMv7Thread.h b/rpcs3/Emu/PSP2/ARMv7Thread.h index d6ba10e7c8..e20fc1c6ac 100644 --- a/rpcs3/Emu/PSP2/ARMv7Thread.h +++ b/rpcs3/Emu/PSP2/ARMv7Thread.h @@ -237,6 +237,20 @@ struct arm_gpr_cast_impl } }; +template<> +struct arm_gpr_cast_impl +{ + static inline u32 to(const error_code& code) + { + return code; + } + + static inline error_code from(const u32 reg) + { + return not_an_error(reg); + } +}; + template struct arm_gpr_cast_impl, void> { diff --git a/rpcs3/Emu/PSP2/ErrorCodes.h b/rpcs3/Emu/PSP2/ErrorCodes.h index b2bd40e3dd..854c5a2e75 100644 --- a/rpcs3/Emu/PSP2/ErrorCodes.h +++ b/rpcs3/Emu/PSP2/ErrorCodes.h @@ -1,10 +1,18 @@ #pragma once -enum SceOk : s32 +struct SceOk { - SCE_OK = 0, + enum : s32 + { + __not_an_error, + + SCE_OK = 0 + }; }; +// Temporary workaround +constexpr auto SCE_OK = SceOk::SCE_OK; + enum SceError : u32 { SCE_ERROR_ERRNO_EPERM = 0x80010001, @@ -135,211 +143,3 @@ enum SceError : u32 SCE_ERROR_ERRNO_ENOTRECOVERABLE = 0x8001008D, SCE_ERROR_ERRNO_EOWNERDEAD = 0x8001008E, }; - -// Special return type signaling on errors -struct arm_error_code -{ - s32 value; - - // Print error message, error code is returned - static s32 report(s32 error, const char* text); - - // Must be specialized for specific tag type T - template - static const char* print(T code) - { - return nullptr; - } - - template - s32 error_check(T code) - { - if (const auto text = print(code)) - { - return report(code, text); - } - - return code; - } - - arm_error_code() = default; - - // General error check - template::value>> - arm_error_code(T value) - : value(error_check(value)) - { - } - - // Force error reporting with a message specified - arm_error_code(s32 value, const char* text) - : value(report(value, text)) - { - } - - // Silence any error - constexpr arm_error_code(not_an_error_t value) - : value(static_cast(value)) - { - } - - // Conversion - constexpr operator s32() const - { - return value; - } -}; - -template -struct arm_gpr_cast_impl; - -template<> -struct arm_gpr_cast_impl -{ - static inline u32 to(const arm_error_code& code) - { - return code; - } - - static inline arm_error_code from(const u32 reg) - { - return not_an_error(reg); - } -}; - -template<> -inline const char* arm_error_code::print(SceError error) -{ - switch (error) - { - STR_CASE(SCE_ERROR_ERRNO_EPERM); - STR_CASE(SCE_ERROR_ERRNO_ENOENT); - STR_CASE(SCE_ERROR_ERRNO_ESRCH); - STR_CASE(SCE_ERROR_ERRNO_EINTR); - STR_CASE(SCE_ERROR_ERRNO_EIO); - STR_CASE(SCE_ERROR_ERRNO_ENXIO); - STR_CASE(SCE_ERROR_ERRNO_E2BIG); - STR_CASE(SCE_ERROR_ERRNO_ENOEXEC); - STR_CASE(SCE_ERROR_ERRNO_EBADF); - STR_CASE(SCE_ERROR_ERRNO_ECHILD); - STR_CASE(SCE_ERROR_ERRNO_EAGAIN); - STR_CASE(SCE_ERROR_ERRNO_ENOMEM); - STR_CASE(SCE_ERROR_ERRNO_EACCES); - STR_CASE(SCE_ERROR_ERRNO_EFAULT); - STR_CASE(SCE_ERROR_ERRNO_ENOTBLK); - STR_CASE(SCE_ERROR_ERRNO_EBUSY); - STR_CASE(SCE_ERROR_ERRNO_EEXIST); - STR_CASE(SCE_ERROR_ERRNO_EXDEV); - STR_CASE(SCE_ERROR_ERRNO_ENODEV); - STR_CASE(SCE_ERROR_ERRNO_ENOTDIR); - STR_CASE(SCE_ERROR_ERRNO_EISDIR); - STR_CASE(SCE_ERROR_ERRNO_EINVAL); - STR_CASE(SCE_ERROR_ERRNO_ENFILE); - STR_CASE(SCE_ERROR_ERRNO_EMFILE); - STR_CASE(SCE_ERROR_ERRNO_ENOTTY); - STR_CASE(SCE_ERROR_ERRNO_ETXTBSY); - STR_CASE(SCE_ERROR_ERRNO_EFBIG); - STR_CASE(SCE_ERROR_ERRNO_ENOSPC); - STR_CASE(SCE_ERROR_ERRNO_ESPIPE); - STR_CASE(SCE_ERROR_ERRNO_EROFS); - STR_CASE(SCE_ERROR_ERRNO_EMLINK); - STR_CASE(SCE_ERROR_ERRNO_EPIPE); - STR_CASE(SCE_ERROR_ERRNO_EDOM); - STR_CASE(SCE_ERROR_ERRNO_ERANGE); - STR_CASE(SCE_ERROR_ERRNO_ENOMSG); - STR_CASE(SCE_ERROR_ERRNO_EIDRM); - STR_CASE(SCE_ERROR_ERRNO_ECHRNG); - STR_CASE(SCE_ERROR_ERRNO_EL2NSYNC); - STR_CASE(SCE_ERROR_ERRNO_EL3HLT); - STR_CASE(SCE_ERROR_ERRNO_EL3RST); - STR_CASE(SCE_ERROR_ERRNO_ELNRNG); - STR_CASE(SCE_ERROR_ERRNO_EUNATCH); - STR_CASE(SCE_ERROR_ERRNO_ENOCSI); - STR_CASE(SCE_ERROR_ERRNO_EL2HLT); - STR_CASE(SCE_ERROR_ERRNO_EDEADLK); - STR_CASE(SCE_ERROR_ERRNO_ENOLCK); - STR_CASE(SCE_ERROR_ERRNO_EFORMAT); - STR_CASE(SCE_ERROR_ERRNO_EUNSUP); - STR_CASE(SCE_ERROR_ERRNO_EBADE); - STR_CASE(SCE_ERROR_ERRNO_EBADR); - STR_CASE(SCE_ERROR_ERRNO_EXFULL); - STR_CASE(SCE_ERROR_ERRNO_ENOANO); - STR_CASE(SCE_ERROR_ERRNO_EBADRQC); - STR_CASE(SCE_ERROR_ERRNO_EBADSLT); - STR_CASE(SCE_ERROR_ERRNO_EDEADLOCK); - STR_CASE(SCE_ERROR_ERRNO_EBFONT); - STR_CASE(SCE_ERROR_ERRNO_ENOSTR); - STR_CASE(SCE_ERROR_ERRNO_ENODATA); - STR_CASE(SCE_ERROR_ERRNO_ETIME); - STR_CASE(SCE_ERROR_ERRNO_ENOSR); - STR_CASE(SCE_ERROR_ERRNO_ENONET); - STR_CASE(SCE_ERROR_ERRNO_ENOPKG); - STR_CASE(SCE_ERROR_ERRNO_EREMOTE); - STR_CASE(SCE_ERROR_ERRNO_ENOLINK); - STR_CASE(SCE_ERROR_ERRNO_EADV); - STR_CASE(SCE_ERROR_ERRNO_ESRMNT); - STR_CASE(SCE_ERROR_ERRNO_ECOMM); - STR_CASE(SCE_ERROR_ERRNO_EPROTO); - STR_CASE(SCE_ERROR_ERRNO_EMULTIHOP); - STR_CASE(SCE_ERROR_ERRNO_ELBIN); - STR_CASE(SCE_ERROR_ERRNO_EDOTDOT); - STR_CASE(SCE_ERROR_ERRNO_EBADMSG); - STR_CASE(SCE_ERROR_ERRNO_EFTYPE); - STR_CASE(SCE_ERROR_ERRNO_ENOTUNIQ); - STR_CASE(SCE_ERROR_ERRNO_EBADFD); - STR_CASE(SCE_ERROR_ERRNO_EREMCHG); - STR_CASE(SCE_ERROR_ERRNO_ELIBACC); - STR_CASE(SCE_ERROR_ERRNO_ELIBBAD); - STR_CASE(SCE_ERROR_ERRNO_ELIBSCN); - STR_CASE(SCE_ERROR_ERRNO_ELIBMAX); - STR_CASE(SCE_ERROR_ERRNO_ELIBEXEC); - STR_CASE(SCE_ERROR_ERRNO_ENOSYS); - STR_CASE(SCE_ERROR_ERRNO_ENMFILE); - STR_CASE(SCE_ERROR_ERRNO_ENOTEMPTY); - STR_CASE(SCE_ERROR_ERRNO_ENAMETOOLONG); - STR_CASE(SCE_ERROR_ERRNO_ELOOP); - STR_CASE(SCE_ERROR_ERRNO_EOPNOTSUPP); - STR_CASE(SCE_ERROR_ERRNO_EPFNOSUPPORT); - STR_CASE(SCE_ERROR_ERRNO_ECONNRESET); - STR_CASE(SCE_ERROR_ERRNO_ENOBUFS); - STR_CASE(SCE_ERROR_ERRNO_EAFNOSUPPORT); - STR_CASE(SCE_ERROR_ERRNO_EPROTOTYPE); - STR_CASE(SCE_ERROR_ERRNO_ENOTSOCK); - STR_CASE(SCE_ERROR_ERRNO_ENOPROTOOPT); - STR_CASE(SCE_ERROR_ERRNO_ESHUTDOWN); - STR_CASE(SCE_ERROR_ERRNO_ECONNREFUSED); - STR_CASE(SCE_ERROR_ERRNO_EADDRINUSE); - STR_CASE(SCE_ERROR_ERRNO_ECONNABORTED); - STR_CASE(SCE_ERROR_ERRNO_ENETUNREACH); - STR_CASE(SCE_ERROR_ERRNO_ENETDOWN); - STR_CASE(SCE_ERROR_ERRNO_ETIMEDOUT); - STR_CASE(SCE_ERROR_ERRNO_EHOSTDOWN); - STR_CASE(SCE_ERROR_ERRNO_EHOSTUNREACH); - STR_CASE(SCE_ERROR_ERRNO_EINPROGRESS); - STR_CASE(SCE_ERROR_ERRNO_EALREADY); - STR_CASE(SCE_ERROR_ERRNO_EDESTADDRREQ); - STR_CASE(SCE_ERROR_ERRNO_EMSGSIZE); - STR_CASE(SCE_ERROR_ERRNO_EPROTONOSUPPORT); - STR_CASE(SCE_ERROR_ERRNO_ESOCKTNOSUPPORT); - STR_CASE(SCE_ERROR_ERRNO_EADDRNOTAVAIL); - STR_CASE(SCE_ERROR_ERRNO_ENETRESET); - STR_CASE(SCE_ERROR_ERRNO_EISCONN); - STR_CASE(SCE_ERROR_ERRNO_ENOTCONN); - STR_CASE(SCE_ERROR_ERRNO_ETOOMANYREFS); - STR_CASE(SCE_ERROR_ERRNO_EPROCLIM); - STR_CASE(SCE_ERROR_ERRNO_EUSERS); - STR_CASE(SCE_ERROR_ERRNO_EDQUOT); - STR_CASE(SCE_ERROR_ERRNO_ESTALE); - STR_CASE(SCE_ERROR_ERRNO_ENOTSUP); - STR_CASE(SCE_ERROR_ERRNO_ENOMEDIUM); - STR_CASE(SCE_ERROR_ERRNO_ENOSHARE); - STR_CASE(SCE_ERROR_ERRNO_ECASECLASH); - STR_CASE(SCE_ERROR_ERRNO_EILSEQ); - STR_CASE(SCE_ERROR_ERRNO_EOVERFLOW); - STR_CASE(SCE_ERROR_ERRNO_ECANCELED); - STR_CASE(SCE_ERROR_ERRNO_ENOTRECOVERABLE); - STR_CASE(SCE_ERROR_ERRNO_EOWNERDEAD); - } - - return nullptr; -} diff --git a/rpcs3/Emu/PSP2/Modules/sceLibKernel.cpp b/rpcs3/Emu/PSP2/Modules/sceLibKernel.cpp index 559f0cdd62..5aa0054b09 100644 --- a/rpcs3/Emu/PSP2/Modules/sceLibKernel.cpp +++ b/rpcs3/Emu/PSP2/Modules/sceLibKernel.cpp @@ -15,6 +15,403 @@ logs::channel sceLibKernel("sceLibKernel", logs::level::notice); extern u64 get_system_time(); +template<> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](auto error) + { + switch (error) + { + STR_CASE(SCE_ERROR_ERRNO_EPERM); + STR_CASE(SCE_ERROR_ERRNO_ENOENT); + STR_CASE(SCE_ERROR_ERRNO_ESRCH); + STR_CASE(SCE_ERROR_ERRNO_EINTR); + STR_CASE(SCE_ERROR_ERRNO_EIO); + STR_CASE(SCE_ERROR_ERRNO_ENXIO); + STR_CASE(SCE_ERROR_ERRNO_E2BIG); + STR_CASE(SCE_ERROR_ERRNO_ENOEXEC); + STR_CASE(SCE_ERROR_ERRNO_EBADF); + STR_CASE(SCE_ERROR_ERRNO_ECHILD); + STR_CASE(SCE_ERROR_ERRNO_EAGAIN); + STR_CASE(SCE_ERROR_ERRNO_ENOMEM); + STR_CASE(SCE_ERROR_ERRNO_EACCES); + STR_CASE(SCE_ERROR_ERRNO_EFAULT); + STR_CASE(SCE_ERROR_ERRNO_ENOTBLK); + STR_CASE(SCE_ERROR_ERRNO_EBUSY); + STR_CASE(SCE_ERROR_ERRNO_EEXIST); + STR_CASE(SCE_ERROR_ERRNO_EXDEV); + STR_CASE(SCE_ERROR_ERRNO_ENODEV); + STR_CASE(SCE_ERROR_ERRNO_ENOTDIR); + STR_CASE(SCE_ERROR_ERRNO_EISDIR); + STR_CASE(SCE_ERROR_ERRNO_EINVAL); + STR_CASE(SCE_ERROR_ERRNO_ENFILE); + STR_CASE(SCE_ERROR_ERRNO_EMFILE); + STR_CASE(SCE_ERROR_ERRNO_ENOTTY); + STR_CASE(SCE_ERROR_ERRNO_ETXTBSY); + STR_CASE(SCE_ERROR_ERRNO_EFBIG); + STR_CASE(SCE_ERROR_ERRNO_ENOSPC); + STR_CASE(SCE_ERROR_ERRNO_ESPIPE); + STR_CASE(SCE_ERROR_ERRNO_EROFS); + STR_CASE(SCE_ERROR_ERRNO_EMLINK); + STR_CASE(SCE_ERROR_ERRNO_EPIPE); + STR_CASE(SCE_ERROR_ERRNO_EDOM); + STR_CASE(SCE_ERROR_ERRNO_ERANGE); + STR_CASE(SCE_ERROR_ERRNO_ENOMSG); + STR_CASE(SCE_ERROR_ERRNO_EIDRM); + STR_CASE(SCE_ERROR_ERRNO_ECHRNG); + STR_CASE(SCE_ERROR_ERRNO_EL2NSYNC); + STR_CASE(SCE_ERROR_ERRNO_EL3HLT); + STR_CASE(SCE_ERROR_ERRNO_EL3RST); + STR_CASE(SCE_ERROR_ERRNO_ELNRNG); + STR_CASE(SCE_ERROR_ERRNO_EUNATCH); + STR_CASE(SCE_ERROR_ERRNO_ENOCSI); + STR_CASE(SCE_ERROR_ERRNO_EL2HLT); + STR_CASE(SCE_ERROR_ERRNO_EDEADLK); + STR_CASE(SCE_ERROR_ERRNO_ENOLCK); + STR_CASE(SCE_ERROR_ERRNO_EFORMAT); + STR_CASE(SCE_ERROR_ERRNO_EUNSUP); + STR_CASE(SCE_ERROR_ERRNO_EBADE); + STR_CASE(SCE_ERROR_ERRNO_EBADR); + STR_CASE(SCE_ERROR_ERRNO_EXFULL); + STR_CASE(SCE_ERROR_ERRNO_ENOANO); + STR_CASE(SCE_ERROR_ERRNO_EBADRQC); + STR_CASE(SCE_ERROR_ERRNO_EBADSLT); + STR_CASE(SCE_ERROR_ERRNO_EDEADLOCK); + STR_CASE(SCE_ERROR_ERRNO_EBFONT); + STR_CASE(SCE_ERROR_ERRNO_ENOSTR); + STR_CASE(SCE_ERROR_ERRNO_ENODATA); + STR_CASE(SCE_ERROR_ERRNO_ETIME); + STR_CASE(SCE_ERROR_ERRNO_ENOSR); + STR_CASE(SCE_ERROR_ERRNO_ENONET); + STR_CASE(SCE_ERROR_ERRNO_ENOPKG); + STR_CASE(SCE_ERROR_ERRNO_EREMOTE); + STR_CASE(SCE_ERROR_ERRNO_ENOLINK); + STR_CASE(SCE_ERROR_ERRNO_EADV); + STR_CASE(SCE_ERROR_ERRNO_ESRMNT); + STR_CASE(SCE_ERROR_ERRNO_ECOMM); + STR_CASE(SCE_ERROR_ERRNO_EPROTO); + STR_CASE(SCE_ERROR_ERRNO_EMULTIHOP); + STR_CASE(SCE_ERROR_ERRNO_ELBIN); + STR_CASE(SCE_ERROR_ERRNO_EDOTDOT); + STR_CASE(SCE_ERROR_ERRNO_EBADMSG); + STR_CASE(SCE_ERROR_ERRNO_EFTYPE); + STR_CASE(SCE_ERROR_ERRNO_ENOTUNIQ); + STR_CASE(SCE_ERROR_ERRNO_EBADFD); + STR_CASE(SCE_ERROR_ERRNO_EREMCHG); + STR_CASE(SCE_ERROR_ERRNO_ELIBACC); + STR_CASE(SCE_ERROR_ERRNO_ELIBBAD); + STR_CASE(SCE_ERROR_ERRNO_ELIBSCN); + STR_CASE(SCE_ERROR_ERRNO_ELIBMAX); + STR_CASE(SCE_ERROR_ERRNO_ELIBEXEC); + STR_CASE(SCE_ERROR_ERRNO_ENOSYS); + STR_CASE(SCE_ERROR_ERRNO_ENMFILE); + STR_CASE(SCE_ERROR_ERRNO_ENOTEMPTY); + STR_CASE(SCE_ERROR_ERRNO_ENAMETOOLONG); + STR_CASE(SCE_ERROR_ERRNO_ELOOP); + STR_CASE(SCE_ERROR_ERRNO_EOPNOTSUPP); + STR_CASE(SCE_ERROR_ERRNO_EPFNOSUPPORT); + STR_CASE(SCE_ERROR_ERRNO_ECONNRESET); + STR_CASE(SCE_ERROR_ERRNO_ENOBUFS); + STR_CASE(SCE_ERROR_ERRNO_EAFNOSUPPORT); + STR_CASE(SCE_ERROR_ERRNO_EPROTOTYPE); + STR_CASE(SCE_ERROR_ERRNO_ENOTSOCK); + STR_CASE(SCE_ERROR_ERRNO_ENOPROTOOPT); + STR_CASE(SCE_ERROR_ERRNO_ESHUTDOWN); + STR_CASE(SCE_ERROR_ERRNO_ECONNREFUSED); + STR_CASE(SCE_ERROR_ERRNO_EADDRINUSE); + STR_CASE(SCE_ERROR_ERRNO_ECONNABORTED); + STR_CASE(SCE_ERROR_ERRNO_ENETUNREACH); + STR_CASE(SCE_ERROR_ERRNO_ENETDOWN); + STR_CASE(SCE_ERROR_ERRNO_ETIMEDOUT); + STR_CASE(SCE_ERROR_ERRNO_EHOSTDOWN); + STR_CASE(SCE_ERROR_ERRNO_EHOSTUNREACH); + STR_CASE(SCE_ERROR_ERRNO_EINPROGRESS); + STR_CASE(SCE_ERROR_ERRNO_EALREADY); + STR_CASE(SCE_ERROR_ERRNO_EDESTADDRREQ); + STR_CASE(SCE_ERROR_ERRNO_EMSGSIZE); + STR_CASE(SCE_ERROR_ERRNO_EPROTONOSUPPORT); + STR_CASE(SCE_ERROR_ERRNO_ESOCKTNOSUPPORT); + STR_CASE(SCE_ERROR_ERRNO_EADDRNOTAVAIL); + STR_CASE(SCE_ERROR_ERRNO_ENETRESET); + STR_CASE(SCE_ERROR_ERRNO_EISCONN); + STR_CASE(SCE_ERROR_ERRNO_ENOTCONN); + STR_CASE(SCE_ERROR_ERRNO_ETOOMANYREFS); + STR_CASE(SCE_ERROR_ERRNO_EPROCLIM); + STR_CASE(SCE_ERROR_ERRNO_EUSERS); + STR_CASE(SCE_ERROR_ERRNO_EDQUOT); + STR_CASE(SCE_ERROR_ERRNO_ESTALE); + STR_CASE(SCE_ERROR_ERRNO_ENOTSUP); + STR_CASE(SCE_ERROR_ERRNO_ENOMEDIUM); + STR_CASE(SCE_ERROR_ERRNO_ENOSHARE); + STR_CASE(SCE_ERROR_ERRNO_ECASECLASH); + STR_CASE(SCE_ERROR_ERRNO_EILSEQ); + STR_CASE(SCE_ERROR_ERRNO_EOVERFLOW); + STR_CASE(SCE_ERROR_ERRNO_ECANCELED); + STR_CASE(SCE_ERROR_ERRNO_ENOTRECOVERABLE); + STR_CASE(SCE_ERROR_ERRNO_EOWNERDEAD); + } + + return unknown; + }); +} + +template<> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](auto error) + { + switch (error) + { + STR_CASE(SCE_KERNEL_ERROR_ERROR); + STR_CASE(SCE_KERNEL_ERROR_NOT_IMPLEMENTED); + STR_CASE(SCE_KERNEL_ERROR_INVALID_ARGUMENT); + STR_CASE(SCE_KERNEL_ERROR_INVALID_ARGUMENT_SIZE); + STR_CASE(SCE_KERNEL_ERROR_INVALID_FLAGS); + STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_SIZE); + STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_ADDR); + STR_CASE(SCE_KERNEL_ERROR_UNSUP); + STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_MODE); + STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_ALIGNMENT); + STR_CASE(SCE_KERNEL_ERROR_NOSYS); + STR_CASE(SCE_KERNEL_ERROR_DEBUG_ERROR); + STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_DIPSW_NUMBER); + STR_CASE(SCE_KERNEL_ERROR_CPU_ERROR); + STR_CASE(SCE_KERNEL_ERROR_MMU_ILLEGAL_L1_TYPE); + STR_CASE(SCE_KERNEL_ERROR_MMU_L2_INDEX_OVERFLOW); + STR_CASE(SCE_KERNEL_ERROR_MMU_L2_SIZE_OVERFLOW); + STR_CASE(SCE_KERNEL_ERROR_INVALID_CPU_AFFINITY); + STR_CASE(SCE_KERNEL_ERROR_INVALID_MEMORY_ACCESS); + STR_CASE(SCE_KERNEL_ERROR_INVALID_MEMORY_ACCESS_PERMISSION); + STR_CASE(SCE_KERNEL_ERROR_VA2PA_FAULT); + STR_CASE(SCE_KERNEL_ERROR_VA2PA_MAPPED); + STR_CASE(SCE_KERNEL_ERROR_VALIDATION_CHECK_FAILED); + STR_CASE(SCE_KERNEL_ERROR_SYSMEM_ERROR); + STR_CASE(SCE_KERNEL_ERROR_INVALID_PROCESS_CONTEXT); + STR_CASE(SCE_KERNEL_ERROR_UID_NAME_TOO_LONG); + STR_CASE(SCE_KERNEL_ERROR_VARANGE_IS_NOT_PHYSICAL_CONTINUOUS); + STR_CASE(SCE_KERNEL_ERROR_PHYADDR_ERROR); + STR_CASE(SCE_KERNEL_ERROR_NO_PHYADDR); + STR_CASE(SCE_KERNEL_ERROR_PHYADDR_USED); + STR_CASE(SCE_KERNEL_ERROR_PHYADDR_NOT_USED); + STR_CASE(SCE_KERNEL_ERROR_NO_IOADDR); + STR_CASE(SCE_KERNEL_ERROR_PHYMEM_ERROR); + STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_PHYPAGE_STATUS); + STR_CASE(SCE_KERNEL_ERROR_NO_FREE_PHYSICAL_PAGE); + STR_CASE(SCE_KERNEL_ERROR_NO_FREE_PHYSICAL_PAGE_UNIT); + STR_CASE(SCE_KERNEL_ERROR_PHYMEMPART_NOT_EMPTY); + STR_CASE(SCE_KERNEL_ERROR_NO_PHYMEMPART_LPDDR2); + STR_CASE(SCE_KERNEL_ERROR_NO_PHYMEMPART_CDRAM); + STR_CASE(SCE_KERNEL_ERROR_FIXEDHEAP_ERROR); + STR_CASE(SCE_KERNEL_ERROR_FIXEDHEAP_ILLEGAL_SIZE); + STR_CASE(SCE_KERNEL_ERROR_FIXEDHEAP_ILLEGAL_INDEX); + STR_CASE(SCE_KERNEL_ERROR_FIXEDHEAP_INDEX_OVERFLOW); + STR_CASE(SCE_KERNEL_ERROR_FIXEDHEAP_NO_CHUNK); + STR_CASE(SCE_KERNEL_ERROR_UID_ERROR); + STR_CASE(SCE_KERNEL_ERROR_INVALID_UID); + STR_CASE(SCE_KERNEL_ERROR_SYSMEM_UID_INVALID_ARGUMENT); + STR_CASE(SCE_KERNEL_ERROR_SYSMEM_INVALID_UID_RANGE); + STR_CASE(SCE_KERNEL_ERROR_SYSMEM_NO_VALID_UID); + STR_CASE(SCE_KERNEL_ERROR_SYSMEM_CANNOT_ALLOCATE_UIDENTRY); + STR_CASE(SCE_KERNEL_ERROR_NOT_PROCESS_UID); + STR_CASE(SCE_KERNEL_ERROR_NOT_KERNEL_UID); + STR_CASE(SCE_KERNEL_ERROR_INVALID_UID_CLASS); + STR_CASE(SCE_KERNEL_ERROR_INVALID_UID_SUBCLASS); + STR_CASE(SCE_KERNEL_ERROR_UID_CANNOT_FIND_BY_NAME); + STR_CASE(SCE_KERNEL_ERROR_VIRPAGE_ERROR); + STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_VIRPAGE_TYPE); + STR_CASE(SCE_KERNEL_ERROR_BLOCK_ERROR); + STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_BLOCK_ID); + STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_BLOCK_TYPE); + STR_CASE(SCE_KERNEL_ERROR_BLOCK_IN_USE); + STR_CASE(SCE_KERNEL_ERROR_PARTITION_ERROR); + STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_PARTITION_ID); + STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_PARTITION_INDEX); + STR_CASE(SCE_KERNEL_ERROR_NO_L2PAGETABLE); + STR_CASE(SCE_KERNEL_ERROR_HEAPLIB_ERROR); + STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_HEAP_ID); + STR_CASE(SCE_KERNEL_ERROR_OUT_OF_RANG); + STR_CASE(SCE_KERNEL_ERROR_HEAPLIB_NOMEM); + STR_CASE(SCE_KERNEL_ERROR_SYSMEM_ADDRESS_SPACE_ERROR); + STR_CASE(SCE_KERNEL_ERROR_INVALID_ADDRESS_SPACE_ID); + STR_CASE(SCE_KERNEL_ERROR_INVALID_PARTITION_INDEX); + STR_CASE(SCE_KERNEL_ERROR_ADDRESS_SPACE_CANNOT_FIND_PARTITION_BY_ADDR); + STR_CASE(SCE_KERNEL_ERROR_SYSMEM_MEMBLOCK_ERROR); + STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_MEMBLOCK_TYPE); + STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_MEMBLOCK_REMAP_TYPE); + STR_CASE(SCE_KERNEL_ERROR_NOT_PHY_CONT_MEMBLOCK); + STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_MEMBLOCK_CODE); + STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_MEMBLOCK_SIZE); + STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_USERMAP_SIZE); + STR_CASE(SCE_KERNEL_ERROR_MEMBLOCK_TYPE_FOR_KERNEL_PROCESS); + STR_CASE(SCE_KERNEL_ERROR_PROCESS_CANNOT_REMAP_MEMBLOCK); + STR_CASE(SCE_KERNEL_ERROR_SYSMEM_PHYMEMLOW_ERROR); + STR_CASE(SCE_KERNEL_ERROR_CANNOT_ALLOC_PHYMEMLOW); + STR_CASE(SCE_KERNEL_ERROR_UNKNOWN_PHYMEMLOW_TYPE); + STR_CASE(SCE_KERNEL_ERROR_SYSMEM_BITHEAP_ERROR); + STR_CASE(SCE_KERNEL_ERROR_CANNOT_ALLOC_BITHEAP); + STR_CASE(SCE_KERNEL_ERROR_LOADCORE_ERROR); + STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_ELF_HEADER); + STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_SELF_HEADER); + STR_CASE(SCE_KERNEL_ERROR_EXCPMGR_ERROR); + STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_EXCPCODE); + STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_EXCPHANDLER); + STR_CASE(SCE_KERNEL_ERROR_NOTFOUND_EXCPHANDLER); + STR_CASE(SCE_KERNEL_ERROR_CANNOT_RELEASE_EXCPHANDLER); + STR_CASE(SCE_KERNEL_ERROR_INTRMGR_ERROR); + STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_CONTEXT); + STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_INTRCODE); + STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_INTRPARAM); + STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_INTRPRIORITY); + STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_TARGET_CPU); + STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_INTRFILTER); + STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_INTRTYPE); + STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_HANDLER); + STR_CASE(SCE_KERNEL_ERROR_FOUND_HANDLER); + STR_CASE(SCE_KERNEL_ERROR_NOTFOUND_HANDLER); + STR_CASE(SCE_KERNEL_ERROR_NO_MEMORY); + STR_CASE(SCE_KERNEL_ERROR_DMACMGR_ERROR); + STR_CASE(SCE_KERNEL_ERROR_ALREADY_QUEUED); + STR_CASE(SCE_KERNEL_ERROR_NOT_QUEUED); + STR_CASE(SCE_KERNEL_ERROR_NOT_SETUP); + STR_CASE(SCE_KERNEL_ERROR_ON_TRANSFERRING); + STR_CASE(SCE_KERNEL_ERROR_NOT_INITIALIZED); + STR_CASE(SCE_KERNEL_ERROR_TRANSFERRED); + STR_CASE(SCE_KERNEL_ERROR_NOT_UNDER_CONTROL); + STR_CASE(SCE_KERNEL_ERROR_SYSTIMER_ERROR); + STR_CASE(SCE_KERNEL_ERROR_NO_FREE_TIMER); + STR_CASE(SCE_KERNEL_ERROR_TIMER_NOT_ALLOCATED); + STR_CASE(SCE_KERNEL_ERROR_TIMER_COUNTING); + STR_CASE(SCE_KERNEL_ERROR_TIMER_STOPPED); + STR_CASE(SCE_KERNEL_ERROR_THREADMGR_ERROR); + STR_CASE(SCE_KERNEL_ERROR_DORMANT); + STR_CASE(SCE_KERNEL_ERROR_NOT_DORMANT); + STR_CASE(SCE_KERNEL_ERROR_UNKNOWN_THID); + STR_CASE(SCE_KERNEL_ERROR_CAN_NOT_WAIT); + STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_THID); + STR_CASE(SCE_KERNEL_ERROR_THREAD_TERMINATED); + STR_CASE(SCE_KERNEL_ERROR_DELETED); + STR_CASE(SCE_KERNEL_ERROR_WAIT_TIMEOUT); + STR_CASE(SCE_KERNEL_ERROR_NOTIFY_CALLBACK); + STR_CASE(SCE_KERNEL_ERROR_WAIT_DELETE); + STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_ATTR); + STR_CASE(SCE_KERNEL_ERROR_EVF_MULTI); + STR_CASE(SCE_KERNEL_ERROR_WAIT_CANCEL); + STR_CASE(SCE_KERNEL_ERROR_EVF_COND); + STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_COUNT); + STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_PRIORITY); + STR_CASE(SCE_KERNEL_ERROR_MUTEX_RECURSIVE); + STR_CASE(SCE_KERNEL_ERROR_MUTEX_LOCK_OVF); + STR_CASE(SCE_KERNEL_ERROR_MUTEX_NOT_OWNED); + STR_CASE(SCE_KERNEL_ERROR_MUTEX_UNLOCK_UDF); + STR_CASE(SCE_KERNEL_ERROR_MUTEX_FAILED_TO_OWN); + STR_CASE(SCE_KERNEL_ERROR_FAST_MUTEX_RECURSIVE); + STR_CASE(SCE_KERNEL_ERROR_FAST_MUTEX_LOCK_OVF); + STR_CASE(SCE_KERNEL_ERROR_FAST_MUTEX_FAILED_TO_OWN); + STR_CASE(SCE_KERNEL_ERROR_FAST_MUTEX_NOT_OWNED); + STR_CASE(SCE_KERNEL_ERROR_FAST_MUTEX_OWNED); + STR_CASE(SCE_KERNEL_ERROR_ALARM_CAN_NOT_CANCEL); + STR_CASE(SCE_KERNEL_ERROR_INVALID_OBJECT_TYPE); + STR_CASE(SCE_KERNEL_ERROR_KERNEL_TLS_FULL); + STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_KERNEL_TLS_INDEX); + STR_CASE(SCE_KERNEL_ERROR_KERNEL_TLS_BUSY); + STR_CASE(SCE_KERNEL_ERROR_DIFFERENT_UID_CLASS); + STR_CASE(SCE_KERNEL_ERROR_UNKNOWN_UID); + STR_CASE(SCE_KERNEL_ERROR_SEMA_ZERO); + STR_CASE(SCE_KERNEL_ERROR_SEMA_OVF); + STR_CASE(SCE_KERNEL_ERROR_PMON_NOT_THREAD_MODE); + STR_CASE(SCE_KERNEL_ERROR_PMON_NOT_CPU_MODE); + STR_CASE(SCE_KERNEL_ERROR_ALREADY_REGISTERED); + STR_CASE(SCE_KERNEL_ERROR_INVALID_THREAD_ID); + STR_CASE(SCE_KERNEL_ERROR_ALREADY_DEBUG_SUSPENDED); + STR_CASE(SCE_KERNEL_ERROR_NOT_DEBUG_SUSPENDED); + STR_CASE(SCE_KERNEL_ERROR_CAN_NOT_USE_VFP); + STR_CASE(SCE_KERNEL_ERROR_RUNNING); + STR_CASE(SCE_KERNEL_ERROR_EVENT_COND); + STR_CASE(SCE_KERNEL_ERROR_MSG_PIPE_FULL); + STR_CASE(SCE_KERNEL_ERROR_MSG_PIPE_EMPTY); + STR_CASE(SCE_KERNEL_ERROR_ALREADY_SENT); + STR_CASE(SCE_KERNEL_ERROR_CAN_NOT_SUSPEND); + STR_CASE(SCE_KERNEL_ERROR_FAST_MUTEX_ALREADY_INITIALIZED); + STR_CASE(SCE_KERNEL_ERROR_FAST_MUTEX_NOT_INITIALIZED); + STR_CASE(SCE_KERNEL_ERROR_THREAD_STOPPED); + STR_CASE(SCE_KERNEL_ERROR_THREAD_SUSPENDED); + STR_CASE(SCE_KERNEL_ERROR_NOT_SUSPENDED); + STR_CASE(SCE_KERNEL_ERROR_WAIT_DELETE_MUTEX); + STR_CASE(SCE_KERNEL_ERROR_WAIT_CANCEL_MUTEX); + STR_CASE(SCE_KERNEL_ERROR_WAIT_DELETE_COND); + STR_CASE(SCE_KERNEL_ERROR_WAIT_CANCEL_COND); + STR_CASE(SCE_KERNEL_ERROR_LW_MUTEX_NOT_OWNED); + STR_CASE(SCE_KERNEL_ERROR_LW_MUTEX_LOCK_OVF); + STR_CASE(SCE_KERNEL_ERROR_LW_MUTEX_UNLOCK_UDF); + STR_CASE(SCE_KERNEL_ERROR_LW_MUTEX_RECURSIVE); + STR_CASE(SCE_KERNEL_ERROR_LW_MUTEX_FAILED_TO_OWN); + STR_CASE(SCE_KERNEL_ERROR_WAIT_DELETE_LW_MUTEX); + STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_STACK_SIZE); + STR_CASE(SCE_KERNEL_ERROR_RW_LOCK_RECURSIVE); + STR_CASE(SCE_KERNEL_ERROR_RW_LOCK_LOCK_OVF); + STR_CASE(SCE_KERNEL_ERROR_RW_LOCK_NOT_OWNED); + STR_CASE(SCE_KERNEL_ERROR_RW_LOCK_UNLOCK_UDF); + STR_CASE(SCE_KERNEL_ERROR_RW_LOCK_FAILED_TO_LOCK); + STR_CASE(SCE_KERNEL_ERROR_RW_LOCK_FAILED_TO_UNLOCK); + STR_CASE(SCE_KERNEL_ERROR_PROCESSMGR_ERROR); + STR_CASE(SCE_KERNEL_ERROR_INVALID_PID); + STR_CASE(SCE_KERNEL_ERROR_INVALID_PROCESS_TYPE); + STR_CASE(SCE_KERNEL_ERROR_PLS_FULL); + STR_CASE(SCE_KERNEL_ERROR_INVALID_PROCESS_STATUS); + STR_CASE(SCE_KERNEL_ERROR_INVALID_BUDGET_ID); + STR_CASE(SCE_KERNEL_ERROR_INVALID_BUDGET_SIZE); + STR_CASE(SCE_KERNEL_ERROR_CP14_DISABLED); + STR_CASE(SCE_KERNEL_ERROR_EXCEEDED_MAX_PROCESSES); + STR_CASE(SCE_KERNEL_ERROR_PROCESS_REMAINING); + STR_CASE(SCE_KERNEL_ERROR_IOFILEMGR_ERROR); + STR_CASE(SCE_KERNEL_ERROR_IO_NAME_TOO_LONG); + STR_CASE(SCE_KERNEL_ERROR_IO_REG_DEV); + STR_CASE(SCE_KERNEL_ERROR_IO_ALIAS_USED); + STR_CASE(SCE_KERNEL_ERROR_IO_DEL_DEV); + STR_CASE(SCE_KERNEL_ERROR_IO_WOULD_BLOCK); + STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_START_FAILED); + STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_STOP_FAIL); + STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_IN_USE); + STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_NO_LIB); + STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_SYSCALL_REG); + STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_NOMEM_LIB); + STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_NOMEM_STUB); + STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_NOMEM_SELF); + STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_NOMEM); + STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_INVALID_LIB); + STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_INVALID_STUB); + STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_NO_FUNC_NID); + STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_NO_VAR_NID); + STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_INVALID_TYPE); + STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_NO_MOD_ENTRY); + STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_INVALID_PROC_PARAM); + STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_NO_MODOBJ); + STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_NO_MOD); + STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_NO_PROCESS); + STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_OLD_LIB); + STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_STARTED); + STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_NOT_STARTED); + STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_NOT_STOPPED); + STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_INVALID_PROCESS_UID); + STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_CANNOT_EXPORT_LIB_TO_SHARED); + STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_INVALID_REL_INFO); + STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_INVALID_REF_INFO); + STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_ELINK); + STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_NOENT); + STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_BUSY); + STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_NOEXEC); + STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_NAMETOOLONG); + STR_CASE(SCE_KERNEL_ERROR_LIBRARYDB_NOENT); + STR_CASE(SCE_KERNEL_ERROR_LIBRARYDB_NO_LIB); + STR_CASE(SCE_KERNEL_ERROR_LIBRARYDB_NO_MOD); + STR_CASE(SCE_KERNEL_ERROR_AUTHFAIL); + STR_CASE(SCE_KERNEL_ERROR_NO_AUTH); + } + + return unknown; + }); +} + arm_tls_manager::arm_tls_manager(u32 vaddr, u32 fsize, u32 vsize) : vaddr(vaddr) , fsize(fsize) @@ -88,7 +485,7 @@ s32 sceKernelGetMemBlockInfoByAddr(vm::ptr vbase, vm::ptr pName, vm::ptr entry, s32 initPriority, u32 stackSize, u32 attr, s32 cpuAffinityMask, vm::cptr pOptParam) +error_code sceKernelCreateThread(vm::cptr pName, vm::ptr entry, s32 initPriority, u32 stackSize, u32 attr, s32 cpuAffinityMask, vm::cptr pOptParam) { sceLibKernel.warning("sceKernelCreateThread(pName=%s, entry=*0x%x, initPriority=%d, stackSize=0x%x, attr=0x%x, cpuAffinityMask=0x%x, pOptParam=*0x%x)", pName, entry, initPriority, stackSize, attr, cpuAffinityMask, pOptParam); @@ -101,7 +498,7 @@ arm_error_code sceKernelCreateThread(vm::cptr pName, vm::ptrid); } -arm_error_code sceKernelStartThread(s32 threadId, u32 argSize, vm::cptr pArgBlock) +error_code sceKernelStartThread(s32 threadId, u32 argSize, vm::cptr pArgBlock) { sceLibKernel.warning("sceKernelStartThread(threadId=0x%x, argSize=0x%x, pArgBlock=*0x%x)", threadId, argSize, pArgBlock); @@ -130,7 +527,7 @@ arm_error_code sceKernelStartThread(s32 threadId, u32 argSize, vm::cptr pA return SCE_OK; } -arm_error_code sceKernelExitThread(ARMv7Thread& cpu, s32 exitStatus) +error_code sceKernelExitThread(ARMv7Thread& cpu, s32 exitStatus) { sceLibKernel.warning("sceKernelExitThread(exitStatus=0x%x)", exitStatus); @@ -140,7 +537,7 @@ arm_error_code sceKernelExitThread(ARMv7Thread& cpu, s32 exitStatus) return SCE_OK; } -arm_error_code sceKernelDeleteThread(s32 threadId) +error_code sceKernelDeleteThread(s32 threadId) { sceLibKernel.warning("sceKernelDeleteThread(threadId=0x%x)", threadId); @@ -163,7 +560,7 @@ arm_error_code sceKernelDeleteThread(s32 threadId) return SCE_OK; } -arm_error_code sceKernelExitDeleteThread(ARMv7Thread& cpu, s32 exitStatus) +error_code sceKernelExitDeleteThread(ARMv7Thread& cpu, s32 exitStatus) { sceLibKernel.warning("sceKernelExitDeleteThread(exitStatus=0x%x)", exitStatus); @@ -288,7 +685,7 @@ s32 sceKernelDelayThreadCB(u32 usec) fmt::throw_exception("Unimplemented" HERE); } -arm_error_code sceKernelWaitThreadEnd(s32 threadId, vm::ptr pExitStatus, vm::ptr pTimeout) +error_code sceKernelWaitThreadEnd(s32 threadId, vm::ptr pExitStatus, vm::ptr pTimeout) { sceLibKernel.warning("sceKernelWaitThreadEnd(threadId=0x%x, pExitStatus=*0x%x, pTimeout=*0x%x)", threadId, pExitStatus, pTimeout); @@ -733,7 +1130,7 @@ private: template<> DECLARE(psp2_event_flag::ipc::g_ipc) {}; -arm_error_code sceKernelCreateEventFlag(vm::cptr pName, u32 attr, u32 initPattern, vm::cptr pOptParam) +error_code sceKernelCreateEventFlag(vm::cptr pName, u32 attr, u32 initPattern, vm::cptr pOptParam) { sceLibKernel.error("sceKernelCreateEventFlag(pName=%s, attr=0x%x, initPattern=0x%x, pOptParam=*0x%x)", pName, attr, initPattern, pOptParam); @@ -750,7 +1147,7 @@ arm_error_code sceKernelCreateEventFlag(vm::cptr pName, u32 attr, u32 init return not_an_error(idm::import_existing(evf)); } -arm_error_code sceKernelDeleteEventFlag(s32 evfId) +error_code sceKernelDeleteEventFlag(s32 evfId) { sceLibKernel.error("sceKernelDeleteEventFlag(evfId=0x%x)", evfId); @@ -776,7 +1173,7 @@ arm_error_code sceKernelDeleteEventFlag(s32 evfId) return SCE_OK; } -arm_error_code sceKernelOpenEventFlag(vm::cptr pName) +error_code sceKernelOpenEventFlag(vm::cptr pName) { sceLibKernel.error("sceKernelOpenEventFlag(pName=%s)", pName); @@ -791,7 +1188,7 @@ arm_error_code sceKernelOpenEventFlag(vm::cptr pName) return not_an_error(idm::import_existing(evf)); } -arm_error_code sceKernelCloseEventFlag(s32 evfId) +error_code sceKernelCloseEventFlag(s32 evfId) { sceLibKernel.error("sceKernelCloseEventFlag(evfId=0x%x)", evfId); @@ -811,7 +1208,7 @@ arm_error_code sceKernelCloseEventFlag(s32 evfId) return SCE_OK; } -arm_error_code sceKernelWaitEventFlag(ARMv7Thread& cpu, s32 evfId, u32 bitPattern, u32 waitMode, vm::ptr pResultPat, vm::ptr pTimeout) +error_code sceKernelWaitEventFlag(ARMv7Thread& cpu, s32 evfId, u32 bitPattern, u32 waitMode, vm::ptr pResultPat, vm::ptr pTimeout) { sceLibKernel.error("sceKernelWaitEventFlag(evfId=0x%x, bitPattern=0x%x, waitMode=0x%x, pResultPat=*0x%x, pTimeout=*0x%x)", evfId, bitPattern, waitMode, pResultPat, pTimeout); @@ -884,14 +1281,14 @@ arm_error_code sceKernelWaitEventFlag(ARMv7Thread& cpu, s32 evfId, u32 bitPatter return not_an_error(cpu.GPR[0]); } -arm_error_code sceKernelWaitEventFlagCB(ARMv7Thread& cpu, s32 evfId, u32 bitPattern, u32 waitMode, vm::ptr pResultPat, vm::ptr pTimeout) +error_code sceKernelWaitEventFlagCB(ARMv7Thread& cpu, s32 evfId, u32 bitPattern, u32 waitMode, vm::ptr pResultPat, vm::ptr pTimeout) { sceLibKernel.todo("sceKernelWaitEventFlagCB(evfId=0x%x, bitPattern=0x%x, waitMode=0x%x, pResultPat=*0x%x, pTimeout=*0x%x)", evfId, bitPattern, waitMode, pResultPat, pTimeout); return sceKernelWaitEventFlag(cpu, evfId, bitPattern, waitMode, pResultPat, pTimeout); } -arm_error_code sceKernelPollEventFlag(ARMv7Thread& cpu, s32 evfId, u32 bitPattern, u32 waitMode, vm::ptr pResultPat) +error_code sceKernelPollEventFlag(ARMv7Thread& cpu, s32 evfId, u32 bitPattern, u32 waitMode, vm::ptr pResultPat) { sceLibKernel.error("sceKernelPollEventFlag(evfId=0x%x, bitPattern=0x%x, waitMode=0x%x, pResultPat=*0x%x)", evfId, bitPattern, waitMode, pResultPat); @@ -934,7 +1331,7 @@ arm_error_code sceKernelPollEventFlag(ARMv7Thread& cpu, s32 evfId, u32 bitPatter return not_an_error(SCE_KERNEL_ERROR_EVENT_COND); } -arm_error_code sceKernelSetEventFlag(s32 evfId, u32 bitPattern) +error_code sceKernelSetEventFlag(s32 evfId, u32 bitPattern) { sceLibKernel.error("sceKernelSetEventFlag(evfId=0x%x, bitPattern=0x%x)", evfId, bitPattern); @@ -952,7 +1349,7 @@ arm_error_code sceKernelSetEventFlag(s32 evfId, u32 bitPattern) return SCE_OK; } -arm_error_code sceKernelClearEventFlag(s32 evfId, u32 bitPattern) +error_code sceKernelClearEventFlag(s32 evfId, u32 bitPattern) { sceLibKernel.error("sceKernelClearEventFlag(evfId=0x%x, bitPattern=0x%x)", evfId, bitPattern); @@ -970,7 +1367,7 @@ arm_error_code sceKernelClearEventFlag(s32 evfId, u32 bitPattern) return SCE_OK; } -arm_error_code sceKernelCancelEventFlag(ARMv7Thread& cpu, s32 evfId, u32 setPattern, vm::ptr pNumWaitThreads) +error_code sceKernelCancelEventFlag(ARMv7Thread& cpu, s32 evfId, u32 setPattern, vm::ptr pNumWaitThreads) { sceLibKernel.error("sceKernelCancelEventFlag(evfId=0x%x, setPattern=0x%x, pNumWaitThreads=*0x%x)", evfId, setPattern, pNumWaitThreads); @@ -988,7 +1385,7 @@ arm_error_code sceKernelCancelEventFlag(ARMv7Thread& cpu, s32 evfId, u32 setPatt return SCE_OK; } -arm_error_code sceKernelGetEventFlagInfo(s32 evfId, vm::ptr pInfo) +error_code sceKernelGetEventFlagInfo(s32 evfId, vm::ptr pInfo) { sceLibKernel.error("sceKernelGetEventFlagInfo(evfId=0x%x, pInfo=*0x%x)", evfId, pInfo); @@ -1017,14 +1414,14 @@ arm_error_code sceKernelGetEventFlagInfo(s32 evfId, vm::ptr pName, u32 attr, s32 initCount, s32 maxCount, vm::cptr pOptParam) +error_code sceKernelCreateSema(vm::cptr pName, u32 attr, s32 initCount, s32 maxCount, vm::cptr pOptParam) { sceLibKernel.error("sceKernelCreateSema(pName=%s, attr=0x%x, initCount=%d, maxCount=%d, pOptParam=*0x%x)", pName, attr, initCount, maxCount, pOptParam); return not_an_error(idm::make(pName.get_ptr(), attr, initCount, maxCount)); } -arm_error_code sceKernelDeleteSema(s32 semaId) +error_code sceKernelDeleteSema(s32 semaId) { sceLibKernel.error("sceKernelDeleteSema(semaId=0x%x)", semaId); @@ -1050,7 +1447,7 @@ s32 sceKernelCloseSema(s32 semaId) fmt::throw_exception("Unimplemented" HERE); } -arm_error_code sceKernelWaitSema(s32 semaId, s32 needCount, vm::ptr pTimeout) +error_code sceKernelWaitSema(s32 semaId, s32 needCount, vm::ptr pTimeout) { sceLibKernel.error("sceKernelWaitSema(semaId=0x%x, needCount=%d, pTimeout=*0x%x)", semaId, needCount, pTimeout); @@ -1093,14 +1490,14 @@ s32 sceKernelGetSemaInfo(s32 semaId, vm::ptr pInfo) // Mutex functions -arm_error_code sceKernelCreateMutex(vm::cptr pName, u32 attr, s32 initCount, vm::cptr pOptParam) +error_code sceKernelCreateMutex(vm::cptr pName, u32 attr, s32 initCount, vm::cptr pOptParam) { sceLibKernel.error("sceKernelCreateMutex(pName=%s, attr=0x%x, initCount=%d, pOptParam=*0x%x)", pName, attr, initCount, pOptParam); return not_an_error(idm::make(pName.get_ptr(), attr, initCount)); } -arm_error_code sceKernelDeleteMutex(s32 mutexId) +error_code sceKernelDeleteMutex(s32 mutexId) { sceLibKernel.error("sceKernelDeleteMutex(mutexId=0x%x)", mutexId); @@ -1200,7 +1597,7 @@ s32 sceKernelGetLwMutexInfoById(s32 lwMutexId, vm::ptr pIn // Condition variable functions -arm_error_code sceKernelCreateCond(vm::cptr pName, u32 attr, s32 mutexId, vm::cptr pOptParam) +error_code sceKernelCreateCond(vm::cptr pName, u32 attr, s32 mutexId, vm::cptr pOptParam) { sceLibKernel.error("sceKernelCreateCond(pName=%s, attr=0x%x, mutexId=0x%x, pOptParam=*0x%x)", pName, attr, mutexId, pOptParam); @@ -1214,7 +1611,7 @@ arm_error_code sceKernelCreateCond(vm::cptr pName, u32 attr, s32 mutexId, return not_an_error(idm::make(pName.get_ptr(), attr, mutex)); } -arm_error_code sceKernelDeleteCond(s32 condId) +error_code sceKernelDeleteCond(s32 condId) { sceLibKernel.error("sceKernelDeleteCond(condId=0x%x)", condId); @@ -1483,15 +1880,15 @@ s32 sceKernelGetRWLockInfo(s32 rwLockId, vm::ptr pInfo) fmt::throw_exception("Unimplemented" HERE); } -arm_error_code sceKernelGetThreadmgrUIDClass(s32 uid) +error_code sceKernelGetThreadmgrUIDClass(s32 uid) { sceLibKernel.error("sceKernelGetThreadmgrUIDClass(uid=0x%x)", uid); - if (idm::check(uid)) return SCE_KERNEL_THREADMGR_UID_CLASS_THREAD; - if (idm::check(uid)) return SCE_KERNEL_THREADMGR_UID_CLASS_SEMA; - if (idm::check(uid)) return SCE_KERNEL_THREADMGR_UID_CLASS_EVENT_FLAG; - if (idm::check(uid)) return SCE_KERNEL_THREADMGR_UID_CLASS_MUTEX; - if (idm::check(uid)) return SCE_KERNEL_THREADMGR_UID_CLASS_COND; + if (idm::check(uid)) return not_an_error(SCE_KERNEL_THREADMGR_UID_CLASS_THREAD); + if (idm::check(uid)) return not_an_error(SCE_KERNEL_THREADMGR_UID_CLASS_SEMA); + if (idm::check(uid)) return not_an_error(SCE_KERNEL_THREADMGR_UID_CLASS_EVENT_FLAG); + if (idm::check(uid)) return not_an_error(SCE_KERNEL_THREADMGR_UID_CLASS_MUTEX); + if (idm::check(uid)) return not_an_error(SCE_KERNEL_THREADMGR_UID_CLASS_COND); return SCE_KERNEL_ERROR_INVALID_UID; } diff --git a/rpcs3/Emu/PSP2/Modules/sceLibKernel.h b/rpcs3/Emu/PSP2/Modules/sceLibKernel.h index 9d23b3ddaf..ddf988a5bd 100644 --- a/rpcs3/Emu/PSP2/Modules/sceLibKernel.h +++ b/rpcs3/Emu/PSP2/Modules/sceLibKernel.h @@ -117,11 +117,6 @@ enum SceLibKernelError : u32 SCE_KERNEL_ERROR_LOADCORE_ERROR = 0x80025000, SCE_KERNEL_ERROR_ILLEGAL_ELF_HEADER = 0x80025001, SCE_KERNEL_ERROR_ILLEGAL_SELF_HEADER = 0x80025002, -}; - -// Error Codes -enum SceLibKernelError0 : u32 -{ SCE_KERNEL_ERROR_EXCPMGR_ERROR = 0x80027000, SCE_KERNEL_ERROR_ILLEGAL_EXCPCODE = 0x80027001, SCE_KERNEL_ERROR_ILLEGAL_EXCPHANDLER = 0x80027002, @@ -223,11 +218,6 @@ enum SceLibKernelError0 : u32 SCE_KERNEL_ERROR_RW_LOCK_UNLOCK_UDF = 0x80028044, SCE_KERNEL_ERROR_RW_LOCK_FAILED_TO_LOCK = 0x80028045, SCE_KERNEL_ERROR_RW_LOCK_FAILED_TO_UNLOCK = 0x80028046, -}; - -// Error Codes -enum SceLibKernelError1 : u32 -{ SCE_KERNEL_ERROR_PROCESSMGR_ERROR = 0x80029000, SCE_KERNEL_ERROR_INVALID_PID = 0x80029001, SCE_KERNEL_ERROR_INVALID_PROCESS_TYPE = 0x80029002, @@ -283,280 +273,6 @@ enum SceLibKernelError1 : u32 SCE_KERNEL_ERROR_NO_AUTH = 0x8002F001, }; -template<> -inline const char* arm_error_code::print(SceLibKernelError error) -{ - switch (error) - { - STR_CASE(SCE_KERNEL_ERROR_ERROR); - STR_CASE(SCE_KERNEL_ERROR_NOT_IMPLEMENTED); - STR_CASE(SCE_KERNEL_ERROR_INVALID_ARGUMENT); - STR_CASE(SCE_KERNEL_ERROR_INVALID_ARGUMENT_SIZE); - STR_CASE(SCE_KERNEL_ERROR_INVALID_FLAGS); - STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_SIZE); - STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_ADDR); - STR_CASE(SCE_KERNEL_ERROR_UNSUP); - STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_MODE); - STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_ALIGNMENT); - STR_CASE(SCE_KERNEL_ERROR_NOSYS); - STR_CASE(SCE_KERNEL_ERROR_DEBUG_ERROR); - STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_DIPSW_NUMBER); - STR_CASE(SCE_KERNEL_ERROR_CPU_ERROR); - STR_CASE(SCE_KERNEL_ERROR_MMU_ILLEGAL_L1_TYPE); - STR_CASE(SCE_KERNEL_ERROR_MMU_L2_INDEX_OVERFLOW); - STR_CASE(SCE_KERNEL_ERROR_MMU_L2_SIZE_OVERFLOW); - STR_CASE(SCE_KERNEL_ERROR_INVALID_CPU_AFFINITY); - STR_CASE(SCE_KERNEL_ERROR_INVALID_MEMORY_ACCESS); - STR_CASE(SCE_KERNEL_ERROR_INVALID_MEMORY_ACCESS_PERMISSION); - STR_CASE(SCE_KERNEL_ERROR_VA2PA_FAULT); - STR_CASE(SCE_KERNEL_ERROR_VA2PA_MAPPED); - STR_CASE(SCE_KERNEL_ERROR_VALIDATION_CHECK_FAILED); - STR_CASE(SCE_KERNEL_ERROR_SYSMEM_ERROR); - STR_CASE(SCE_KERNEL_ERROR_INVALID_PROCESS_CONTEXT); - STR_CASE(SCE_KERNEL_ERROR_UID_NAME_TOO_LONG); - STR_CASE(SCE_KERNEL_ERROR_VARANGE_IS_NOT_PHYSICAL_CONTINUOUS); - STR_CASE(SCE_KERNEL_ERROR_PHYADDR_ERROR); - STR_CASE(SCE_KERNEL_ERROR_NO_PHYADDR); - STR_CASE(SCE_KERNEL_ERROR_PHYADDR_USED); - STR_CASE(SCE_KERNEL_ERROR_PHYADDR_NOT_USED); - STR_CASE(SCE_KERNEL_ERROR_NO_IOADDR); - STR_CASE(SCE_KERNEL_ERROR_PHYMEM_ERROR); - STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_PHYPAGE_STATUS); - STR_CASE(SCE_KERNEL_ERROR_NO_FREE_PHYSICAL_PAGE); - STR_CASE(SCE_KERNEL_ERROR_NO_FREE_PHYSICAL_PAGE_UNIT); - STR_CASE(SCE_KERNEL_ERROR_PHYMEMPART_NOT_EMPTY); - STR_CASE(SCE_KERNEL_ERROR_NO_PHYMEMPART_LPDDR2); - STR_CASE(SCE_KERNEL_ERROR_NO_PHYMEMPART_CDRAM); - STR_CASE(SCE_KERNEL_ERROR_FIXEDHEAP_ERROR); - STR_CASE(SCE_KERNEL_ERROR_FIXEDHEAP_ILLEGAL_SIZE); - STR_CASE(SCE_KERNEL_ERROR_FIXEDHEAP_ILLEGAL_INDEX); - STR_CASE(SCE_KERNEL_ERROR_FIXEDHEAP_INDEX_OVERFLOW); - STR_CASE(SCE_KERNEL_ERROR_FIXEDHEAP_NO_CHUNK); - STR_CASE(SCE_KERNEL_ERROR_UID_ERROR); - STR_CASE(SCE_KERNEL_ERROR_INVALID_UID); - STR_CASE(SCE_KERNEL_ERROR_SYSMEM_UID_INVALID_ARGUMENT); - STR_CASE(SCE_KERNEL_ERROR_SYSMEM_INVALID_UID_RANGE); - STR_CASE(SCE_KERNEL_ERROR_SYSMEM_NO_VALID_UID); - STR_CASE(SCE_KERNEL_ERROR_SYSMEM_CANNOT_ALLOCATE_UIDENTRY); - STR_CASE(SCE_KERNEL_ERROR_NOT_PROCESS_UID); - STR_CASE(SCE_KERNEL_ERROR_NOT_KERNEL_UID); - STR_CASE(SCE_KERNEL_ERROR_INVALID_UID_CLASS); - STR_CASE(SCE_KERNEL_ERROR_INVALID_UID_SUBCLASS); - STR_CASE(SCE_KERNEL_ERROR_UID_CANNOT_FIND_BY_NAME); - STR_CASE(SCE_KERNEL_ERROR_VIRPAGE_ERROR); - STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_VIRPAGE_TYPE); - STR_CASE(SCE_KERNEL_ERROR_BLOCK_ERROR); - STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_BLOCK_ID); - STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_BLOCK_TYPE); - STR_CASE(SCE_KERNEL_ERROR_BLOCK_IN_USE); - STR_CASE(SCE_KERNEL_ERROR_PARTITION_ERROR); - STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_PARTITION_ID); - STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_PARTITION_INDEX); - STR_CASE(SCE_KERNEL_ERROR_NO_L2PAGETABLE); - STR_CASE(SCE_KERNEL_ERROR_HEAPLIB_ERROR); - STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_HEAP_ID); - STR_CASE(SCE_KERNEL_ERROR_OUT_OF_RANG); - STR_CASE(SCE_KERNEL_ERROR_HEAPLIB_NOMEM); - STR_CASE(SCE_KERNEL_ERROR_SYSMEM_ADDRESS_SPACE_ERROR); - STR_CASE(SCE_KERNEL_ERROR_INVALID_ADDRESS_SPACE_ID); - STR_CASE(SCE_KERNEL_ERROR_INVALID_PARTITION_INDEX); - STR_CASE(SCE_KERNEL_ERROR_ADDRESS_SPACE_CANNOT_FIND_PARTITION_BY_ADDR); - STR_CASE(SCE_KERNEL_ERROR_SYSMEM_MEMBLOCK_ERROR); - STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_MEMBLOCK_TYPE); - STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_MEMBLOCK_REMAP_TYPE); - STR_CASE(SCE_KERNEL_ERROR_NOT_PHY_CONT_MEMBLOCK); - STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_MEMBLOCK_CODE); - STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_MEMBLOCK_SIZE); - STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_USERMAP_SIZE); - STR_CASE(SCE_KERNEL_ERROR_MEMBLOCK_TYPE_FOR_KERNEL_PROCESS); - STR_CASE(SCE_KERNEL_ERROR_PROCESS_CANNOT_REMAP_MEMBLOCK); - STR_CASE(SCE_KERNEL_ERROR_SYSMEM_PHYMEMLOW_ERROR); - STR_CASE(SCE_KERNEL_ERROR_CANNOT_ALLOC_PHYMEMLOW); - STR_CASE(SCE_KERNEL_ERROR_UNKNOWN_PHYMEMLOW_TYPE); - STR_CASE(SCE_KERNEL_ERROR_SYSMEM_BITHEAP_ERROR); - STR_CASE(SCE_KERNEL_ERROR_CANNOT_ALLOC_BITHEAP); - STR_CASE(SCE_KERNEL_ERROR_LOADCORE_ERROR); - STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_ELF_HEADER); - STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_SELF_HEADER); - } - - return nullptr; -} - -template<> -inline const char* arm_error_code::print(SceLibKernelError0 error) -{ - switch (error) - { - STR_CASE(SCE_KERNEL_ERROR_EXCPMGR_ERROR); - STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_EXCPCODE); - STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_EXCPHANDLER); - STR_CASE(SCE_KERNEL_ERROR_NOTFOUND_EXCPHANDLER); - STR_CASE(SCE_KERNEL_ERROR_CANNOT_RELEASE_EXCPHANDLER); - STR_CASE(SCE_KERNEL_ERROR_INTRMGR_ERROR); - STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_CONTEXT); - STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_INTRCODE); - STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_INTRPARAM); - STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_INTRPRIORITY); - STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_TARGET_CPU); - STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_INTRFILTER); - STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_INTRTYPE); - STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_HANDLER); - STR_CASE(SCE_KERNEL_ERROR_FOUND_HANDLER); - STR_CASE(SCE_KERNEL_ERROR_NOTFOUND_HANDLER); - STR_CASE(SCE_KERNEL_ERROR_NO_MEMORY); - STR_CASE(SCE_KERNEL_ERROR_DMACMGR_ERROR); - STR_CASE(SCE_KERNEL_ERROR_ALREADY_QUEUED); - STR_CASE(SCE_KERNEL_ERROR_NOT_QUEUED); - STR_CASE(SCE_KERNEL_ERROR_NOT_SETUP); - STR_CASE(SCE_KERNEL_ERROR_ON_TRANSFERRING); - STR_CASE(SCE_KERNEL_ERROR_NOT_INITIALIZED); - STR_CASE(SCE_KERNEL_ERROR_TRANSFERRED); - STR_CASE(SCE_KERNEL_ERROR_NOT_UNDER_CONTROL); - STR_CASE(SCE_KERNEL_ERROR_SYSTIMER_ERROR); - STR_CASE(SCE_KERNEL_ERROR_NO_FREE_TIMER); - STR_CASE(SCE_KERNEL_ERROR_TIMER_NOT_ALLOCATED); - STR_CASE(SCE_KERNEL_ERROR_TIMER_COUNTING); - STR_CASE(SCE_KERNEL_ERROR_TIMER_STOPPED); - STR_CASE(SCE_KERNEL_ERROR_THREADMGR_ERROR); - STR_CASE(SCE_KERNEL_ERROR_DORMANT); - STR_CASE(SCE_KERNEL_ERROR_NOT_DORMANT); - STR_CASE(SCE_KERNEL_ERROR_UNKNOWN_THID); - STR_CASE(SCE_KERNEL_ERROR_CAN_NOT_WAIT); - STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_THID); - STR_CASE(SCE_KERNEL_ERROR_THREAD_TERMINATED); - STR_CASE(SCE_KERNEL_ERROR_DELETED); - STR_CASE(SCE_KERNEL_ERROR_WAIT_TIMEOUT); - STR_CASE(SCE_KERNEL_ERROR_NOTIFY_CALLBACK); - STR_CASE(SCE_KERNEL_ERROR_WAIT_DELETE); - STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_ATTR); - STR_CASE(SCE_KERNEL_ERROR_EVF_MULTI); - STR_CASE(SCE_KERNEL_ERROR_WAIT_CANCEL); - STR_CASE(SCE_KERNEL_ERROR_EVF_COND); - STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_COUNT); - STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_PRIORITY); - STR_CASE(SCE_KERNEL_ERROR_MUTEX_RECURSIVE); - STR_CASE(SCE_KERNEL_ERROR_MUTEX_LOCK_OVF); - STR_CASE(SCE_KERNEL_ERROR_MUTEX_NOT_OWNED); - STR_CASE(SCE_KERNEL_ERROR_MUTEX_UNLOCK_UDF); - STR_CASE(SCE_KERNEL_ERROR_MUTEX_FAILED_TO_OWN); - STR_CASE(SCE_KERNEL_ERROR_FAST_MUTEX_RECURSIVE); - STR_CASE(SCE_KERNEL_ERROR_FAST_MUTEX_LOCK_OVF); - STR_CASE(SCE_KERNEL_ERROR_FAST_MUTEX_FAILED_TO_OWN); - STR_CASE(SCE_KERNEL_ERROR_FAST_MUTEX_NOT_OWNED); - STR_CASE(SCE_KERNEL_ERROR_FAST_MUTEX_OWNED); - STR_CASE(SCE_KERNEL_ERROR_ALARM_CAN_NOT_CANCEL); - STR_CASE(SCE_KERNEL_ERROR_INVALID_OBJECT_TYPE); - STR_CASE(SCE_KERNEL_ERROR_KERNEL_TLS_FULL); - STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_KERNEL_TLS_INDEX); - STR_CASE(SCE_KERNEL_ERROR_KERNEL_TLS_BUSY); - STR_CASE(SCE_KERNEL_ERROR_DIFFERENT_UID_CLASS); - STR_CASE(SCE_KERNEL_ERROR_UNKNOWN_UID); - STR_CASE(SCE_KERNEL_ERROR_SEMA_ZERO); - STR_CASE(SCE_KERNEL_ERROR_SEMA_OVF); - STR_CASE(SCE_KERNEL_ERROR_PMON_NOT_THREAD_MODE); - STR_CASE(SCE_KERNEL_ERROR_PMON_NOT_CPU_MODE); - STR_CASE(SCE_KERNEL_ERROR_ALREADY_REGISTERED); - STR_CASE(SCE_KERNEL_ERROR_INVALID_THREAD_ID); - STR_CASE(SCE_KERNEL_ERROR_ALREADY_DEBUG_SUSPENDED); - STR_CASE(SCE_KERNEL_ERROR_NOT_DEBUG_SUSPENDED); - STR_CASE(SCE_KERNEL_ERROR_CAN_NOT_USE_VFP); - STR_CASE(SCE_KERNEL_ERROR_RUNNING); - STR_CASE(SCE_KERNEL_ERROR_EVENT_COND); - STR_CASE(SCE_KERNEL_ERROR_MSG_PIPE_FULL); - STR_CASE(SCE_KERNEL_ERROR_MSG_PIPE_EMPTY); - STR_CASE(SCE_KERNEL_ERROR_ALREADY_SENT); - STR_CASE(SCE_KERNEL_ERROR_CAN_NOT_SUSPEND); - STR_CASE(SCE_KERNEL_ERROR_FAST_MUTEX_ALREADY_INITIALIZED); - STR_CASE(SCE_KERNEL_ERROR_FAST_MUTEX_NOT_INITIALIZED); - STR_CASE(SCE_KERNEL_ERROR_THREAD_STOPPED); - STR_CASE(SCE_KERNEL_ERROR_THREAD_SUSPENDED); - STR_CASE(SCE_KERNEL_ERROR_NOT_SUSPENDED); - STR_CASE(SCE_KERNEL_ERROR_WAIT_DELETE_MUTEX); - STR_CASE(SCE_KERNEL_ERROR_WAIT_CANCEL_MUTEX); - STR_CASE(SCE_KERNEL_ERROR_WAIT_DELETE_COND); - STR_CASE(SCE_KERNEL_ERROR_WAIT_CANCEL_COND); - STR_CASE(SCE_KERNEL_ERROR_LW_MUTEX_NOT_OWNED); - STR_CASE(SCE_KERNEL_ERROR_LW_MUTEX_LOCK_OVF); - STR_CASE(SCE_KERNEL_ERROR_LW_MUTEX_UNLOCK_UDF); - STR_CASE(SCE_KERNEL_ERROR_LW_MUTEX_RECURSIVE); - STR_CASE(SCE_KERNEL_ERROR_LW_MUTEX_FAILED_TO_OWN); - STR_CASE(SCE_KERNEL_ERROR_WAIT_DELETE_LW_MUTEX); - STR_CASE(SCE_KERNEL_ERROR_ILLEGAL_STACK_SIZE); - STR_CASE(SCE_KERNEL_ERROR_RW_LOCK_RECURSIVE); - STR_CASE(SCE_KERNEL_ERROR_RW_LOCK_LOCK_OVF); - STR_CASE(SCE_KERNEL_ERROR_RW_LOCK_NOT_OWNED); - STR_CASE(SCE_KERNEL_ERROR_RW_LOCK_UNLOCK_UDF); - STR_CASE(SCE_KERNEL_ERROR_RW_LOCK_FAILED_TO_LOCK); - STR_CASE(SCE_KERNEL_ERROR_RW_LOCK_FAILED_TO_UNLOCK); - } - - return nullptr; -} - -template<> -inline const char* arm_error_code::print(SceLibKernelError1 error) -{ - switch (error) - { - STR_CASE(SCE_KERNEL_ERROR_PROCESSMGR_ERROR); - STR_CASE(SCE_KERNEL_ERROR_INVALID_PID); - STR_CASE(SCE_KERNEL_ERROR_INVALID_PROCESS_TYPE); - STR_CASE(SCE_KERNEL_ERROR_PLS_FULL); - STR_CASE(SCE_KERNEL_ERROR_INVALID_PROCESS_STATUS); - STR_CASE(SCE_KERNEL_ERROR_INVALID_BUDGET_ID); - STR_CASE(SCE_KERNEL_ERROR_INVALID_BUDGET_SIZE); - STR_CASE(SCE_KERNEL_ERROR_CP14_DISABLED); - STR_CASE(SCE_KERNEL_ERROR_EXCEEDED_MAX_PROCESSES); - STR_CASE(SCE_KERNEL_ERROR_PROCESS_REMAINING); - STR_CASE(SCE_KERNEL_ERROR_IOFILEMGR_ERROR); - STR_CASE(SCE_KERNEL_ERROR_IO_NAME_TOO_LONG); - STR_CASE(SCE_KERNEL_ERROR_IO_REG_DEV); - STR_CASE(SCE_KERNEL_ERROR_IO_ALIAS_USED); - STR_CASE(SCE_KERNEL_ERROR_IO_DEL_DEV); - STR_CASE(SCE_KERNEL_ERROR_IO_WOULD_BLOCK); - STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_START_FAILED); - STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_STOP_FAIL); - STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_IN_USE); - STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_NO_LIB); - STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_SYSCALL_REG); - STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_NOMEM_LIB); - STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_NOMEM_STUB); - STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_NOMEM_SELF); - STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_NOMEM); - STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_INVALID_LIB); - STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_INVALID_STUB); - STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_NO_FUNC_NID); - STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_NO_VAR_NID); - STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_INVALID_TYPE); - STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_NO_MOD_ENTRY); - STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_INVALID_PROC_PARAM); - STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_NO_MODOBJ); - STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_NO_MOD); - STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_NO_PROCESS); - STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_OLD_LIB); - STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_STARTED); - STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_NOT_STARTED); - STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_NOT_STOPPED); - STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_INVALID_PROCESS_UID); - STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_CANNOT_EXPORT_LIB_TO_SHARED); - STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_INVALID_REL_INFO); - STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_INVALID_REF_INFO); - STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_ELINK); - STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_NOENT); - STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_BUSY); - STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_NOEXEC); - STR_CASE(SCE_KERNEL_ERROR_MODULEMGR_NAMETOOLONG); - STR_CASE(SCE_KERNEL_ERROR_LIBRARYDB_NOENT); - STR_CASE(SCE_KERNEL_ERROR_LIBRARYDB_NO_LIB); - STR_CASE(SCE_KERNEL_ERROR_LIBRARYDB_NO_MOD); - STR_CASE(SCE_KERNEL_ERROR_AUTHFAIL); - STR_CASE(SCE_KERNEL_ERROR_NO_AUTH); - } - - return nullptr; -} - // PSP2 UID Class enum : u32 { diff --git a/rpcs3/Emu/PSP2/Modules/scePerf.cpp b/rpcs3/Emu/PSP2/Modules/scePerf.cpp index 6373646327..abef505937 100644 --- a/rpcs3/Emu/PSP2/Modules/scePerf.cpp +++ b/rpcs3/Emu/PSP2/Modules/scePerf.cpp @@ -8,7 +8,21 @@ logs::channel scePerf("scePerf", logs::level::notice); extern u64 get_system_time(); -arm_error_code scePerfArmPmonReset(ARMv7Thread& cpu, s32 threadId) +template<> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](auto error) + { + switch (error) + { + STR_CASE(SCE_PERF_ERROR_INVALID_ARGUMENT); + } + + return unknown; + }); +} + +error_code scePerfArmPmonReset(ARMv7Thread& cpu, s32 threadId) { scePerf.warning("scePerfArmPmonReset(threadId=0x%x)", threadId); @@ -19,7 +33,7 @@ arm_error_code scePerfArmPmonReset(ARMv7Thread& cpu, s32 threadId) return SCE_OK; } -arm_error_code scePerfArmPmonSelectEvent(ARMv7Thread& cpu, s32 threadId, u32 counter, u8 eventCode) +error_code scePerfArmPmonSelectEvent(ARMv7Thread& cpu, s32 threadId, u32 counter, u8 eventCode) { scePerf.warning("scePerfArmPmonSelectEvent(threadId=0x%x, counter=0x%x, eventCode=0x%x)", threadId, counter, eventCode); @@ -68,7 +82,7 @@ arm_error_code scePerfArmPmonSelectEvent(ARMv7Thread& cpu, s32 threadId, u32 cou return SCE_OK; } -arm_error_code scePerfArmPmonStart(ARMv7Thread& cpu, s32 threadId) +error_code scePerfArmPmonStart(ARMv7Thread& cpu, s32 threadId) { scePerf.warning("scePerfArmPmonStart(threadId=0x%x)", threadId); @@ -77,7 +91,7 @@ arm_error_code scePerfArmPmonStart(ARMv7Thread& cpu, s32 threadId) return SCE_OK; } -arm_error_code scePerfArmPmonStop(ARMv7Thread& cpu, s32 threadId) +error_code scePerfArmPmonStop(ARMv7Thread& cpu, s32 threadId) { scePerf.warning("scePerfArmPmonStop(threadId=0x%x)"); @@ -86,7 +100,7 @@ arm_error_code scePerfArmPmonStop(ARMv7Thread& cpu, s32 threadId) return SCE_OK; } -arm_error_code scePerfArmPmonGetCounterValue(ARMv7Thread& cpu, s32 threadId, u32 counter, vm::ptr pValue) +error_code scePerfArmPmonGetCounterValue(ARMv7Thread& cpu, s32 threadId, u32 counter, vm::ptr pValue) { scePerf.warning("scePerfArmPmonGetCounterValue(threadId=0x%x, counter=%d, pValue=*0x%x)", threadId, counter, pValue); @@ -109,7 +123,7 @@ arm_error_code scePerfArmPmonGetCounterValue(ARMv7Thread& cpu, s32 threadId, u32 return SCE_OK; } -arm_error_code scePerfArmPmonSoftwareIncrement(ARMv7Thread& cpu, u32 mask) +error_code scePerfArmPmonSoftwareIncrement(ARMv7Thread& cpu, u32 mask) { scePerf.warning("scePerfArmPmonSoftwareIncrement(mask=0x%x)", mask); diff --git a/rpcs3/Emu/PSP2/Modules/scePerf.h b/rpcs3/Emu/PSP2/Modules/scePerf.h index 422a51b19b..456b0e0b62 100644 --- a/rpcs3/Emu/PSP2/Modules/scePerf.h +++ b/rpcs3/Emu/PSP2/Modules/scePerf.h @@ -8,17 +8,6 @@ enum ScePerfError : u32 SCE_PERF_ERROR_INVALID_ARGUMENT = 0x80580000, }; -template<> -inline const char* arm_error_code::print(ScePerfError error) -{ - switch (error) - { - STR_CASE(SCE_PERF_ERROR_INVALID_ARGUMENT); - } - - return nullptr; -} - enum : s32 { // Thread IDs diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index 7945cf87b0..7a86741232 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -475,4 +475,50 @@ void Emulator::Stop() } } +s32 error_code::error_report(const fmt_type_info* sup, u64 arg) +{ + std::string out; + + if (auto thread = get_current_cpu_thread()) + { + if (g_system == system_type::ps3 && thread->id >= ppu_thread::id_min) + { + if (auto func = static_cast(thread)->last_function) + { + out += "'"; + out += func; + out += "'"; + } + } + + if (g_system == system_type::psv) + { + if (auto func = static_cast(thread)->last_function) + { + out += "'"; + out += func; + out += "'"; + } + } + } + + if (out.empty()) + { + fmt::append(out, "Unknown function failed with 0x%08x", arg); + } + else + { + fmt::append(out, " failed with 0x%08x", arg); + } + + if (sup) + { + fmt::raw_append(out, " : %s", sup, fmt_args_t{arg}); + } + + LOG_ERROR(GENERAL, "%s", out); + + return static_cast(arg); +} + Emulator Emu;