From 3ae8431aef1e54f4ad9982224acfa27bdfff67c5 Mon Sep 17 00:00:00 2001 From: GPUCode Date: Mon, 11 Dec 2023 23:52:28 +0200 Subject: [PATCH] code: Rename ResultCode to Result --- src/core/file_sys/archive_backend.h | 20 +- src/core/file_sys/archive_extsavedata.cpp | 8 +- src/core/file_sys/archive_extsavedata.h | 4 +- src/core/file_sys/archive_ncch.cpp | 31 +- src/core/file_sys/archive_ncch.h | 18 +- src/core/file_sys/archive_other_savedata.cpp | 10 +- src/core/file_sys/archive_other_savedata.h | 8 +- src/core/file_sys/archive_savedata.cpp | 6 +- src/core/file_sys/archive_savedata.h | 4 +- src/core/file_sys/archive_sdmc.cpp | 38 +-- src/core/file_sys/archive_sdmc.h | 18 +- src/core/file_sys/archive_sdmcwriteonly.cpp | 6 +- src/core/file_sys/archive_sdmcwriteonly.h | 4 +- src/core/file_sys/archive_selfncch.cpp | 18 +- src/core/file_sys/archive_selfncch.h | 4 +- .../file_sys/archive_source_sd_savedata.cpp | 4 +- .../file_sys/archive_source_sd_savedata.h | 2 +- src/core/file_sys/archive_systemsavedata.cpp | 6 +- src/core/file_sys/archive_systemsavedata.h | 4 +- src/core/file_sys/errors.h | 100 +++--- src/core/file_sys/ivfc_archive.cpp | 22 +- src/core/file_sys/ivfc_archive.h | 14 +- src/core/file_sys/savedata_archive.cpp | 33 +- src/core/file_sys/savedata_archive.h | 14 +- src/core/hle/applets/applet.cpp | 12 +- src/core/hle/applets/applet.h | 20 +- src/core/hle/applets/erreula.cpp | 8 +- src/core/hle/applets/erreula.h | 6 +- src/core/hle/applets/mii_selector.cpp | 8 +- src/core/hle/applets/mii_selector.h | 6 +- src/core/hle/applets/mint.cpp | 8 +- src/core/hle/applets/mint.h | 6 +- src/core/hle/applets/swkbd.cpp | 8 +- src/core/hle/applets/swkbd.h | 6 +- src/core/hle/ipc_helpers.h | 6 +- src/core/hle/kernel/address_arbiter.cpp | 4 +- src/core/hle/kernel/address_arbiter.h | 4 +- src/core/hle/kernel/client_port.cpp | 2 +- src/core/hle/kernel/client_port.h | 2 +- src/core/hle/kernel/client_session.cpp | 2 +- src/core/hle/kernel/client_session.h | 4 +- src/core/hle/kernel/errors.h | 154 +++++---- src/core/hle/kernel/handle_table.cpp | 6 +- src/core/hle/kernel/handle_table.h | 6 +- src/core/hle/kernel/hle_ipc.cpp | 8 +- src/core/hle/kernel/hle_ipc.h | 6 +- src/core/hle/kernel/ipc.cpp | 17 +- src/core/hle/kernel/ipc.h | 11 +- src/core/hle/kernel/mutex.cpp | 10 +- src/core/hle/kernel/mutex.h | 2 +- src/core/hle/kernel/process.cpp | 18 +- src/core/hle/kernel/process.h | 19 +- src/core/hle/kernel/semaphore.cpp | 2 +- src/core/hle/kernel/semaphore.h | 2 +- src/core/hle/kernel/server_port.cpp | 2 +- src/core/hle/kernel/server_port.h | 2 +- src/core/hle/kernel/server_session.cpp | 2 +- src/core/hle/kernel/server_session.h | 4 +- src/core/hle/kernel/shared_memory.cpp | 8 +- src/core/hle/kernel/shared_memory.h | 6 +- src/core/hle/kernel/svc.cpp | 317 +++++++++--------- src/core/hle/kernel/svc_wrapper.h | 10 +- src/core/hle/kernel/thread.cpp | 6 +- src/core/hle/kernel/thread.h | 2 +- src/core/hle/kernel/vm_manager.cpp | 14 +- src/core/hle/kernel/vm_manager.h | 10 +- src/core/hle/result.h | 48 +-- src/core/hle/service/am/am.cpp | 101 +++--- src/core/hle/service/am/am.h | 6 +- src/core/hle/service/apt/applet_manager.cpp | 128 ++++--- src/core/hle/service/apt/applet_manager.h | 80 +++-- src/core/hle/service/apt/apt.cpp | 10 +- src/core/hle/service/boss/online_service.cpp | 11 +- src/core/hle/service/boss/online_service.h | 10 +- src/core/hle/service/cam/cam.cpp | 16 +- src/core/hle/service/cam/cam.h | 74 ++-- src/core/hle/service/cam/y2r_u.cpp | 25 +- src/core/hle/service/cam/y2r_u.h | 6 +- src/core/hle/service/cecd/cecd.cpp | 48 +-- src/core/hle/service/cecd/cecd.h | 8 +- src/core/hle/service/cfg/cfg.cpp | 49 ++- src/core/hle/service/cfg/cfg.h | 31 +- src/core/hle/service/csnd/csnd_snd.cpp | 8 +- src/core/hle/service/dsp/dsp_dsp.cpp | 4 +- src/core/hle/service/err/err_f.cpp | 2 +- src/core/hle/service/fs/archive.cpp | 72 ++-- src/core/hle/service/fs/archive.h | 61 ++-- src/core/hle/service/fs/file.cpp | 2 +- src/core/hle/service/fs/fs_user.cpp | 12 +- src/core/hle/service/fs/fs_user.h | 4 +- src/core/hle/service/gsp/gsp_gpu.cpp | 27 +- src/core/hle/service/http/http_c.cpp | 90 ++--- src/core/hle/service/ir/ir_user.cpp | 8 +- src/core/hle/service/ldr_ro/cro_helper.cpp | 148 ++++---- src/core/hle/service/ldr_ro/cro_helper.h | 132 ++++---- src/core/hle/service/ldr_ro/ldr_ro.cpp | 64 ++-- src/core/hle/service/nfc/nfc.cpp | 16 +- src/core/hle/service/nfc/nfc_device.cpp | 72 ++-- src/core/hle/service/nfc/nfc_device.h | 60 ++-- src/core/hle/service/nfc/nfc_results.h | 42 +-- src/core/hle/service/nim/nim_u.cpp | 8 +- src/core/hle/service/nwm/nwm_uds.cpp | 80 ++--- src/core/hle/service/nwm/nwm_uds.h | 3 +- src/core/hle/service/ps/ps_ps.cpp | 4 +- src/core/hle/service/sm/sm.cpp | 14 +- src/core/hle/service/sm/sm.h | 37 +- src/core/hle/service/sm/srv.cpp | 12 +- src/core/hle/service/soc/soc_u.h | 16 +- 108 files changed, 1385 insertions(+), 1416 deletions(-) diff --git a/src/core/file_sys/archive_backend.h b/src/core/file_sys/archive_backend.h index 8dc0f14d8..7eb3893ba 100644 --- a/src/core/file_sys/archive_backend.h +++ b/src/core/file_sys/archive_backend.h @@ -127,7 +127,7 @@ public: * @param path Path relative to the archive * @return Result of the operation */ - virtual ResultCode DeleteFile(const Path& path) const = 0; + virtual Result DeleteFile(const Path& path) const = 0; /** * Rename a File specified by its path @@ -135,21 +135,21 @@ public: * @param dest_path Destination path relative to the archive * @return Result of the operation */ - virtual ResultCode RenameFile(const Path& src_path, const Path& dest_path) const = 0; + virtual Result RenameFile(const Path& src_path, const Path& dest_path) const = 0; /** * Delete a directory specified by its path * @param path Path relative to the archive * @return Result of the operation */ - virtual ResultCode DeleteDirectory(const Path& path) const = 0; + virtual Result DeleteDirectory(const Path& path) const = 0; /** * Delete a directory specified by its path and anything under it * @param path Path relative to the archive * @return Result of the operation */ - virtual ResultCode DeleteDirectoryRecursively(const Path& path) const = 0; + virtual Result DeleteDirectoryRecursively(const Path& path) const = 0; /** * Create a file specified by its path @@ -157,14 +157,14 @@ public: * @param size The size of the new file, filled with zeroes * @return Result of the operation */ - virtual ResultCode CreateFile(const Path& path, u64 size) const = 0; + virtual Result CreateFile(const Path& path, u64 size) const = 0; /** * Create a directory specified by its path * @param path Path relative to the archive * @return Result of the operation */ - virtual ResultCode CreateDirectory(const Path& path) const = 0; + virtual Result CreateDirectory(const Path& path) const = 0; /** * Rename a Directory specified by its path @@ -172,7 +172,7 @@ public: * @param dest_path Destination path relative to the archive * @return Result of the operation */ - virtual ResultCode RenameDirectory(const Path& src_path, const Path& dest_path) const = 0; + virtual Result RenameDirectory(const Path& src_path, const Path& dest_path) const = 0; /** * Open a directory specified by its path @@ -229,10 +229,10 @@ public: * @param path Path to the archive * @param format_info Format information for the new archive * @param program_id the program ID of the client that requests the operation - * @return ResultCode of the operation, 0 on success + * @return Result of the operation, 0 on success */ - virtual ResultCode Format(const Path& path, const FileSys::ArchiveFormatInfo& format_info, - u64 program_id) = 0; + virtual Result Format(const Path& path, const FileSys::ArchiveFormatInfo& format_info, + u64 program_id) = 0; /** * Retrieves the format info about the archive with the specified path diff --git a/src/core/file_sys/archive_extsavedata.cpp b/src/core/file_sys/archive_extsavedata.cpp index 06c033467..bc8338494 100644 --- a/src/core/file_sys/archive_extsavedata.cpp +++ b/src/core/file_sys/archive_extsavedata.cpp @@ -155,7 +155,7 @@ public: std::move(delay_generator)); } - ResultCode CreateFile(const Path& path, u64 size) const override { + Result CreateFile(const Path& path, u64 size) const override { if (size == 0) { LOG_ERROR(Service_FS, "Zero-size file is not supported"); return ERROR_UNSUPPORTED_OPEN_FLAGS; @@ -259,9 +259,9 @@ ResultVal> ArchiveFactory_ExtSaveData::Open(cons return std::make_unique(fullpath, std::move(delay_generator)); } -ResultCode ArchiveFactory_ExtSaveData::Format(const Path& path, - const FileSys::ArchiveFormatInfo& format_info, - u64 program_id) { +Result ArchiveFactory_ExtSaveData::Format(const Path& path, + const FileSys::ArchiveFormatInfo& format_info, + u64 program_id) { auto corrected_path = GetCorrectedPath(path); // These folders are always created with the ExtSaveData diff --git a/src/core/file_sys/archive_extsavedata.h b/src/core/file_sys/archive_extsavedata.h index 17ed459f4..5093ecdc1 100644 --- a/src/core/file_sys/archive_extsavedata.h +++ b/src/core/file_sys/archive_extsavedata.h @@ -31,8 +31,8 @@ public: } ResultVal> Open(const Path& path, u64 program_id) override; - ResultCode Format(const Path& path, const FileSys::ArchiveFormatInfo& format_info, - u64 program_id) override; + Result Format(const Path& path, const FileSys::ArchiveFormatInfo& format_info, + u64 program_id) override; ResultVal GetFormatInfo(const Path& path, u64 program_id) const override; const std::string& GetMountPoint() const { diff --git a/src/core/file_sys/archive_ncch.cpp b/src/core/file_sys/archive_ncch.cpp index 49744efd2..252e0810c 100644 --- a/src/core/file_sys/archive_ncch.cpp +++ b/src/core/file_sys/archive_ncch.cpp @@ -180,47 +180,47 @@ ResultVal> NCCHArchive::OpenFile(const Path& path, return file; } -ResultCode NCCHArchive::DeleteFile(const Path& path) const { +Result NCCHArchive::DeleteFile(const Path& path) const { LOG_CRITICAL(Service_FS, "Attempted to delete a file from an NCCH archive ({}).", GetName()); // TODO(Subv): Verify error code - return ResultCode(ErrorDescription::NoData, ErrorModule::FS, ErrorSummary::Canceled, - ErrorLevel::Status); + return Result(ErrorDescription::NoData, ErrorModule::FS, ErrorSummary::Canceled, + ErrorLevel::Status); } -ResultCode NCCHArchive::RenameFile(const Path& src_path, const Path& dest_path) const { +Result NCCHArchive::RenameFile(const Path& src_path, const Path& dest_path) const { LOG_CRITICAL(Service_FS, "Attempted to rename a file within an NCCH archive ({}).", GetName()); // TODO(wwylele): Use correct error code return RESULT_UNKNOWN; } -ResultCode NCCHArchive::DeleteDirectory(const Path& path) const { +Result NCCHArchive::DeleteDirectory(const Path& path) const { LOG_CRITICAL(Service_FS, "Attempted to delete a directory from an NCCH archive ({}).", GetName()); // TODO(wwylele): Use correct error code return RESULT_UNKNOWN; } -ResultCode NCCHArchive::DeleteDirectoryRecursively(const Path& path) const { +Result NCCHArchive::DeleteDirectoryRecursively(const Path& path) const { LOG_CRITICAL(Service_FS, "Attempted to delete a directory from an NCCH archive ({}).", GetName()); // TODO(wwylele): Use correct error code return RESULT_UNKNOWN; } -ResultCode NCCHArchive::CreateFile(const Path& path, u64 size) const { +Result NCCHArchive::CreateFile(const Path& path, u64 size) const { LOG_CRITICAL(Service_FS, "Attempted to create a file in an NCCH archive ({}).", GetName()); // TODO: Verify error code - return ResultCode(ErrorDescription::NotAuthorized, ErrorModule::FS, ErrorSummary::NotSupported, - ErrorLevel::Permanent); + return Result(ErrorDescription::NotAuthorized, ErrorModule::FS, ErrorSummary::NotSupported, + ErrorLevel::Permanent); } -ResultCode NCCHArchive::CreateDirectory(const Path& path) const { +Result NCCHArchive::CreateDirectory(const Path& path) const { LOG_CRITICAL(Service_FS, "Attempted to create a directory in an NCCH archive ({}).", GetName()); // TODO(wwylele): Use correct error code return RESULT_UNKNOWN; } -ResultCode NCCHArchive::RenameDirectory(const Path& src_path, const Path& dest_path) const { +Result NCCHArchive::RenameDirectory(const Path& src_path, const Path& dest_path) const { LOG_CRITICAL(Service_FS, "Attempted to rename a file within an NCCH archive ({}).", GetName()); // TODO(wwylele): Use correct error code return RESULT_UNKNOWN; @@ -292,13 +292,12 @@ ResultVal> ArchiveFactory_NCCH::Open(const Path& open_path.tid, static_cast(open_path.media_type & 0xFF)); } -ResultCode ArchiveFactory_NCCH::Format(const Path& path, - const FileSys::ArchiveFormatInfo& format_info, - u64 program_id) { +Result ArchiveFactory_NCCH::Format(const Path& path, const FileSys::ArchiveFormatInfo& format_info, + u64 program_id) { LOG_ERROR(Service_FS, "Attempted to format a NCCH archive."); // TODO: Verify error code - return ResultCode(ErrorDescription::NotAuthorized, ErrorModule::FS, ErrorSummary::NotSupported, - ErrorLevel::Permanent); + return Result(ErrorDescription::NotAuthorized, ErrorModule::FS, ErrorSummary::NotSupported, + ErrorLevel::Permanent); } ResultVal ArchiveFactory_NCCH::GetFormatInfo(const Path& path, diff --git a/src/core/file_sys/archive_ncch.h b/src/core/file_sys/archive_ncch.h index 09fc28d43..3e22ef02a 100644 --- a/src/core/file_sys/archive_ncch.h +++ b/src/core/file_sys/archive_ncch.h @@ -50,13 +50,13 @@ public: ResultVal> OpenFile(const Path& path, const Mode& mode) const override; - ResultCode DeleteFile(const Path& path) const override; - ResultCode RenameFile(const Path& src_path, const Path& dest_path) const override; - ResultCode DeleteDirectory(const Path& path) const override; - ResultCode DeleteDirectoryRecursively(const Path& path) const override; - ResultCode CreateFile(const Path& path, u64 size) const override; - ResultCode CreateDirectory(const Path& path) const override; - ResultCode RenameDirectory(const Path& src_path, const Path& dest_path) const override; + Result DeleteFile(const Path& path) const override; + Result RenameFile(const Path& src_path, const Path& dest_path) const override; + Result DeleteDirectory(const Path& path) const override; + Result DeleteDirectoryRecursively(const Path& path) const override; + Result CreateFile(const Path& path, u64 size) const override; + Result CreateDirectory(const Path& path) const override; + Result RenameDirectory(const Path& src_path, const Path& dest_path) const override; ResultVal> OpenDirectory(const Path& path) const override; u64 GetFreeBytes() const override; @@ -114,8 +114,8 @@ public: } ResultVal> Open(const Path& path, u64 program_id) override; - ResultCode Format(const Path& path, const FileSys::ArchiveFormatInfo& format_info, - u64 program_id) override; + Result Format(const Path& path, const FileSys::ArchiveFormatInfo& format_info, + u64 program_id) override; ResultVal GetFormatInfo(const Path& path, u64 program_id) const override; private: diff --git a/src/core/file_sys/archive_other_savedata.cpp b/src/core/file_sys/archive_other_savedata.cpp index 319415f55..014af4a02 100644 --- a/src/core/file_sys/archive_other_savedata.cpp +++ b/src/core/file_sys/archive_other_savedata.cpp @@ -78,8 +78,9 @@ ResultVal> ArchiveFactory_OtherSaveDataPermitted return sd_savedata_source->Open(program_id); } -ResultCode ArchiveFactory_OtherSaveDataPermitted::Format( - const Path& path, const FileSys::ArchiveFormatInfo& format_info, u64 program_id) { +Result ArchiveFactory_OtherSaveDataPermitted::Format(const Path& path, + const FileSys::ArchiveFormatInfo& format_info, + u64 program_id) { LOG_ERROR(Service_FS, "Attempted to format a OtherSaveDataPermitted archive."); return ERROR_INVALID_PATH; } @@ -116,8 +117,9 @@ ResultVal> ArchiveFactory_OtherSaveDataGeneral:: return sd_savedata_source->Open(program_id); } -ResultCode ArchiveFactory_OtherSaveDataGeneral::Format( - const Path& path, const FileSys::ArchiveFormatInfo& format_info, u64 /*client_program_id*/) { +Result ArchiveFactory_OtherSaveDataGeneral::Format(const Path& path, + const FileSys::ArchiveFormatInfo& format_info, + u64 /*client_program_id*/) { MediaType media_type; u64 program_id; CASCADE_RESULT(std::tie(media_type, program_id), ParsePathGeneral(path)); diff --git a/src/core/file_sys/archive_other_savedata.h b/src/core/file_sys/archive_other_savedata.h index cc1a61b4a..c9e720a8d 100644 --- a/src/core/file_sys/archive_other_savedata.h +++ b/src/core/file_sys/archive_other_savedata.h @@ -22,8 +22,8 @@ public: } ResultVal> Open(const Path& path, u64 program_id) override; - ResultCode Format(const Path& path, const FileSys::ArchiveFormatInfo& format_info, - u64 program_id) override; + Result Format(const Path& path, const FileSys::ArchiveFormatInfo& format_info, + u64 program_id) override; ResultVal GetFormatInfo(const Path& path, u64 program_id) const override; private: @@ -49,8 +49,8 @@ public: } ResultVal> Open(const Path& path, u64 program_id) override; - ResultCode Format(const Path& path, const FileSys::ArchiveFormatInfo& format_info, - u64 program_id) override; + Result Format(const Path& path, const FileSys::ArchiveFormatInfo& format_info, + u64 program_id) override; ResultVal GetFormatInfo(const Path& path, u64 program_id) const override; private: diff --git a/src/core/file_sys/archive_savedata.cpp b/src/core/file_sys/archive_savedata.cpp index f3e2d0943..a5e767b14 100644 --- a/src/core/file_sys/archive_savedata.cpp +++ b/src/core/file_sys/archive_savedata.cpp @@ -21,9 +21,9 @@ ResultVal> ArchiveFactory_SaveData::Open(const P return sd_savedata_source->Open(program_id); } -ResultCode ArchiveFactory_SaveData::Format(const Path& path, - const FileSys::ArchiveFormatInfo& format_info, - u64 program_id) { +Result ArchiveFactory_SaveData::Format(const Path& path, + const FileSys::ArchiveFormatInfo& format_info, + u64 program_id) { return sd_savedata_source->Format(program_id, format_info); } diff --git a/src/core/file_sys/archive_savedata.h b/src/core/file_sys/archive_savedata.h index c315c33f0..dba6d5cdb 100644 --- a/src/core/file_sys/archive_savedata.h +++ b/src/core/file_sys/archive_savedata.h @@ -20,8 +20,8 @@ public: } ResultVal> Open(const Path& path, u64 program_id) override; - ResultCode Format(const Path& path, const FileSys::ArchiveFormatInfo& format_info, - u64 program_id) override; + Result Format(const Path& path, const FileSys::ArchiveFormatInfo& format_info, + u64 program_id) override; ResultVal GetFormatInfo(const Path& path, u64 program_id) const override; diff --git a/src/core/file_sys/archive_sdmc.cpp b/src/core/file_sys/archive_sdmc.cpp index 994108a68..b72cb2833 100644 --- a/src/core/file_sys/archive_sdmc.cpp +++ b/src/core/file_sys/archive_sdmc.cpp @@ -112,7 +112,7 @@ ResultVal> SDMCArchive::OpenFileBase(const Path& pa return std::make_unique(std::move(file), mode, std::move(delay_generator)); } -ResultCode SDMCArchive::DeleteFile(const Path& path) const { +Result SDMCArchive::DeleteFile(const Path& path) const { const PathParser path_parser(path); if (!path_parser.IsValid()) { @@ -146,7 +146,7 @@ ResultCode SDMCArchive::DeleteFile(const Path& path) const { return ERROR_NOT_FOUND; } -ResultCode SDMCArchive::RenameFile(const Path& src_path, const Path& dest_path) const { +Result SDMCArchive::RenameFile(const Path& src_path, const Path& dest_path) const { const PathParser path_parser_src(src_path); // TODO: Verify these return codes with HW @@ -171,13 +171,12 @@ ResultCode SDMCArchive::RenameFile(const Path& src_path, const Path& dest_path) // TODO(yuriks): This code probably isn't right, it'll return a Status even if the file didn't // exist or similar. Verify. - return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description - ErrorSummary::NothingHappened, ErrorLevel::Status); + return Result(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description + ErrorSummary::NothingHappened, ErrorLevel::Status); } template -static ResultCode DeleteDirectoryHelper(const Path& path, const std::string& mount_point, - T deleter) { +static Result DeleteDirectoryHelper(const Path& path, const std::string& mount_point, T deleter) { const PathParser path_parser(path); if (!path_parser.IsValid()) { @@ -214,16 +213,16 @@ static ResultCode DeleteDirectoryHelper(const Path& path, const std::string& mou return ERROR_UNEXPECTED_FILE_OR_DIRECTORY_SDMC; } -ResultCode SDMCArchive::DeleteDirectory(const Path& path) const { +Result SDMCArchive::DeleteDirectory(const Path& path) const { return DeleteDirectoryHelper(path, mount_point, FileUtil::DeleteDir); } -ResultCode SDMCArchive::DeleteDirectoryRecursively(const Path& path) const { +Result SDMCArchive::DeleteDirectoryRecursively(const Path& path) const { return DeleteDirectoryHelper( path, mount_point, [](const std::string& p) { return FileUtil::DeleteDirRecursively(p); }); } -ResultCode SDMCArchive::CreateFile(const FileSys::Path& path, u64 size) const { +Result SDMCArchive::CreateFile(const FileSys::Path& path, u64 size) const { const PathParser path_parser(path); if (!path_parser.IsValid()) { @@ -264,11 +263,11 @@ ResultCode SDMCArchive::CreateFile(const FileSys::Path& path, u64 size) const { } LOG_ERROR(Service_FS, "Too large file"); - return ResultCode(ErrorDescription::TooLarge, ErrorModule::FS, ErrorSummary::OutOfResource, - ErrorLevel::Info); + return Result(ErrorDescription::TooLarge, ErrorModule::FS, ErrorSummary::OutOfResource, + ErrorLevel::Info); } -ResultCode SDMCArchive::CreateDirectory(const Path& path) const { +Result SDMCArchive::CreateDirectory(const Path& path) const { const PathParser path_parser(path); if (!path_parser.IsValid()) { @@ -299,11 +298,11 @@ ResultCode SDMCArchive::CreateDirectory(const Path& path) const { } LOG_CRITICAL(Service_FS, "(unreachable) Unknown error creating {}", mount_point); - return ResultCode(ErrorDescription::NoData, ErrorModule::FS, ErrorSummary::Canceled, - ErrorLevel::Status); + return Result(ErrorDescription::NoData, ErrorModule::FS, ErrorSummary::Canceled, + ErrorLevel::Status); } -ResultCode SDMCArchive::RenameDirectory(const Path& src_path, const Path& dest_path) const { +Result SDMCArchive::RenameDirectory(const Path& src_path, const Path& dest_path) const { const PathParser path_parser_src(src_path); // TODO: Verify these return codes with HW @@ -328,8 +327,8 @@ ResultCode SDMCArchive::RenameDirectory(const Path& src_path, const Path& dest_p // TODO(yuriks): This code probably isn't right, it'll return a Status even if the file didn't // exist or similar. Verify. - return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description - ErrorSummary::NothingHappened, ErrorLevel::Status); + return Result(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description + ErrorSummary::NothingHappened, ErrorLevel::Status); } ResultVal> SDMCArchive::OpenDirectory(const Path& path) const { @@ -392,9 +391,8 @@ ResultVal> ArchiveFactory_SDMC::Open(const Path& return std::make_unique(sdmc_directory, std::move(delay_generator)); } -ResultCode ArchiveFactory_SDMC::Format(const Path& path, - const FileSys::ArchiveFormatInfo& format_info, - u64 program_id) { +Result ArchiveFactory_SDMC::Format(const Path& path, const FileSys::ArchiveFormatInfo& format_info, + u64 program_id) { // This is kind of an undesirable operation, so let's just ignore it. :) return RESULT_SUCCESS; } diff --git a/src/core/file_sys/archive_sdmc.h b/src/core/file_sys/archive_sdmc.h index 253d3df7c..267b1dfdf 100644 --- a/src/core/file_sys/archive_sdmc.h +++ b/src/core/file_sys/archive_sdmc.h @@ -29,13 +29,13 @@ public: ResultVal> OpenFile(const Path& path, const Mode& mode) const override; - ResultCode DeleteFile(const Path& path) const override; - ResultCode RenameFile(const Path& src_path, const Path& dest_path) const override; - ResultCode DeleteDirectory(const Path& path) const override; - ResultCode DeleteDirectoryRecursively(const Path& path) const override; - ResultCode CreateFile(const Path& path, u64 size) const override; - ResultCode CreateDirectory(const Path& path) const override; - ResultCode RenameDirectory(const Path& src_path, const Path& dest_path) const override; + Result DeleteFile(const Path& path) const override; + Result RenameFile(const Path& src_path, const Path& dest_path) const override; + Result DeleteDirectory(const Path& path) const override; + Result DeleteDirectoryRecursively(const Path& path) const override; + Result CreateFile(const Path& path, u64 size) const override; + Result CreateDirectory(const Path& path) const override; + Result RenameDirectory(const Path& src_path, const Path& dest_path) const override; ResultVal> OpenDirectory(const Path& path) const override; u64 GetFreeBytes() const override; @@ -68,8 +68,8 @@ public: } ResultVal> Open(const Path& path, u64 program_id) override; - ResultCode Format(const Path& path, const FileSys::ArchiveFormatInfo& format_info, - u64 program_id) override; + Result Format(const Path& path, const FileSys::ArchiveFormatInfo& format_info, + u64 program_id) override; ResultVal GetFormatInfo(const Path& path, u64 program_id) const override; private: diff --git a/src/core/file_sys/archive_sdmcwriteonly.cpp b/src/core/file_sys/archive_sdmcwriteonly.cpp index 102279d68..b549eddbb 100644 --- a/src/core/file_sys/archive_sdmcwriteonly.cpp +++ b/src/core/file_sys/archive_sdmcwriteonly.cpp @@ -81,9 +81,9 @@ ResultVal> ArchiveFactory_SDMCWriteOnly::Open(co return std::make_unique(sdmc_directory, std::move(delay_generator)); } -ResultCode ArchiveFactory_SDMCWriteOnly::Format(const Path& path, - const FileSys::ArchiveFormatInfo& format_info, - u64 program_id) { +Result ArchiveFactory_SDMCWriteOnly::Format(const Path& path, + const FileSys::ArchiveFormatInfo& format_info, + u64 program_id) { // TODO(wwylele): hwtest this LOG_ERROR(Service_FS, "Attempted to format a SDMC write-only archive."); return RESULT_UNKNOWN; diff --git a/src/core/file_sys/archive_sdmcwriteonly.h b/src/core/file_sys/archive_sdmcwriteonly.h index 1bba375ba..c05f408d9 100644 --- a/src/core/file_sys/archive_sdmcwriteonly.h +++ b/src/core/file_sys/archive_sdmcwriteonly.h @@ -54,8 +54,8 @@ public: } ResultVal> Open(const Path& path, u64 program_id) override; - ResultCode Format(const Path& path, const FileSys::ArchiveFormatInfo& format_info, - u64 program_id) override; + Result Format(const Path& path, const FileSys::ArchiveFormatInfo& format_info, + u64 program_id) override; ResultVal GetFormatInfo(const Path& path, u64 program_id) const override; private: diff --git a/src/core/file_sys/archive_selfncch.cpp b/src/core/file_sys/archive_selfncch.cpp index b0955f1e7..5827340f1 100644 --- a/src/core/file_sys/archive_selfncch.cpp +++ b/src/core/file_sys/archive_selfncch.cpp @@ -134,37 +134,37 @@ public: } } - ResultCode DeleteFile(const Path& path) const override { + Result DeleteFile(const Path& path) const override { LOG_ERROR(Service_FS, "Unsupported"); return ERROR_UNSUPPORTED_OPEN_FLAGS; } - ResultCode RenameFile(const Path& src_path, const Path& dest_path) const override { + Result RenameFile(const Path& src_path, const Path& dest_path) const override { LOG_ERROR(Service_FS, "Unsupported"); return ERROR_UNSUPPORTED_OPEN_FLAGS; } - ResultCode DeleteDirectory(const Path& path) const override { + Result DeleteDirectory(const Path& path) const override { LOG_ERROR(Service_FS, "Unsupported"); return ERROR_UNSUPPORTED_OPEN_FLAGS; } - ResultCode DeleteDirectoryRecursively(const Path& path) const override { + Result DeleteDirectoryRecursively(const Path& path) const override { LOG_ERROR(Service_FS, "Unsupported"); return ERROR_UNSUPPORTED_OPEN_FLAGS; } - ResultCode CreateFile(const Path& path, u64 size) const override { + Result CreateFile(const Path& path, u64 size) const override { LOG_ERROR(Service_FS, "Unsupported"); return ERROR_UNSUPPORTED_OPEN_FLAGS; } - ResultCode CreateDirectory(const Path& path) const override { + Result CreateDirectory(const Path& path) const override { LOG_ERROR(Service_FS, "Unsupported"); return ERROR_UNSUPPORTED_OPEN_FLAGS; } - ResultCode RenameDirectory(const Path& src_path, const Path& dest_path) const override { + Result RenameDirectory(const Path& src_path, const Path& dest_path) const override { LOG_ERROR(Service_FS, "Unsupported"); return ERROR_UNSUPPORTED_OPEN_FLAGS; } @@ -296,8 +296,8 @@ ResultVal> ArchiveFactory_SelfNCCH::Open(const P return std::make_unique(ncch_data[program_id]); } -ResultCode ArchiveFactory_SelfNCCH::Format(const Path&, const FileSys::ArchiveFormatInfo&, - u64 program_id) { +Result ArchiveFactory_SelfNCCH::Format(const Path&, const FileSys::ArchiveFormatInfo&, + u64 program_id) { LOG_ERROR(Service_FS, "Attempted to format a SelfNCCH archive."); return ERROR_INVALID_PATH; } diff --git a/src/core/file_sys/archive_selfncch.h b/src/core/file_sys/archive_selfncch.h index 19a001444..0643faf63 100644 --- a/src/core/file_sys/archive_selfncch.h +++ b/src/core/file_sys/archive_selfncch.h @@ -50,8 +50,8 @@ public: return "SelfNCCH"; } ResultVal> Open(const Path& path, u64 program_id) override; - ResultCode Format(const Path& path, const FileSys::ArchiveFormatInfo& format_info, - u64 program_id) override; + Result Format(const Path& path, const FileSys::ArchiveFormatInfo& format_info, + u64 program_id) override; ResultVal GetFormatInfo(const Path& path, u64 program_id) const override; private: diff --git a/src/core/file_sys/archive_source_sd_savedata.cpp b/src/core/file_sys/archive_source_sd_savedata.cpp index de2a06cbb..4f5d6d042 100644 --- a/src/core/file_sys/archive_source_sd_savedata.cpp +++ b/src/core/file_sys/archive_source_sd_savedata.cpp @@ -53,8 +53,8 @@ ResultVal> ArchiveSource_SDSaveData::Open(u64 pr return std::make_unique(std::move(concrete_mount_point)); } -ResultCode ArchiveSource_SDSaveData::Format(u64 program_id, - const FileSys::ArchiveFormatInfo& format_info) { +Result ArchiveSource_SDSaveData::Format(u64 program_id, + const FileSys::ArchiveFormatInfo& format_info) { std::string concrete_mount_point = GetSaveDataPath(mount_point, program_id); FileUtil::DeleteDirRecursively(concrete_mount_point); FileUtil::CreateFullPath(concrete_mount_point); diff --git a/src/core/file_sys/archive_source_sd_savedata.h b/src/core/file_sys/archive_source_sd_savedata.h index c8ceb047e..07832c3ae 100644 --- a/src/core/file_sys/archive_source_sd_savedata.h +++ b/src/core/file_sys/archive_source_sd_savedata.h @@ -19,7 +19,7 @@ public: explicit ArchiveSource_SDSaveData(const std::string& mount_point); ResultVal> Open(u64 program_id); - ResultCode Format(u64 program_id, const FileSys::ArchiveFormatInfo& format_info); + Result Format(u64 program_id, const FileSys::ArchiveFormatInfo& format_info); ResultVal GetFormatInfo(u64 program_id) const; static std::string GetSaveDataPathFor(const std::string& mount_point, u64 program_id); diff --git a/src/core/file_sys/archive_systemsavedata.cpp b/src/core/file_sys/archive_systemsavedata.cpp index d1e285571..064cca4c1 100644 --- a/src/core/file_sys/archive_systemsavedata.cpp +++ b/src/core/file_sys/archive_systemsavedata.cpp @@ -62,9 +62,9 @@ ResultVal> ArchiveFactory_SystemSaveData::Open(c return std::make_unique(fullpath); } -ResultCode ArchiveFactory_SystemSaveData::Format(const Path& path, - const FileSys::ArchiveFormatInfo& format_info, - u64 program_id) { +Result ArchiveFactory_SystemSaveData::Format(const Path& path, + const FileSys::ArchiveFormatInfo& format_info, + u64 program_id) { std::string fullpath = GetSystemSaveDataPath(base_path, path); FileUtil::DeleteDirRecursively(fullpath); FileUtil::CreateFullPath(fullpath); diff --git a/src/core/file_sys/archive_systemsavedata.h b/src/core/file_sys/archive_systemsavedata.h index d81c111e8..af7c341e2 100644 --- a/src/core/file_sys/archive_systemsavedata.h +++ b/src/core/file_sys/archive_systemsavedata.h @@ -20,8 +20,8 @@ public: explicit ArchiveFactory_SystemSaveData(const std::string& mount_point); ResultVal> Open(const Path& path, u64 program_id) override; - ResultCode Format(const Path& path, const FileSys::ArchiveFormatInfo& format_info, - u64 program_id) override; + Result Format(const Path& path, const FileSys::ArchiveFormatInfo& format_info, + u64 program_id) override; ResultVal GetFormatInfo(const Path& path, u64 program_id) const override; std::string GetName() const override { diff --git a/src/core/file_sys/errors.h b/src/core/file_sys/errors.h index 38156e4f0..b66421012 100644 --- a/src/core/file_sys/errors.h +++ b/src/core/file_sys/errors.h @@ -35,63 +35,61 @@ enum { }; } -constexpr ResultCode ERROR_INVALID_PATH(ErrCodes::InvalidPath, ErrorModule::FS, - ErrorSummary::InvalidArgument, ErrorLevel::Usage); -constexpr ResultCode ERROR_UNSUPPORTED_OPEN_FLAGS(ErrCodes::UnsupportedOpenFlags, ErrorModule::FS, - ErrorSummary::NotSupported, ErrorLevel::Usage); -constexpr ResultCode ERROR_INVALID_OPEN_FLAGS(ErrCodes::InvalidOpenFlags, ErrorModule::FS, - ErrorSummary::Canceled, ErrorLevel::Status); -constexpr ResultCode ERROR_INVALID_READ_FLAG(ErrCodes::InvalidReadFlag, ErrorModule::FS, - ErrorSummary::InvalidArgument, ErrorLevel::Usage); -constexpr ResultCode ERROR_FILE_NOT_FOUND(ErrCodes::FileNotFound, ErrorModule::FS, - ErrorSummary::NotFound, ErrorLevel::Status); -constexpr ResultCode ERROR_PATH_NOT_FOUND(ErrCodes::PathNotFound, ErrorModule::FS, - ErrorSummary::NotFound, ErrorLevel::Status); -constexpr ResultCode ERROR_NOT_FOUND(ErrCodes::NotFound, ErrorModule::FS, ErrorSummary::NotFound, - ErrorLevel::Status); -constexpr ResultCode ERROR_UNEXPECTED_FILE_OR_DIRECTORY(ErrCodes::UnexpectedFileOrDirectory, - ErrorModule::FS, ErrorSummary::NotSupported, - ErrorLevel::Usage); -constexpr ResultCode ERROR_UNEXPECTED_FILE_OR_DIRECTORY_SDMC(ErrCodes::NotAFile, ErrorModule::FS, - ErrorSummary::Canceled, - ErrorLevel::Status); -constexpr ResultCode ERROR_DIRECTORY_ALREADY_EXISTS(ErrCodes::DirectoryAlreadyExists, - ErrorModule::FS, ErrorSummary::NothingHappened, - ErrorLevel::Status); -constexpr ResultCode ERROR_FILE_ALREADY_EXISTS(ErrCodes::FileAlreadyExists, ErrorModule::FS, - ErrorSummary::NothingHappened, ErrorLevel::Status); -constexpr ResultCode ERROR_ALREADY_EXISTS(ErrCodes::AlreadyExists, ErrorModule::FS, - ErrorSummary::NothingHappened, ErrorLevel::Status); -constexpr ResultCode ERROR_DIRECTORY_NOT_EMPTY(ErrCodes::DirectoryNotEmpty, ErrorModule::FS, - ErrorSummary::Canceled, ErrorLevel::Status); -constexpr ResultCode ERROR_GAMECARD_NOT_INSERTED(ErrCodes::GameCardNotInserted, ErrorModule::FS, - ErrorSummary::NotFound, ErrorLevel::Status); -constexpr ResultCode ERROR_INCORRECT_EXEFS_READ_SIZE(ErrCodes::IncorrectExeFSReadSize, - ErrorModule::FS, ErrorSummary::NotSupported, - ErrorLevel::Usage); -constexpr ResultCode ERROR_ROMFS_NOT_FOUND(ErrCodes::RomFSNotFound, ErrorModule::FS, - ErrorSummary::NotFound, ErrorLevel::Status); -constexpr ResultCode ERROR_COMMAND_NOT_ALLOWED(ErrCodes::CommandNotAllowed, ErrorModule::FS, - ErrorSummary::WrongArgument, ErrorLevel::Permanent); -constexpr ResultCode ERROR_EXEFS_SECTION_NOT_FOUND(ErrCodes::ExeFSSectionNotFound, ErrorModule::FS, - ErrorSummary::NotFound, ErrorLevel::Status); -constexpr ResultCode ERROR_INSUFFICIENT_SPACE(ErrCodes::InsufficientSpace, ErrorModule::FS, - ErrorSummary::OutOfResource, ErrorLevel::Status); +constexpr Result ERROR_INVALID_PATH(ErrCodes::InvalidPath, ErrorModule::FS, + ErrorSummary::InvalidArgument, ErrorLevel::Usage); +constexpr Result ERROR_UNSUPPORTED_OPEN_FLAGS(ErrCodes::UnsupportedOpenFlags, ErrorModule::FS, + ErrorSummary::NotSupported, ErrorLevel::Usage); +constexpr Result ERROR_INVALID_OPEN_FLAGS(ErrCodes::InvalidOpenFlags, ErrorModule::FS, + ErrorSummary::Canceled, ErrorLevel::Status); +constexpr Result ERROR_INVALID_READ_FLAG(ErrCodes::InvalidReadFlag, ErrorModule::FS, + ErrorSummary::InvalidArgument, ErrorLevel::Usage); +constexpr Result ERROR_FILE_NOT_FOUND(ErrCodes::FileNotFound, ErrorModule::FS, + ErrorSummary::NotFound, ErrorLevel::Status); +constexpr Result ERROR_PATH_NOT_FOUND(ErrCodes::PathNotFound, ErrorModule::FS, + ErrorSummary::NotFound, ErrorLevel::Status); +constexpr Result ERROR_NOT_FOUND(ErrCodes::NotFound, ErrorModule::FS, ErrorSummary::NotFound, + ErrorLevel::Status); +constexpr Result ERROR_UNEXPECTED_FILE_OR_DIRECTORY(ErrCodes::UnexpectedFileOrDirectory, + ErrorModule::FS, ErrorSummary::NotSupported, + ErrorLevel::Usage); +constexpr Result ERROR_UNEXPECTED_FILE_OR_DIRECTORY_SDMC(ErrCodes::NotAFile, ErrorModule::FS, + ErrorSummary::Canceled, + ErrorLevel::Status); +constexpr Result ERROR_DIRECTORY_ALREADY_EXISTS(ErrCodes::DirectoryAlreadyExists, ErrorModule::FS, + ErrorSummary::NothingHappened, ErrorLevel::Status); +constexpr Result ERROR_FILE_ALREADY_EXISTS(ErrCodes::FileAlreadyExists, ErrorModule::FS, + ErrorSummary::NothingHappened, ErrorLevel::Status); +constexpr Result ERROR_ALREADY_EXISTS(ErrCodes::AlreadyExists, ErrorModule::FS, + ErrorSummary::NothingHappened, ErrorLevel::Status); +constexpr Result ERROR_DIRECTORY_NOT_EMPTY(ErrCodes::DirectoryNotEmpty, ErrorModule::FS, + ErrorSummary::Canceled, ErrorLevel::Status); +constexpr Result ERROR_GAMECARD_NOT_INSERTED(ErrCodes::GameCardNotInserted, ErrorModule::FS, + ErrorSummary::NotFound, ErrorLevel::Status); +constexpr Result ERROR_INCORRECT_EXEFS_READ_SIZE(ErrCodes::IncorrectExeFSReadSize, ErrorModule::FS, + ErrorSummary::NotSupported, ErrorLevel::Usage); +constexpr Result ERROR_ROMFS_NOT_FOUND(ErrCodes::RomFSNotFound, ErrorModule::FS, + ErrorSummary::NotFound, ErrorLevel::Status); +constexpr Result ERROR_COMMAND_NOT_ALLOWED(ErrCodes::CommandNotAllowed, ErrorModule::FS, + ErrorSummary::WrongArgument, ErrorLevel::Permanent); +constexpr Result ERROR_EXEFS_SECTION_NOT_FOUND(ErrCodes::ExeFSSectionNotFound, ErrorModule::FS, + ErrorSummary::NotFound, ErrorLevel::Status); +constexpr Result ERROR_INSUFFICIENT_SPACE(ErrCodes::InsufficientSpace, ErrorModule::FS, + ErrorSummary::OutOfResource, ErrorLevel::Status); /// Returned when a function is passed an invalid archive handle. -constexpr ResultCode ERR_INVALID_ARCHIVE_HANDLE(ErrCodes::ArchiveNotMounted, ErrorModule::FS, - ErrorSummary::NotFound, - ErrorLevel::Status); // 0xC8804465 -constexpr ResultCode ERR_WRITE_BEYOND_END(ErrCodes::WriteBeyondEnd, ErrorModule::FS, - ErrorSummary::InvalidArgument, ErrorLevel::Usage); +constexpr Result ERR_INVALID_ARCHIVE_HANDLE(ErrCodes::ArchiveNotMounted, ErrorModule::FS, + ErrorSummary::NotFound, + ErrorLevel::Status); // 0xC8804465 +constexpr Result ERR_WRITE_BEYOND_END(ErrCodes::WriteBeyondEnd, ErrorModule::FS, + ErrorSummary::InvalidArgument, ErrorLevel::Usage); /** * Variant of ERROR_NOT_FOUND returned in some places in the code. Unknown if these usages are * correct or a bug. */ -constexpr ResultCode ERR_NOT_FOUND_INVALID_STATE(ErrCodes::NotFound, ErrorModule::FS, - ErrorSummary::InvalidState, ErrorLevel::Status); -constexpr ResultCode ERR_NOT_FORMATTED(ErrCodes::NotFormatted, ErrorModule::FS, - ErrorSummary::InvalidState, ErrorLevel::Status); +constexpr Result ERR_NOT_FOUND_INVALID_STATE(ErrCodes::NotFound, ErrorModule::FS, + ErrorSummary::InvalidState, ErrorLevel::Status); +constexpr Result ERR_NOT_FORMATTED(ErrCodes::NotFormatted, ErrorModule::FS, + ErrorSummary::InvalidState, ErrorLevel::Status); } // namespace FileSys diff --git a/src/core/file_sys/ivfc_archive.cpp b/src/core/file_sys/ivfc_archive.cpp index d5d46e0ef..3681775af 100644 --- a/src/core/file_sys/ivfc_archive.cpp +++ b/src/core/file_sys/ivfc_archive.cpp @@ -34,47 +34,47 @@ ResultVal> IVFCArchive::OpenFile(const Path& path, return std::make_unique(romfs_file, std::move(delay_generator)); } -ResultCode IVFCArchive::DeleteFile(const Path& path) const { +Result IVFCArchive::DeleteFile(const Path& path) const { LOG_CRITICAL(Service_FS, "Attempted to delete a file from an IVFC archive ({}).", GetName()); // TODO(Subv): Verify error code - return ResultCode(ErrorDescription::NoData, ErrorModule::FS, ErrorSummary::Canceled, - ErrorLevel::Status); + return Result(ErrorDescription::NoData, ErrorModule::FS, ErrorSummary::Canceled, + ErrorLevel::Status); } -ResultCode IVFCArchive::RenameFile(const Path& src_path, const Path& dest_path) const { +Result IVFCArchive::RenameFile(const Path& src_path, const Path& dest_path) const { LOG_CRITICAL(Service_FS, "Attempted to rename a file within an IVFC archive ({}).", GetName()); // TODO(wwylele): Use correct error code return RESULT_UNKNOWN; } -ResultCode IVFCArchive::DeleteDirectory(const Path& path) const { +Result IVFCArchive::DeleteDirectory(const Path& path) const { LOG_CRITICAL(Service_FS, "Attempted to delete a directory from an IVFC archive ({}).", GetName()); // TODO(wwylele): Use correct error code return RESULT_UNKNOWN; } -ResultCode IVFCArchive::DeleteDirectoryRecursively(const Path& path) const { +Result IVFCArchive::DeleteDirectoryRecursively(const Path& path) const { LOG_CRITICAL(Service_FS, "Attempted to delete a directory from an IVFC archive ({}).", GetName()); // TODO(wwylele): Use correct error code return RESULT_UNKNOWN; } -ResultCode IVFCArchive::CreateFile(const Path& path, u64 size) const { +Result IVFCArchive::CreateFile(const Path& path, u64 size) const { LOG_CRITICAL(Service_FS, "Attempted to create a file in an IVFC archive ({}).", GetName()); // TODO: Verify error code - return ResultCode(ErrorDescription::NotAuthorized, ErrorModule::FS, ErrorSummary::NotSupported, - ErrorLevel::Permanent); + return Result(ErrorDescription::NotAuthorized, ErrorModule::FS, ErrorSummary::NotSupported, + ErrorLevel::Permanent); } -ResultCode IVFCArchive::CreateDirectory(const Path& path) const { +Result IVFCArchive::CreateDirectory(const Path& path) const { LOG_CRITICAL(Service_FS, "Attempted to create a directory in an IVFC archive ({}).", GetName()); // TODO(wwylele): Use correct error code return RESULT_UNKNOWN; } -ResultCode IVFCArchive::RenameDirectory(const Path& src_path, const Path& dest_path) const { +Result IVFCArchive::RenameDirectory(const Path& src_path, const Path& dest_path) const { LOG_CRITICAL(Service_FS, "Attempted to rename a file within an IVFC archive ({}).", GetName()); // TODO(wwylele): Use correct error code return RESULT_UNKNOWN; diff --git a/src/core/file_sys/ivfc_archive.h b/src/core/file_sys/ivfc_archive.h index 0c0f7969e..765e41444 100644 --- a/src/core/file_sys/ivfc_archive.h +++ b/src/core/file_sys/ivfc_archive.h @@ -103,13 +103,13 @@ public: ResultVal> OpenFile(const Path& path, const Mode& mode) const override; - ResultCode DeleteFile(const Path& path) const override; - ResultCode RenameFile(const Path& src_path, const Path& dest_path) const override; - ResultCode DeleteDirectory(const Path& path) const override; - ResultCode DeleteDirectoryRecursively(const Path& path) const override; - ResultCode CreateFile(const Path& path, u64 size) const override; - ResultCode CreateDirectory(const Path& path) const override; - ResultCode RenameDirectory(const Path& src_path, const Path& dest_path) const override; + Result DeleteFile(const Path& path) const override; + Result RenameFile(const Path& src_path, const Path& dest_path) const override; + Result DeleteDirectory(const Path& path) const override; + Result DeleteDirectoryRecursively(const Path& path) const override; + Result CreateFile(const Path& path, u64 size) const override; + Result CreateDirectory(const Path& path) const override; + Result RenameDirectory(const Path& src_path, const Path& dest_path) const override; ResultVal> OpenDirectory(const Path& path) const override; u64 GetFreeBytes() const override; diff --git a/src/core/file_sys/savedata_archive.cpp b/src/core/file_sys/savedata_archive.cpp index 63a905560..4af4d9cdd 100644 --- a/src/core/file_sys/savedata_archive.cpp +++ b/src/core/file_sys/savedata_archive.cpp @@ -93,7 +93,7 @@ ResultVal> SaveDataArchive::OpenFile(const Path& pa return std::make_unique(std::move(file), mode, std::move(delay_generator)); } -ResultCode SaveDataArchive::DeleteFile(const Path& path) const { +Result SaveDataArchive::DeleteFile(const Path& path) const { const PathParser path_parser(path); if (!path_parser.IsValid()) { @@ -127,7 +127,7 @@ ResultCode SaveDataArchive::DeleteFile(const Path& path) const { return ERROR_FILE_NOT_FOUND; } -ResultCode SaveDataArchive::RenameFile(const Path& src_path, const Path& dest_path) const { +Result SaveDataArchive::RenameFile(const Path& src_path, const Path& dest_path) const { const PathParser path_parser_src(src_path); // TODO: Verify these return codes with HW @@ -152,13 +152,12 @@ ResultCode SaveDataArchive::RenameFile(const Path& src_path, const Path& dest_pa // TODO(yuriks): This code probably isn't right, it'll return a Status even if the file didn't // exist or similar. Verify. - return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description - ErrorSummary::NothingHappened, ErrorLevel::Status); + return Result(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description + ErrorSummary::NothingHappened, ErrorLevel::Status); } template -static ResultCode DeleteDirectoryHelper(const Path& path, const std::string& mount_point, - T deleter) { +static Result DeleteDirectoryHelper(const Path& path, const std::string& mount_point, T deleter) { const PathParser path_parser(path); if (!path_parser.IsValid()) { @@ -195,16 +194,16 @@ static ResultCode DeleteDirectoryHelper(const Path& path, const std::string& mou return ERROR_DIRECTORY_NOT_EMPTY; } -ResultCode SaveDataArchive::DeleteDirectory(const Path& path) const { +Result SaveDataArchive::DeleteDirectory(const Path& path) const { return DeleteDirectoryHelper(path, mount_point, FileUtil::DeleteDir); } -ResultCode SaveDataArchive::DeleteDirectoryRecursively(const Path& path) const { +Result SaveDataArchive::DeleteDirectoryRecursively(const Path& path) const { return DeleteDirectoryHelper( path, mount_point, [](const std::string& p) { return FileUtil::DeleteDirRecursively(p); }); } -ResultCode SaveDataArchive::CreateFile(const FileSys::Path& path, u64 size) const { +Result SaveDataArchive::CreateFile(const FileSys::Path& path, u64 size) const { const PathParser path_parser(path); if (!path_parser.IsValid()) { @@ -245,11 +244,11 @@ ResultCode SaveDataArchive::CreateFile(const FileSys::Path& path, u64 size) cons } LOG_ERROR(Service_FS, "Too large file"); - return ResultCode(ErrorDescription::TooLarge, ErrorModule::FS, ErrorSummary::OutOfResource, - ErrorLevel::Info); + return Result(ErrorDescription::TooLarge, ErrorModule::FS, ErrorSummary::OutOfResource, + ErrorLevel::Info); } -ResultCode SaveDataArchive::CreateDirectory(const Path& path) const { +Result SaveDataArchive::CreateDirectory(const Path& path) const { const PathParser path_parser(path); if (!path_parser.IsValid()) { @@ -282,11 +281,11 @@ ResultCode SaveDataArchive::CreateDirectory(const Path& path) const { } LOG_CRITICAL(Service_FS, "(unreachable) Unknown error creating {}", mount_point); - return ResultCode(ErrorDescription::NoData, ErrorModule::FS, ErrorSummary::Canceled, - ErrorLevel::Status); + return Result(ErrorDescription::NoData, ErrorModule::FS, ErrorSummary::Canceled, + ErrorLevel::Status); } -ResultCode SaveDataArchive::RenameDirectory(const Path& src_path, const Path& dest_path) const { +Result SaveDataArchive::RenameDirectory(const Path& src_path, const Path& dest_path) const { const PathParser path_parser_src(src_path); // TODO: Verify these return codes with HW @@ -311,8 +310,8 @@ ResultCode SaveDataArchive::RenameDirectory(const Path& src_path, const Path& de // TODO(yuriks): This code probably isn't right, it'll return a Status even if the file didn't // exist or similar. Verify. - return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description - ErrorSummary::NothingHappened, ErrorLevel::Status); + return Result(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description + ErrorSummary::NothingHappened, ErrorLevel::Status); } ResultVal> SaveDataArchive::OpenDirectory( diff --git a/src/core/file_sys/savedata_archive.h b/src/core/file_sys/savedata_archive.h index f438b182d..e243dc1c0 100644 --- a/src/core/file_sys/savedata_archive.h +++ b/src/core/file_sys/savedata_archive.h @@ -23,13 +23,13 @@ public: ResultVal> OpenFile(const Path& path, const Mode& mode) const override; - ResultCode DeleteFile(const Path& path) const override; - ResultCode RenameFile(const Path& src_path, const Path& dest_path) const override; - ResultCode DeleteDirectory(const Path& path) const override; - ResultCode DeleteDirectoryRecursively(const Path& path) const override; - ResultCode CreateFile(const Path& path, u64 size) const override; - ResultCode CreateDirectory(const Path& path) const override; - ResultCode RenameDirectory(const Path& src_path, const Path& dest_path) const override; + Result DeleteFile(const Path& path) const override; + Result RenameFile(const Path& src_path, const Path& dest_path) const override; + Result DeleteDirectory(const Path& path) const override; + Result DeleteDirectoryRecursively(const Path& path) const override; + Result CreateFile(const Path& path, u64 size) const override; + Result CreateDirectory(const Path& path) const override; + Result RenameDirectory(const Path& src_path, const Path& dest_path) const override; ResultVal> OpenDirectory(const Path& path) const override; u64 GetFreeBytes() const override; diff --git a/src/core/hle/applets/applet.cpp b/src/core/hle/applets/applet.cpp index d8b03704d..6e17762d8 100644 --- a/src/core/hle/applets/applet.cpp +++ b/src/core/hle/applets/applet.cpp @@ -26,8 +26,8 @@ static Core::TimingEventType* applet_update_event = nullptr; /// The interval at which the Applet update callback will be called, 16.6ms static const u64 applet_update_interval_us = 16666; -ResultCode Applet::Create(Service::APT::AppletId id, Service::APT::AppletId parent, bool preload, - const std::shared_ptr& manager) { +Result Applet::Create(Service::APT::AppletId id, Service::APT::AppletId parent, bool preload, + const std::shared_ptr& manager) { switch (id) { case Service::APT::AppletId::SoftwareKeyboard1: case Service::APT::AppletId::SoftwareKeyboard2: @@ -48,8 +48,8 @@ ResultCode Applet::Create(Service::APT::AppletId id, Service::APT::AppletId pare default: LOG_ERROR(Service_APT, "Could not create applet {}", id); // TODO(Subv): Find the right error code - return ResultCode(ErrorDescription::NotFound, ErrorModule::Applet, - ErrorSummary::NotSupported, ErrorLevel::Permanent); + return Result(ErrorDescription::NotFound, ErrorModule::Applet, ErrorSummary::NotSupported, + ErrorLevel::Permanent); } Service::APT::AppletAttributes attributes; @@ -104,10 +104,10 @@ bool Applet::IsActive() const { return is_active; } -ResultCode Applet::ReceiveParameter(const Service::APT::MessageParameter& parameter) { +Result Applet::ReceiveParameter(const Service::APT::MessageParameter& parameter) { switch (parameter.signal) { case Service::APT::SignalType::Wakeup: { - ResultCode result = Start(parameter); + Result result = Start(parameter); if (!result.IsError()) { is_active = true; } diff --git a/src/core/hle/applets/applet.h b/src/core/hle/applets/applet.h index 8160aeeb2..39aeca58a 100644 --- a/src/core/hle/applets/applet.h +++ b/src/core/hle/applets/applet.h @@ -20,10 +20,10 @@ public: * @param id Id of the applet to create. * @param parent Id of the applet's parent. * @param preload Whether the applet is being preloaded. - * @returns ResultCode Whether the operation was successful or not. + * @returns Result Whether the operation was successful or not. */ - static ResultCode Create(Service::APT::AppletId id, Service::APT::AppletId parent, bool preload, - const std::shared_ptr& manager); + static Result Create(Service::APT::AppletId id, Service::APT::AppletId parent, bool preload, + const std::shared_ptr& manager); /** * Retrieves the Applet instance identified by the specified id. @@ -35,9 +35,9 @@ public: /** * Handles a parameter from the application. * @param parameter Parameter data to handle. - * @returns ResultCode Whether the operation was successful or not. + * @returns Result Whether the operation was successful or not. */ - ResultCode ReceiveParameter(const Service::APT::MessageParameter& parameter); + Result ReceiveParameter(const Service::APT::MessageParameter& parameter); /** * Whether the applet is currently running. @@ -62,22 +62,22 @@ protected: /** * Handles a parameter from the application. * @param parameter Parameter data to handle. - * @returns ResultCode Whether the operation was successful or not. + * @returns Result Whether the operation was successful or not. */ - virtual ResultCode ReceiveParameterImpl(const Service::APT::MessageParameter& parameter) = 0; + virtual Result ReceiveParameterImpl(const Service::APT::MessageParameter& parameter) = 0; /** * Handles the Applet start event, triggered from the application. * @param parameter Parameter data to handle. - * @returns ResultCode Whether the operation was successful or not. + * @returns Result Whether the operation was successful or not. */ - virtual ResultCode Start(const Service::APT::MessageParameter& parameter) = 0; + virtual Result Start(const Service::APT::MessageParameter& parameter) = 0; /** * Sends the LibAppletClosing signal to the application, * along with the relevant data buffers. */ - virtual ResultCode Finalize() = 0; + virtual Result Finalize() = 0; Service::APT::AppletId id; ///< Id of this Applet Service::APT::AppletId parent; ///< Id of this Applet's parent diff --git a/src/core/hle/applets/erreula.cpp b/src/core/hle/applets/erreula.cpp index 66ace0f8a..2403ed5be 100644 --- a/src/core/hle/applets/erreula.cpp +++ b/src/core/hle/applets/erreula.cpp @@ -9,12 +9,12 @@ namespace HLE::Applets { -ResultCode ErrEula::ReceiveParameterImpl(const Service::APT::MessageParameter& parameter) { +Result ErrEula::ReceiveParameterImpl(const Service::APT::MessageParameter& parameter) { if (parameter.signal != Service::APT::SignalType::Request) { LOG_ERROR(Service_APT, "unsupported signal {}", parameter.signal); UNIMPLEMENTED(); // TODO(Subv): Find the right error code - return ResultCode(-1); + return Result(-1); } // The LibAppJustStarted message contains a buffer with the size of the framebuffer shared @@ -43,7 +43,7 @@ ResultCode ErrEula::ReceiveParameterImpl(const Service::APT::MessageParameter& p return RESULT_SUCCESS; } -ResultCode ErrEula::Start(const Service::APT::MessageParameter& parameter) { +Result ErrEula::Start(const Service::APT::MessageParameter& parameter) { startup_param = parameter.buffer; // TODO(Subv): Set the expected fields in the response buffer before resending it to the @@ -55,7 +55,7 @@ ResultCode ErrEula::Start(const Service::APT::MessageParameter& parameter) { return RESULT_SUCCESS; } -ResultCode ErrEula::Finalize() { +Result ErrEula::Finalize() { std::vector buffer(startup_param.size()); std::fill(buffer.begin(), buffer.end(), 0); CloseApplet(nullptr, buffer); diff --git a/src/core/hle/applets/erreula.h b/src/core/hle/applets/erreula.h index bdb169b13..c47bb99ef 100644 --- a/src/core/hle/applets/erreula.h +++ b/src/core/hle/applets/erreula.h @@ -15,9 +15,9 @@ public: std::weak_ptr manager) : Applet(id, parent, preload, std::move(manager)) {} - ResultCode ReceiveParameterImpl(const Service::APT::MessageParameter& parameter) override; - ResultCode Start(const Service::APT::MessageParameter& parameter) override; - ResultCode Finalize() override; + Result ReceiveParameterImpl(const Service::APT::MessageParameter& parameter) override; + Result Start(const Service::APT::MessageParameter& parameter) override; + Result Finalize() override; void Update() override; private: diff --git a/src/core/hle/applets/mii_selector.cpp b/src/core/hle/applets/mii_selector.cpp index 7be3e0b46..69f12db90 100644 --- a/src/core/hle/applets/mii_selector.cpp +++ b/src/core/hle/applets/mii_selector.cpp @@ -17,12 +17,12 @@ namespace HLE::Applets { -ResultCode MiiSelector::ReceiveParameterImpl(const Service::APT::MessageParameter& parameter) { +Result MiiSelector::ReceiveParameterImpl(const Service::APT::MessageParameter& parameter) { if (parameter.signal != Service::APT::SignalType::Request) { LOG_ERROR(Service_APT, "unsupported signal {}", parameter.signal); UNIMPLEMENTED(); // TODO(Subv): Find the right error code - return ResultCode(-1); + return Result(-1); } // The LibAppJustStarted message contains a buffer with the size of the framebuffer shared @@ -50,7 +50,7 @@ ResultCode MiiSelector::ReceiveParameterImpl(const Service::APT::MessageParamete return RESULT_SUCCESS; } -ResultCode MiiSelector::Start(const Service::APT::MessageParameter& parameter) { +Result MiiSelector::Start(const Service::APT::MessageParameter& parameter) { ASSERT_MSG(parameter.buffer.size() == sizeof(config), "The size of the parameter (MiiConfig) is wrong"); @@ -78,7 +78,7 @@ void MiiSelector::Update() { Finalize(); } -ResultCode MiiSelector::Finalize() { +Result MiiSelector::Finalize() { std::vector buffer(sizeof(MiiResult)); std::memcpy(buffer.data(), &result, buffer.size()); CloseApplet(nullptr, buffer); diff --git a/src/core/hle/applets/mii_selector.h b/src/core/hle/applets/mii_selector.h index 63d7298de..40662795d 100644 --- a/src/core/hle/applets/mii_selector.h +++ b/src/core/hle/applets/mii_selector.h @@ -66,9 +66,9 @@ public: std::weak_ptr manager) : Applet(id, parent, preload, std::move(manager)) {} - ResultCode ReceiveParameterImpl(const Service::APT::MessageParameter& parameter) override; - ResultCode Start(const Service::APT::MessageParameter& parameter) override; - ResultCode Finalize() override; + Result ReceiveParameterImpl(const Service::APT::MessageParameter& parameter) override; + Result Start(const Service::APT::MessageParameter& parameter) override; + Result Finalize() override; void Update() override; static MiiResult GetStandardMiiResult(); diff --git a/src/core/hle/applets/mint.cpp b/src/core/hle/applets/mint.cpp index 1a952d02e..6ed602825 100644 --- a/src/core/hle/applets/mint.cpp +++ b/src/core/hle/applets/mint.cpp @@ -9,12 +9,12 @@ namespace HLE::Applets { -ResultCode Mint::ReceiveParameterImpl(const Service::APT::MessageParameter& parameter) { +Result Mint::ReceiveParameterImpl(const Service::APT::MessageParameter& parameter) { if (parameter.signal != Service::APT::SignalType::Request) { LOG_ERROR(Service_APT, "unsupported signal {}", parameter.signal); UNIMPLEMENTED(); // TODO(Subv): Find the right error code - return ResultCode(-1); + return Result(-1); } // The Request message contains a buffer with the size of the framebuffer shared @@ -43,7 +43,7 @@ ResultCode Mint::ReceiveParameterImpl(const Service::APT::MessageParameter& para return RESULT_SUCCESS; } -ResultCode Mint::Start(const Service::APT::MessageParameter& parameter) { +Result Mint::Start(const Service::APT::MessageParameter& parameter) { startup_param = parameter.buffer; // TODO(Subv): Set the expected fields in the response buffer before resending it to the @@ -55,7 +55,7 @@ ResultCode Mint::Start(const Service::APT::MessageParameter& parameter) { return RESULT_SUCCESS; } -ResultCode Mint::Finalize() { +Result Mint::Finalize() { std::vector buffer(startup_param.size()); std::fill(buffer.begin(), buffer.end(), 0); CloseApplet(nullptr, buffer); diff --git a/src/core/hle/applets/mint.h b/src/core/hle/applets/mint.h index 4c2f8ffd6..bffa972ab 100644 --- a/src/core/hle/applets/mint.h +++ b/src/core/hle/applets/mint.h @@ -15,9 +15,9 @@ public: std::weak_ptr manager) : Applet(id, parent, preload, std::move(manager)) {} - ResultCode ReceiveParameterImpl(const Service::APT::MessageParameter& parameter) override; - ResultCode Start(const Service::APT::MessageParameter& parameter) override; - ResultCode Finalize() override; + Result ReceiveParameterImpl(const Service::APT::MessageParameter& parameter) override; + Result Start(const Service::APT::MessageParameter& parameter) override; + Result Finalize() override; void Update() override; private: diff --git a/src/core/hle/applets/swkbd.cpp b/src/core/hle/applets/swkbd.cpp index 81e2eedb1..6ef77409c 100644 --- a/src/core/hle/applets/swkbd.cpp +++ b/src/core/hle/applets/swkbd.cpp @@ -19,7 +19,7 @@ namespace HLE::Applets { -ResultCode SoftwareKeyboard::ReceiveParameterImpl(Service::APT::MessageParameter const& parameter) { +Result SoftwareKeyboard::ReceiveParameterImpl(Service::APT::MessageParameter const& parameter) { switch (parameter.signal) { case Service::APT::SignalType::Request: { // The LibAppJustStarted message contains a buffer with the size of the framebuffer shared @@ -84,12 +84,12 @@ ResultCode SoftwareKeyboard::ReceiveParameterImpl(Service::APT::MessageParameter LOG_ERROR(Service_APT, "unsupported signal {}", parameter.signal); UNIMPLEMENTED(); // TODO(Subv): Find the right error code - return ResultCode(-1); + return Result(-1); } } } -ResultCode SoftwareKeyboard::Start(Service::APT::MessageParameter const& parameter) { +Result SoftwareKeyboard::Start(Service::APT::MessageParameter const& parameter) { ASSERT_MSG(parameter.buffer.size() == sizeof(config), "The size of the parameter (SoftwareKeyboardConfig) is wrong"); @@ -166,7 +166,7 @@ void SoftwareKeyboard::DrawScreenKeyboard() { // TODO(Subv): Draw the HLE keyboard, for now just do nothing } -ResultCode SoftwareKeyboard::Finalize() { +Result SoftwareKeyboard::Finalize() { std::vector buffer(sizeof(SoftwareKeyboardConfig)); std::memcpy(buffer.data(), &config, buffer.size()); CloseApplet(nullptr, buffer); diff --git a/src/core/hle/applets/swkbd.h b/src/core/hle/applets/swkbd.h index 663693ba6..10a906728 100644 --- a/src/core/hle/applets/swkbd.h +++ b/src/core/hle/applets/swkbd.h @@ -179,9 +179,9 @@ public: std::weak_ptr manager) : Applet(id, parent, preload, std::move(manager)) {} - ResultCode ReceiveParameterImpl(const Service::APT::MessageParameter& parameter) override; - ResultCode Start(const Service::APT::MessageParameter& parameter) override; - ResultCode Finalize() override; + Result ReceiveParameterImpl(const Service::APT::MessageParameter& parameter) override; + Result Start(const Service::APT::MessageParameter& parameter) override; + Result Finalize() override; void Update() override; /** diff --git a/src/core/hle/ipc_helpers.h b/src/core/hle/ipc_helpers.h index 724be2434..9b7dbe73a 100644 --- a/src/core/hle/ipc_helpers.h +++ b/src/core/hle/ipc_helpers.h @@ -161,7 +161,7 @@ inline void RequestBuilder::Push(bool value) { } template <> -inline void RequestBuilder::Push(ResultCode value) { +inline void RequestBuilder::Push(Result value) { Push(value.raw); } @@ -371,8 +371,8 @@ inline bool RequestParser::Pop() { } template <> -inline ResultCode RequestParser::Pop() { - return ResultCode{Pop()}; +inline Result RequestParser::Pop() { + return Result{Pop()}; } template diff --git a/src/core/hle/kernel/address_arbiter.cpp b/src/core/hle/kernel/address_arbiter.cpp index fb9cd454a..e501bac30 100644 --- a/src/core/hle/kernel/address_arbiter.cpp +++ b/src/core/hle/kernel/address_arbiter.cpp @@ -108,8 +108,8 @@ void AddressArbiter::WakeUp(ThreadWakeupReason reason, std::shared_ptr t waiting_threads.end()); }; -ResultCode AddressArbiter::ArbitrateAddress(std::shared_ptr thread, ArbitrationType type, - VAddr address, s32 value, u64 nanoseconds) { +Result AddressArbiter::ArbitrateAddress(std::shared_ptr thread, ArbitrationType type, + VAddr address, s32 value, u64 nanoseconds) { switch (type) { // Signal thread(s) waiting for arbitrate address... diff --git a/src/core/hle/kernel/address_arbiter.h b/src/core/hle/kernel/address_arbiter.h index dc8bfbf2d..5c8570a8c 100644 --- a/src/core/hle/kernel/address_arbiter.h +++ b/src/core/hle/kernel/address_arbiter.h @@ -55,8 +55,8 @@ public: std::shared_ptr resource_limit; std::string name; ///< Name of address arbiter object (optional) - ResultCode ArbitrateAddress(std::shared_ptr thread, ArbitrationType type, VAddr address, - s32 value, u64 nanoseconds); + Result ArbitrateAddress(std::shared_ptr thread, ArbitrationType type, VAddr address, + s32 value, u64 nanoseconds); class Callback; diff --git a/src/core/hle/kernel/client_port.cpp b/src/core/hle/kernel/client_port.cpp index b5aebf0b3..86dfde4e5 100644 --- a/src/core/hle/kernel/client_port.cpp +++ b/src/core/hle/kernel/client_port.cpp @@ -20,7 +20,7 @@ namespace Kernel { ClientPort::ClientPort(KernelSystem& kernel) : Object(kernel), kernel(kernel) {} ClientPort::~ClientPort() = default; -ResultCode ClientPort::Connect(std::shared_ptr& client_session) { +Result ClientPort::Connect(std::shared_ptr& client_session) { // Note: Threads do not wait for the server endpoint to call // AcceptSession before returning from this call. diff --git a/src/core/hle/kernel/client_port.h b/src/core/hle/kernel/client_port.h index 66d022a38..9d8e0af65 100644 --- a/src/core/hle/kernel/client_port.h +++ b/src/core/hle/kernel/client_port.h @@ -46,7 +46,7 @@ public: * waiting on it to awake. * @returns ClientSession The client endpoint of the created Session pair, or error code. */ - ResultCode Connect(std::shared_ptr& client_session); + Result Connect(std::shared_ptr& client_session); /** * Signifies that a previously active connection has been closed, diff --git a/src/core/hle/kernel/client_session.cpp b/src/core/hle/kernel/client_session.cpp index 46b21df44..93d1fa140 100644 --- a/src/core/hle/kernel/client_session.cpp +++ b/src/core/hle/kernel/client_session.cpp @@ -44,7 +44,7 @@ ClientSession::~ClientSession() { } } -ResultCode ClientSession::SendSyncRequest(std::shared_ptr thread) { +Result ClientSession::SendSyncRequest(std::shared_ptr thread) { // Keep ServerSession alive until we're done working with it. std::shared_ptr server = SharedFrom(parent->server); R_UNLESS(server, ERR_SESSION_CLOSED_BY_REMOTE); diff --git a/src/core/hle/kernel/client_session.h b/src/core/hle/kernel/client_session.h index 1943db8e6..71075de70 100644 --- a/src/core/hle/kernel/client_session.h +++ b/src/core/hle/kernel/client_session.h @@ -42,9 +42,9 @@ public: /** * Sends an SyncRequest from the current emulated thread. * @param thread Thread that initiated the request. - * @return ResultCode of the operation. + * @return Result of the operation. */ - ResultCode SendSyncRequest(std::shared_ptr thread); + Result SendSyncRequest(std::shared_ptr thread); std::string name; ///< Name of client port (optional) diff --git a/src/core/hle/kernel/errors.h b/src/core/hle/kernel/errors.h index 49255dfd1..4f37b632c 100644 --- a/src/core/hle/kernel/errors.h +++ b/src/core/hle/kernel/errors.h @@ -31,85 +31,83 @@ enum { // WARNING: The kernel is quite inconsistent in it's usage of errors code. Make sure to always // double check that the code matches before re-using the constant. -constexpr ResultCode ERR_OUT_OF_HANDLES(ErrCodes::OutOfHandles, ErrorModule::Kernel, - ErrorSummary::OutOfResource, - ErrorLevel::Permanent); // 0xD8600413 -constexpr ResultCode ERR_SESSION_CLOSED_BY_REMOTE(ErrCodes::SessionClosedByRemote, ErrorModule::OS, - ErrorSummary::Canceled, - ErrorLevel::Status); // 0xC920181A -constexpr ResultCode ERR_PORT_NAME_TOO_LONG(ErrCodes::PortNameTooLong, ErrorModule::OS, - ErrorSummary::InvalidArgument, - ErrorLevel::Usage); // 0xE0E0181E -constexpr ResultCode ERR_WRONG_PERMISSION(ErrCodes::WrongPermission, ErrorModule::OS, - ErrorSummary::WrongArgument, ErrorLevel::Permanent); -constexpr ResultCode ERR_INVALID_BUFFER_DESCRIPTOR(ErrCodes::InvalidBufferDescriptor, - ErrorModule::OS, ErrorSummary::WrongArgument, - ErrorLevel::Permanent); -constexpr ResultCode ERR_MAX_CONNECTIONS_REACHED(ErrCodes::MaxConnectionsReached, ErrorModule::OS, - ErrorSummary::WouldBlock, - ErrorLevel::Temporary); // 0xD0401834 - -constexpr ResultCode ERR_NOT_AUTHORIZED(ErrorDescription::NotAuthorized, ErrorModule::OS, - ErrorSummary::WrongArgument, - ErrorLevel::Permanent); // 0xD9001BEA -constexpr ResultCode ERR_INVALID_ENUM_VALUE(ErrorDescription::InvalidEnumValue, ErrorModule::Kernel, - ErrorSummary::InvalidArgument, - ErrorLevel::Permanent); // 0xD8E007ED -constexpr ResultCode ERR_INVALID_ENUM_VALUE_FND(ErrorDescription::InvalidEnumValue, - ErrorModule::FND, ErrorSummary::InvalidArgument, - ErrorLevel::Permanent); // 0xD8E093ED -constexpr ResultCode ERR_INVALID_COMBINATION(ErrorDescription::InvalidCombination, ErrorModule::OS, - ErrorSummary::InvalidArgument, - ErrorLevel::Usage); // 0xE0E01BEE -constexpr ResultCode ERR_INVALID_COMBINATION_KERNEL(ErrorDescription::InvalidCombination, - ErrorModule::Kernel, - ErrorSummary::WrongArgument, - ErrorLevel::Permanent); // 0xD90007EE -constexpr ResultCode ERR_MISALIGNED_ADDRESS(ErrorDescription::MisalignedAddress, ErrorModule::OS, - ErrorSummary::InvalidArgument, - ErrorLevel::Usage); // 0xE0E01BF1 -constexpr ResultCode ERR_MISALIGNED_SIZE(ErrorDescription::MisalignedSize, ErrorModule::OS, - ErrorSummary::InvalidArgument, - ErrorLevel::Usage); // 0xE0E01BF2 -constexpr ResultCode ERR_OUT_OF_MEMORY(ErrorDescription::OutOfMemory, ErrorModule::Kernel, - ErrorSummary::OutOfResource, - ErrorLevel::Permanent); // 0xD86007F3 -/// Returned when out of heap or linear heap memory when allocating -constexpr ResultCode ERR_OUT_OF_HEAP_MEMORY(ErrorDescription::OutOfMemory, ErrorModule::OS, - ErrorSummary::OutOfResource, - ErrorLevel::Status); // 0xC860180A -constexpr ResultCode ERR_NOT_IMPLEMENTED(ErrorDescription::NotImplemented, ErrorModule::OS, - ErrorSummary::InvalidArgument, - ErrorLevel::Usage); // 0xE0E01BF4 -constexpr ResultCode ERR_INVALID_ADDRESS(ErrorDescription::InvalidAddress, ErrorModule::OS, - ErrorSummary::InvalidArgument, - ErrorLevel::Usage); // 0xE0E01BF5 -constexpr ResultCode ERR_INVALID_ADDRESS_STATE(ErrorDescription::InvalidAddress, ErrorModule::OS, - ErrorSummary::InvalidState, - ErrorLevel::Usage); // 0xE0A01BF5 -constexpr ResultCode ERR_INVALID_POINTER(ErrorDescription::InvalidPointer, ErrorModule::Kernel, - ErrorSummary::InvalidArgument, - ErrorLevel::Permanent); // 0xD8E007F6 -constexpr ResultCode ERR_INVALID_HANDLE(ErrorDescription::InvalidHandle, ErrorModule::Kernel, +constexpr Result ERR_OUT_OF_HANDLES(ErrCodes::OutOfHandles, ErrorModule::Kernel, + ErrorSummary::OutOfResource, + ErrorLevel::Permanent); // 0xD8600413 +constexpr Result ERR_SESSION_CLOSED_BY_REMOTE(ErrCodes::SessionClosedByRemote, ErrorModule::OS, + ErrorSummary::Canceled, + ErrorLevel::Status); // 0xC920181A +constexpr Result ERR_PORT_NAME_TOO_LONG(ErrCodes::PortNameTooLong, ErrorModule::OS, ErrorSummary::InvalidArgument, - ErrorLevel::Permanent); // 0xD8E007F7 -/// Alternate code returned instead of ERR_INVALID_HANDLE in some code paths. -constexpr ResultCode ERR_INVALID_HANDLE_OS(ErrorDescription::InvalidHandle, ErrorModule::OS, - ErrorSummary::WrongArgument, - ErrorLevel::Permanent); // 0xD9001BF7 -constexpr ResultCode ERR_NOT_FOUND(ErrorDescription::NotFound, ErrorModule::Kernel, - ErrorSummary::NotFound, ErrorLevel::Permanent); // 0xD88007FA -constexpr ResultCode ERR_OUT_OF_RANGE(ErrorDescription::OutOfRange, ErrorModule::OS, - ErrorSummary::InvalidArgument, - ErrorLevel::Usage); // 0xE0E01BFD -constexpr ResultCode ERR_OUT_OF_RANGE_KERNEL(ErrorDescription::OutOfRange, ErrorModule::Kernel, - ErrorSummary::InvalidArgument, - ErrorLevel::Permanent); // 0xD8E007FD -constexpr ResultCode RESULT_TIMEOUT(ErrorDescription::Timeout, ErrorModule::OS, - ErrorSummary::StatusChanged, ErrorLevel::Info); -/// Returned when Accept() is called on a port with no sessions to be accepted. -constexpr ResultCode ERR_NO_PENDING_SESSIONS(ErrCodes::NoPendingSessions, ErrorModule::OS, + ErrorLevel::Usage); // 0xE0E0181E +constexpr Result ERR_WRONG_PERMISSION(ErrCodes::WrongPermission, ErrorModule::OS, + ErrorSummary::WrongArgument, ErrorLevel::Permanent); +constexpr Result ERR_INVALID_BUFFER_DESCRIPTOR(ErrCodes::InvalidBufferDescriptor, ErrorModule::OS, + ErrorSummary::WrongArgument, ErrorLevel::Permanent); +constexpr Result ERR_MAX_CONNECTIONS_REACHED(ErrCodes::MaxConnectionsReached, ErrorModule::OS, ErrorSummary::WouldBlock, - ErrorLevel::Permanent); // 0xD8401823 + ErrorLevel::Temporary); // 0xD0401834 + +constexpr Result ERR_NOT_AUTHORIZED(ErrorDescription::NotAuthorized, ErrorModule::OS, + ErrorSummary::WrongArgument, + ErrorLevel::Permanent); // 0xD9001BEA +constexpr Result ERR_INVALID_ENUM_VALUE(ErrorDescription::InvalidEnumValue, ErrorModule::Kernel, + ErrorSummary::InvalidArgument, + ErrorLevel::Permanent); // 0xD8E007ED +constexpr Result ERR_INVALID_ENUM_VALUE_FND(ErrorDescription::InvalidEnumValue, ErrorModule::FND, + ErrorSummary::InvalidArgument, + ErrorLevel::Permanent); // 0xD8E093ED +constexpr Result ERR_INVALID_COMBINATION(ErrorDescription::InvalidCombination, ErrorModule::OS, + ErrorSummary::InvalidArgument, + ErrorLevel::Usage); // 0xE0E01BEE +constexpr Result ERR_INVALID_COMBINATION_KERNEL(ErrorDescription::InvalidCombination, + ErrorModule::Kernel, ErrorSummary::WrongArgument, + ErrorLevel::Permanent); // 0xD90007EE +constexpr Result ERR_MISALIGNED_ADDRESS(ErrorDescription::MisalignedAddress, ErrorModule::OS, + ErrorSummary::InvalidArgument, + ErrorLevel::Usage); // 0xE0E01BF1 +constexpr Result ERR_MISALIGNED_SIZE(ErrorDescription::MisalignedSize, ErrorModule::OS, + ErrorSummary::InvalidArgument, + ErrorLevel::Usage); // 0xE0E01BF2 +constexpr Result ERR_OUT_OF_MEMORY(ErrorDescription::OutOfMemory, ErrorModule::Kernel, + ErrorSummary::OutOfResource, + ErrorLevel::Permanent); // 0xD86007F3 +/// Returned when out of heap or linear heap memory when allocating +constexpr Result ERR_OUT_OF_HEAP_MEMORY(ErrorDescription::OutOfMemory, ErrorModule::OS, + ErrorSummary::OutOfResource, + ErrorLevel::Status); // 0xC860180A +constexpr Result ERR_NOT_IMPLEMENTED(ErrorDescription::NotImplemented, ErrorModule::OS, + ErrorSummary::InvalidArgument, + ErrorLevel::Usage); // 0xE0E01BF4 +constexpr Result ERR_INVALID_ADDRESS(ErrorDescription::InvalidAddress, ErrorModule::OS, + ErrorSummary::InvalidArgument, + ErrorLevel::Usage); // 0xE0E01BF5 +constexpr Result ERR_INVALID_ADDRESS_STATE(ErrorDescription::InvalidAddress, ErrorModule::OS, + ErrorSummary::InvalidState, + ErrorLevel::Usage); // 0xE0A01BF5 +constexpr Result ERR_INVALID_POINTER(ErrorDescription::InvalidPointer, ErrorModule::Kernel, + ErrorSummary::InvalidArgument, + ErrorLevel::Permanent); // 0xD8E007F6 +constexpr Result ERR_INVALID_HANDLE(ErrorDescription::InvalidHandle, ErrorModule::Kernel, + ErrorSummary::InvalidArgument, + ErrorLevel::Permanent); // 0xD8E007F7 +/// Alternate code returned instead of ERR_INVALID_HANDLE in some code paths. +constexpr Result ERR_INVALID_HANDLE_OS(ErrorDescription::InvalidHandle, ErrorModule::OS, + ErrorSummary::WrongArgument, + ErrorLevel::Permanent); // 0xD9001BF7 +constexpr Result ERR_NOT_FOUND(ErrorDescription::NotFound, ErrorModule::Kernel, + ErrorSummary::NotFound, ErrorLevel::Permanent); // 0xD88007FA +constexpr Result ERR_OUT_OF_RANGE(ErrorDescription::OutOfRange, ErrorModule::OS, + ErrorSummary::InvalidArgument, + ErrorLevel::Usage); // 0xE0E01BFD +constexpr Result ERR_OUT_OF_RANGE_KERNEL(ErrorDescription::OutOfRange, ErrorModule::Kernel, + ErrorSummary::InvalidArgument, + ErrorLevel::Permanent); // 0xD8E007FD +constexpr Result RESULT_TIMEOUT(ErrorDescription::Timeout, ErrorModule::OS, + ErrorSummary::StatusChanged, ErrorLevel::Info); +/// Returned when Accept() is called on a port with no sessions to be accepted. +constexpr Result ERR_NO_PENDING_SESSIONS(ErrCodes::NoPendingSessions, ErrorModule::OS, + ErrorSummary::WouldBlock, + ErrorLevel::Permanent); // 0xD8401823 } // namespace Kernel diff --git a/src/core/hle/kernel/handle_table.cpp b/src/core/hle/kernel/handle_table.cpp index b38e33432..d3743dee4 100644 --- a/src/core/hle/kernel/handle_table.cpp +++ b/src/core/hle/kernel/handle_table.cpp @@ -28,7 +28,7 @@ HandleTable::HandleTable(KernelSystem& kernel) : kernel(kernel) { HandleTable::~HandleTable() = default; -ResultCode HandleTable::Create(Handle* out_handle, std::shared_ptr obj) { +Result HandleTable::Create(Handle* out_handle, std::shared_ptr obj) { DEBUG_ASSERT(obj != nullptr); u16 slot = next_free_slot; @@ -50,13 +50,13 @@ ResultCode HandleTable::Create(Handle* out_handle, std::shared_ptr obj) return RESULT_SUCCESS; } -ResultCode HandleTable::Duplicate(Handle* out, Handle handle) { +Result HandleTable::Duplicate(Handle* out, Handle handle) { std::shared_ptr object = GetGeneric(handle); R_UNLESS(object, ERR_INVALID_HANDLE); return Create(out, std::move(object)); } -ResultCode HandleTable::Close(Handle handle) { +Result HandleTable::Close(Handle handle) { R_UNLESS(IsValid(handle), ERR_INVALID_HANDLE); const u16 slot = GetSlot(handle); diff --git a/src/core/hle/kernel/handle_table.h b/src/core/hle/kernel/handle_table.h index 540971284..258dc9d9e 100644 --- a/src/core/hle/kernel/handle_table.h +++ b/src/core/hle/kernel/handle_table.h @@ -53,7 +53,7 @@ public: * @return The created Handle or one of the following errors: * - `ERR_OUT_OF_HANDLES`: the maximum number of handles has been exceeded. */ - ResultCode Create(Handle* out_handle, std::shared_ptr obj); + Result Create(Handle* out_handle, std::shared_ptr obj); /** * Returns a new handle that points to the same object as the passed in handle. @@ -61,14 +61,14 @@ public: * - `ERR_INVALID_HANDLE`: an invalid handle was passed in. * - Any errors returned by `Create()`. */ - ResultCode Duplicate(Handle* out, Handle handle); + Result Duplicate(Handle* out, Handle handle); /** * Closes a handle, removing it from the table and decreasing the object's ref-count. * @return `RESULT_SUCCESS` or one of the following errors: * - `ERR_INVALID_HANDLE`: an invalid handle was passed in. */ - ResultCode Close(Handle handle); + Result Close(Handle handle); /// Checks if a handle is valid and points to an existing object. bool IsValid(Handle handle) const; diff --git a/src/core/hle/kernel/hle_ipc.cpp b/src/core/hle/kernel/hle_ipc.cpp index 199d45b02..2d58cc977 100644 --- a/src/core/hle/kernel/hle_ipc.cpp +++ b/src/core/hle/kernel/hle_ipc.cpp @@ -126,8 +126,8 @@ void HLERequestContext::AddStaticBuffer(u8 buffer_id, std::vector data) { static_buffers[buffer_id] = std::move(data); } -ResultCode HLERequestContext::PopulateFromIncomingCommandBuffer( - const u32_le* src_cmdbuf, std::shared_ptr src_process_) { +Result HLERequestContext::PopulateFromIncomingCommandBuffer(const u32_le* src_cmdbuf, + std::shared_ptr src_process_) { auto& src_process = *src_process_; IPC::Header header{src_cmdbuf[0]}; @@ -206,8 +206,8 @@ ResultCode HLERequestContext::PopulateFromIncomingCommandBuffer( return RESULT_SUCCESS; } -ResultCode HLERequestContext::WriteToOutgoingCommandBuffer(u32_le* dst_cmdbuf, - Process& dst_process) const { +Result HLERequestContext::WriteToOutgoingCommandBuffer(u32_le* dst_cmdbuf, + Process& dst_process) const { IPC::Header header{cmd_buf[0]}; std::size_t untranslated_size = 1u + header.normal_params_size; diff --git a/src/core/hle/kernel/hle_ipc.h b/src/core/hle/kernel/hle_ipc.h index c0702cdb2..43a03d5e9 100644 --- a/src/core/hle/kernel/hle_ipc.h +++ b/src/core/hle/kernel/hle_ipc.h @@ -363,10 +363,10 @@ public: MappedBuffer& GetMappedBuffer(u32 id_from_cmdbuf); /// Populates this context with data from the requesting process/thread. - ResultCode PopulateFromIncomingCommandBuffer(const u32_le* src_cmdbuf, - std::shared_ptr src_process); + Result PopulateFromIncomingCommandBuffer(const u32_le* src_cmdbuf, + std::shared_ptr src_process); /// Writes data from this context back to the requesting process/thread. - ResultCode WriteToOutgoingCommandBuffer(u32_le* dst_cmdbuf, Process& dst_process) const; + Result WriteToOutgoingCommandBuffer(u32_le* dst_cmdbuf, Process& dst_process) const; /// Reports an unimplemented function. void ReportUnimplemented() const; diff --git a/src/core/hle/kernel/ipc.cpp b/src/core/hle/kernel/ipc.cpp index 41e597ed4..3cfaa4c17 100644 --- a/src/core/hle/kernel/ipc.cpp +++ b/src/core/hle/kernel/ipc.cpp @@ -18,12 +18,11 @@ namespace Kernel { -ResultCode TranslateCommandBuffer(Kernel::KernelSystem& kernel, Memory::MemorySystem& memory, - std::shared_ptr src_thread, - std::shared_ptr dst_thread, VAddr src_address, - VAddr dst_address, - std::vector& mapped_buffer_context, - bool reply) { +Result TranslateCommandBuffer(Kernel::KernelSystem& kernel, Memory::MemorySystem& memory, + std::shared_ptr src_thread, + std::shared_ptr dst_thread, VAddr src_address, + VAddr dst_address, + std::vector& mapped_buffer_context, bool reply) { auto src_process = src_thread->owner_process.lock(); auto dst_process = dst_thread->owner_process.lock(); ASSERT(src_process && dst_process); @@ -60,8 +59,8 @@ ResultCode TranslateCommandBuffer(Kernel::KernelSystem& kernel, Memory::MemorySy // Note: The real kernel does not check that the number of handles fits into the command // buffer before writing them, only after finishing. if (i + num_handles > command_size) { - return ResultCode(ErrCodes::CommandTooLarge, ErrorModule::OS, - ErrorSummary::InvalidState, ErrorLevel::Status); + return Result(ErrCodes::CommandTooLarge, ErrorModule::OS, + ErrorSummary::InvalidState, ErrorLevel::Status); } for (u32 j = 0; j < num_handles; ++j) { @@ -180,7 +179,7 @@ ResultCode TranslateCommandBuffer(Kernel::KernelSystem& kernel, Memory::MemorySy next_vma.meminfo_state == MemoryState::Reserved); // Unmap the buffer and guard pages from the source process - ResultCode result = + Result result = src_process->vm_manager.UnmapRange(page_start - Memory::CITRA_PAGE_SIZE, (num_pages + 2) * Memory::CITRA_PAGE_SIZE); ASSERT(result == RESULT_SUCCESS); diff --git a/src/core/hle/kernel/ipc.h b/src/core/hle/kernel/ipc.h index c1fd5b6fb..dec2fd95a 100644 --- a/src/core/hle/kernel/ipc.h +++ b/src/core/hle/kernel/ipc.h @@ -40,10 +40,9 @@ private: }; /// Performs IPC command buffer translation from one process to another. -ResultCode TranslateCommandBuffer(KernelSystem& system, Memory::MemorySystem& memory, - std::shared_ptr src_thread, - std::shared_ptr dst_thread, VAddr src_address, - VAddr dst_address, - std::vector& mapped_buffer_context, - bool reply); +Result TranslateCommandBuffer(KernelSystem& system, Memory::MemorySystem& memory, + std::shared_ptr src_thread, + std::shared_ptr dst_thread, VAddr src_address, + VAddr dst_address, + std::vector& mapped_buffer_context, bool reply); } // namespace Kernel diff --git a/src/core/hle/kernel/mutex.cpp b/src/core/hle/kernel/mutex.cpp index 5ce8abe49..c5be71993 100644 --- a/src/core/hle/kernel/mutex.cpp +++ b/src/core/hle/kernel/mutex.cpp @@ -66,7 +66,7 @@ void Mutex::Acquire(Thread* thread) { lock_count++; } -ResultCode Mutex::Release(Thread* thread) { +Result Mutex::Release(Thread* thread) { // We can only release the mutex if it's held by the calling thread. if (thread != holding_thread.get()) { if (holding_thread) { @@ -75,15 +75,15 @@ ResultCode Mutex::Release(Thread* thread) { "Tried to release a mutex (owned by thread id {}) from a different thread id {}", holding_thread->thread_id, thread->thread_id); } - return ResultCode(ErrCodes::WrongLockingThread, ErrorModule::Kernel, - ErrorSummary::InvalidArgument, ErrorLevel::Permanent); + return Result(ErrCodes::WrongLockingThread, ErrorModule::Kernel, + ErrorSummary::InvalidArgument, ErrorLevel::Permanent); } // Note: It should not be possible for the situation where the mutex has a holding thread with a // zero lock count to occur. The real kernel still checks for this, so we do too. if (lock_count <= 0) - return ResultCode(ErrorDescription::InvalidResultValue, ErrorModule::Kernel, - ErrorSummary::InvalidState, ErrorLevel::Permanent); + return Result(ErrorDescription::InvalidResultValue, ErrorModule::Kernel, + ErrorSummary::InvalidState, ErrorLevel::Permanent); lock_count--; diff --git a/src/core/hle/kernel/mutex.h b/src/core/hle/kernel/mutex.h index 5094b3c4f..0ff7ef7cb 100644 --- a/src/core/hle/kernel/mutex.h +++ b/src/core/hle/kernel/mutex.h @@ -60,7 +60,7 @@ public: * @param thread Thread that wants to release the mutex. * @returns The result code of the operation. */ - ResultCode Release(Thread* thread); + Result Release(Thread* thread); private: KernelSystem& kernel; diff --git a/src/core/hle/kernel/process.cpp b/src/core/hle/kernel/process.cpp index a71c67e18..1524e56bd 100644 --- a/src/core/hle/kernel/process.cpp +++ b/src/core/hle/kernel/process.cpp @@ -249,8 +249,8 @@ VAddr Process::GetLinearHeapLimit() const { return GetLinearHeapBase() + memory_region->size; } -ResultCode Process::HeapAllocate(VAddr* out_addr, VAddr target, u32 size, VMAPermission perms, - MemoryState memory_state, bool skip_range_check) { +Result Process::HeapAllocate(VAddr* out_addr, VAddr target, u32 size, VMAPermission perms, + MemoryState memory_state, bool skip_range_check) { LOG_DEBUG(Kernel, "Allocate heap target={:08X}, size={:08X}", target, size); if (target < Memory::HEAP_VADDR || target + size > Memory::HEAP_VADDR_END || target + size < target) { @@ -297,7 +297,7 @@ ResultCode Process::HeapAllocate(VAddr* out_addr, VAddr target, u32 size, VMAPer return RESULT_SUCCESS; } -ResultCode Process::HeapFree(VAddr target, u32 size) { +Result Process::HeapFree(VAddr target, u32 size) { LOG_DEBUG(Kernel, "Free heap target={:08X}, size={:08X}", target, size); if (target < Memory::HEAP_VADDR || target + size > Memory::HEAP_VADDR_END || target + size < target) { @@ -315,7 +315,7 @@ ResultCode Process::HeapFree(VAddr target, u32 size) { holding_memory -= MemoryRegionInfo::Interval(backing_offset, backing_offset + block_size); } - ResultCode result = vm_manager.UnmapRange(target, size); + Result result = vm_manager.UnmapRange(target, size); ASSERT(result.IsSuccess()); memory_used -= size; @@ -324,7 +324,7 @@ ResultCode Process::HeapFree(VAddr target, u32 size) { return RESULT_SUCCESS; } -ResultCode Process::LinearAllocate(VAddr* out_addr, VAddr target, u32 size, VMAPermission perms) { +Result Process::LinearAllocate(VAddr* out_addr, VAddr target, u32 size, VMAPermission perms) { LOG_DEBUG(Kernel, "Allocate linear heap target={:08X}, size={:08X}", target, size); u32 physical_offset; if (target == 0) { @@ -372,7 +372,7 @@ ResultCode Process::LinearAllocate(VAddr* out_addr, VAddr target, u32 size, VMAP return RESULT_SUCCESS; } -ResultCode Process::LinearFree(VAddr target, u32 size) { +Result Process::LinearFree(VAddr target, u32 size) { LOG_DEBUG(Kernel, "Free linear heap target={:08X}, size={:08X}", target, size); if (target < GetLinearHeapBase() || target + size > GetLinearHeapLimit() || target + size < target) { @@ -463,8 +463,7 @@ ResultVal Process::AllocateThreadLocalStorage() { return tls_address; } -ResultCode Process::Map(VAddr target, VAddr source, u32 size, VMAPermission perms, - bool privileged) { +Result Process::Map(VAddr target, VAddr source, u32 size, VMAPermission perms, bool privileged) { LOG_DEBUG(Kernel, "Map memory target={:08X}, source={:08X}, size={:08X}, perms={:08X}", target, source, size, perms); if (!privileged && (source < Memory::HEAP_VADDR || source + size > Memory::HEAP_VADDR_END || @@ -518,8 +517,7 @@ ResultCode Process::Map(VAddr target, VAddr source, u32 size, VMAPermission perm return RESULT_SUCCESS; } -ResultCode Process::Unmap(VAddr target, VAddr source, u32 size, VMAPermission perms, - bool privileged) { +Result Process::Unmap(VAddr target, VAddr source, u32 size, VMAPermission perms, bool privileged) { LOG_DEBUG(Kernel, "Unmap memory target={:08X}, source={:08X}, size={:08X}, perms={:08X}", target, source, size, perms); if (!privileged && (source < Memory::HEAP_VADDR || source + size > Memory::HEAP_VADDR_END || diff --git a/src/core/hle/kernel/process.h b/src/core/hle/kernel/process.h index 1a911f139..58703b7a6 100644 --- a/src/core/hle/kernel/process.h +++ b/src/core/hle/kernel/process.h @@ -231,20 +231,19 @@ public: VAddr GetLinearHeapBase() const; VAddr GetLinearHeapLimit() const; - ResultCode HeapAllocate(VAddr* out_addr, VAddr target, u32 size, VMAPermission perms, - MemoryState memory_state = MemoryState::Private, - bool skip_range_check = false); - ResultCode HeapFree(VAddr target, u32 size); + Result HeapAllocate(VAddr* out_addr, VAddr target, u32 size, VMAPermission perms, + MemoryState memory_state = MemoryState::Private, + bool skip_range_check = false); + Result HeapFree(VAddr target, u32 size); - ResultCode LinearAllocate(VAddr* out_addr, VAddr target, u32 size, VMAPermission perms); - ResultCode LinearFree(VAddr target, u32 size); + Result LinearAllocate(VAddr* out_addr, VAddr target, u32 size, VMAPermission perms); + Result LinearFree(VAddr target, u32 size); ResultVal AllocateThreadLocalStorage(); - ResultCode Map(VAddr target, VAddr source, u32 size, VMAPermission perms, - bool privileged = false); - ResultCode Unmap(VAddr target, VAddr source, u32 size, VMAPermission perms, - bool privileged = false); + Result Map(VAddr target, VAddr source, u32 size, VMAPermission perms, bool privileged = false); + Result Unmap(VAddr target, VAddr source, u32 size, VMAPermission perms, + bool privileged = false); private: void FreeAllMemory(); diff --git a/src/core/hle/kernel/semaphore.cpp b/src/core/hle/kernel/semaphore.cpp index f023fe599..8c38ba12f 100644 --- a/src/core/hle/kernel/semaphore.cpp +++ b/src/core/hle/kernel/semaphore.cpp @@ -48,7 +48,7 @@ void Semaphore::Acquire(Thread* thread) { --available_count; } -ResultCode Semaphore::Release(s32* count, s32 release_count) { +Result Semaphore::Release(s32* count, s32 release_count) { R_UNLESS(max_count >= release_count + available_count, ERR_OUT_OF_RANGE_KERNEL); *count = available_count; diff --git a/src/core/hle/kernel/semaphore.h b/src/core/hle/kernel/semaphore.h index abd864e16..a1a61e83d 100644 --- a/src/core/hle/kernel/semaphore.h +++ b/src/core/hle/kernel/semaphore.h @@ -47,7 +47,7 @@ public: * @param release_count The number of slots to release * @return The number of free slots the semaphore had before this call */ - ResultCode Release(s32* count, s32 release_count); + Result Release(s32* count, s32 release_count); private: friend class boost::serialization::access; diff --git a/src/core/hle/kernel/server_port.cpp b/src/core/hle/kernel/server_port.cpp index 57d411dea..395780a55 100644 --- a/src/core/hle/kernel/server_port.cpp +++ b/src/core/hle/kernel/server_port.cpp @@ -24,7 +24,7 @@ namespace Kernel { ServerPort::ServerPort(KernelSystem& kernel) : WaitObject(kernel) {} ServerPort::~ServerPort() {} -ResultCode ServerPort::Accept(std::shared_ptr& session) { +Result ServerPort::Accept(std::shared_ptr& session) { R_UNLESS(!pending_sessions.empty(), ERR_NO_PENDING_SESSIONS); session = std::move(pending_sessions.back()); diff --git a/src/core/hle/kernel/server_port.h b/src/core/hle/kernel/server_port.h index f246527fa..10a9b658d 100644 --- a/src/core/hle/kernel/server_port.h +++ b/src/core/hle/kernel/server_port.h @@ -41,7 +41,7 @@ public: * Accepts a pending incoming connection on this port. If there are no pending sessions, will * return ERR_NO_PENDING_SESSIONS. */ - ResultCode Accept(std::shared_ptr& session); + Result Accept(std::shared_ptr& session); /** * Sets the HLE handler template for the port. ServerSessions crated by connecting to this port diff --git a/src/core/hle/kernel/server_session.cpp b/src/core/hle/kernel/server_session.cpp index 2e0c647e4..abe741b4a 100644 --- a/src/core/hle/kernel/server_session.cpp +++ b/src/core/hle/kernel/server_session.cpp @@ -77,7 +77,7 @@ void ServerSession::Acquire(Thread* thread) { pending_requesting_threads.pop_back(); } -ResultCode ServerSession::HandleSyncRequest(std::shared_ptr thread) { +Result ServerSession::HandleSyncRequest(std::shared_ptr thread) { // The ServerSession received a sync request, this means that there's new data available // from its ClientSession, so wake up any threads that may be waiting on a svcReplyAndReceive or // similar. diff --git a/src/core/hle/kernel/server_session.h b/src/core/hle/kernel/server_session.h index b91accce5..e631c9a1c 100644 --- a/src/core/hle/kernel/server_session.h +++ b/src/core/hle/kernel/server_session.h @@ -66,9 +66,9 @@ public: /** * Handle a sync request from the emulated application. * @param thread Thread that initiated the request. - * @returns ResultCode from the operation. + * @returns Result from the operation. */ - ResultCode HandleSyncRequest(std::shared_ptr thread); + Result HandleSyncRequest(std::shared_ptr thread); bool ShouldWait(const Thread* thread) const override; diff --git a/src/core/hle/kernel/shared_memory.cpp b/src/core/hle/kernel/shared_memory.cpp index 46e216551..4c2220d11 100644 --- a/src/core/hle/kernel/shared_memory.cpp +++ b/src/core/hle/kernel/shared_memory.cpp @@ -106,8 +106,8 @@ std::shared_ptr KernelSystem::CreateSharedMemoryForApplet( return shared_memory; } -ResultCode SharedMemory::Map(Process& target_process, VAddr address, MemoryPermission permissions, - MemoryPermission other_permissions) { +Result SharedMemory::Map(Process& target_process, VAddr address, MemoryPermission permissions, + MemoryPermission other_permissions) { MemoryPermission own_other_permissions = &target_process == owner_process.lock().get() ? this->permissions : this->other_permissions; @@ -141,7 +141,7 @@ ResultCode SharedMemory::Map(Process& target_process, VAddr address, MemoryPermi // TODO(Subv): Check for the Shared Device Mem flag in the creator process. /*if (was_created_with_shared_device_mem && address != 0) { - return ResultCode(ErrorDescription::InvalidCombination, ErrorModule::OS, + return Result(ErrorDescription::InvalidCombination, ErrorModule::OS, ErrorSummary::InvalidArgument, ErrorLevel::Usage); }*/ @@ -190,7 +190,7 @@ ResultCode SharedMemory::Map(Process& target_process, VAddr address, MemoryPermi return RESULT_SUCCESS; } -ResultCode SharedMemory::Unmap(Process& target_process, VAddr address) { +Result SharedMemory::Unmap(Process& target_process, VAddr address) { // TODO(Subv): Verify what happens if the application tries to unmap an address that is not // mapped to a SharedMemory. return target_process.vm_manager.UnmapRange(address, size); diff --git a/src/core/hle/kernel/shared_memory.h b/src/core/hle/kernel/shared_memory.h index d5cec7678..ca7b76f12 100644 --- a/src/core/hle/kernel/shared_memory.h +++ b/src/core/hle/kernel/shared_memory.h @@ -61,8 +61,8 @@ public: * @param permissions Memory block map permissions (specified by SVC field) * @param other_permissions Memory block map other permissions (specified by SVC field) */ - ResultCode Map(Process& target_process, VAddr address, MemoryPermission permissions, - MemoryPermission other_permissions); + Result Map(Process& target_process, VAddr address, MemoryPermission permissions, + MemoryPermission other_permissions); /** * Unmaps a shared memory block from the specified address in system memory @@ -70,7 +70,7 @@ public: * @param address Address in system memory where the shared memory block is mapped * @return Result code of the unmap operation */ - ResultCode Unmap(Process& target_process, VAddr address); + Result Unmap(Process& target_process, VAddr address); /** * Gets a pointer to the shared memory block diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index 6921b704d..569c172dd 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp @@ -366,79 +366,78 @@ private: // SVC interfaces - ResultCode ControlMemory(u32* out_addr, u32 addr0, u32 addr1, u32 size, u32 operation, - u32 permissions); + Result ControlMemory(u32* out_addr, u32 addr0, u32 addr1, u32 size, u32 operation, + u32 permissions); void ExitProcess(); - ResultCode TerminateProcess(Handle handle); - ResultCode MapMemoryBlock(Handle handle, u32 addr, u32 permissions, u32 other_permissions); - ResultCode UnmapMemoryBlock(Handle handle, u32 addr); - ResultCode ConnectToPort(Handle* out_handle, VAddr port_name_address); - ResultCode SendSyncRequest(Handle handle); - ResultCode OpenProcess(Handle* out_handle, u32 process_id); - ResultCode OpenThread(Handle* out_handle, Handle process_handle, u32 thread_id); - ResultCode CloseHandle(Handle handle); - ResultCode WaitSynchronization1(Handle handle, s64 nano_seconds); - ResultCode WaitSynchronizationN(s32* out, VAddr handles_address, s32 handle_count, - bool wait_all, s64 nano_seconds); - ResultCode ReplyAndReceive(s32* index, VAddr handles_address, s32 handle_count, - Handle reply_target); - ResultCode CreateAddressArbiter(Handle* out_handle); - ResultCode ArbitrateAddress(Handle handle, u32 address, u32 type, u32 value, s64 nanoseconds); + Result TerminateProcess(Handle handle); + Result MapMemoryBlock(Handle handle, u32 addr, u32 permissions, u32 other_permissions); + Result UnmapMemoryBlock(Handle handle, u32 addr); + Result ConnectToPort(Handle* out_handle, VAddr port_name_address); + Result SendSyncRequest(Handle handle); + Result OpenProcess(Handle* out_handle, u32 process_id); + Result OpenThread(Handle* out_handle, Handle process_handle, u32 thread_id); + Result CloseHandle(Handle handle); + Result WaitSynchronization1(Handle handle, s64 nano_seconds); + Result WaitSynchronizationN(s32* out, VAddr handles_address, s32 handle_count, bool wait_all, + s64 nano_seconds); + Result ReplyAndReceive(s32* index, VAddr handles_address, s32 handle_count, + Handle reply_target); + Result CreateAddressArbiter(Handle* out_handle); + Result ArbitrateAddress(Handle handle, u32 address, u32 type, u32 value, s64 nanoseconds); void Break(u8 break_reason); void OutputDebugString(VAddr address, s32 len); - ResultCode GetResourceLimit(Handle* resource_limit, Handle process_handle); - ResultCode GetResourceLimitCurrentValues(VAddr values, Handle resource_limit_handle, - VAddr names, u32 name_count); - ResultCode GetResourceLimitLimitValues(VAddr values, Handle resource_limit_handle, VAddr names, - u32 name_count); - ResultCode SetResourceLimitLimitValues(Handle res_limit, VAddr names, VAddr resource_list, - u32 name_count); - ResultCode CreateThread(Handle* out_handle, u32 entry_point, u32 arg, VAddr stack_top, - u32 priority, s32 processor_id); + Result GetResourceLimit(Handle* resource_limit, Handle process_handle); + Result GetResourceLimitCurrentValues(VAddr values, Handle resource_limit_handle, VAddr names, + u32 name_count); + Result GetResourceLimitLimitValues(VAddr values, Handle resource_limit_handle, VAddr names, + u32 name_count); + Result SetResourceLimitLimitValues(Handle res_limit, VAddr names, VAddr resource_list, + u32 name_count); + Result CreateThread(Handle* out_handle, u32 entry_point, u32 arg, VAddr stack_top, u32 priority, + s32 processor_id); void ExitThread(); - ResultCode GetThreadPriority(u32* priority, Handle handle); - ResultCode SetThreadPriority(Handle handle, u32 priority); - ResultCode CreateMutex(Handle* out_handle, u32 initial_locked); - ResultCode ReleaseMutex(Handle handle); - ResultCode GetProcessId(u32* process_id, Handle process_handle); - ResultCode GetProcessIdOfThread(u32* process_id, Handle thread_handle); - ResultCode GetThreadId(u32* thread_id, Handle handle); - ResultCode CreateSemaphore(Handle* out_handle, s32 initial_count, s32 max_count); - ResultCode ReleaseSemaphore(s32* count, Handle handle, s32 release_count); - ResultCode KernelSetState(u32 kernel_state, u32 varg1, u32 varg2); - ResultCode QueryProcessMemory(MemoryInfo* memory_info, PageInfo* page_info, - Handle process_handle, u32 addr); - ResultCode QueryMemory(MemoryInfo* memory_info, PageInfo* page_info, u32 addr); - ResultCode CreateEvent(Handle* out_handle, u32 reset_type); - ResultCode DuplicateHandle(Handle* out, Handle handle); - ResultCode SignalEvent(Handle handle); - ResultCode ClearEvent(Handle handle); - ResultCode CreateTimer(Handle* out_handle, u32 reset_type); - ResultCode ClearTimer(Handle handle); - ResultCode SetTimer(Handle handle, s64 initial, s64 interval); - ResultCode CancelTimer(Handle handle); + Result GetThreadPriority(u32* priority, Handle handle); + Result SetThreadPriority(Handle handle, u32 priority); + Result CreateMutex(Handle* out_handle, u32 initial_locked); + Result ReleaseMutex(Handle handle); + Result GetProcessId(u32* process_id, Handle process_handle); + Result GetProcessIdOfThread(u32* process_id, Handle thread_handle); + Result GetThreadId(u32* thread_id, Handle handle); + Result CreateSemaphore(Handle* out_handle, s32 initial_count, s32 max_count); + Result ReleaseSemaphore(s32* count, Handle handle, s32 release_count); + Result KernelSetState(u32 kernel_state, u32 varg1, u32 varg2); + Result QueryProcessMemory(MemoryInfo* memory_info, PageInfo* page_info, Handle process_handle, + u32 addr); + Result QueryMemory(MemoryInfo* memory_info, PageInfo* page_info, u32 addr); + Result CreateEvent(Handle* out_handle, u32 reset_type); + Result DuplicateHandle(Handle* out, Handle handle); + Result SignalEvent(Handle handle); + Result ClearEvent(Handle handle); + Result CreateTimer(Handle* out_handle, u32 reset_type); + Result ClearTimer(Handle handle); + Result SetTimer(Handle handle, s64 initial, s64 interval); + Result CancelTimer(Handle handle); void SleepThread(s64 nanoseconds); s64 GetSystemTick(); - ResultCode GetHandleInfo(s64* out, Handle handle, u32 type); - ResultCode CreateMemoryBlock(Handle* out_handle, u32 addr, u32 size, u32 my_permission, - u32 other_permission); - ResultCode CreatePort(Handle* server_port, Handle* client_port, VAddr name_address, - u32 max_sessions); - ResultCode CreateSessionToPort(Handle* out_client_session, Handle client_port_handle); - ResultCode CreateSession(Handle* server_session, Handle* client_session); - ResultCode AcceptSession(Handle* out_server_session, Handle server_port_handle); - ResultCode GetSystemInfo(s64* out, u32 type, s32 param); - ResultCode GetProcessInfo(s64* out, Handle process_handle, u32 type); - ResultCode GetThreadInfo(s64* out, Handle thread_handle, u32 type); - ResultCode GetProcessList(s32* process_count, VAddr out_process_array, - s32 out_process_array_count); - ResultCode InvalidateInstructionCacheRange(u32 addr, u32 size); - ResultCode InvalidateEntireInstructionCache(); + Result GetHandleInfo(s64* out, Handle handle, u32 type); + Result CreateMemoryBlock(Handle* out_handle, u32 addr, u32 size, u32 my_permission, + u32 other_permission); + Result CreatePort(Handle* server_port, Handle* client_port, VAddr name_address, + u32 max_sessions); + Result CreateSessionToPort(Handle* out_client_session, Handle client_port_handle); + Result CreateSession(Handle* server_session, Handle* client_session); + Result AcceptSession(Handle* out_server_session, Handle server_port_handle); + Result GetSystemInfo(s64* out, u32 type, s32 param); + Result GetProcessInfo(s64* out, Handle process_handle, u32 type); + Result GetThreadInfo(s64* out, Handle thread_handle, u32 type); + Result GetProcessList(s32* process_count, VAddr out_process_array, s32 out_process_array_count); + Result InvalidateInstructionCacheRange(u32 addr, u32 size); + Result InvalidateEntireInstructionCache(); u32 ConvertVaToPa(u32 addr); - ResultCode MapProcessMemoryEx(Handle dst_process_handle, u32 dst_address, - Handle src_process_handle, u32 src_address, u32 size); - ResultCode UnmapProcessMemoryEx(Handle process, u32 dst_address, u32 size); - ResultCode ControlProcess(Handle process_handle, u32 process_OP, u32 varg2, u32 varg3); + Result MapProcessMemoryEx(Handle dst_process_handle, u32 dst_address, Handle src_process_handle, + u32 src_address, u32 size); + Result UnmapProcessMemoryEx(Handle process, u32 dst_address, u32 size); + Result ControlProcess(Handle process_handle, u32 process_OP, u32 varg2, u32 varg3); struct FunctionDef { using Func = void (SVC::*)(); @@ -453,8 +452,8 @@ private: }; /// Map application or GSP heap memory -ResultCode SVC::ControlMemory(u32* out_addr, u32 addr0, u32 addr1, u32 size, u32 operation, - u32 permissions) { +Result SVC::ControlMemory(u32* out_addr, u32 addr0, u32 addr1, u32 size, u32 operation, + u32 permissions) { LOG_DEBUG(Kernel_SVC, "called operation=0x{:08X}, addr0=0x{:08X}, addr1=0x{:08X}, " "size=0x{:X}, permissions=0x{:08X}", @@ -522,7 +521,7 @@ void SVC::ExitProcess() { kernel.TerminateProcess(kernel.GetCurrentProcess()); } -ResultCode SVC::TerminateProcess(Handle handle) { +Result SVC::TerminateProcess(Handle handle) { std::shared_ptr process = kernel.GetCurrentProcess()->handle_table.Get(handle); R_UNLESS(process, ERR_INVALID_HANDLE); @@ -532,7 +531,7 @@ ResultCode SVC::TerminateProcess(Handle handle) { } /// Maps a memory block to specified address -ResultCode SVC::MapMemoryBlock(Handle handle, u32 addr, u32 permissions, u32 other_permissions) { +Result SVC::MapMemoryBlock(Handle handle, u32 addr, u32 permissions, u32 other_permissions) { LOG_TRACE(Kernel_SVC, "called memblock=0x{:08X}, addr=0x{:08X}, mypermissions=0x{:08X}, " "otherpermission={}", @@ -561,7 +560,7 @@ ResultCode SVC::MapMemoryBlock(Handle handle, u32 addr, u32 permissions, u32 oth return ERR_INVALID_COMBINATION; } -ResultCode SVC::UnmapMemoryBlock(Handle handle, u32 addr) { +Result SVC::UnmapMemoryBlock(Handle handle, u32 addr) { LOG_TRACE(Kernel_SVC, "called memblock=0x{:08X}, addr=0x{:08X}", handle, addr); // TODO(Subv): Return E0A01BF5 if the address is not in the application's heap @@ -575,7 +574,7 @@ ResultCode SVC::UnmapMemoryBlock(Handle handle, u32 addr) { } /// Connect to an OS service given the port name, returns the handle to the port to out -ResultCode SVC::ConnectToPort(Handle* out_handle, VAddr port_name_address) { +Result SVC::ConnectToPort(Handle* out_handle, VAddr port_name_address) { R_UNLESS(memory.IsValidVirtualAddress(*kernel.GetCurrentProcess(), port_name_address), ERR_NOT_FOUND); @@ -598,7 +597,7 @@ ResultCode SVC::ConnectToPort(Handle* out_handle, VAddr port_name_address) { } /// Makes a blocking IPC call to an OS service. -ResultCode SVC::SendSyncRequest(Handle handle) { +Result SVC::SendSyncRequest(Handle handle) { std::shared_ptr session = kernel.GetCurrentProcess()->handle_table.Get(handle); R_UNLESS(session, ERR_INVALID_HANDLE); @@ -616,19 +615,19 @@ ResultCode SVC::SendSyncRequest(Handle handle) { return session->SendSyncRequest(thread); } -ResultCode SVC::OpenProcess(Handle* out_handle, u32 process_id) { +Result SVC::OpenProcess(Handle* out_handle, u32 process_id) { std::shared_ptr process = kernel.GetProcessById(process_id); if (!process) { // Result 0xd9001818 (process not found?) - return ResultCode(24, ErrorModule::OS, ErrorSummary::WrongArgument, ErrorLevel::Permanent); + return Result(24, ErrorModule::OS, ErrorSummary::WrongArgument, ErrorLevel::Permanent); } return kernel.GetCurrentProcess()->handle_table.Create(out_handle, process); } -ResultCode SVC::OpenThread(Handle* out_handle, Handle process_handle, u32 thread_id) { +Result SVC::OpenThread(Handle* out_handle, Handle process_handle, u32 thread_id) { // Result 0xd9001819 (thread not found?) - constexpr static ResultCode ResultThreadNotFound( - 25, ErrorModule::OS, ErrorSummary::WrongArgument, ErrorLevel::Permanent); + constexpr static Result ResultThreadNotFound(25, ErrorModule::OS, ErrorSummary::WrongArgument, + ErrorLevel::Permanent); if (process_handle == 0) { LOG_ERROR(Kernel_SVC, "Uninplemented svcOpenThread process_handle=0"); @@ -651,14 +650,14 @@ ResultCode SVC::OpenThread(Handle* out_handle, Handle process_handle, u32 thread } /// Close a handle -ResultCode SVC::CloseHandle(Handle handle) { +Result SVC::CloseHandle(Handle handle) { LOG_TRACE(Kernel_SVC, "Closing handle 0x{:08X}", handle); return kernel.GetCurrentProcess()->handle_table.Close(handle); } -static ResultCode ReceiveIPCRequest(Kernel::KernelSystem& kernel, Memory::MemorySystem& memory, - std::shared_ptr server_session, - std::shared_ptr thread); +static Result ReceiveIPCRequest(Kernel::KernelSystem& kernel, Memory::MemorySystem& memory, + std::shared_ptr server_session, + std::shared_ptr thread); class SVC_SyncCallback : public Kernel::WakeupCallback { public: @@ -703,7 +702,7 @@ public: ASSERT(thread->status == ThreadStatus::WaitSynchAny); ASSERT(reason == ThreadWakeupReason::Signal); - ResultCode result = RESULT_SUCCESS; + Result result = RESULT_SUCCESS; if (object->GetHandleType() == HandleType::ServerSession) { auto server_session = DynamicObjectCast(object); @@ -727,7 +726,7 @@ private: }; /// Wait for a handle to synchronize, timeout after the specified nanoseconds -ResultCode SVC::WaitSynchronization1(Handle handle, s64 nano_seconds) { +Result SVC::WaitSynchronization1(Handle handle, s64 nano_seconds) { auto object = kernel.GetCurrentProcess()->handle_table.Get(handle); Thread* thread = kernel.GetCurrentThreadManager().GetCurrentThread(); R_UNLESS(object, ERR_INVALID_HANDLE); @@ -760,8 +759,8 @@ ResultCode SVC::WaitSynchronization1(Handle handle, s64 nano_seconds) { } /// Wait for the given handles to synchronize, timeout after the specified nanoseconds -ResultCode SVC::WaitSynchronizationN(s32* out, VAddr handles_address, s32 handle_count, - bool wait_all, s64 nano_seconds) { +Result SVC::WaitSynchronizationN(s32* out, VAddr handles_address, s32 handle_count, bool wait_all, + s64 nano_seconds) { Thread* thread = kernel.GetCurrentThreadManager().GetCurrentThread(); R_UNLESS(memory.IsValidVirtualAddress(*kernel.GetCurrentProcess(), handles_address), ERR_INVALID_POINTER); @@ -873,15 +872,15 @@ ResultCode SVC::WaitSynchronizationN(s32* out, VAddr handles_address, s32 handle } } -static ResultCode ReceiveIPCRequest(Kernel::KernelSystem& kernel, Memory::MemorySystem& memory, - std::shared_ptr server_session, - std::shared_ptr thread) { +static Result ReceiveIPCRequest(Kernel::KernelSystem& kernel, Memory::MemorySystem& memory, + std::shared_ptr server_session, + std::shared_ptr thread) { R_UNLESS(server_session->parent->client, ERR_SESSION_CLOSED_BY_REMOTE); VAddr target_address = thread->GetCommandBufferAddress(); VAddr source_address = server_session->currently_handling->GetCommandBufferAddress(); - ResultCode translation_result = TranslateCommandBuffer( + Result translation_result = TranslateCommandBuffer( kernel, memory, server_session->currently_handling, thread, source_address, target_address, server_session->mapped_buffer_context, false); @@ -901,8 +900,8 @@ static ResultCode ReceiveIPCRequest(Kernel::KernelSystem& kernel, Memory::Memory } /// In a single operation, sends a IPC reply and waits for a new request. -ResultCode SVC::ReplyAndReceive(s32* index, VAddr handles_address, s32 handle_count, - Handle reply_target) { +Result SVC::ReplyAndReceive(s32* index, VAddr handles_address, s32 handle_count, + Handle reply_target) { R_UNLESS(memory.IsValidVirtualAddress(*kernel.GetCurrentProcess(), handles_address), ERR_INVALID_POINTER); @@ -945,7 +944,7 @@ ResultCode SVC::ReplyAndReceive(s32* index, VAddr handles_address, s32 handle_co VAddr source_address = thread->GetCommandBufferAddress(); VAddr target_address = request_thread->GetCommandBufferAddress(); - ResultCode translation_result = TranslateCommandBuffer( + Result translation_result = TranslateCommandBuffer( kernel, memory, SharedFrom(thread), request_thread, source_address, target_address, session->mapped_buffer_context, true); @@ -962,7 +961,7 @@ ResultCode SVC::ReplyAndReceive(s32* index, VAddr handles_address, s32 handle_co R_SUCCEED_IF(reply_target != 0 && header.command_id != 0xFFFF); // The kernel uses this value as a placeholder for the real error, and returns it when we // pass no handles and do not perform any reply. - return ResultCode(0xE7E3FFFF); + return Result(0xE7E3FFFF); } // Find the first object that is acquirable in the provided list of objects @@ -1007,13 +1006,13 @@ ResultCode SVC::ReplyAndReceive(s32* index, VAddr handles_address, s32 handle_co } /// Create an address arbiter (to allocate access to shared resources) -ResultCode SVC::CreateAddressArbiter(Handle* out_handle) { +Result SVC::CreateAddressArbiter(Handle* out_handle) { // Update address arbiter count in resource limit. const auto current_process = kernel.GetCurrentProcess(); const auto& resource_limit = current_process->resource_limit; if (!resource_limit->Reserve(ResourceLimitType::AddressArbiter, 1)) { - return ResultCode(ErrCodes::OutOfAddressArbiters, ErrorModule::OS, - ErrorSummary::OutOfResource, ErrorLevel::Status); + return Result(ErrCodes::OutOfAddressArbiters, ErrorModule::OS, ErrorSummary::OutOfResource, + ErrorLevel::Status); } // Create address arbiter. @@ -1023,7 +1022,7 @@ ResultCode SVC::CreateAddressArbiter(Handle* out_handle) { } /// Arbitrate address -ResultCode SVC::ArbitrateAddress(Handle handle, u32 address, u32 type, u32 value, s64 nanoseconds) { +Result SVC::ArbitrateAddress(Handle handle, u32 address, u32 type, u32 value, s64 nanoseconds) { LOG_TRACE(Kernel_SVC, "called handle=0x{:08X}, address=0x{:08X}, type=0x{:08X}, value=0x{:08X}", handle, address, type, value); @@ -1085,7 +1084,7 @@ void SVC::OutputDebugString(VAddr address, s32 len) { } /// Get resource limit -ResultCode SVC::GetResourceLimit(Handle* resource_limit, Handle process_handle) { +Result SVC::GetResourceLimit(Handle* resource_limit, Handle process_handle) { LOG_TRACE(Kernel_SVC, "called process=0x{:08X}", process_handle); std::shared_ptr current_process = kernel.GetCurrentProcess(); @@ -1096,8 +1095,8 @@ ResultCode SVC::GetResourceLimit(Handle* resource_limit, Handle process_handle) } /// Get resource limit current values -ResultCode SVC::GetResourceLimitCurrentValues(VAddr values, Handle resource_limit_handle, - VAddr names, u32 name_count) { +Result SVC::GetResourceLimitCurrentValues(VAddr values, Handle resource_limit_handle, VAddr names, + u32 name_count) { LOG_TRACE(Kernel_SVC, "called resource_limit={:08X}, names={:08X}, name_count={}", resource_limit_handle, names, name_count); @@ -1115,8 +1114,8 @@ ResultCode SVC::GetResourceLimitCurrentValues(VAddr values, Handle resource_limi } /// Get resource limit max values -ResultCode SVC::GetResourceLimitLimitValues(VAddr values, Handle resource_limit_handle, VAddr names, - u32 name_count) { +Result SVC::GetResourceLimitLimitValues(VAddr values, Handle resource_limit_handle, VAddr names, + u32 name_count) { LOG_TRACE(Kernel_SVC, "called resource_limit={:08X}, names={:08X}, name_count={}", resource_limit_handle, names, name_count); @@ -1134,8 +1133,8 @@ ResultCode SVC::GetResourceLimitLimitValues(VAddr values, Handle resource_limit_ return RESULT_SUCCESS; } -ResultCode SVC::SetResourceLimitLimitValues(Handle res_limit, VAddr names, VAddr resource_list, - u32 name_count) { +Result SVC::SetResourceLimitLimitValues(Handle res_limit, VAddr names, VAddr resource_list, + u32 name_count) { LOG_TRACE(Kernel_SVC, "called resource_limit={:08X}, names={:08X}, name_count={}", res_limit, names, name_count); @@ -1162,8 +1161,8 @@ ResultCode SVC::SetResourceLimitLimitValues(Handle res_limit, VAddr names, VAddr } /// Creates a new thread -ResultCode SVC::CreateThread(Handle* out_handle, u32 entry_point, u32 arg, VAddr stack_top, - u32 priority, s32 processor_id) { +Result SVC::CreateThread(Handle* out_handle, u32 entry_point, u32 arg, VAddr stack_top, + u32 priority, s32 processor_id) { R_UNLESS(priority <= ThreadPrioLowest, ERR_OUT_OF_RANGE); const auto current_process = kernel.GetCurrentProcess(); @@ -1202,8 +1201,8 @@ ResultCode SVC::CreateThread(Handle* out_handle, u32 entry_point, u32 arg, VAddr // Update thread count in resource limit. if (!resource_limit->Reserve(ResourceLimitType::Thread, 1)) { - return ResultCode(ErrCodes::OutOfThreads, ErrorModule::OS, ErrorSummary::OutOfResource, - ErrorLevel::Status); + return Result(ErrCodes::OutOfThreads, ErrorModule::OS, ErrorSummary::OutOfResource, + ErrorLevel::Status); } // Create thread. @@ -1234,7 +1233,7 @@ void SVC::ExitThread() { } /// Gets the priority for the specified thread -ResultCode SVC::GetThreadPriority(u32* priority, Handle handle) { +Result SVC::GetThreadPriority(u32* priority, Handle handle) { const std::shared_ptr thread = kernel.GetCurrentProcess()->handle_table.Get(handle); R_UNLESS(thread, ERR_INVALID_HANDLE); @@ -1244,7 +1243,7 @@ ResultCode SVC::GetThreadPriority(u32* priority, Handle handle) { } /// Sets the priority for the specified thread -ResultCode SVC::SetThreadPriority(Handle handle, u32 priority) { +Result SVC::SetThreadPriority(Handle handle, u32 priority) { R_UNLESS(priority <= ThreadPrioLowest, ERR_OUT_OF_RANGE); const auto thread = kernel.GetCurrentProcess()->handle_table.Get(handle); @@ -1269,13 +1268,13 @@ ResultCode SVC::SetThreadPriority(Handle handle, u32 priority) { } /// Create a mutex -ResultCode SVC::CreateMutex(Handle* out_handle, u32 initial_locked) { +Result SVC::CreateMutex(Handle* out_handle, u32 initial_locked) { // Update mutex count in resource limit. const auto current_process = kernel.GetCurrentProcess(); const auto& resource_limit = current_process->resource_limit; if (!resource_limit->Reserve(ResourceLimitType::Mutex, 1)) { - return ResultCode(ErrCodes::OutOfMutexes, ErrorModule::OS, ErrorSummary::OutOfResource, - ErrorLevel::Status); + return Result(ErrCodes::OutOfMutexes, ErrorModule::OS, ErrorSummary::OutOfResource, + ErrorLevel::Status); } // Create mutex. @@ -1286,7 +1285,7 @@ ResultCode SVC::CreateMutex(Handle* out_handle, u32 initial_locked) { } /// Release a mutex -ResultCode SVC::ReleaseMutex(Handle handle) { +Result SVC::ReleaseMutex(Handle handle) { LOG_TRACE(Kernel_SVC, "called handle=0x{:08X}", handle); std::shared_ptr mutex = kernel.GetCurrentProcess()->handle_table.Get(handle); @@ -1296,7 +1295,7 @@ ResultCode SVC::ReleaseMutex(Handle handle) { } /// Get the ID of the specified process -ResultCode SVC::GetProcessId(u32* process_id, Handle process_handle) { +Result SVC::GetProcessId(u32* process_id, Handle process_handle) { LOG_TRACE(Kernel_SVC, "called process=0x{:08X}", process_handle); const std::shared_ptr process = @@ -1308,7 +1307,7 @@ ResultCode SVC::GetProcessId(u32* process_id, Handle process_handle) { } /// Get the ID of the process that owns the specified thread -ResultCode SVC::GetProcessIdOfThread(u32* process_id, Handle thread_handle) { +Result SVC::GetProcessIdOfThread(u32* process_id, Handle thread_handle) { LOG_TRACE(Kernel_SVC, "called thread=0x{:08X}", thread_handle); const std::shared_ptr thread = @@ -1323,7 +1322,7 @@ ResultCode SVC::GetProcessIdOfThread(u32* process_id, Handle thread_handle) { } /// Get the ID for the specified thread. -ResultCode SVC::GetThreadId(u32* thread_id, Handle handle) { +Result SVC::GetThreadId(u32* thread_id, Handle handle) { LOG_TRACE(Kernel_SVC, "called thread=0x{:08X}", handle); const std::shared_ptr thread = @@ -1335,13 +1334,13 @@ ResultCode SVC::GetThreadId(u32* thread_id, Handle handle) { } /// Creates a semaphore -ResultCode SVC::CreateSemaphore(Handle* out_handle, s32 initial_count, s32 max_count) { +Result SVC::CreateSemaphore(Handle* out_handle, s32 initial_count, s32 max_count) { // Update semaphore count in resource limit. const auto current_process = kernel.GetCurrentProcess(); const auto& resource_limit = current_process->resource_limit; if (!resource_limit->Reserve(ResourceLimitType::Semaphore, 1)) { - return ResultCode(ErrCodes::OutOfSemaphores, ErrorModule::OS, ErrorSummary::OutOfResource, - ErrorLevel::Status); + return Result(ErrCodes::OutOfSemaphores, ErrorModule::OS, ErrorSummary::OutOfResource, + ErrorLevel::Status); } // Create semaphore @@ -1353,7 +1352,7 @@ ResultCode SVC::CreateSemaphore(Handle* out_handle, s32 initial_count, s32 max_c } /// Releases a certain number of slots in a semaphore -ResultCode SVC::ReleaseSemaphore(s32* count, Handle handle, s32 release_count) { +Result SVC::ReleaseSemaphore(s32* count, Handle handle, s32 release_count) { LOG_TRACE(Kernel_SVC, "called release_count={}, handle=0x{:08X}", release_count, handle); std::shared_ptr semaphore = @@ -1364,7 +1363,7 @@ ResultCode SVC::ReleaseSemaphore(s32* count, Handle handle, s32 release_count) { } /// Sets the kernel state -ResultCode SVC::KernelSetState(u32 kernel_state, u32 varg1, u32 varg2) { +Result SVC::KernelSetState(u32 kernel_state, u32 varg1, u32 varg2) { switch (static_cast(kernel_state)) { // This triggers a hardware reboot on real console, since this doesn't make sense // on emulator, we shutdown instead. @@ -1379,8 +1378,8 @@ ResultCode SVC::KernelSetState(u32 kernel_state, u32 varg1, u32 varg2) { } /// Query process memory -ResultCode SVC::QueryProcessMemory(MemoryInfo* memory_info, PageInfo* page_info, - Handle process_handle, u32 addr) { +Result SVC::QueryProcessMemory(MemoryInfo* memory_info, PageInfo* page_info, Handle process_handle, + u32 addr) { std::shared_ptr process = kernel.GetCurrentProcess()->handle_table.Get(process_handle); R_UNLESS(process, ERR_INVALID_HANDLE); @@ -1416,18 +1415,18 @@ ResultCode SVC::QueryProcessMemory(MemoryInfo* memory_info, PageInfo* page_info, } /// Query memory -ResultCode SVC::QueryMemory(MemoryInfo* memory_info, PageInfo* page_info, u32 addr) { +Result SVC::QueryMemory(MemoryInfo* memory_info, PageInfo* page_info, u32 addr) { return QueryProcessMemory(memory_info, page_info, CurrentProcess, addr); } /// Create an event -ResultCode SVC::CreateEvent(Handle* out_handle, u32 reset_type) { +Result SVC::CreateEvent(Handle* out_handle, u32 reset_type) { // Update event count in resource limit. const auto current_process = kernel.GetCurrentProcess(); const auto& resource_limit = current_process->resource_limit; if (!resource_limit->Reserve(ResourceLimitType::Event, 1)) { - return ResultCode(ErrCodes::OutOfEvents, ErrorModule::OS, ErrorSummary::OutOfResource, - ErrorLevel::Status); + return Result(ErrCodes::OutOfEvents, ErrorModule::OS, ErrorSummary::OutOfResource, + ErrorLevel::Status); } // Create event. @@ -1438,12 +1437,12 @@ ResultCode SVC::CreateEvent(Handle* out_handle, u32 reset_type) { } /// Duplicates a kernel handle -ResultCode SVC::DuplicateHandle(Handle* out, Handle handle) { +Result SVC::DuplicateHandle(Handle* out, Handle handle) { return kernel.GetCurrentProcess()->handle_table.Duplicate(out, handle); } /// Signals an event -ResultCode SVC::SignalEvent(Handle handle) { +Result SVC::SignalEvent(Handle handle) { LOG_TRACE(Kernel_SVC, "called event=0x{:08X}", handle); std::shared_ptr evt = kernel.GetCurrentProcess()->handle_table.Get(handle); @@ -1454,7 +1453,7 @@ ResultCode SVC::SignalEvent(Handle handle) { } /// Clears an event -ResultCode SVC::ClearEvent(Handle handle) { +Result SVC::ClearEvent(Handle handle) { LOG_TRACE(Kernel_SVC, "called event=0x{:08X}", handle); std::shared_ptr evt = kernel.GetCurrentProcess()->handle_table.Get(handle); @@ -1465,13 +1464,13 @@ ResultCode SVC::ClearEvent(Handle handle) { } /// Creates a timer -ResultCode SVC::CreateTimer(Handle* out_handle, u32 reset_type) { +Result SVC::CreateTimer(Handle* out_handle, u32 reset_type) { // Update timer count in resource limit. const auto current_process = kernel.GetCurrentProcess(); const auto& resource_limit = current_process->resource_limit; if (!resource_limit->Reserve(ResourceLimitType::Timer, 1)) { - return ResultCode(ErrCodes::OutOfTimers, ErrorModule::OS, ErrorSummary::OutOfResource, - ErrorLevel::Status); + return Result(ErrCodes::OutOfTimers, ErrorModule::OS, ErrorSummary::OutOfResource, + ErrorLevel::Status); } // Create timer. @@ -1482,7 +1481,7 @@ ResultCode SVC::CreateTimer(Handle* out_handle, u32 reset_type) { } /// Clears a timer -ResultCode SVC::ClearTimer(Handle handle) { +Result SVC::ClearTimer(Handle handle) { LOG_TRACE(Kernel_SVC, "called timer=0x{:08X}", handle); std::shared_ptr timer = kernel.GetCurrentProcess()->handle_table.Get(handle); @@ -1493,7 +1492,7 @@ ResultCode SVC::ClearTimer(Handle handle) { } /// Starts a timer -ResultCode SVC::SetTimer(Handle handle, s64 initial, s64 interval) { +Result SVC::SetTimer(Handle handle, s64 initial, s64 interval) { LOG_TRACE(Kernel_SVC, "called timer=0x{:08X}", handle); R_UNLESS(initial >= 0 && interval >= 0, ERR_OUT_OF_RANGE_KERNEL); @@ -1507,7 +1506,7 @@ ResultCode SVC::SetTimer(Handle handle, s64 initial, s64 interval) { } /// Cancels a timer -ResultCode SVC::CancelTimer(Handle handle) { +Result SVC::CancelTimer(Handle handle) { LOG_TRACE(Kernel_SVC, "called timer=0x{:08X}", handle); std::shared_ptr timer = kernel.GetCurrentProcess()->handle_table.Get(handle); @@ -1549,7 +1548,7 @@ s64 SVC::GetSystemTick() { } // Returns information of the specified handle -ResultCode SVC::GetHandleInfo(s64* out, Handle handle, u32 type) { +Result SVC::GetHandleInfo(s64* out, Handle handle, u32 type) { std::shared_ptr object = kernel.GetCurrentProcess()->handle_table.GetGeneric(handle); R_UNLESS(object, ERR_INVALID_HANDLE); @@ -1581,8 +1580,8 @@ ResultCode SVC::GetHandleInfo(s64* out, Handle handle, u32 type) { } /// Creates a memory block at the specified address with the specified permissions and size -ResultCode SVC::CreateMemoryBlock(Handle* out_handle, u32 addr, u32 size, u32 my_permission, - u32 other_permission) { +Result SVC::CreateMemoryBlock(Handle* out_handle, u32 addr, u32 size, u32 my_permission, + u32 other_permission) { R_UNLESS(size % Memory::CITRA_PAGE_SIZE == 0, ERR_MISALIGNED_SIZE); std::shared_ptr shared_memory = nullptr; @@ -1618,8 +1617,8 @@ ResultCode SVC::CreateMemoryBlock(Handle* out_handle, u32 addr, u32 size, u32 my const auto current_process = kernel.GetCurrentProcess(); const auto& resource_limit = current_process->resource_limit; if (!resource_limit->Reserve(ResourceLimitType::SharedMemory, 1)) { - return ResultCode(ErrCodes::OutOfSharedMems, ErrorModule::OS, ErrorSummary::OutOfResource, - ErrorLevel::Status); + return Result(ErrCodes::OutOfSharedMems, ErrorModule::OS, ErrorSummary::OutOfResource, + ErrorLevel::Status); } // When trying to create a memory block with address = 0, @@ -1638,8 +1637,8 @@ ResultCode SVC::CreateMemoryBlock(Handle* out_handle, u32 addr, u32 size, u32 my return current_process->handle_table.Create(out_handle, std::move(shared_memory)); } -ResultCode SVC::CreatePort(Handle* server_port, Handle* client_port, VAddr name_address, - u32 max_sessions) { +Result SVC::CreatePort(Handle* server_port, Handle* client_port, VAddr name_address, + u32 max_sessions) { // TODO(Subv): Implement named ports. ASSERT_MSG(name_address == 0, "Named ports are currently unimplemented"); LOG_TRACE(Kernel_SVC, "called max_sessions={}", max_sessions); @@ -1653,7 +1652,7 @@ ResultCode SVC::CreatePort(Handle* server_port, Handle* client_port, VAddr name_ return current_process->handle_table.Create(server_port, std::move(server)); } -ResultCode SVC::CreateSessionToPort(Handle* out_client_session, Handle client_port_handle) { +Result SVC::CreateSessionToPort(Handle* out_client_session, Handle client_port_handle) { std::shared_ptr current_process = kernel.GetCurrentProcess(); std::shared_ptr client_port = current_process->handle_table.Get(client_port_handle); @@ -1665,7 +1664,7 @@ ResultCode SVC::CreateSessionToPort(Handle* out_client_session, Handle client_po return current_process->handle_table.Create(out_client_session, std::move(session)); } -ResultCode SVC::CreateSession(Handle* server_session, Handle* client_session) { +Result SVC::CreateSession(Handle* server_session, Handle* client_session) { auto [server, client] = kernel.CreateSessionPair(); LOG_TRACE(Kernel_SVC, "called"); @@ -1675,7 +1674,7 @@ ResultCode SVC::CreateSession(Handle* server_session, Handle* client_session) { return current_process->handle_table.Create(client_session, std::move(client)); } -ResultCode SVC::AcceptSession(Handle* out_server_session, Handle server_port_handle) { +Result SVC::AcceptSession(Handle* out_server_session, Handle server_port_handle) { std::shared_ptr current_process = kernel.GetCurrentProcess(); std::shared_ptr server_port = current_process->handle_table.Get(server_port_handle); @@ -1697,7 +1696,7 @@ static void CopyStringPart(char* out, const char* in, size_t offset, size_t max_ } } -ResultCode SVC::GetSystemInfo(s64* out, u32 type, s32 param) { +Result SVC::GetSystemInfo(s64* out, u32 type, s32 param) { LOG_TRACE(Kernel_SVC, "called type={} param={}", type, param); switch ((SystemInfoType)type) { @@ -1795,7 +1794,7 @@ ResultCode SVC::GetSystemInfo(s64* out, u32 type, s32 param) { return RESULT_SUCCESS; } -ResultCode SVC::GetProcessInfo(s64* out, Handle process_handle, u32 type) { +Result SVC::GetProcessInfo(s64* out, Handle process_handle, u32 type) { LOG_TRACE(Kernel_SVC, "called process=0x{:08X} type={}", process_handle, type); std::shared_ptr process = @@ -1868,7 +1867,7 @@ ResultCode SVC::GetProcessInfo(s64* out, Handle process_handle, u32 type) { return RESULT_SUCCESS; } -ResultCode SVC::GetThreadInfo(s64* out, Handle thread_handle, u32 type) { +Result SVC::GetThreadInfo(s64* out, Handle thread_handle, u32 type) { LOG_TRACE(Kernel_SVC, "called thread=0x{:08X} type={}", thread_handle, type); std::shared_ptr thread = @@ -1887,8 +1886,8 @@ ResultCode SVC::GetThreadInfo(s64* out, Handle thread_handle, u32 type) { return RESULT_SUCCESS; } -ResultCode SVC::GetProcessList(s32* process_count, VAddr out_process_array, - s32 out_process_array_count) { +Result SVC::GetProcessList(s32* process_count, VAddr out_process_array, + s32 out_process_array_count) { R_UNLESS(memory.IsValidVirtualAddress(*kernel.GetCurrentProcess(), out_process_array), ERR_INVALID_POINTER); @@ -1905,12 +1904,12 @@ ResultCode SVC::GetProcessList(s32* process_count, VAddr out_process_array, return RESULT_SUCCESS; } -ResultCode SVC::InvalidateInstructionCacheRange(u32 addr, u32 size) { +Result SVC::InvalidateInstructionCacheRange(u32 addr, u32 size) { system.GetRunningCore().InvalidateCacheRange(addr, size); return RESULT_SUCCESS; } -ResultCode SVC::InvalidateEntireInstructionCache() { +Result SVC::InvalidateEntireInstructionCache() { system.GetRunningCore().ClearInstructionCache(); return RESULT_SUCCESS; } @@ -1926,8 +1925,8 @@ u32 SVC::ConvertVaToPa(u32 addr) { Memory::FCRAM_PADDR; } -ResultCode SVC::MapProcessMemoryEx(Handle dst_process_handle, u32 dst_address, - Handle src_process_handle, u32 src_address, u32 size) { +Result SVC::MapProcessMemoryEx(Handle dst_process_handle, u32 dst_address, + Handle src_process_handle, u32 src_address, u32 size) { std::shared_ptr dst_process = kernel.GetCurrentProcess()->handle_table.Get(dst_process_handle); std::shared_ptr src_process = @@ -1963,7 +1962,7 @@ ResultCode SVC::MapProcessMemoryEx(Handle dst_process_handle, u32 dst_address, return RESULT_SUCCESS; } -ResultCode SVC::UnmapProcessMemoryEx(Handle process, u32 dst_address, u32 size) { +Result SVC::UnmapProcessMemoryEx(Handle process, u32 dst_address, u32 size) { std::shared_ptr dst_process = kernel.GetCurrentProcess()->handle_table.Get(process); R_UNLESS(dst_process, ERR_INVALID_HANDLE); @@ -1983,7 +1982,7 @@ ResultCode SVC::UnmapProcessMemoryEx(Handle process, u32 dst_address, u32 size) return RESULT_SUCCESS; } -ResultCode SVC::ControlProcess(Handle process_handle, u32 process_OP, u32 varg2, u32 varg3) { +Result SVC::ControlProcess(Handle process_handle, u32 process_OP, u32 varg2, u32 varg3) { std::shared_ptr process = kernel.GetCurrentProcess()->handle_table.Get(process_handle); R_UNLESS(process, ERR_INVALID_HANDLE); diff --git a/src/core/hle/kernel/svc_wrapper.h b/src/core/hle/kernel/svc_wrapper.h index 77334152d..50c7adb46 100644 --- a/src/core/hle/kernel/svc_wrapper.h +++ b/src/core/hle/kernel/svc_wrapper.h @@ -281,21 +281,21 @@ private: }; template - struct WrapPass { + struct WrapPass { // Call function R(Context::svc)(Us...) and transfer the return value to registers template static void Call(Context& context, SVCT svc, Us... u) { - static_assert(std::is_same_v); - if constexpr (std::is_void_v) { + static_assert(std::is_same_v); + if constexpr (std::is_void_v) { (context.*svc)(u...); } else { - ResultCode r = (context.*svc)(u...); + Result r = (context.*svc)(u...); if (r.IsError()) { LOG_ERROR(Kernel_SVC, "level={} summary={} module={} description={}", r.level.ExtractValue(r.raw), r.summary.ExtractValue(r.raw), r.module.ExtractValue(r.raw), r.description.ExtractValue(r.raw)); } - SetParam(context, r); + SetParam(context, r); } } }; diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index 1daa7a185..a932c3020 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp @@ -344,8 +344,8 @@ ResultVal> KernelSystem::CreateThread( if (!memory.IsValidVirtualAddress(*owner_process, entry_point)) { LOG_ERROR(Kernel_SVC, "(name={}): invalid entry {:08x}", name, entry_point); // TODO: Verify error - return ResultCode(ErrorDescription::InvalidAddress, ErrorModule::Kernel, - ErrorSummary::InvalidArgument, ErrorLevel::Permanent); + return Result(ErrorDescription::InvalidAddress, ErrorModule::Kernel, + ErrorSummary::InvalidArgument, ErrorLevel::Permanent); } auto thread = std::make_shared(*this, processor_id); @@ -445,7 +445,7 @@ void ThreadManager::Reschedule() { SwitchContext(next); } -void Thread::SetWaitSynchronizationResult(ResultCode result) { +void Thread::SetWaitSynchronizationResult(Result result) { context.cpu_registers[0] = result.raw; } diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h index 86c25a424..108611041 100644 --- a/src/core/hle/kernel/thread.h +++ b/src/core/hle/kernel/thread.h @@ -243,7 +243,7 @@ public: * Sets the result after the thread awakens (from either WaitSynchronization SVC) * @param result Value to set to the returned result */ - void SetWaitSynchronizationResult(ResultCode result); + void SetWaitSynchronizationResult(Result result); /** * Sets the output parameter value after the thread awakens (from WaitSynchronizationN SVC only) diff --git a/src/core/hle/kernel/vm_manager.cpp b/src/core/hle/kernel/vm_manager.cpp index 6601f1f9d..b0dcbb07d 100644 --- a/src/core/hle/kernel/vm_manager.cpp +++ b/src/core/hle/kernel/vm_manager.cpp @@ -83,8 +83,8 @@ ResultVal VMManager::MapBackingMemoryToBase(VAddr base, u32 region_size, // Do not try to allocate the block if there are no available addresses within the desired // region. if (vma_handle == vma_map.end() || target + size > base + region_size) { - return ResultCode(ErrorDescription::OutOfMemory, ErrorModule::Kernel, - ErrorSummary::OutOfResource, ErrorLevel::Permanent); + return Result(ErrorDescription::OutOfMemory, ErrorModule::Kernel, + ErrorSummary::OutOfResource, ErrorLevel::Permanent); } auto result = MapBackingMemory(target, memory, size, state); @@ -114,9 +114,9 @@ ResultVal VMManager::MapBackingMemory(VAddr target, Memory return MergeAdjacent(vma_handle); } -ResultCode VMManager::ChangeMemoryState(VAddr target, u32 size, MemoryState expected_state, - VMAPermission expected_perms, MemoryState new_state, - VMAPermission new_perms) { +Result VMManager::ChangeMemoryState(VAddr target, u32 size, MemoryState expected_state, + VMAPermission expected_perms, MemoryState new_state, + VMAPermission new_perms) { if (is_locked) { return RESULT_SUCCESS; } @@ -168,7 +168,7 @@ VMManager::VMAIter VMManager::Unmap(VMAIter vma_handle) { return MergeAdjacent(vma_handle); } -ResultCode VMManager::UnmapRange(VAddr target, u32 size) { +Result VMManager::UnmapRange(VAddr target, u32 size) { ASSERT(!is_locked); CASCADE_RESULT(VMAIter vma, CarveVMARange(target, size)); @@ -197,7 +197,7 @@ VMManager::VMAHandle VMManager::Reprotect(VMAHandle vma_handle, VMAPermission ne return MergeAdjacent(iter); } -ResultCode VMManager::ReprotectRange(VAddr target, u32 size, VMAPermission new_perms) { +Result VMManager::ReprotectRange(VAddr target, u32 size, VMAPermission new_perms) { ASSERT(!is_locked); CASCADE_RESULT(VMAIter vma, CarveVMARange(target, size)); diff --git a/src/core/hle/kernel/vm_manager.h b/src/core/hle/kernel/vm_manager.h index 6114594f6..37aac9cdf 100644 --- a/src/core/hle/kernel/vm_manager.h +++ b/src/core/hle/kernel/vm_manager.h @@ -165,18 +165,18 @@ public: * @param new_state New MemoryState for the range. * @param new_perms New VMAPermission for the range. */ - ResultCode ChangeMemoryState(VAddr target, u32 size, MemoryState expected_state, - VMAPermission expected_perms, MemoryState new_state, - VMAPermission new_perms); + Result ChangeMemoryState(VAddr target, u32 size, MemoryState expected_state, + VMAPermission expected_perms, MemoryState new_state, + VMAPermission new_perms); /// Unmaps a range of addresses, splitting VMAs as necessary. - ResultCode UnmapRange(VAddr target, u32 size); + Result UnmapRange(VAddr target, u32 size); /// Changes the permissions of the given VMA. VMAHandle Reprotect(VMAHandle vma, VMAPermission new_perms); /// Changes the permissions of a range of addresses, splitting VMAs as necessary. - ResultCode ReprotectRange(VAddr target, u32 size, VMAPermission new_perms); + Result ReprotectRange(VAddr target, u32 size, VMAPermission new_perms); /// Dumps the address space layout to the log, for debugging void LogLayout(Common::Log::Level log_level) const; diff --git a/src/core/hle/result.h b/src/core/hle/result.h index 82bac490e..0dc1fa483 100644 --- a/src/core/hle/result.h +++ b/src/core/hle/result.h @@ -192,7 +192,7 @@ enum class ErrorLevel : u32 { }; /// Encapsulates a CTR-OS error code, allowing it to be separated into its constituent fields. -union ResultCode { +union Result { u32 raw; BitField<0, 10, u32> description; @@ -205,18 +205,18 @@ union ResultCode { // error BitField<31, 1, u32> is_error; - constexpr explicit ResultCode(u32 raw) : raw(raw) {} + constexpr explicit Result(u32 raw) : raw(raw) {} - constexpr ResultCode(ErrorDescription description, ErrorModule module, ErrorSummary summary, - ErrorLevel level) - : ResultCode(static_cast(description), module, summary, level) {} + constexpr Result(ErrorDescription description, ErrorModule module, ErrorSummary summary, + ErrorLevel level) + : Result(static_cast(description), module, summary, level) {} - constexpr ResultCode(u32 description_, ErrorModule module_, ErrorSummary summary_, - ErrorLevel level_) + constexpr Result(u32 description_, ErrorModule module_, ErrorSummary summary_, + ErrorLevel level_) : raw(description.FormatValue(description_) | module.FormatValue(module_) | summary.FormatValue(summary_) | level.FormatValue(level_)) {} - constexpr ResultCode& operator=(const ResultCode& o) = default; + constexpr Result& operator=(const Result& o) = default; constexpr bool IsSuccess() const { return is_error.ExtractValue(raw) == 0; @@ -234,23 +234,23 @@ private: friend class boost::serialization::access; }; -constexpr bool operator==(const ResultCode& a, const ResultCode& b) { +constexpr bool operator==(const Result& a, const Result& b) { return a.raw == b.raw; } -constexpr bool operator!=(const ResultCode& a, const ResultCode& b) { +constexpr bool operator!=(const Result& a, const Result& b) { return a.raw != b.raw; } // Convenience functions for creating some common kinds of errors: -/// The default success `ResultCode`. -constexpr ResultCode RESULT_SUCCESS(0); +/// The default success `Result`. +constexpr Result RESULT_SUCCESS(0); /// Might be returned instead of a dummy success for unimplemented APIs. -constexpr ResultCode UnimplementedFunction(ErrorModule module) { - return ResultCode(ErrorDescription::NotImplemented, module, ErrorSummary::NotSupported, - ErrorLevel::Permanent); +constexpr Result UnimplementedFunction(ErrorModule module) { + return Result(ErrorDescription::NotImplemented, module, ErrorSummary::NotSupported, + ErrorLevel::Permanent); } /** @@ -259,10 +259,10 @@ constexpr ResultCode UnimplementedFunction(ErrorModule module) { * @note This should only be used when a particular error code * is not known yet. */ -constexpr ResultCode RESULT_UNKNOWN(UINT32_MAX); +constexpr Result RESULT_UNKNOWN(UINT32_MAX); /** - * This is an optional value type. It holds a `ResultCode` and, if that code is ResultSuccess, it + * This is an optional value type. It holds a `Result` and, if that code is ResultSuccess, it * also holds a result of type `T`. If the code is an error code (not ResultSuccess), then trying * to access the inner value with operator* is undefined behavior and will assert with Unwrap(). * Users of this class must be cognizant to check the status of the ResultVal with operator bool(), @@ -273,7 +273,7 @@ constexpr ResultCode RESULT_UNKNOWN(UINT32_MAX); * ResultVal Frobnicate(float strength) { * if (strength < 0.f || strength > 1.0f) { * // Can't frobnicate too weakly or too strongly - * return ResultCode(ErrorDescription::OutOfRange, ErrorModule::Common, + * return Result(ErrorDescription::OutOfRange, ErrorModule::Common, * ErrorSummary::InvalidArgument, ErrorLevel::Permanent); * } else { * // Frobnicated! Give caller a cookie @@ -297,7 +297,7 @@ class ResultVal { public: constexpr ResultVal() : expected{} {} - constexpr ResultVal(ResultCode code) : expected{Common::Unexpected(code)} {} + constexpr ResultVal(Result code) : expected{Common::Unexpected(code)} {} template constexpr ResultVal(U&& val) : expected{std::forward(val)} {} @@ -317,7 +317,7 @@ public: return expected.has_value(); } - [[nodiscard]] constexpr ResultCode Code() const { + [[nodiscard]] constexpr Result Code() const { return expected.has_value() ? RESULT_SUCCESS : expected.error(); } @@ -385,7 +385,7 @@ public: private: // TODO: Replace this with std::expected once it is standardized in the STL. - Common::Expected expected; + Common::Expected expected; }; /** @@ -401,7 +401,7 @@ private: target = std::move(*CONCAT2(check_result_L, __LINE__)) /** - * Analogous to CASCADE_RESULT, but for a bare ResultCode. The code will be propagated if + * Analogous to CASCADE_RESULT, but for a bare Result. The code will be propagated if * non-success, or discarded otherwise. */ #define CASCADE_CODE(source) \ @@ -409,8 +409,8 @@ private: if (CONCAT2(check_result_L, __LINE__).IsError()) \ return CONCAT2(check_result_L, __LINE__); -#define R_SUCCEEDED(res) (static_cast(res).IsSuccess()) -#define R_FAILED(res) (static_cast(res).IsError()) +#define R_SUCCEEDED(res) (static_cast(res).IsSuccess()) +#define R_FAILED(res) (static_cast(res).IsError()) /// Evaluates a boolean expression, and returns a result unless that expression is true. #define R_UNLESS(expr, res) \ diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index cf68e34e9..769c17892 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp @@ -93,7 +93,7 @@ ResultVal CIAFile::Read(u64 offset, std::size_t length, u8* buffer) return length; } -ResultCode CIAFile::WriteTicket() { +Result CIAFile::WriteTicket() { auto load_result = container.LoadTicket(data, container.GetTicketOffset()); if (load_result != Loader::ResultStatus::Success) { LOG_ERROR(Service_AM, "Could not read ticket from CIA."); @@ -108,7 +108,7 @@ ResultCode CIAFile::WriteTicket() { return RESULT_SUCCESS; } -ResultCode CIAFile::WriteTitleMetadata() { +Result CIAFile::WriteTitleMetadata() { auto load_result = container.LoadTitleMetadata(data, container.GetTitleMetadataOffset()); if (load_result != Loader::ResultStatus::Success) { LOG_ERROR(Service_AM, "Could not read title metadata from CIA."); @@ -789,8 +789,8 @@ void Module::Interface::FindDLCContentInfos(Kernel::HLERequestContext& ctx) { u32 tid_high = static_cast(title_id >> 32); if (tid_high != TID_HIGH_DLC) { IPC::RequestBuilder rb = rp.MakeBuilder(1, 4); - rb.Push(ResultCode(ErrCodes::InvalidTIDInList, ErrorModule::AM, - ErrorSummary::InvalidArgument, ErrorLevel::Usage)); + rb.Push(Result(ErrCodes::InvalidTIDInList, ErrorModule::AM, ErrorSummary::InvalidArgument, + ErrorLevel::Usage)); rb.PushMappedBuffer(content_requested_in); rb.PushMappedBuffer(content_info_out); return; @@ -854,8 +854,8 @@ void Module::Interface::ListDLCContentInfos(Kernel::HLERequestContext& ctx) { u32 tid_high = static_cast(title_id >> 32); if (tid_high != TID_HIGH_DLC) { IPC::RequestBuilder rb = rp.MakeBuilder(2, 2); - rb.Push(ResultCode(ErrCodes::InvalidTIDInList, ErrorModule::AM, - ErrorSummary::InvalidArgument, ErrorLevel::Usage)); + rb.Push(Result(ErrCodes::InvalidTIDInList, ErrorModule::AM, ErrorSummary::InvalidArgument, + ErrorLevel::Usage)); rb.Push(0); rb.PushMappedBuffer(content_info_out); return; @@ -934,9 +934,8 @@ void Module::Interface::GetProgramList(Kernel::HLERequestContext& ctx) { rb.PushMappedBuffer(title_ids_output); } -ResultCode GetTitleInfoFromList(std::span title_id_list, - Service::FS::MediaType media_type, - Kernel::MappedBuffer& title_info_out) { +Result GetTitleInfoFromList(std::span title_id_list, Service::FS::MediaType media_type, + Kernel::MappedBuffer& title_info_out) { std::size_t write_offset = 0; for (u32 i = 0; i < title_id_list.size(); i++) { std::string tmd_path = GetTitleMetadataPath(media_type, title_id_list[i]); @@ -952,8 +951,8 @@ ResultCode GetTitleInfoFromList(std::span title_id_list, title_info.version = tmd.GetTitleVersion(); title_info.type = tmd.GetTitleType(); } else { - return ResultCode(ErrorDescription::NotFound, ErrorModule::AM, - ErrorSummary::InvalidState, ErrorLevel::Permanent); + return Result(ErrorDescription::NotFound, ErrorModule::AM, ErrorSummary::InvalidState, + ErrorLevel::Permanent); } title_info_out.Write(&title_info, write_offset, sizeof(TitleInfo)); write_offset += sizeof(TitleInfo); @@ -973,7 +972,7 @@ void Module::Interface::GetProgramInfos(Kernel::HLERequestContext& ctx) { std::vector title_id_list(title_count); title_id_list_buffer.Read(title_id_list.data(), 0, title_count * sizeof(u64)); - ResultCode result = GetTitleInfoFromList(title_id_list, media_type, title_info_out); + Result result = GetTitleInfoFromList(title_id_list, media_type, title_info_out); IPC::RequestBuilder rb = rp.MakeBuilder(1, 4); rb.Push(result); @@ -994,15 +993,15 @@ void Module::Interface::DeleteUserProgram(Kernel::HLERequestContext& ctx) { u8 variation = static_cast(title_id & 0xFF); if (category & CATEGORY_SYSTEM || category & CATEGORY_DLP || variation & VARIATION_SYSTEM) { LOG_ERROR(Service_AM, "Trying to uninstall system app"); - rb.Push(ResultCode(ErrCodes::TryingToUninstallSystemApp, ErrorModule::AM, - ErrorSummary::InvalidArgument, ErrorLevel::Usage)); + rb.Push(Result(ErrCodes::TryingToUninstallSystemApp, ErrorModule::AM, + ErrorSummary::InvalidArgument, ErrorLevel::Usage)); return; } LOG_INFO(Service_AM, "Deleting title 0x{:016x}", title_id); std::string path = GetTitlePath(media_type, title_id); if (!FileUtil::Exists(path)) { - rb.Push(ResultCode(ErrorDescription::NotFound, ErrorModule::AM, ErrorSummary::InvalidState, - ErrorLevel::Permanent)); + rb.Push(Result(ErrorDescription::NotFound, ErrorModule::AM, ErrorSummary::InvalidState, + ErrorLevel::Permanent)); LOG_ERROR(Service_AM, "Title not found"); return; } @@ -1021,8 +1020,8 @@ void Module::Interface::GetProductCode(Kernel::HLERequestContext& ctx) { if (!FileUtil::Exists(path)) { IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); - rb.Push(ResultCode(ErrorDescription::NotFound, ErrorModule::AM, ErrorSummary::InvalidState, - ErrorLevel::Permanent)); + rb.Push(Result(ErrorDescription::NotFound, ErrorModule::AM, ErrorSummary::InvalidState, + ErrorLevel::Permanent)); } else { struct ProductCode { u8 code[0x10]; @@ -1050,14 +1049,14 @@ void Module::Interface::GetDLCTitleInfos(Kernel::HLERequestContext& ctx) { std::vector title_id_list(title_count); title_id_list_buffer.Read(title_id_list.data(), 0, title_count * sizeof(u64)); - ResultCode result = RESULT_SUCCESS; + Result result = RESULT_SUCCESS; // Validate that DLC TIDs were passed in for (u32 i = 0; i < title_count; i++) { u32 tid_high = static_cast(title_id_list[i] >> 32); if (tid_high != TID_HIGH_DLC) { - result = ResultCode(ErrCodes::InvalidTIDInList, ErrorModule::AM, - ErrorSummary::InvalidArgument, ErrorLevel::Usage); + result = Result(ErrCodes::InvalidTIDInList, ErrorModule::AM, + ErrorSummary::InvalidArgument, ErrorLevel::Usage); break; } } @@ -1083,14 +1082,14 @@ void Module::Interface::GetPatchTitleInfos(Kernel::HLERequestContext& ctx) { std::vector title_id_list(title_count); title_id_list_buffer.Read(title_id_list.data(), 0, title_count * sizeof(u64)); - ResultCode result = RESULT_SUCCESS; + Result result = RESULT_SUCCESS; // Validate that update TIDs were passed in for (u32 i = 0; i < title_count; i++) { u32 tid_high = static_cast(title_id_list[i] >> 32); if (tid_high != TID_HIGH_UPDATE) { - result = ResultCode(ErrCodes::InvalidTIDInList, ErrorModule::AM, - ErrorSummary::InvalidArgument, ErrorLevel::Usage); + result = Result(ErrCodes::InvalidTIDInList, ErrorModule::AM, + ErrorSummary::InvalidArgument, ErrorLevel::Usage); break; } } @@ -1142,8 +1141,8 @@ void Module::Interface::GetDLCContentInfoCount(Kernel::HLERequestContext& ctx) { u32 tid_high = static_cast(title_id >> 32); if (tid_high != TID_HIGH_DLC) { IPC::RequestBuilder rb = rp.MakeBuilder(2, 2); - rb.Push(ResultCode(ErrCodes::InvalidTID, ErrorModule::AM, ErrorSummary::InvalidArgument, - ErrorLevel::Usage)); + rb.Push(Result(ErrCodes::InvalidTID, ErrorModule::AM, ErrorSummary::InvalidArgument, + ErrorLevel::Usage)); rb.Push(0); return; } @@ -1319,8 +1318,8 @@ void Module::Interface::BeginImportProgram(Kernel::HLERequestContext& ctx) { if (am->cia_installing) { IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); - rb.Push(ResultCode(ErrCodes::CIACurrentlyInstalling, ErrorModule::AM, - ErrorSummary::InvalidState, ErrorLevel::Permanent)); + rb.Push(Result(ErrCodes::CIACurrentlyInstalling, ErrorModule::AM, + ErrorSummary::InvalidState, ErrorLevel::Permanent)); return; } @@ -1344,8 +1343,8 @@ void Module::Interface::BeginImportProgramTemporarily(Kernel::HLERequestContext& if (am->cia_installing) { IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); - rb.Push(ResultCode(ErrCodes::CIACurrentlyInstalling, ErrorModule::AM, - ErrorSummary::InvalidState, ErrorLevel::Permanent)); + rb.Push(Result(ErrCodes::CIACurrentlyInstalling, ErrorModule::AM, + ErrorSummary::InvalidState, ErrorLevel::Permanent)); return; } @@ -1492,8 +1491,8 @@ void Module::Interface::GetProgramInfoFromCia(Kernel::HLERequestContext& ctx) { FileSys::CIAContainer container; if (container.Load(*file_res.Unwrap()) != Loader::ResultStatus::Success) { IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); - rb.Push(ResultCode(ErrCodes::InvalidCIAHeader, ErrorModule::AM, - ErrorSummary::InvalidArgument, ErrorLevel::Permanent)); + rb.Push(Result(ErrCodes::InvalidCIAHeader, ErrorModule::AM, ErrorSummary::InvalidArgument, + ErrorLevel::Permanent)); return; } @@ -1533,8 +1532,8 @@ void Module::Interface::GetSystemMenuDataFromCia(Kernel::HLERequestContext& ctx) FileSys::CIAContainer container; if (container.Load(*file) != Loader::ResultStatus::Success) { IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); - rb.Push(ResultCode(ErrCodes::InvalidCIAHeader, ErrorModule::AM, - ErrorSummary::InvalidArgument, ErrorLevel::Permanent)); + rb.Push(Result(ErrCodes::InvalidCIAHeader, ErrorModule::AM, ErrorSummary::InvalidArgument, + ErrorLevel::Permanent)); rb.PushMappedBuffer(output_buffer); return; } @@ -1545,8 +1544,8 @@ void Module::Interface::GetSystemMenuDataFromCia(Kernel::HLERequestContext& ctx) temp.size(), temp.data()); if (read_result.Failed() || *read_result != temp.size()) { IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); - rb.Push(ResultCode(ErrCodes::InvalidCIAHeader, ErrorModule::AM, - ErrorSummary::InvalidArgument, ErrorLevel::Permanent)); + rb.Push(Result(ErrCodes::InvalidCIAHeader, ErrorModule::AM, ErrorSummary::InvalidArgument, + ErrorLevel::Permanent)); rb.PushMappedBuffer(output_buffer); return; } @@ -1572,8 +1571,8 @@ void Module::Interface::GetDependencyListFromCia(Kernel::HLERequestContext& ctx) FileSys::CIAContainer container; if (container.Load(*file_res.Unwrap()) != Loader::ResultStatus::Success) { IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); - rb.Push(ResultCode(ErrCodes::InvalidCIAHeader, ErrorModule::AM, - ErrorSummary::InvalidArgument, ErrorLevel::Permanent)); + rb.Push(Result(ErrCodes::InvalidCIAHeader, ErrorModule::AM, ErrorSummary::InvalidArgument, + ErrorLevel::Permanent)); return; } @@ -1599,8 +1598,8 @@ void Module::Interface::GetTransferSizeFromCia(Kernel::HLERequestContext& ctx) { FileSys::CIAContainer container; if (container.Load(*file_res.Unwrap()) != Loader::ResultStatus::Success) { IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); - rb.Push(ResultCode(ErrCodes::InvalidCIAHeader, ErrorModule::AM, - ErrorSummary::InvalidArgument, ErrorLevel::Permanent)); + rb.Push(Result(ErrCodes::InvalidCIAHeader, ErrorModule::AM, ErrorSummary::InvalidArgument, + ErrorLevel::Permanent)); return; } @@ -1623,8 +1622,8 @@ void Module::Interface::GetCoreVersionFromCia(Kernel::HLERequestContext& ctx) { FileSys::CIAContainer container; if (container.Load(*file_res.Unwrap()) != Loader::ResultStatus::Success) { IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); - rb.Push(ResultCode(ErrCodes::InvalidCIAHeader, ErrorModule::AM, - ErrorSummary::InvalidArgument, ErrorLevel::Permanent)); + rb.Push(Result(ErrCodes::InvalidCIAHeader, ErrorModule::AM, ErrorSummary::InvalidArgument, + ErrorLevel::Permanent)); return; } @@ -1648,8 +1647,8 @@ void Module::Interface::GetRequiredSizeFromCia(Kernel::HLERequestContext& ctx) { FileSys::CIAContainer container; if (container.Load(*file_res.Unwrap()) != Loader::ResultStatus::Success) { IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); - rb.Push(ResultCode(ErrCodes::InvalidCIAHeader, ErrorModule::AM, - ErrorSummary::InvalidArgument, ErrorLevel::Permanent)); + rb.Push(Result(ErrCodes::InvalidCIAHeader, ErrorModule::AM, ErrorSummary::InvalidArgument, + ErrorLevel::Permanent)); return; } @@ -1661,7 +1660,7 @@ void Module::Interface::GetRequiredSizeFromCia(Kernel::HLERequestContext& ctx) { rb.Push(container.GetTitleMetadata().GetContentSizeByIndex(FileSys::TMDContentIndex::Main)); } -ResultCode UninstallProgram(const FS::MediaType media_type, const u64 title_id) { +Result UninstallProgram(const FS::MediaType media_type, const u64 title_id) { // Use the content folder so we don't delete the user's save data. const auto path = GetTitlePath(media_type, title_id) + "content/"; if (!FileUtil::Exists(path)) { @@ -1713,8 +1712,8 @@ void Module::Interface::GetMetaSizeFromCia(Kernel::HLERequestContext& ctx) { if (container.Load(*file_res.Unwrap()) != Loader::ResultStatus::Success) { IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); - rb.Push(ResultCode(ErrCodes::InvalidCIAHeader, ErrorModule::AM, - ErrorSummary::InvalidArgument, ErrorLevel::Permanent)); + rb.Push(Result(ErrCodes::InvalidCIAHeader, ErrorModule::AM, ErrorSummary::InvalidArgument, + ErrorLevel::Permanent)); return; } @@ -1744,8 +1743,8 @@ void Module::Interface::GetMetaDataFromCia(Kernel::HLERequestContext& ctx) { FileSys::CIAContainer container; if (container.Load(*file) != Loader::ResultStatus::Success) { IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); - rb.Push(ResultCode(ErrCodes::InvalidCIAHeader, ErrorModule::AM, - ErrorSummary::InvalidArgument, ErrorLevel::Permanent)); + rb.Push(Result(ErrCodes::InvalidCIAHeader, ErrorModule::AM, ErrorSummary::InvalidArgument, + ErrorLevel::Permanent)); rb.PushMappedBuffer(output_buffer); return; } @@ -1755,8 +1754,8 @@ void Module::Interface::GetMetaDataFromCia(Kernel::HLERequestContext& ctx) { auto read_result = file->Read(container.GetMetadataOffset(), output_size, temp.data()); if (read_result.Failed() || *read_result != output_size) { IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); - rb.Push(ResultCode(ErrCodes::InvalidCIAHeader, ErrorModule::AM, - ErrorSummary::InvalidArgument, ErrorLevel::Permanent)); + rb.Push(Result(ErrCodes::InvalidCIAHeader, ErrorModule::AM, ErrorSummary::InvalidArgument, + ErrorLevel::Permanent)); return; } diff --git a/src/core/hle/service/am/am.h b/src/core/hle/service/am/am.h index 9f115086c..fed2228a6 100644 --- a/src/core/hle/service/am/am.h +++ b/src/core/hle/service/am/am.h @@ -84,8 +84,8 @@ public: ~CIAFile(); ResultVal Read(u64 offset, std::size_t length, u8* buffer) const override; - ResultCode WriteTicket(); - ResultCode WriteTitleMetadata(); + Result WriteTicket(); + Result WriteTitleMetadata(); ResultVal WriteContentData(u64 offset, std::size_t length, const u8* buffer); ResultVal Write(u64 offset, std::size_t length, bool flush, const u8* buffer) override; @@ -203,7 +203,7 @@ std::string GetMediaTitlePath(Service::FS::MediaType media_type); * @param title_id the title ID to uninstall * @return result of the uninstall operation */ -ResultCode UninstallProgram(const FS::MediaType media_type, const u64 title_id); +Result UninstallProgram(const FS::MediaType media_type, const u64 title_id); class Module final { public: diff --git a/src/core/hle/service/apt/applet_manager.cpp b/src/core/hle/service/apt/applet_manager.cpp index db55a6d10..f30a6ddaa 100644 --- a/src/core/hle/service/apt/applet_manager.cpp +++ b/src/core/hle/service/apt/applet_manager.cpp @@ -261,7 +261,7 @@ void AppletManager::CancelAndSendParameter(const MessageParameter& parameter) { } } -ResultCode AppletManager::SendParameter(const MessageParameter& parameter) { +Result AppletManager::SendParameter(const MessageParameter& parameter) { // A new parameter can not be sent if the previous one hasn't been consumed yet if (next_parameter) { LOG_WARNING(Service_APT, "Parameter from {:03X} to {:03X} blocked by pending parameter.", @@ -276,13 +276,13 @@ ResultCode AppletManager::SendParameter(const MessageParameter& parameter) { ResultVal AppletManager::GlanceParameter(AppletId app_id) { if (!next_parameter) { - return ResultCode(ErrorDescription::NoData, ErrorModule::Applet, ErrorSummary::InvalidState, - ErrorLevel::Status); + return Result(ErrorDescription::NoData, ErrorModule::Applet, ErrorSummary::InvalidState, + ErrorLevel::Status); } if (next_parameter->destination_id != app_id) { - return ResultCode(ErrorDescription::NotFound, ErrorModule::Applet, ErrorSummary::NotFound, - ErrorLevel::Status); + return Result(ErrorDescription::NotFound, ErrorModule::Applet, ErrorSummary::NotFound, + ErrorLevel::Status); } auto parameter = *next_parameter; @@ -348,8 +348,8 @@ ResultVal AppletManager::Initialize(AppletId ap auto slot_data = GetAppletSlot(slot); if (slot_data->registered) { LOG_WARNING(Service_APT, "Applet attempted to register in occupied slot {:02X}", slot); - return ResultCode(ErrorDescription::AlreadyExists, ErrorModule::Applet, - ErrorSummary::InvalidState, ErrorLevel::Status); + return Result(ErrorDescription::AlreadyExists, ErrorModule::Applet, + ErrorSummary::InvalidState, ErrorLevel::Status); } LOG_DEBUG(Service_APT, "Initializing applet with ID {:03X} and attributes {:08X}.", app_id, @@ -377,7 +377,7 @@ ResultVal AppletManager::Initialize(AppletId ap return InitializeResult{slot_data->notification_event, slot_data->parameter_event}; } -ResultCode AppletManager::Enable(AppletAttributes attributes) { +Result AppletManager::Enable(AppletAttributes attributes) { auto slot = GetAppletSlotFromAttributes(attributes); if (slot == AppletSlot::Error) { LOG_WARNING(Service_APT, @@ -409,7 +409,7 @@ ResultCode AppletManager::Enable(AppletAttributes attributes) { return RESULT_SUCCESS; } -ResultCode AppletManager::Finalize(AppletId app_id) { +Result AppletManager::Finalize(AppletId app_id) { auto slot = GetAppletSlotFromId(app_id); if (slot == AppletSlot::Error) { return {ErrorDescription::NotFound, ErrorModule::Applet, ErrorSummary::NotFound, @@ -446,14 +446,14 @@ bool AppletManager::IsRegistered(AppletId app_id) { ResultVal AppletManager::GetAttribute(AppletId app_id) { auto slot = GetAppletSlotFromId(app_id); if (slot == AppletSlot::Error) { - return ResultCode(ErrorDescription::NotFound, ErrorModule::Applet, ErrorSummary::NotFound, - ErrorLevel::Status); + return Result(ErrorDescription::NotFound, ErrorModule::Applet, ErrorSummary::NotFound, + ErrorLevel::Status); } auto slot_data = GetAppletSlot(slot); if (!slot_data->registered) { - return ResultCode(ErrorDescription::NotFound, ErrorModule::Applet, ErrorSummary::NotFound, - ErrorLevel::Status); + return Result(ErrorDescription::NotFound, ErrorModule::Applet, ErrorSummary::NotFound, + ErrorLevel::Status); } return slot_data->attributes; @@ -470,11 +470,11 @@ ResultVal AppletManager::InquireNotification(AppletId app_id) { } } - return ResultCode(ErrorDescription::NotFound, ErrorModule::Applet, ErrorSummary::NotFound, - ErrorLevel::Status); + return Result(ErrorDescription::NotFound, ErrorModule::Applet, ErrorSummary::NotFound, + ErrorLevel::Status); } -ResultCode AppletManager::SendNotification(Notification notification) { +Result AppletManager::SendNotification(Notification notification) { if (active_slot != AppletSlot::Error) { const auto slot_data = GetAppletSlot(active_slot); if (slot_data->registered) { @@ -497,7 +497,7 @@ void AppletManager::SendNotificationToAll(Notification notification) { } } -ResultCode AppletManager::PrepareToStartLibraryApplet(AppletId applet_id) { +Result AppletManager::PrepareToStartLibraryApplet(AppletId applet_id) { // The real APT service returns an error if there's a pending APT parameter when this function // is called. if (next_parameter) { @@ -534,7 +534,7 @@ ResultCode AppletManager::PrepareToStartLibraryApplet(AppletId applet_id) { } } -ResultCode AppletManager::PreloadLibraryApplet(AppletId applet_id) { +Result AppletManager::PreloadLibraryApplet(AppletId applet_id) { if (GetAppletSlot(AppletSlot::LibraryApplet)->registered) { return {ErrorDescription::AlreadyExists, ErrorModule::Applet, ErrorSummary::InvalidState, ErrorLevel::Status}; @@ -562,15 +562,14 @@ ResultCode AppletManager::PreloadLibraryApplet(AppletId applet_id) { } } -ResultCode AppletManager::FinishPreloadingLibraryApplet(AppletId applet_id) { +Result AppletManager::FinishPreloadingLibraryApplet(AppletId applet_id) { // TODO(Subv): This function should fail depending on the applet preparation state. GetAppletSlot(AppletSlot::LibraryApplet)->loaded = true; return RESULT_SUCCESS; } -ResultCode AppletManager::StartLibraryApplet(AppletId applet_id, - std::shared_ptr object, - const std::vector& buffer) { +Result AppletManager::StartLibraryApplet(AppletId applet_id, std::shared_ptr object, + const std::vector& buffer) { active_slot = AppletSlot::LibraryApplet; auto send_res = SendParameter({ @@ -588,8 +587,7 @@ ResultCode AppletManager::StartLibraryApplet(AppletId applet_id, return RESULT_SUCCESS; } -ResultCode AppletManager::PrepareToCloseLibraryApplet(bool not_pause, bool exiting, - bool jump_home) { +Result AppletManager::PrepareToCloseLibraryApplet(bool not_pause, bool exiting, bool jump_home) { if (next_parameter) { return {ErrCodes::ParameterPresent, ErrorModule::Applet, ErrorSummary::InvalidState, ErrorLevel::Status}; @@ -607,8 +605,8 @@ ResultCode AppletManager::PrepareToCloseLibraryApplet(bool not_pause, bool exiti return RESULT_SUCCESS; } -ResultCode AppletManager::CloseLibraryApplet(std::shared_ptr object, - const std::vector& buffer) { +Result AppletManager::CloseLibraryApplet(std::shared_ptr object, + const std::vector& buffer) { auto slot = GetAppletSlot(AppletSlot::LibraryApplet); auto destination_id = GetAppletSlotId(last_library_launcher_slot); @@ -633,7 +631,7 @@ ResultCode AppletManager::CloseLibraryApplet(std::shared_ptr obj return RESULT_SUCCESS; } -ResultCode AppletManager::CancelLibraryApplet(bool app_exiting) { +Result AppletManager::CancelLibraryApplet(bool app_exiting) { if (next_parameter) { return {ErrCodes::ParameterPresent, ErrorModule::Applet, ErrorSummary::InvalidState, ErrorLevel::Status}; @@ -652,8 +650,8 @@ ResultCode AppletManager::CancelLibraryApplet(bool app_exiting) { }); } -ResultCode AppletManager::SendDspSleep(AppletId from_applet_id, - std::shared_ptr object) { +Result AppletManager::SendDspSleep(AppletId from_applet_id, + std::shared_ptr object) { auto lib_slot = GetAppletSlotFromPos(AppletPos::Library); auto lib_app_id = lib_slot != AppletSlot::Error ? GetAppletSlot(lib_slot)->applet_id : AppletId::None; @@ -684,8 +682,8 @@ ResultCode AppletManager::SendDspSleep(AppletId from_applet_id, return RESULT_SUCCESS; } -ResultCode AppletManager::SendDspWakeUp(AppletId from_applet_id, - std::shared_ptr object) { +Result AppletManager::SendDspWakeUp(AppletId from_applet_id, + std::shared_ptr object) { auto lib_slot = GetAppletSlotFromPos(AppletPos::Library); auto lib_app_id = lib_slot != AppletSlot::Error ? GetAppletSlot(lib_slot)->applet_id : AppletId::None; @@ -717,7 +715,7 @@ ResultCode AppletManager::SendDspWakeUp(AppletId from_applet_id, return RESULT_SUCCESS; } -ResultCode AppletManager::PrepareToStartSystemApplet(AppletId applet_id) { +Result AppletManager::PrepareToStartSystemApplet(AppletId applet_id) { // The real APT service returns an error if there's a pending APT parameter when this function // is called. if (next_parameter) { @@ -729,9 +727,8 @@ ResultCode AppletManager::PrepareToStartSystemApplet(AppletId applet_id) { return RESULT_SUCCESS; } -ResultCode AppletManager::StartSystemApplet(AppletId applet_id, - std::shared_ptr object, - const std::vector& buffer) { +Result AppletManager::StartSystemApplet(AppletId applet_id, std::shared_ptr object, + const std::vector& buffer) { auto source_applet_id = AppletId::None; if (last_system_launcher_slot != AppletSlot::Error) { const auto slot_data = GetAppletSlot(last_system_launcher_slot); @@ -772,7 +769,7 @@ ResultCode AppletManager::StartSystemApplet(AppletId applet_id, return RESULT_SUCCESS; } -ResultCode AppletManager::PrepareToCloseSystemApplet() { +Result AppletManager::PrepareToCloseSystemApplet() { if (next_parameter) { return {ErrCodes::ParameterPresent, ErrorModule::Applet, ErrorSummary::InvalidState, ErrorLevel::Status}; @@ -781,8 +778,8 @@ ResultCode AppletManager::PrepareToCloseSystemApplet() { return RESULT_SUCCESS; } -ResultCode AppletManager::CloseSystemApplet(std::shared_ptr object, - const std::vector& buffer) { +Result AppletManager::CloseSystemApplet(std::shared_ptr object, + const std::vector& buffer) { ASSERT_MSG(active_slot == AppletSlot::HomeMenu || active_slot == AppletSlot::SystemApplet, "Attempting to close a system applet from a non-system applet."); @@ -809,7 +806,7 @@ ResultCode AppletManager::CloseSystemApplet(std::shared_ptr obje return RESULT_SUCCESS; } -ResultCode AppletManager::OrderToCloseSystemApplet() { +Result AppletManager::OrderToCloseSystemApplet() { if (active_slot == AppletSlot::Error) { return {ErrCodes::InvalidAppletSlot, ErrorModule::Applet, ErrorSummary::InvalidState, ErrorLevel::Status}; @@ -846,7 +843,7 @@ ResultCode AppletManager::OrderToCloseSystemApplet() { return RESULT_SUCCESS; } -ResultCode AppletManager::PrepareToJumpToHomeMenu() { +Result AppletManager::PrepareToJumpToHomeMenu() { if (next_parameter) { return {ErrCodes::ParameterPresent, ErrorModule::Applet, ErrorSummary::InvalidState, ErrorLevel::Status}; @@ -863,8 +860,8 @@ ResultCode AppletManager::PrepareToJumpToHomeMenu() { return RESULT_SUCCESS; } -ResultCode AppletManager::JumpToHomeMenu(std::shared_ptr object, - const std::vector& buffer) { +Result AppletManager::JumpToHomeMenu(std::shared_ptr object, + const std::vector& buffer) { if (last_jump_to_home_slot != AppletSlot::Error) { auto slot_data = GetAppletSlot(last_jump_to_home_slot); if (slot_data->applet_id != AppletId::None) { @@ -913,7 +910,7 @@ ResultCode AppletManager::JumpToHomeMenu(std::shared_ptr object, return RESULT_SUCCESS; } -ResultCode AppletManager::PrepareToLeaveHomeMenu() { +Result AppletManager::PrepareToLeaveHomeMenu() { if (!GetAppletSlot(AppletSlot::Application)->registered) { return {ErrCodes::InvalidAppletSlot, ErrorModule::Applet, ErrorSummary::InvalidState, ErrorLevel::Status}; @@ -927,8 +924,8 @@ ResultCode AppletManager::PrepareToLeaveHomeMenu() { return RESULT_SUCCESS; } -ResultCode AppletManager::LeaveHomeMenu(std::shared_ptr object, - const std::vector& buffer) { +Result AppletManager::LeaveHomeMenu(std::shared_ptr object, + const std::vector& buffer) { active_slot = AppletSlot::Application; SendParameter({ @@ -942,7 +939,7 @@ ResultCode AppletManager::LeaveHomeMenu(std::shared_ptr object, return RESULT_SUCCESS; } -ResultCode AppletManager::OrderToCloseApplication() { +Result AppletManager::OrderToCloseApplication() { if (active_slot == AppletSlot::Error) { return {ErrCodes::InvalidAppletSlot, ErrorModule::Applet, ErrorSummary::InvalidState, ErrorLevel::Status}; @@ -967,7 +964,7 @@ ResultCode AppletManager::OrderToCloseApplication() { return RESULT_SUCCESS; } -ResultCode AppletManager::PrepareToCloseApplication(bool return_to_sys) { +Result AppletManager::PrepareToCloseApplication(bool return_to_sys) { if (active_slot == AppletSlot::Error) { return {ErrCodes::InvalidAppletSlot, ErrorModule::Applet, ErrorSummary::InvalidState, ErrorLevel::Status}; @@ -1018,8 +1015,8 @@ ResultCode AppletManager::PrepareToCloseApplication(bool return_to_sys) { return RESULT_SUCCESS; } -ResultCode AppletManager::CloseApplication(std::shared_ptr object, - const std::vector& buffer) { +Result AppletManager::CloseApplication(std::shared_ptr object, + const std::vector& buffer) { ordered_to_close_application = false; application_cancelled = false; @@ -1079,14 +1076,14 @@ ResultVal AppletManager::GetAppletManInfo( ResultVal AppletManager::GetAppletInfo(AppletId app_id) { auto slot = GetAppletSlotFromId(app_id); if (slot == AppletSlot::Error) { - return ResultCode(ErrorDescription::NotFound, ErrorModule::Applet, ErrorSummary::NotFound, - ErrorLevel::Status); + return Result(ErrorDescription::NotFound, ErrorModule::Applet, ErrorSummary::NotFound, + ErrorLevel::Status); } auto slot_data = GetAppletSlot(slot); if (!slot_data->registered) { - return ResultCode(ErrorDescription::NotFound, ErrorModule::Applet, ErrorSummary::NotFound, - ErrorLevel::Status); + return Result(ErrorDescription::NotFound, ErrorModule::Applet, ErrorSummary::NotFound, + ErrorLevel::Status); } auto media_type = Service::AM::GetTitleMediaType(slot_data->title_id); @@ -1102,14 +1099,13 @@ ResultVal AppletManager::GetAppletInfo(AppletId app_i ResultVal AppletManager::Unknown54(u32 in_param) { auto slot_data = GetAppletSlot(AppletSlot::Application); if (slot_data->applet_id == AppletId::None) { - return ResultCode{ErrCodes::AppNotRunning, ErrorModule::Applet, ErrorSummary::InvalidState, - ErrorLevel::Permanent}; + return Result{ErrCodes::AppNotRunning, ErrorModule::Applet, ErrorSummary::InvalidState, + ErrorLevel::Permanent}; } if (in_param >= 0x80) { // TODO: Add error description name when the parameter is known. - return ResultCode{10, ErrorModule::Applet, ErrorSummary::InvalidArgument, - ErrorLevel::Usage}; + return Result{10, ErrorModule::Applet, ErrorSummary::InvalidArgument, ErrorLevel::Usage}; } // TODO: Figure out what this logic is actually for. @@ -1154,8 +1150,8 @@ ApplicationRunningMode AppletManager::GetApplicationRunningMode() { } } -ResultCode AppletManager::PrepareToDoApplicationJump(u64 title_id, FS::MediaType media_type, - ApplicationJumpFlags flags) { +Result AppletManager::PrepareToDoApplicationJump(u64 title_id, FS::MediaType media_type, + ApplicationJumpFlags flags) { // A running application can not launch another application directly because the applet state // for the Application slot is already in use. The way this is implemented in hardware is to // launch the Home Menu and tell it to launch our desired application. @@ -1183,7 +1179,7 @@ ResultCode AppletManager::PrepareToDoApplicationJump(u64 title_id, FS::MediaType return RESULT_SUCCESS; } -ResultCode AppletManager::DoApplicationJump(const DeliverArg& arg) { +Result AppletManager::DoApplicationJump(const DeliverArg& arg) { // Note: The real console uses the Home Menu to perform the application jump, it goes // OldApplication->Home Menu->NewApplication. We do not need to use the Home Menu to do this so // we launch the new application directly. In the real APT service, the Home Menu must be @@ -1236,7 +1232,7 @@ ResultCode AppletManager::DoApplicationJump(const DeliverArg& arg) { } } -ResultCode AppletManager::PrepareToStartApplication(u64 title_id, FS::MediaType media_type) { +Result AppletManager::PrepareToStartApplication(u64 title_id, FS::MediaType media_type) { if (active_slot == AppletSlot::Error || GetAppletSlot(active_slot)->attributes.applet_pos != AppletPos::System) { return {ErrCodes::InvalidAppletSlot, ErrorModule::Applet, ErrorSummary::InvalidState, @@ -1262,8 +1258,8 @@ ResultCode AppletManager::PrepareToStartApplication(u64 title_id, FS::MediaType return RESULT_SUCCESS; } -ResultCode AppletManager::StartApplication(const std::vector& parameter, - const std::vector& hmac, bool paused) { +Result AppletManager::StartApplication(const std::vector& parameter, + const std::vector& hmac, bool paused) { // The delivery argument is always unconditionally set. deliver_arg.emplace(DeliverArg{parameter, hmac}); @@ -1298,8 +1294,8 @@ ResultCode AppletManager::StartApplication(const std::vector& parameter, return RESULT_SUCCESS; } -ResultCode AppletManager::WakeupApplication(std::shared_ptr object, - const std::vector& buffer) { +Result AppletManager::WakeupApplication(std::shared_ptr object, + const std::vector& buffer) { // Send a Wakeup signal via the apt parameter to the application once it registers itself. // The real APT service does this by spin waiting on another thread until the application is // registered. @@ -1314,7 +1310,7 @@ ResultCode AppletManager::WakeupApplication(std::shared_ptr obje return RESULT_SUCCESS; } -ResultCode AppletManager::CancelApplication() { +Result AppletManager::CancelApplication() { auto application_slot_data = GetAppletSlot(AppletSlot::Application); if (application_slot_data->applet_id == AppletId::None) { return {ErrCodes::InvalidAppletSlot, ErrorModule::Applet, ErrorSummary::InvalidState, diff --git a/src/core/hle/service/apt/applet_manager.h b/src/core/hle/service/apt/applet_manager.h index 98f6adc8e..9b5a1056d 100644 --- a/src/core/hle/service/apt/applet_manager.h +++ b/src/core/hle/service/apt/applet_manager.h @@ -264,7 +264,7 @@ public: */ void CancelAndSendParameter(const MessageParameter& parameter); - ResultCode SendParameter(const MessageParameter& parameter); + Result SendParameter(const MessageParameter& parameter); ResultVal GlanceParameter(AppletId app_id); ResultVal ReceiveParameter(AppletId app_id); bool CancelParameter(bool check_sender, AppletId sender_appid, bool check_receiver, @@ -283,51 +283,48 @@ public: }; ResultVal Initialize(AppletId app_id, AppletAttributes attributes); - ResultCode Enable(AppletAttributes attributes); - ResultCode Finalize(AppletId app_id); + Result Enable(AppletAttributes attributes); + Result Finalize(AppletId app_id); u32 CountRegisteredApplet(); bool IsRegistered(AppletId app_id); ResultVal GetAttribute(AppletId app_id); ResultVal InquireNotification(AppletId app_id); - ResultCode SendNotification(Notification notification); + Result SendNotification(Notification notification); void SendNotificationToAll(Notification notification); - ResultCode PrepareToStartLibraryApplet(AppletId applet_id); - ResultCode PreloadLibraryApplet(AppletId applet_id); - ResultCode FinishPreloadingLibraryApplet(AppletId applet_id); - ResultCode StartLibraryApplet(AppletId applet_id, std::shared_ptr object, - const std::vector& buffer); - ResultCode PrepareToCloseLibraryApplet(bool not_pause, bool exiting, bool jump_home); - ResultCode CloseLibraryApplet(std::shared_ptr object, - const std::vector& buffer); - ResultCode CancelLibraryApplet(bool app_exiting); - - ResultCode SendDspSleep(AppletId from_applet_id, std::shared_ptr object); - ResultCode SendDspWakeUp(AppletId from_applet_id, std::shared_ptr object); - - ResultCode PrepareToStartSystemApplet(AppletId applet_id); - ResultCode StartSystemApplet(AppletId applet_id, std::shared_ptr object, - const std::vector& buffer); - ResultCode PrepareToCloseSystemApplet(); - ResultCode CloseSystemApplet(std::shared_ptr object, - const std::vector& buffer); - ResultCode OrderToCloseSystemApplet(); - - ResultCode PrepareToJumpToHomeMenu(); - ResultCode JumpToHomeMenu(std::shared_ptr object, + Result PrepareToStartLibraryApplet(AppletId applet_id); + Result PreloadLibraryApplet(AppletId applet_id); + Result FinishPreloadingLibraryApplet(AppletId applet_id); + Result StartLibraryApplet(AppletId applet_id, std::shared_ptr object, const std::vector& buffer); - ResultCode PrepareToLeaveHomeMenu(); - ResultCode LeaveHomeMenu(std::shared_ptr object, const std::vector& buffer); + Result PrepareToCloseLibraryApplet(bool not_pause, bool exiting, bool jump_home); + Result CloseLibraryApplet(std::shared_ptr object, + const std::vector& buffer); + Result CancelLibraryApplet(bool app_exiting); - ResultCode OrderToCloseApplication(); - ResultCode PrepareToCloseApplication(bool return_to_sys); - ResultCode CloseApplication(std::shared_ptr object, - const std::vector& buffer); + Result SendDspSleep(AppletId from_applet_id, std::shared_ptr object); + Result SendDspWakeUp(AppletId from_applet_id, std::shared_ptr object); - ResultCode PrepareToDoApplicationJump(u64 title_id, FS::MediaType media_type, - ApplicationJumpFlags flags); - ResultCode DoApplicationJump(const DeliverArg& arg); + Result PrepareToStartSystemApplet(AppletId applet_id); + Result StartSystemApplet(AppletId applet_id, std::shared_ptr object, + const std::vector& buffer); + Result PrepareToCloseSystemApplet(); + Result CloseSystemApplet(std::shared_ptr object, const std::vector& buffer); + Result OrderToCloseSystemApplet(); + + Result PrepareToJumpToHomeMenu(); + Result JumpToHomeMenu(std::shared_ptr object, const std::vector& buffer); + Result PrepareToLeaveHomeMenu(); + Result LeaveHomeMenu(std::shared_ptr object, const std::vector& buffer); + + Result OrderToCloseApplication(); + Result PrepareToCloseApplication(bool return_to_sys); + Result CloseApplication(std::shared_ptr object, const std::vector& buffer); + + Result PrepareToDoApplicationJump(u64 title_id, FS::MediaType media_type, + ApplicationJumpFlags flags); + Result DoApplicationJump(const DeliverArg& arg); boost::optional ReceiveDeliverArg() { auto arg = deliver_arg; @@ -369,12 +366,11 @@ public: std::memcpy(&capture_buffer_info.get(), buffer.data(), sizeof(CaptureBufferInfo)); } - ResultCode PrepareToStartApplication(u64 title_id, FS::MediaType media_type); - ResultCode StartApplication(const std::vector& parameter, const std::vector& hmac, - bool paused); - ResultCode WakeupApplication(std::shared_ptr object, - const std::vector& buffer); - ResultCode CancelApplication(); + Result PrepareToStartApplication(u64 title_id, FS::MediaType media_type); + Result StartApplication(const std::vector& parameter, const std::vector& hmac, + bool paused); + Result WakeupApplication(std::shared_ptr object, const std::vector& buffer); + Result CancelApplication(); struct AppletManInfo { AppletPos active_applet_pos; diff --git a/src/core/hle/service/apt/apt.cpp b/src/core/hle/service/apt/apt.cpp index 860a7513d..e7cc456a5 100644 --- a/src/core/hle/service/apt/apt.cpp +++ b/src/core/hle/service/apt/apt.cpp @@ -564,7 +564,7 @@ void Module::APTInterface::PrepareToDoApplicationJump(Kernel::HLERequestContext& LOG_INFO(Service_APT, "called title_id={:016X}, media_type={:#01X}, flags={:#08X}", title_id, media_type, flags); - ResultCode result = apt->applet_manager->PrepareToDoApplicationJump( + Result result = apt->applet_manager->PrepareToDoApplicationJump( title_id, static_cast(media_type), flags); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); @@ -767,8 +767,8 @@ void Module::APTInterface::PrepareToStartNewestHomeMenu(Kernel::HLERequestContex // This command must return an error when called, otherwise the Home Menu will try to reboot the // system. - rb.Push(ResultCode(ErrorDescription::AlreadyExists, ErrorModule::Applet, - ErrorSummary::InvalidState, ErrorLevel::Status)); + rb.Push(Result(ErrorDescription::AlreadyExists, ErrorModule::Applet, ErrorSummary::InvalidState, + ErrorLevel::Status)); } void Module::APTInterface::PreloadLibraryApplet(Kernel::HLERequestContext& ctx) { @@ -1341,8 +1341,8 @@ void Module::APTInterface::Unwrap(Kernel::HLERequestContext& ctx) { rb.Push(RESULT_SUCCESS); } else { LOG_ERROR(Service_APT, "Failed to decrypt data"); - rb.Push(ResultCode(static_cast(1), ErrorModule::PS, - ErrorSummary::WrongArgument, ErrorLevel::Status)); + rb.Push(Result(static_cast(1), ErrorModule::PS, + ErrorSummary::WrongArgument, ErrorLevel::Status)); } // Unmap buffer diff --git a/src/core/hle/service/boss/online_service.cpp b/src/core/hle/service/boss/online_service.cpp index 10f1ba058..94cff5794 100644 --- a/src/core/hle/service/boss/online_service.cpp +++ b/src/core/hle/service/boss/online_service.cpp @@ -38,7 +38,7 @@ void BossTaskProperties::serialize(Archive& ar, const unsigned int) { } SERIALIZE_IMPL(BossTaskProperties) -ResultCode OnlineService::InitializeSession(u64 init_program_id) { +Result OnlineService::InitializeSession(u64 init_program_id) { // The BOSS service uses three databases: // BOSS_A: Archive? A list of program ids and some properties that are keyed on program // BOSS_SS: Saved Strings? Includes the url and the other string properties, and also some other @@ -150,7 +150,7 @@ void OnlineService::RegisterTask(const u32 size, Kernel::MappedBuffer& buffer) { current_props = BossTaskProperties(); } -ResultCode OnlineService::UnregisterTask(const u32 size, Kernel::MappedBuffer& buffer) { +Result OnlineService::UnregisterTask(const u32 size, Kernel::MappedBuffer& buffer) { if (size > TASK_ID_SIZE) { LOG_WARNING(Service_BOSS, "TaskId cannot be longer than 8"); // TODO: Proper error code. @@ -334,7 +334,7 @@ std::optional OnlineService::GetNsDataEntryFromId(const u32 ns_data return *entry_iter; } -ResultCode OnlineService::GetNsDataHeaderInfo(const u32 ns_data_id, const NsDataHeaderInfoType type, +Result OnlineService::GetNsDataHeaderInfo(const u32 ns_data_id, const NsDataHeaderInfoType type, const u32 size, Kernel::MappedBuffer& buffer) { const auto entry = GetNsDataEntryFromId(ns_data_id); if (!entry.has_value()) { @@ -452,7 +452,7 @@ struct overload : Ts... { template overload(Ts...) -> overload; -ResultCode OnlineService::SendProperty(const u16 id, const u32 size, Kernel::MappedBuffer& buffer) { +Result OnlineService::SendProperty(const u16 id, const u32 size, Kernel::MappedBuffer& buffer) { const auto property_id = static_cast(id); if (!current_props.properties.contains(property_id)) { LOG_ERROR(Service_BOSS, "Unknown property with ID {:#06x} and size {}", property_id, size); @@ -492,8 +492,7 @@ ResultCode OnlineService::SendProperty(const u16 id, const u32 size, Kernel::Map return RESULT_SUCCESS; } -ResultCode OnlineService::ReceiveProperty(const u16 id, const u32 size, - Kernel::MappedBuffer& buffer) { +Result OnlineService::ReceiveProperty(const u16 id, const u32 size, Kernel::MappedBuffer& buffer) { const auto property_id = static_cast(id); if (!current_props.properties.contains(property_id)) { LOG_ERROR(Service_BOSS, "Unknown property with ID {:#06x} and size {}", property_id, size); diff --git a/src/core/hle/service/boss/online_service.h b/src/core/hle/service/boss/online_service.h index ec2b18a79..17763e85e 100644 --- a/src/core/hle/service/boss/online_service.h +++ b/src/core/hle/service/boss/online_service.h @@ -161,18 +161,18 @@ class OnlineService final { public: explicit OnlineService(u64 program_id_, u64 extdata_id_); - ResultCode InitializeSession(u64 init_program_id); + Result InitializeSession(u64 init_program_id); void RegisterTask(const u32 size, Kernel::MappedBuffer& buffer); - ResultCode UnregisterTask(const u32 size, Kernel::MappedBuffer& buffer); + Result UnregisterTask(const u32 size, Kernel::MappedBuffer& buffer); void GetTaskIdList(); u16 GetNsDataIdList(const u32 filter, const u32 max_entries, Kernel::MappedBuffer& buffer); std::optional GetNsDataEntryFromId(const u32 ns_data_id); - ResultCode GetNsDataHeaderInfo(const u32 ns_data_id, const NsDataHeaderInfoType type, + Result GetNsDataHeaderInfo(const u32 ns_data_id, const NsDataHeaderInfoType type, const u32 size, Kernel::MappedBuffer& buffer); ResultVal ReadNsData(const u32 ns_data_id, const u64 offset, const u32 size, Kernel::MappedBuffer& buffer); - ResultCode SendProperty(const u16 id, const u32 size, Kernel::MappedBuffer& buffer); - ResultCode ReceiveProperty(const u16 id, const u32 size, Kernel::MappedBuffer& buffer); + Result SendProperty(const u16 id, const u32 size, Kernel::MappedBuffer& buffer); + Result ReceiveProperty(const u16 id, const u32 size, Kernel::MappedBuffer& buffer); private: std::unique_ptr OpenBossExtData(); diff --git a/src/core/hle/service/cam/cam.cpp b/src/core/hle/service/cam/cam.cpp index 26a2360db..c2adf180d 100644 --- a/src/core/hle/service/cam/cam.cpp +++ b/src/core/hle/service/cam/cam.cpp @@ -77,10 +77,10 @@ constexpr std::array LATENCY_BY_FRAME_RATE{{ 33, // Rate_30_To_10 }}; -const ResultCode ERROR_INVALID_ENUM_VALUE(ErrorDescription::InvalidEnumValue, ErrorModule::CAM, - ErrorSummary::InvalidArgument, ErrorLevel::Usage); -const ResultCode ERROR_OUT_OF_RANGE(ErrorDescription::OutOfRange, ErrorModule::CAM, - ErrorSummary::InvalidArgument, ErrorLevel::Usage); +const Result ERROR_INVALID_ENUM_VALUE(ErrorDescription::InvalidEnumValue, ErrorModule::CAM, + ErrorSummary::InvalidArgument, ErrorLevel::Usage); +const Result ERROR_OUT_OF_RANGE(ErrorDescription::OutOfRange, ErrorModule::CAM, + ErrorSummary::InvalidArgument, ErrorLevel::Usage); void Module::PortConfig::Clear() { completion_event->Clear(); @@ -476,7 +476,7 @@ void Module::Interface::GetMaxLines(Kernel::HLERequestContext& ctx) { if (lines > height) { lines = height; } - ResultCode result = RESULT_SUCCESS; + Result result = RESULT_SUCCESS; while (height % lines != 0 || (lines * width * 2 % MIN_TRANSFER_UNIT != 0)) { --lines; if (lines == 0) { @@ -980,7 +980,7 @@ void Module::Interface::SetPackageParameterWithoutContext(Kernel::HLERequestCont } template -ResultCode Module::SetPackageParameter(const PackageParameterType& package) { +Result Module::SetPackageParameter(const PackageParameterType& package) { const CameraSet camera_select(package.camera_select); const ContextSet context_select(package.context_select); @@ -1018,7 +1018,7 @@ void Module::Interface::SetPackageParameterWithContext(Kernel::HLERequestContext rp.PopRaw(package); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); - ResultCode result = cam->SetPackageParameter(package); + Result result = cam->SetPackageParameter(package); rb.Push(result); LOG_DEBUG(Service_CAM, "called"); @@ -1031,7 +1031,7 @@ void Module::Interface::SetPackageParameterWithContextDetail(Kernel::HLERequestC rp.PopRaw(package); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); - ResultCode result = cam->SetPackageParameter(package); + Result result = cam->SetPackageParameter(package); rb.Push(result); LOG_DEBUG(Service_CAM, "called"); diff --git a/src/core/hle/service/cam/cam.h b/src/core/hle/service/cam/cam.h index 936a8d447..47439466f 100644 --- a/src/core/hle/service/cam/cam.h +++ b/src/core/hle/service/cam/cam.h @@ -166,7 +166,7 @@ public: * 1: u8 selected port * Outputs: * 0: 0x00010040 - * 1: ResultCode + * 1: Result */ void StartCapture(Kernel::HLERequestContext& ctx); @@ -177,7 +177,7 @@ public: * 1: u8 selected port * Outputs: * 0: 0x00020040 - * 1: ResultCode + * 1: Result */ void StopCapture(Kernel::HLERequestContext& ctx); @@ -188,7 +188,7 @@ public: * 1: u8 selected port * Outputs: * 0: 0x00030080 - * 1: ResultCode + * 1: Result * 2: 0 if not capturing, 1 if capturing */ void IsBusy(Kernel::HLERequestContext& ctx); @@ -200,7 +200,7 @@ public: * 1: u8 selected port * Outputs: * 0: 0x00040040 - * 2: ResultCode + * 2: Result */ void ClearBuffer(Kernel::HLERequestContext& ctx); @@ -211,7 +211,7 @@ public: * 1: u8 selected port * Outputs: * 0: 0x00050042 - * 1: ResultCode + * 1: Result * 2: Descriptor: Handle * 3: Event handle */ @@ -224,7 +224,7 @@ public: * 1: u8 selected port * Outputs: * 0: 0x00060042 - * 1: ResultCode + * 1: Result * 2: Descriptor: Handle * 3: Event handle */ @@ -244,7 +244,7 @@ public: * 6: Handle to destination process * Outputs: * 0: 0x00070042 - * 1: ResultCode + * 1: Result * 2: Descriptor: Handle * 3: Handle to event signalled when transfer finishes */ @@ -257,7 +257,7 @@ public: * 1: u8 selected port * Outputs: * 0: 0x00080080 - * 1: ResultCode + * 1: Result * 2: 0 if not finished, 1 if finished */ void IsFinishedReceiving(Kernel::HLERequestContext& ctx); @@ -272,7 +272,7 @@ public: * 4: u16 Height * Outputs: * 0: 0x00090040 - * 1: ResultCode + * 1: Result * @todo figure out how the "buffer" actually works. */ void SetTransferLines(Kernel::HLERequestContext& ctx); @@ -285,7 +285,7 @@ public: * 2: u16 Height * Outputs: * 0: 0x000A0080 - * 1: ResultCode + * 1: Result * 2: Maximum number of lines that fit in the buffer * @todo figure out how the "buffer" actually works. */ @@ -301,7 +301,7 @@ public: * 4: u16 Height * Outputs: * 0: 0x000B0040 - * 1: ResultCode + * 1: Result * @todo figure out how the "buffer" actually works. */ void SetTransferBytes(Kernel::HLERequestContext& ctx); @@ -313,7 +313,7 @@ public: * 1: u8 selected port * Outputs: * 0: 0x000C0080 - * 1: ResultCode + * 1: Result * 2: The number of bytes the buffer contains * @todo figure out how the "buffer" actually works. */ @@ -327,7 +327,7 @@ public: * 2: u16 Height * Outputs: * 0: 0x000D0080 - * 1: ResultCode + * 1: Result * 2: Maximum number of bytes that fit in the buffer * @todo figure out how the "buffer" actually works. */ @@ -341,7 +341,7 @@ public: * 2: u8 bool Enable trimming if true * Outputs: * 0: 0x000E0040 - * 1: ResultCode + * 1: Result */ void SetTrimming(Kernel::HLERequestContext& ctx); @@ -352,7 +352,7 @@ public: * 1: u8 selected port * Outputs: * 0: 0x000F0080 - * 1: ResultCode + * 1: Result * 2: u8 bool Enable trimming if true */ void IsTrimming(Kernel::HLERequestContext& ctx); @@ -368,7 +368,7 @@ public: * 5: y end (exclusive) * Outputs: * 0: 0x00100040 - * 1: ResultCode + * 1: Result */ void SetTrimmingParams(Kernel::HLERequestContext& ctx); @@ -380,7 +380,7 @@ public: * * Outputs: * 0: 0x00110140 - * 1: ResultCode + * 1: Result * 2: x start * 3: y start * 4: x end (exclusive) @@ -400,7 +400,7 @@ public: * 5: s16 Camera height * Outputs: * 0: 0x00120040 - * 1: ResultCode + * 1: Result */ void SetTrimmingParamsCenter(Kernel::HLERequestContext& ctx); @@ -411,7 +411,7 @@ public: * 1: u8 selected camera * Outputs: * 0: 0x00130040 - * 1: ResultCode + * 1: Result */ void Activate(Kernel::HLERequestContext& ctx); @@ -423,7 +423,7 @@ public: * 2: u8 selected context * Outputs: * 0: 0x00140040 - * 1: ResultCode + * 1: Result */ void SwitchContext(Kernel::HLERequestContext& ctx); @@ -436,7 +436,7 @@ public: * 3: u8 selected context * Outputs: * 0: 0x001D0040 - * 1: ResultCode + * 1: Result */ void FlipImage(Kernel::HLERequestContext& ctx); @@ -455,7 +455,7 @@ public: * 8: u8 selected context * Outputs: * 0: 0x001E0040 - * 1: ResultCode + * 1: Result */ void SetDetailSize(Kernel::HLERequestContext& ctx); @@ -468,7 +468,7 @@ public: * 3: u8 selected context * Outputs: * 0: 0x001F0040 - * 1: ResultCode + * 1: Result */ void SetSize(Kernel::HLERequestContext& ctx); @@ -480,7 +480,7 @@ public: * 2: u8 Camera framerate (`FrameRate` enum) * Outputs: * 0: 0x00200040 - * 1: ResultCode + * 1: Result */ void SetFrameRate(Kernel::HLERequestContext& ctx); @@ -493,7 +493,7 @@ public: * 3: u8 selected context * Outputs: * 0: 0x00220040 - * 1: ResultCode + * 1: Result */ void SetEffect(Kernel::HLERequestContext& ctx); @@ -506,7 +506,7 @@ public: * 3: u8 selected context * Outputs: * 0: 0x00250040 - * 1: ResultCode + * 1: Result */ void SetOutputFormat(Kernel::HLERequestContext& ctx); @@ -518,7 +518,7 @@ public: * 2: u8 selected camera 2 * Outputs: * 0: 0x00280040 - * 1: ResultCode + * 1: Result */ void SynchronizeVsyncTiming(Kernel::HLERequestContext& ctx); @@ -532,7 +532,7 @@ public: * 65: s64* TimingsOutput * Outputs: * 0: 0x002A0042 - * 1: ResultCode + * 1: Result * 2-3: Output static buffer */ void GetLatestVsyncTiming(Kernel::HLERequestContext& ctx); @@ -545,7 +545,7 @@ public: * 0: 0x002B0000 * Outputs: * 0: 0x002B0440 - * 1: ResultCode + * 1: Result * 2-17: `StereoCameraCalibrationData` structure with calibration values */ void GetStereoCameraCalibrationData(Kernel::HLERequestContext& ctx); @@ -559,7 +559,7 @@ public: * 8-11: unused * Outputs: * 0: 0x00330040 - * 1: ResultCode + * 1: Result */ void SetPackageParameterWithoutContext(Kernel::HLERequestContext& ctx); @@ -572,7 +572,7 @@ public: * 3-5: unused * Outputs: * 0: 0x00340040 - * 1: ResultCode + * 1: Result */ void SetPackageParameterWithContext(Kernel::HLERequestContext& ctx); @@ -585,7 +585,7 @@ public: * 5-7: unused * Outputs: * 0: 0x00350040 - * 1: ResultCode + * 1: Result */ void SetPackageParameterWithContextDetail(Kernel::HLERequestContext& ctx); @@ -595,7 +595,7 @@ public: * 0: 0x00360000 * Outputs: * 0: 0x00360080 - * 1: ResultCode + * 1: Result * 2: ? */ void GetSuitableY2rStandardCoefficient(Kernel::HLERequestContext& ctx); @@ -607,7 +607,7 @@ public: * 1: u8 Sound ID * Outputs: * 0: 0x00380040 - * 1: ResultCode + * 1: Result */ void PlayShutterSound(Kernel::HLERequestContext& ctx); @@ -617,7 +617,7 @@ public: * 0: 0x00390000 * Outputs: * 0: 0x00390040 - * 1: ResultCode + * 1: Result */ void DriverInitialize(Kernel::HLERequestContext& ctx); @@ -627,7 +627,7 @@ public: * 0: 0x003A0000 * Outputs: * 0: 0x003A0040 - * 1: ResultCode + * 1: Result */ void DriverFinalize(Kernel::HLERequestContext& ctx); @@ -653,7 +653,7 @@ private: void ActivatePort(int port_id, int camera_id); template - ResultCode SetPackageParameter(const PackageParameterType& package); + Result SetPackageParameter(const PackageParameterType& package); struct ContextConfig { Flip flip{Flip::None}; diff --git a/src/core/hle/service/cam/y2r_u.cpp b/src/core/hle/service/cam/y2r_u.cpp index db1b52f15..baac40010 100644 --- a/src/core/hle/service/cam/y2r_u.cpp +++ b/src/core/hle/service/cam/y2r_u.cpp @@ -37,10 +37,10 @@ constexpr std::array standard_coefficients{{ {{0x12A, 0x1CA, 0x88, 0x36, 0x21C, -0x1F04, 0x99C, -0x2421}}, // ITU_Rec709_Scaling }}; -ResultCode ConversionConfiguration::SetInputLineWidth(u16 width) { +Result ConversionConfiguration::SetInputLineWidth(u16 width) { if (width == 0 || width > 1024 || width % 8 != 0) { - return ResultCode(ErrorDescription::OutOfRange, ErrorModule::CAM, - ErrorSummary::InvalidArgument, ErrorLevel::Usage); // 0xE0E053FD + return Result(ErrorDescription::OutOfRange, ErrorModule::CAM, ErrorSummary::InvalidArgument, + ErrorLevel::Usage); // 0xE0E053FD } // Note: The hardware uses the register value 0 to represent a width of 1024, so for a width of @@ -50,10 +50,10 @@ ResultCode ConversionConfiguration::SetInputLineWidth(u16 width) { return RESULT_SUCCESS; } -ResultCode ConversionConfiguration::SetInputLines(u16 lines) { +Result ConversionConfiguration::SetInputLines(u16 lines) { if (lines == 0 || lines > 1024) { - return ResultCode(ErrorDescription::OutOfRange, ErrorModule::CAM, - ErrorSummary::InvalidArgument, ErrorLevel::Usage); // 0xE0E053FD + return Result(ErrorDescription::OutOfRange, ErrorModule::CAM, ErrorSummary::InvalidArgument, + ErrorLevel::Usage); // 0xE0E053FD } // Note: In what appears to be a bug, the `camera` module does not set the hardware register at @@ -65,12 +65,11 @@ ResultCode ConversionConfiguration::SetInputLines(u16 lines) { return RESULT_SUCCESS; } -ResultCode ConversionConfiguration::SetStandardCoefficient( - StandardCoefficient standard_coefficient) { +Result ConversionConfiguration::SetStandardCoefficient(StandardCoefficient standard_coefficient) { const auto index = static_cast(standard_coefficient); if (index >= standard_coefficients.size()) { - return ResultCode(ErrorDescription::InvalidEnumValue, ErrorModule::CAM, - ErrorSummary::InvalidArgument, ErrorLevel::Usage); // 0xE0E053ED + return Result(ErrorDescription::InvalidEnumValue, ErrorModule::CAM, + ErrorSummary::InvalidArgument, ErrorLevel::Usage); // 0xE0E053ED } std::memcpy(coefficients.data(), standard_coefficients[index].data(), sizeof(coefficients)); @@ -466,8 +465,8 @@ void Y2R_U::GetStandardCoefficient(Kernel::HLERequestContext& ctx) { LOG_DEBUG(Service_Y2R, "called standard_coefficient={} ", index); } else { IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); - rb.Push(ResultCode(ErrorDescription::InvalidEnumValue, ErrorModule::CAM, - ErrorSummary::InvalidArgument, ErrorLevel::Usage)); + rb.Push(Result(ErrorDescription::InvalidEnumValue, ErrorModule::CAM, + ErrorSummary::InvalidArgument, ErrorLevel::Usage)); LOG_ERROR(Service_Y2R, "called standard_coefficient={} The argument is invalid!", index); } @@ -559,7 +558,7 @@ void Y2R_U::SetPackageParameter(Kernel::HLERequestContext& ctx) { conversion.rotation = params.rotation; conversion.block_alignment = params.block_alignment; - ResultCode result = conversion.SetInputLineWidth(params.input_line_width); + Result result = conversion.SetInputLineWidth(params.input_line_width); if (result.IsError()) goto cleanup; diff --git a/src/core/hle/service/cam/y2r_u.h b/src/core/hle/service/cam/y2r_u.h index 1ac675f92..b8757cd77 100644 --- a/src/core/hle/service/cam/y2r_u.h +++ b/src/core/hle/service/cam/y2r_u.h @@ -120,9 +120,9 @@ struct ConversionConfiguration { /// Output parameters for the conversion results ConversionBuffer dst; - ResultCode SetInputLineWidth(u16 width); - ResultCode SetInputLines(u16 lines); - ResultCode SetStandardCoefficient(StandardCoefficient standard_coefficient); + Result SetInputLineWidth(u16 width); + Result SetInputLines(u16 lines); + Result SetStandardCoefficient(StandardCoefficient standard_coefficient); private: template diff --git a/src/core/hle/service/cecd/cecd.cpp b/src/core/hle/service/cecd/cecd.cpp index 4ce144e2e..297f41fa5 100644 --- a/src/core/hle/service/cecd/cecd.cpp +++ b/src/core/hle/service/cecd/cecd.cpp @@ -79,8 +79,8 @@ void Module::Interface::Open(Kernel::HLERequestContext& ctx) { rb.Push(RESULT_SUCCESS); } else { LOG_DEBUG(Service_CECD, "Failed to open directory: {}", path.AsString()); - rb.Push(ResultCode(ErrorDescription::NoData, ErrorModule::CEC, - ErrorSummary::NotFound, ErrorLevel::Status)); + rb.Push(Result(ErrorDescription::NoData, ErrorModule::CEC, ErrorSummary::NotFound, + ErrorLevel::Status)); } rb.Push(0); // Zero entries } else { @@ -103,8 +103,8 @@ void Module::Interface::Open(Kernel::HLERequestContext& ctx) { auto file_result = cecd->cecd_system_save_data_archive->OpenFile(path, mode); if (file_result.Failed()) { LOG_DEBUG(Service_CECD, "Failed to open file: {}", path.AsString()); - rb.Push(ResultCode(ErrorDescription::NoData, ErrorModule::CEC, ErrorSummary::NotFound, - ErrorLevel::Status)); + rb.Push(Result(ErrorDescription::NoData, ErrorModule::CEC, ErrorSummary::NotFound, + ErrorLevel::Status)); rb.Push(0); // No file size } else { session_data->file = std::move(file_result).Unwrap(); @@ -151,8 +151,8 @@ void Module::Interface::Read(Kernel::HLERequestContext& ctx) { case CecDataPathType::MboxDir: case CecDataPathType::InboxDir: case CecDataPathType::OutboxDir: - rb.Push(ResultCode(ErrorDescription::NotAuthorized, ErrorModule::CEC, - ErrorSummary::NotFound, ErrorLevel::Status)); + rb.Push(Result(ErrorDescription::NotAuthorized, ErrorModule::CEC, ErrorSummary::NotFound, + ErrorLevel::Status)); rb.Push(0); // No bytes read break; default: // If not directory, then it is a file @@ -228,8 +228,8 @@ void Module::Interface::ReadMessage(Kernel::HLERequestContext& ctx) { rb.Push(RESULT_SUCCESS); rb.Push(bytes_read); } else { - rb.Push(ResultCode(ErrorDescription::NoData, ErrorModule::CEC, ErrorSummary::NotFound, - ErrorLevel::Status)); + rb.Push(Result(ErrorDescription::NoData, ErrorModule::CEC, ErrorSummary::NotFound, + ErrorLevel::Status)); rb.Push(0); // zero bytes read } rb.PushMappedBuffer(message_id_buffer); @@ -320,8 +320,8 @@ void Module::Interface::ReadMessageWithHMAC(Kernel::HLERequestContext& ctx) { rb.Push(RESULT_SUCCESS); rb.Push(bytes_read); } else { - rb.Push(ResultCode(ErrorDescription::NoData, ErrorModule::CEC, ErrorSummary::NotFound, - ErrorLevel::Status)); + rb.Push(Result(ErrorDescription::NoData, ErrorModule::CEC, ErrorSummary::NotFound, + ErrorLevel::Status)); rb.Push(0); // zero bytes read } @@ -356,8 +356,8 @@ void Module::Interface::Write(Kernel::HLERequestContext& ctx) { case CecDataPathType::MboxDir: case CecDataPathType::InboxDir: case CecDataPathType::OutboxDir: - rb.Push(ResultCode(ErrorDescription::NotAuthorized, ErrorModule::CEC, - ErrorSummary::NotFound, ErrorLevel::Status)); + rb.Push(Result(ErrorDescription::NotAuthorized, ErrorModule::CEC, ErrorSummary::NotFound, + ErrorLevel::Status)); break; default: // If not directory, then it is a file std::vector buffer(read_buffer_size); @@ -440,8 +440,8 @@ void Module::Interface::WriteMessage(Kernel::HLERequestContext& ctx) { rb.Push(RESULT_SUCCESS); } else { - rb.Push(ResultCode(ErrorDescription::NoData, ErrorModule::CEC, ErrorSummary::NotFound, - ErrorLevel::Status)); + rb.Push(Result(ErrorDescription::NoData, ErrorModule::CEC, ErrorSummary::NotFound, + ErrorLevel::Status)); } rb.PushMappedBuffer(read_buffer); @@ -527,8 +527,8 @@ void Module::Interface::WriteMessageWithHMAC(Kernel::HLERequestContext& ctx) { rb.Push(RESULT_SUCCESS); } else { - rb.Push(ResultCode(ErrorDescription::NoData, ErrorModule::CEC, ErrorSummary::NotFound, - ErrorLevel::Status)); + rb.Push(Result(ErrorDescription::NoData, ErrorModule::CEC, ErrorSummary::NotFound, + ErrorLevel::Status)); } rb.PushMappedBuffer(read_buffer); @@ -745,8 +745,8 @@ void Module::Interface::OpenAndWrite(Kernel::HLERequestContext& ctx) { case CecDataPathType::MboxDir: case CecDataPathType::InboxDir: case CecDataPathType::OutboxDir: - rb.Push(ResultCode(ErrorDescription::NotAuthorized, ErrorModule::CEC, - ErrorSummary::NotFound, ErrorLevel::Status)); + rb.Push(Result(ErrorDescription::NotAuthorized, ErrorModule::CEC, ErrorSummary::NotFound, + ErrorLevel::Status)); break; default: // If not directory, then it is a file auto file_result = cecd->cecd_system_save_data_archive->OpenFile(path, mode); @@ -770,8 +770,8 @@ void Module::Interface::OpenAndWrite(Kernel::HLERequestContext& ctx) { rb.Push(RESULT_SUCCESS); } else { - rb.Push(ResultCode(ErrorDescription::NoData, ErrorModule::CEC, ErrorSummary::NotFound, - ErrorLevel::Status)); + rb.Push(Result(ErrorDescription::NoData, ErrorModule::CEC, ErrorSummary::NotFound, + ErrorLevel::Status)); } } rb.PushMappedBuffer(read_buffer); @@ -804,8 +804,8 @@ void Module::Interface::OpenAndRead(Kernel::HLERequestContext& ctx) { case CecDataPathType::MboxDir: case CecDataPathType::InboxDir: case CecDataPathType::OutboxDir: - rb.Push(ResultCode(ErrorDescription::NotAuthorized, ErrorModule::CEC, - ErrorSummary::NotFound, ErrorLevel::Status)); + rb.Push(Result(ErrorDescription::NotAuthorized, ErrorModule::CEC, ErrorSummary::NotFound, + ErrorLevel::Status)); rb.Push(0); // No entries read break; default: // If not directory, then it is a file @@ -822,8 +822,8 @@ void Module::Interface::OpenAndRead(Kernel::HLERequestContext& ctx) { rb.Push(RESULT_SUCCESS); rb.Push(bytes_read); } else { - rb.Push(ResultCode(ErrorDescription::NoData, ErrorModule::CEC, ErrorSummary::NotFound, - ErrorLevel::Status)); + rb.Push(Result(ErrorDescription::NoData, ErrorModule::CEC, ErrorSummary::NotFound, + ErrorLevel::Status)); rb.Push(0); // No bytes read } } diff --git a/src/core/hle/service/cecd/cecd.h b/src/core/hle/service/cecd/cecd.h index bbb473d49..5f3787296 100644 --- a/src/core/hle/service/cecd/cecd.h +++ b/src/core/hle/service/cecd/cecd.h @@ -500,7 +500,7 @@ public: * Inputs: * 0: Header Code[0x000E0000] * Outputs: - * 1: ResultCode + * 1: Result * 2: CecdState */ void GetCecdState(Kernel::HLERequestContext& ctx); @@ -510,7 +510,7 @@ public: * Inputs: * 0: Header Code[0x000F0000] * Outputs: - * 1: ResultCode + * 1: Result * 3: Event Handle */ void GetCecInfoEventHandle(Kernel::HLERequestContext& ctx); @@ -520,7 +520,7 @@ public: * Inputs: * 0: Header Code[0x00100000] * Outputs: - * 1: ResultCode + * 1: Result * 3: Event Handle */ void GetChangeStateEventHandle(Kernel::HLERequestContext& ctx); @@ -593,7 +593,7 @@ public: * Inputs: * 0: Header Code[0x40020002] * Outputs: - * 1: ResultCode + * 1: Result * 3: Event Handle */ void GetCecInfoEventHandleSys(Kernel::HLERequestContext& ctx); diff --git a/src/core/hle/service/cfg/cfg.cpp b/src/core/hle/service/cfg/cfg.cpp index d37fbb242..c30ca9428 100644 --- a/src/core/hle/service/cfg/cfg.cpp +++ b/src/core/hle/service/cfg/cfg.cpp @@ -153,8 +153,8 @@ void Module::Interface::GetCountryCodeString(Kernel::HLERequestContext& ctx) { IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); if (country_code_id >= country_codes.size() || 0 == country_codes[country_code_id]) { LOG_ERROR(Service_CFG, "requested country code id={} is invalid", country_code_id); - rb.Push(ResultCode(ErrorDescription::NotFound, ErrorModule::Config, - ErrorSummary::WrongArgument, ErrorLevel::Permanent)); + rb.Push(Result(ErrorDescription::NotFound, ErrorModule::Config, ErrorSummary::WrongArgument, + ErrorLevel::Permanent)); rb.Skip(1, false); return; } @@ -187,8 +187,8 @@ void Module::Interface::GetCountryCodeID(Kernel::HLERequestContext& ctx) { if (0 == country_code_id) { LOG_ERROR(Service_CFG, "requested country code name={}{} is invalid", static_cast(country_code & 0xff), static_cast(country_code >> 8)); - rb.Push(ResultCode(ErrorDescription::NotFound, ErrorModule::Config, - ErrorSummary::WrongArgument, ErrorLevel::Permanent)); + rb.Push(Result(ErrorDescription::NotFound, ErrorModule::Config, ErrorSummary::WrongArgument, + ErrorLevel::Permanent)); rb.Push(0x00FF); return; } @@ -250,7 +250,7 @@ void Module::Interface::GetTransferableId(Kernel::HLERequestContext& ctx) { IPC::RequestBuilder rb = rp.MakeBuilder(3, 0); std::array buffer; - const ResultCode result = + const Result result = cfg->GetConfigBlock(ConsoleUniqueID2BlockID, 8, AccessFlag::SystemRead, buffer.data()); rb.Push(result); if (result.IsSuccess()) { @@ -407,23 +407,23 @@ ResultVal Module::GetConfigBlockPointer(u32 block_id, u32 size, AccessFla "Config block 0x{:X} with flags {} and size {} was not found, and no default " "exists.", block_id, accesss_flag, size); - return ResultCode(ErrorDescription::NotFound, ErrorModule::Config, - ErrorSummary::WrongArgument, ErrorLevel::Permanent); + return Result(ErrorDescription::NotFound, ErrorModule::Config, + ErrorSummary::WrongArgument, ErrorLevel::Permanent); } } if (False(itr->access_flags & accesss_flag)) { LOG_ERROR(Service_CFG, "Invalid access flag {:X} for config block 0x{:X} with size {}", accesss_flag, block_id, size); - return ResultCode(ErrorDescription::NotAuthorized, ErrorModule::Config, - ErrorSummary::WrongArgument, ErrorLevel::Permanent); + return Result(ErrorDescription::NotAuthorized, ErrorModule::Config, + ErrorSummary::WrongArgument, ErrorLevel::Permanent); } if (itr->size != size) { LOG_ERROR(Service_CFG, "Invalid size {} for config block 0x{:X} with flags {}", size, block_id, accesss_flag); - return ResultCode(ErrorDescription::InvalidSize, ErrorModule::Config, - ErrorSummary::WrongArgument, ErrorLevel::Permanent); + return Result(ErrorDescription::InvalidSize, ErrorModule::Config, + ErrorSummary::WrongArgument, ErrorLevel::Permanent); } void* pointer; @@ -437,7 +437,7 @@ ResultVal Module::GetConfigBlockPointer(u32 block_id, u32 size, AccessFla return pointer; } -ResultCode Module::GetConfigBlock(u32 block_id, u32 size, AccessFlag accesss_flag, void* output) { +Result Module::GetConfigBlock(u32 block_id, u32 size, AccessFlag accesss_flag, void* output) { void* pointer = nullptr; CASCADE_RESULT(pointer, GetConfigBlockPointer(block_id, size, accesss_flag)); std::memcpy(output, pointer, size); @@ -445,19 +445,18 @@ ResultCode Module::GetConfigBlock(u32 block_id, u32 size, AccessFlag accesss_fla return RESULT_SUCCESS; } -ResultCode Module::SetConfigBlock(u32 block_id, u32 size, AccessFlag accesss_flag, - const void* input) { +Result Module::SetConfigBlock(u32 block_id, u32 size, AccessFlag accesss_flag, const void* input) { void* pointer = nullptr; CASCADE_RESULT(pointer, GetConfigBlockPointer(block_id, size, accesss_flag)); std::memcpy(pointer, input, size); return RESULT_SUCCESS; } -ResultCode Module::CreateConfigBlock(u32 block_id, u16 size, AccessFlag access_flags, - const void* data) { +Result Module::CreateConfigBlock(u32 block_id, u16 size, AccessFlag access_flags, + const void* data) { SaveFileConfig* config = reinterpret_cast(cfg_config_file_buffer.data()); if (config->total_entries >= CONFIG_FILE_MAX_BLOCK_ENTRIES) - return ResultCode(-1); // TODO(Subv): Find the right error code + return Result(-1); // TODO(Subv): Find the right error code // Insert the block header with offset 0 for now config->block_entries[config->total_entries] = {block_id, 0, size, access_flags}; @@ -486,12 +485,12 @@ ResultCode Module::CreateConfigBlock(u32 block_id, u16 size, AccessFlag access_f return RESULT_SUCCESS; } -ResultCode Module::DeleteConfigNANDSaveFile() { +Result Module::DeleteConfigNANDSaveFile() { FileSys::Path path("/config"); return cfg_system_save_data_archive->DeleteFile(path); } -ResultCode Module::UpdateConfigNANDSavegame() { +Result Module::UpdateConfigNANDSavegame() { FileSys::Mode mode = {}; mode.write_flag.Assign(1); mode.create_flag.Assign(1); @@ -507,8 +506,8 @@ ResultCode Module::UpdateConfigNANDSavegame() { return RESULT_SUCCESS; } -ResultCode Module::FormatConfig() { - ResultCode res = DeleteConfigNANDSaveFile(); +Result Module::FormatConfig() { + Result res = DeleteConfigNANDSaveFile(); // The delete command fails if the file doesn't exist, so we have to check that too if (!res.IsSuccess() && res != FileSys::ERROR_FILE_NOT_FOUND) { return res; @@ -543,7 +542,7 @@ ResultCode Module::FormatConfig() { return RESULT_SUCCESS; } -ResultCode Module::LoadConfigNANDSaveFile() { +Result Module::LoadConfigNANDSaveFile() { const std::string& nand_directory = FileUtil::GetUserPath(FileUtil::UserPath::NANDDir); FileSys::ArchiveFactory_SystemSaveData systemsavedata_factory(nand_directory); @@ -777,10 +776,10 @@ std::pair Module::GenerateConsoleUniqueId() const { return std::make_pair(random_number, console_id); } -ResultCode Module::SetConsoleUniqueId(u32 random_number, u64 console_id) { +Result Module::SetConsoleUniqueId(u32 random_number, u64 console_id) { u64_le console_id_le = console_id; - ResultCode res = SetConfigBlock(ConsoleUniqueID1BlockID, sizeof(console_id_le), - AccessFlag::Global, &console_id_le); + Result res = SetConfigBlock(ConsoleUniqueID1BlockID, sizeof(console_id_le), AccessFlag::Global, + &console_id_le); if (!res.IsSuccess()) return res; diff --git a/src/core/hle/service/cfg/cfg.h b/src/core/hle/service/cfg/cfg.h index 16edf7746..60bdcb9d5 100644 --- a/src/core/hle/service/cfg/cfg.h +++ b/src/core/hle/service/cfg/cfg.h @@ -389,9 +389,9 @@ private: * @param size The size of the block we want to read * @param accesss_flag The requested block must have this access flag set * @param output A pointer where we will write the read data - * @returns ResultCode indicating the result of the operation, 0 on success + * @returns Result indicating the result of the operation, 0 on success */ - ResultCode GetConfigBlock(u32 block_id, u32 size, AccessFlag accesss_flag, void* output); + Result GetConfigBlock(u32 block_id, u32 size, AccessFlag accesss_flag, void* output); /** * Reads data from input and writes to a block with the specified id and flag @@ -402,9 +402,9 @@ private: * @param size The size of the block we want to write * @param accesss_flag The target block must have this access flag set * @param input A pointer where we will read data and write to Config savegame buffer - * @returns ResultCode indicating the result of the operation, 0 on success + * @returns Result indicating the result of the operation, 0 on success */ - ResultCode SetConfigBlock(u32 block_id, u32 size, AccessFlag accesss_flag, const void* input); + Result SetConfigBlock(u32 block_id, u32 size, AccessFlag accesss_flag, const void* input); /** * Creates a block with the specified id and writes the input data to the cfg savegame buffer in @@ -414,28 +414,27 @@ private: * @param size The size of the block we want to create * @param accesss_flags The access flags of the new block * @param data A pointer containing the data we will write to the new block - * @returns ResultCode indicating the result of the operation, 0 on success + * @returns Result indicating the result of the operation, 0 on success */ - ResultCode CreateConfigBlock(u32 block_id, u16 size, AccessFlag accesss_flags, - const void* data); + Result CreateConfigBlock(u32 block_id, u16 size, AccessFlag accesss_flags, const void* data); /** * Deletes the config savegame file from the filesystem, the buffer in memory is not affected - * @returns ResultCode indicating the result of the operation, 0 on success + * @returns Result indicating the result of the operation, 0 on success */ - ResultCode DeleteConfigNANDSaveFile(); + Result DeleteConfigNANDSaveFile(); /** * Re-creates the config savegame file in memory and the filesystem with the default blocks - * @returns ResultCode indicating the result of the operation, 0 on success + * @returns Result indicating the result of the operation, 0 on success */ - ResultCode FormatConfig(); + Result FormatConfig(); /** * Open the config savegame file and load it to the memory buffer - * @returns ResultCode indicating the result of the operation, 0 on success + * @returns Result indicating the result of the operation, 0 on success */ - ResultCode LoadConfigNANDSaveFile(); + Result LoadConfigNANDSaveFile(); /** * Loads MCU specific data @@ -538,7 +537,7 @@ public: * @param random_number the random_number to set * @param console_id the console id to set */ - ResultCode SetConsoleUniqueId(u32 random_number, u64 console_id); + Result SetConsoleUniqueId(u32 random_number, u64 console_id); /** * Gets the console unique id from config savegame. @@ -572,9 +571,9 @@ public: /** * Writes the config savegame memory buffer to the config savegame file in the filesystem - * @returns ResultCode indicating the result of the operation, 0 on success + * @returns Result indicating the result of the operation, 0 on success */ - ResultCode UpdateConfigNANDSavegame(); + Result UpdateConfigNANDSavegame(); /** * Saves MCU specific data diff --git a/src/core/hle/service/csnd/csnd_snd.cpp b/src/core/hle/service/csnd/csnd_snd.cpp index 112faa468..601b65cc8 100644 --- a/src/core/hle/service/csnd/csnd_snd.cpp +++ b/src/core/hle/service/csnd/csnd_snd.cpp @@ -240,8 +240,8 @@ void CSND_SND::ExecuteCommands(Kernel::HLERequestContext& ctx) { IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); if (!shared_memory) { - rb.Push(ResultCode(ErrorDescription::InvalidResultValue, ErrorModule::CSND, - ErrorSummary::InvalidState, ErrorLevel::Status)); + rb.Push(Result(ErrorDescription::InvalidResultValue, ErrorModule::CSND, + ErrorSummary::InvalidState, ErrorLevel::Status)); LOG_ERROR(Service_CSND, "called, shared memory not allocated"); return; } @@ -428,8 +428,8 @@ void CSND_SND::AcquireCapUnit(Kernel::HLERequestContext& ctx) { IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); if (capture_units[0] && capture_units[1]) { LOG_WARNING(Service_CSND, "No more capture units available"); - rb.Push(ResultCode(ErrorDescription::InvalidResultValue, ErrorModule::CSND, - ErrorSummary::OutOfResource, ErrorLevel::Status)); + rb.Push(Result(ErrorDescription::InvalidResultValue, ErrorModule::CSND, + ErrorSummary::OutOfResource, ErrorLevel::Status)); rb.Skip(1, false); return; } diff --git a/src/core/hle/service/dsp/dsp_dsp.cpp b/src/core/hle/service/dsp/dsp_dsp.cpp index 0549a8f02..5114a0b95 100644 --- a/src/core/hle/service/dsp/dsp_dsp.cpp +++ b/src/core/hle/service/dsp/dsp_dsp.cpp @@ -250,8 +250,8 @@ void DSP_DSP::RegisterInterruptEvents(Kernel::HLERequestContext& ctx) { "Ran out of space to register interrupts (Attempted to register " "interrupt={}, channel={}, event={})", interrupt, channel, event->GetName()); - rb.Push(ResultCode(ErrorDescription::InvalidResultValue, ErrorModule::DSP, - ErrorSummary::OutOfResource, ErrorLevel::Status)); + rb.Push(Result(ErrorDescription::InvalidResultValue, ErrorModule::DSP, + ErrorSummary::OutOfResource, ErrorLevel::Status)); return; } else { GetInterruptEvent(type, pipe) = event; diff --git a/src/core/hle/service/err/err_f.cpp b/src/core/hle/service/err/err_f.cpp index 896306cf1..c64d2ce24 100644 --- a/src/core/hle/service/err/err_f.cpp +++ b/src/core/hle/service/err/err_f.cpp @@ -155,7 +155,7 @@ static void LogGenericInfo(const ErrInfo::ErrInfoCommon& errinfo_common) { errinfo_common.app_title_id_low); LOG_CRITICAL(Service_ERR, "ADR: 0x{:08X}", errinfo_common.pc_address); - ResultCode result_code{errinfo_common.result_code}; + Result result_code{errinfo_common.result_code}; LOG_CRITICAL(Service_ERR, "RSL: 0x{:08X}", result_code.raw); LOG_CRITICAL(Service_ERR, " Level: {}", static_cast(result_code.level.Value())); LOG_CRITICAL(Service_ERR, " Summary: {}", static_cast(result_code.summary.Value())); diff --git a/src/core/hle/service/fs/archive.cpp b/src/core/hle/service/fs/archive.cpp index ea5f0efd5..3af20c5b1 100644 --- a/src/core/hle/service/fs/archive.cpp +++ b/src/core/hle/service/fs/archive.cpp @@ -66,7 +66,7 @@ ResultVal ArchiveManager::OpenArchive(ArchiveIdCode id_code, return next_handle++; } -ResultCode ArchiveManager::CloseArchive(ArchiveHandle handle) { +Result ArchiveManager::CloseArchive(ArchiveHandle handle) { if (handle_map.erase(handle) == 0) return FileSys::ERR_INVALID_ARCHIVE_HANDLE; else @@ -75,8 +75,8 @@ ResultCode ArchiveManager::CloseArchive(ArchiveHandle handle) { // TODO(yuriks): This might be what the fs:REG service is for. See the Register/Unregister calls in // http://3dbrew.org/wiki/Filesystem_services#ProgramRegistry_service_.22fs:REG.22 -ResultCode ArchiveManager::RegisterArchiveType(std::unique_ptr&& factory, - ArchiveIdCode id_code) { +Result ArchiveManager::RegisterArchiveType(std::unique_ptr&& factory, + ArchiveIdCode id_code) { auto result = id_code_map.emplace(id_code, std::move(factory)); bool inserted = result.second; @@ -106,8 +106,8 @@ ArchiveManager::OpenFileFromArchive(ArchiveHandle archive_handle, const FileSys: return std::make_pair(std::move(file), open_timeout_ns); } -ResultCode ArchiveManager::DeleteFileFromArchive(ArchiveHandle archive_handle, - const FileSys::Path& path) { +Result ArchiveManager::DeleteFileFromArchive(ArchiveHandle archive_handle, + const FileSys::Path& path) { ArchiveBackend* archive = GetArchive(archive_handle); if (archive == nullptr) return FileSys::ERR_INVALID_ARCHIVE_HANDLE; @@ -115,10 +115,10 @@ ResultCode ArchiveManager::DeleteFileFromArchive(ArchiveHandle archive_handle, return archive->DeleteFile(path); } -ResultCode ArchiveManager::RenameFileBetweenArchives(ArchiveHandle src_archive_handle, - const FileSys::Path& src_path, - ArchiveHandle dest_archive_handle, - const FileSys::Path& dest_path) { +Result ArchiveManager::RenameFileBetweenArchives(ArchiveHandle src_archive_handle, + const FileSys::Path& src_path, + ArchiveHandle dest_archive_handle, + const FileSys::Path& dest_path) { ArchiveBackend* src_archive = GetArchive(src_archive_handle); ArchiveBackend* dest_archive = GetArchive(dest_archive_handle); if (src_archive == nullptr || dest_archive == nullptr) @@ -132,8 +132,8 @@ ResultCode ArchiveManager::RenameFileBetweenArchives(ArchiveHandle src_archive_h } } -ResultCode ArchiveManager::DeleteDirectoryFromArchive(ArchiveHandle archive_handle, - const FileSys::Path& path) { +Result ArchiveManager::DeleteDirectoryFromArchive(ArchiveHandle archive_handle, + const FileSys::Path& path) { ArchiveBackend* archive = GetArchive(archive_handle); if (archive == nullptr) return FileSys::ERR_INVALID_ARCHIVE_HANDLE; @@ -141,8 +141,8 @@ ResultCode ArchiveManager::DeleteDirectoryFromArchive(ArchiveHandle archive_hand return archive->DeleteDirectory(path); } -ResultCode ArchiveManager::DeleteDirectoryRecursivelyFromArchive(ArchiveHandle archive_handle, - const FileSys::Path& path) { +Result ArchiveManager::DeleteDirectoryRecursivelyFromArchive(ArchiveHandle archive_handle, + const FileSys::Path& path) { ArchiveBackend* archive = GetArchive(archive_handle); if (archive == nullptr) return FileSys::ERR_INVALID_ARCHIVE_HANDLE; @@ -150,8 +150,8 @@ ResultCode ArchiveManager::DeleteDirectoryRecursivelyFromArchive(ArchiveHandle a return archive->DeleteDirectoryRecursively(path); } -ResultCode ArchiveManager::CreateFileInArchive(ArchiveHandle archive_handle, - const FileSys::Path& path, u64 file_size) { +Result ArchiveManager::CreateFileInArchive(ArchiveHandle archive_handle, const FileSys::Path& path, + u64 file_size) { ArchiveBackend* archive = GetArchive(archive_handle); if (archive == nullptr) return FileSys::ERR_INVALID_ARCHIVE_HANDLE; @@ -159,8 +159,8 @@ ResultCode ArchiveManager::CreateFileInArchive(ArchiveHandle archive_handle, return archive->CreateFile(path, file_size); } -ResultCode ArchiveManager::CreateDirectoryFromArchive(ArchiveHandle archive_handle, - const FileSys::Path& path) { +Result ArchiveManager::CreateDirectoryFromArchive(ArchiveHandle archive_handle, + const FileSys::Path& path) { ArchiveBackend* archive = GetArchive(archive_handle); if (archive == nullptr) return FileSys::ERR_INVALID_ARCHIVE_HANDLE; @@ -168,10 +168,10 @@ ResultCode ArchiveManager::CreateDirectoryFromArchive(ArchiveHandle archive_hand return archive->CreateDirectory(path); } -ResultCode ArchiveManager::RenameDirectoryBetweenArchives(ArchiveHandle src_archive_handle, - const FileSys::Path& src_path, - ArchiveHandle dest_archive_handle, - const FileSys::Path& dest_path) { +Result ArchiveManager::RenameDirectoryBetweenArchives(ArchiveHandle src_archive_handle, + const FileSys::Path& src_path, + ArchiveHandle dest_archive_handle, + const FileSys::Path& dest_path) { ArchiveBackend* src_archive = GetArchive(src_archive_handle); ArchiveBackend* dest_archive = GetArchive(dest_archive_handle); if (src_archive == nullptr || dest_archive == nullptr) @@ -208,9 +208,9 @@ ResultVal ArchiveManager::GetFreeBytesInArchive(ArchiveHandle archive_handl return archive->GetFreeBytes(); } -ResultCode ArchiveManager::FormatArchive(ArchiveIdCode id_code, - const FileSys::ArchiveFormatInfo& format_info, - const FileSys::Path& path, u64 program_id) { +Result ArchiveManager::FormatArchive(ArchiveIdCode id_code, + const FileSys::ArchiveFormatInfo& format_info, + const FileSys::Path& path, u64 program_id) { auto archive_itr = id_code_map.find(id_code); if (archive_itr == id_code_map.end()) { return UnimplementedFunction(ErrorModule::FS); // TODO(Subv): Find the right error @@ -229,10 +229,10 @@ ResultVal ArchiveManager::GetArchiveFormatInfo( return archive->second->GetFormatInfo(archive_path, program_id); } -ResultCode ArchiveManager::CreateExtSaveData(MediaType media_type, u32 high, u32 low, - std::span smdh_icon, - const FileSys::ArchiveFormatInfo& format_info, - u64 program_id) { +Result ArchiveManager::CreateExtSaveData(MediaType media_type, u32 high, u32 low, + std::span smdh_icon, + const FileSys::ArchiveFormatInfo& format_info, + u64 program_id) { // Construct the binary path to the archive first FileSys::Path path = FileSys::ConstructExtDataBinaryPath(static_cast(media_type), high, low); @@ -246,7 +246,7 @@ ResultCode ArchiveManager::CreateExtSaveData(MediaType media_type, u32 high, u32 auto ext_savedata = static_cast(archive->second.get()); - ResultCode result = ext_savedata->Format(path, format_info, program_id); + Result result = ext_savedata->Format(path, format_info, program_id); if (result.IsError()) { return result; } @@ -255,7 +255,7 @@ ResultCode ArchiveManager::CreateExtSaveData(MediaType media_type, u32 high, u32 return RESULT_SUCCESS; } -ResultCode ArchiveManager::DeleteExtSaveData(MediaType media_type, u32 high, u32 low) { +Result ArchiveManager::DeleteExtSaveData(MediaType media_type, u32 high, u32 low) { // Construct the binary path to the archive first FileSys::Path path = FileSys::ConstructExtDataBinaryPath(static_cast(media_type), high, low); @@ -267,7 +267,7 @@ ResultCode ArchiveManager::DeleteExtSaveData(MediaType media_type, u32 high, u32 media_type_directory = FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir); } else { LOG_ERROR(Service_FS, "Unsupported media type {}", media_type); - return ResultCode(-1); // TODO(Subv): Find the right error code + return Result(-1); // TODO(Subv): Find the right error code } // Delete all directories (/user, /boss) and the icon file. @@ -275,11 +275,11 @@ ResultCode ArchiveManager::DeleteExtSaveData(MediaType media_type, u32 high, u32 FileSys::GetExtDataContainerPath(media_type_directory, media_type == MediaType::NAND); std::string extsavedata_path = FileSys::GetExtSaveDataPath(base_path, path); if (FileUtil::Exists(extsavedata_path) && !FileUtil::DeleteDirRecursively(extsavedata_path)) - return ResultCode(-1); // TODO(Subv): Find the right error code + return Result(-1); // TODO(Subv): Find the right error code return RESULT_SUCCESS; } -ResultCode ArchiveManager::DeleteSystemSaveData(u32 high, u32 low) { +Result ArchiveManager::DeleteSystemSaveData(u32 high, u32 low) { // Construct the binary path to the archive first const FileSys::Path path = FileSys::ConstructSystemSaveDataBinaryPath(high, low); @@ -287,13 +287,13 @@ ResultCode ArchiveManager::DeleteSystemSaveData(u32 high, u32 low) { const std::string base_path = FileSys::GetSystemSaveDataContainerPath(nand_directory); const std::string systemsavedata_path = FileSys::GetSystemSaveDataPath(base_path, path); if (!FileUtil::DeleteDirRecursively(systemsavedata_path)) { - return ResultCode(-1); // TODO(Subv): Find the right error code + return Result(-1); // TODO(Subv): Find the right error code } return RESULT_SUCCESS; } -ResultCode ArchiveManager::CreateSystemSaveData(u32 high, u32 low) { +Result ArchiveManager::CreateSystemSaveData(u32 high, u32 low) { // Construct the binary path to the archive first const FileSys::Path path = FileSys::ConstructSystemSaveDataBinaryPath(high, low); @@ -301,7 +301,7 @@ ResultCode ArchiveManager::CreateSystemSaveData(u32 high, u32 low) { const std::string base_path = FileSys::GetSystemSaveDataContainerPath(nand_directory); const std::string systemsavedata_path = FileSys::GetSystemSaveDataPath(base_path, path); if (!FileUtil::CreateFullPath(systemsavedata_path)) { - return ResultCode(-1); // TODO(Subv): Find the right error code + return Result(-1); // TODO(Subv): Find the right error code } return RESULT_SUCCESS; diff --git a/src/core/hle/service/fs/archive.h b/src/core/hle/service/fs/archive.h index 0f901a05b..245e929f9 100644 --- a/src/core/hle/service/fs/archive.h +++ b/src/core/hle/service/fs/archive.h @@ -88,7 +88,7 @@ public: * Closes an archive * @param handle Handle to the archive to close */ - ResultCode CloseArchive(ArchiveHandle handle); + Result CloseArchive(ArchiveHandle handle); /** * Open a File from an Archive @@ -106,7 +106,7 @@ public: * @param path Path to the File inside of the Archive * @return Whether deletion succeeded */ - ResultCode DeleteFileFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path); + Result DeleteFileFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path); /** * Rename a File between two Archives @@ -116,10 +116,10 @@ public: * @param dest_path Path to the File inside of the destination Archive * @return Whether rename succeeded */ - ResultCode RenameFileBetweenArchives(ArchiveHandle src_archive_handle, - const FileSys::Path& src_path, - ArchiveHandle dest_archive_handle, - const FileSys::Path& dest_path); + Result RenameFileBetweenArchives(ArchiveHandle src_archive_handle, + const FileSys::Path& src_path, + ArchiveHandle dest_archive_handle, + const FileSys::Path& dest_path); /** * Delete a Directory from an Archive @@ -127,7 +127,7 @@ public: * @param path Path to the Directory inside of the Archive * @return Whether deletion succeeded */ - ResultCode DeleteDirectoryFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path); + Result DeleteDirectoryFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path); /** * Delete a Directory and anything under it from an Archive @@ -135,8 +135,8 @@ public: * @param path Path to the Directory inside of the Archive * @return Whether deletion succeeded */ - ResultCode DeleteDirectoryRecursivelyFromArchive(ArchiveHandle archive_handle, - const FileSys::Path& path); + Result DeleteDirectoryRecursivelyFromArchive(ArchiveHandle archive_handle, + const FileSys::Path& path); /** * Create a File in an Archive @@ -145,8 +145,8 @@ public: * @param file_size The size of the new file, filled with zeroes * @return File creation result code */ - ResultCode CreateFileInArchive(ArchiveHandle archive_handle, const FileSys::Path& path, - u64 file_size); + Result CreateFileInArchive(ArchiveHandle archive_handle, const FileSys::Path& path, + u64 file_size); /** * Create a Directory from an Archive @@ -154,7 +154,7 @@ public: * @param path Path to the Directory inside of the Archive * @return Whether creation of directory succeeded */ - ResultCode CreateDirectoryFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path); + Result CreateDirectoryFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path); /** * Rename a Directory between two Archives @@ -164,10 +164,10 @@ public: * @param dest_path Path to the Directory inside of the destination Archive * @return Whether rename succeeded */ - ResultCode RenameDirectoryBetweenArchives(ArchiveHandle src_archive_handle, - const FileSys::Path& src_path, - ArchiveHandle dest_archive_handle, - const FileSys::Path& dest_path); + Result RenameDirectoryBetweenArchives(ArchiveHandle src_archive_handle, + const FileSys::Path& src_path, + ArchiveHandle dest_archive_handle, + const FileSys::Path& dest_path); /** * Open a Directory from an Archive @@ -192,10 +192,10 @@ public: * @param format_info Format information about the new archive * @param path The path to the archive, if relevant. * @param program_id the program ID of the client that requests the operation - * @return ResultCode 0 on success or the corresponding code on error + * @return Result 0 on success or the corresponding code on error */ - ResultCode FormatArchive(ArchiveIdCode id_code, const FileSys::ArchiveFormatInfo& format_info, - const FileSys::Path& path, u64 program_id); + Result FormatArchive(ArchiveIdCode id_code, const FileSys::ArchiveFormatInfo& format_info, + const FileSys::Path& path, u64 program_id); /** * Retrieves the format info about the archive of the specified type and path. @@ -217,36 +217,35 @@ public: * @param smdh_icon the SMDH icon for this ExtSaveData * @param format_info Format information about the new archive * @param program_id the program ID of the client that requests the operation - * @return ResultCode 0 on success or the corresponding code on error + * @return Result 0 on success or the corresponding code on error */ - ResultCode CreateExtSaveData(MediaType media_type, u32 high, u32 low, - std::span smdh_icon, - const FileSys::ArchiveFormatInfo& format_info, u64 program_id); + Result CreateExtSaveData(MediaType media_type, u32 high, u32 low, std::span smdh_icon, + const FileSys::ArchiveFormatInfo& format_info, u64 program_id); /** * Deletes the SharedExtSaveData archive for the specified extdata ID * @param media_type The media type of the archive to delete (NAND / SDMC) * @param high The high word of the extdata id to delete * @param low The low word of the extdata id to delete - * @return ResultCode 0 on success or the corresponding code on error + * @return Result 0 on success or the corresponding code on error */ - ResultCode DeleteExtSaveData(MediaType media_type, u32 high, u32 low); + Result DeleteExtSaveData(MediaType media_type, u32 high, u32 low); /** * Deletes the SystemSaveData archive folder for the specified save data id * @param high The high word of the SystemSaveData archive to delete * @param low The low word of the SystemSaveData archive to delete - * @return ResultCode 0 on success or the corresponding code on error + * @return Result 0 on success or the corresponding code on error */ - ResultCode DeleteSystemSaveData(u32 high, u32 low); + Result DeleteSystemSaveData(u32 high, u32 low); /** * Creates the SystemSaveData archive folder for the specified save data id * @param high The high word of the SystemSaveData archive to create * @param low The low word of the SystemSaveData archive to create - * @return ResultCode 0 on success or the corresponding code on error + * @return Result 0 on success or the corresponding code on error */ - ResultCode CreateSystemSaveData(u32 high, u32 low); + Result CreateSystemSaveData(u32 high, u32 low); /** * Returns capacity and free space information about the given media type. @@ -266,8 +265,8 @@ private: * @param factory File system backend interface to the archive * @param id_code Id code used to access this type of archive */ - ResultCode RegisterArchiveType(std::unique_ptr&& factory, - ArchiveIdCode id_code); + Result RegisterArchiveType(std::unique_ptr&& factory, + ArchiveIdCode id_code); /// Register all archive types void RegisterArchiveTypes(); diff --git a/src/core/hle/service/fs/file.cpp b/src/core/hle/service/fs/file.cpp index 62e02d263..067419cbb 100644 --- a/src/core/hle/service/fs/file.cpp +++ b/src/core/hle/service/fs/file.cpp @@ -104,7 +104,7 @@ void File::Read(Kernel::HLERequestContext& ctx) { bool cache_ready; // Output - ResultCode ret{0}; + Result ret{0}; Kernel::MappedBuffer* buffer; std::unique_ptr data; size_t read_size; diff --git a/src/core/hle/service/fs/fs_user.cpp b/src/core/hle/service/fs/fs_user.cpp index 9da46b7b7..0df3d8418 100644 --- a/src/core/hle/service/fs/fs_user.cpp +++ b/src/core/hle/service/fs/fs_user.cpp @@ -699,8 +699,8 @@ void FS_USER::GetProductInfo(Kernel::HLERequestContext& ctx) { const auto product_info = GetProductInfo(process_id); if (!product_info.has_value()) { - rb.Push(ResultCode(FileSys::ErrCodes::ArchiveNotMounted, ErrorModule::FS, - ErrorSummary::NotFound, ErrorLevel::Status)); + rb.Push(Result(FileSys::ErrCodes::ArchiveNotMounted, ErrorModule::FS, + ErrorSummary::NotFound, ErrorLevel::Status)); return; } @@ -966,7 +966,7 @@ ResultVal FS_USER::GetSpecialContentIndexFromGameCard(u64 title_id, Special if (type > SpecialContentType::DLPChild) { // Maybe type 4 is New 3DS update/partition 6 but this needs more research // TODO(B3N30): Find correct result code - return ResultCode(-1); + return Result(-1); } switch (type) { @@ -985,7 +985,7 @@ ResultVal FS_USER::GetSpecialContentIndexFromTMD(MediaType media_type, u64 SpecialContentType type) { if (type > SpecialContentType::DLPChild) { // TODO(B3N30): Find correct result code - return ResultCode(-1); + return Result(-1); } std::string tmd_path = AM::GetTitleMetadataPath(media_type, title_id); @@ -993,7 +993,7 @@ ResultVal FS_USER::GetSpecialContentIndexFromTMD(MediaType media_type, u64 FileSys::TitleMetadata tmd; if (tmd.Load(tmd_path) != Loader::ResultStatus::Success || type == SpecialContentType::Update) { // TODO(B3N30): Find correct result code - return ResultCode(-1); + return Result(-1); } // TODO(B3N30): Does real 3DS check if content exists in TMD? @@ -1007,7 +1007,7 @@ ResultVal FS_USER::GetSpecialContentIndexFromTMD(MediaType media_type, u64 ASSERT(false); } - return ResultCode(-1); + return Result(-1); } FS_USER::FS_USER(Core::System& system) diff --git a/src/core/hle/service/fs/fs_user.h b/src/core/hle/service/fs/fs_user.h index f3cdd2b41..57285995a 100644 --- a/src/core/hle/service/fs/fs_user.h +++ b/src/core/hle/service/fs/fs_user.h @@ -72,8 +72,8 @@ public: if (info != program_info_map.end()) { return info->second; } else { - return ResultCode(FileSys::ErrCodes::ArchiveNotMounted, ErrorModule::FS, - ErrorSummary::NotFound, ErrorLevel::Status); + return Result(FileSys::ErrCodes::ArchiveNotMounted, ErrorModule::FS, + ErrorSummary::NotFound, ErrorLevel::Status); } } diff --git a/src/core/hle/service/gsp/gsp_gpu.cpp b/src/core/hle/service/gsp/gsp_gpu.cpp index b12cb703c..0ab97bb47 100644 --- a/src/core/hle/service/gsp/gsp_gpu.cpp +++ b/src/core/hle/service/gsp/gsp_gpu.cpp @@ -37,18 +37,17 @@ enum { }; } -constexpr ResultCode RESULT_FIRST_INITIALIZATION(ErrCodes::FirstInitialization, ErrorModule::GX, - ErrorSummary::Success, ErrorLevel::Success); -constexpr ResultCode ERR_REGS_OUTOFRANGE_OR_MISALIGNED(ErrCodes::OutofRangeOrMisalignedAddress, - ErrorModule::GX, - ErrorSummary::InvalidArgument, - ErrorLevel::Usage); // 0xE0E02A01 -constexpr ResultCode ERR_REGS_MISALIGNED(ErrorDescription::MisalignedSize, ErrorModule::GX, - ErrorSummary::InvalidArgument, - ErrorLevel::Usage); // 0xE0E02BF2 -constexpr ResultCode ERR_REGS_INVALID_SIZE(ErrorDescription::InvalidSize, ErrorModule::GX, - ErrorSummary::InvalidArgument, - ErrorLevel::Usage); // 0xE0E02BEC +constexpr Result RESULT_FIRST_INITIALIZATION(ErrCodes::FirstInitialization, ErrorModule::GX, + ErrorSummary::Success, ErrorLevel::Success); +constexpr Result ERR_REGS_OUTOFRANGE_OR_MISALIGNED(ErrCodes::OutofRangeOrMisalignedAddress, + ErrorModule::GX, ErrorSummary::InvalidArgument, + ErrorLevel::Usage); // 0xE0E02A01 +constexpr Result ERR_REGS_MISALIGNED(ErrorDescription::MisalignedSize, ErrorModule::GX, + ErrorSummary::InvalidArgument, + ErrorLevel::Usage); // 0xE0E02BF2 +constexpr Result ERR_REGS_INVALID_SIZE(ErrorDescription::InvalidSize, ErrorModule::GX, + ErrorSummary::InvalidArgument, + ErrorLevel::Usage); // 0xE0E02BEC u32 GSP_GPU::GetUnusedThreadId() const { for (u32 id = 0; id < MaxGSPThreads; ++id) { @@ -96,7 +95,7 @@ void GSP_GPU::ClientDisconnected(std::shared_ptr server_s * @param data A vector containing the source data * @return RESULT_SUCCESS if the parameters are valid, error code otherwise */ -static ResultCode WriteHWRegs(u32 base_address, u32 size_in_bytes, std::span data, +static Result WriteHWRegs(u32 base_address, u32 size_in_bytes, std::span data, VideoCore::GPU& gpu) { // This magic number is verified to be done by the gsp module const u32 max_size_in_bytes = 0x80; @@ -142,7 +141,7 @@ static ResultCode WriteHWRegs(u32 base_address, u32 size_in_bytes, std::span data, +static Result WriteHWRegsWithMask(u32 base_address, u32 size_in_bytes, std::span data, std::span masks, VideoCore::GPU& gpu) { // This magic number is verified to be done by the gsp module const u32 max_size_in_bytes = 0x80; diff --git a/src/core/hle/service/http/http_c.cpp b/src/core/hle/service/http/http_c.cpp index 861f35e8b..80579c98c 100644 --- a/src/core/hle/service/http/http_c.cpp +++ b/src/core/hle/service/http/http_c.cpp @@ -45,25 +45,25 @@ enum { }; } -const ResultCode ERROR_STATE_ERROR = // 0xD8A0A066 - ResultCode(ErrCodes::SessionStateError, ErrorModule::HTTP, ErrorSummary::InvalidState, - ErrorLevel::Permanent); -const ResultCode ERROR_NOT_IMPLEMENTED = // 0xD960A3F4 - ResultCode(ErrCodes::NotImplemented, ErrorModule::HTTP, ErrorSummary::Internal, - ErrorLevel::Permanent); -const ResultCode ERROR_TOO_MANY_CLIENT_CERTS = // 0xD8A0A0CB - ResultCode(ErrCodes::TooManyClientCerts, ErrorModule::HTTP, ErrorSummary::InvalidState, - ErrorLevel::Permanent); -const ResultCode ERROR_HEADER_NOT_FOUND = ResultCode( - ErrCodes::HeaderNotFound, ErrorModule::HTTP, ErrorSummary::InvalidState, ErrorLevel::Permanent); -const ResultCode ERROR_BUFFER_SMALL = ResultCode(ErrCodes::BufferTooSmall, ErrorModule::HTTP, - ErrorSummary::WouldBlock, ErrorLevel::Permanent); -const ResultCode ERROR_WRONG_CERT_ID = // 0xD8E0B839 - ResultCode(57, ErrorModule::SSL, ErrorSummary::InvalidArgument, ErrorLevel::Permanent); -const ResultCode ERROR_WRONG_CERT_HANDLE = // 0xD8A0A0C9 - ResultCode(201, ErrorModule::HTTP, ErrorSummary::InvalidState, ErrorLevel::Permanent); -const ResultCode ERROR_CERT_ALREADY_SET = // 0xD8A0A03D - ResultCode(61, ErrorModule::HTTP, ErrorSummary::InvalidState, ErrorLevel::Permanent); +const Result ERROR_STATE_ERROR = // 0xD8A0A066 + Result(ErrCodes::SessionStateError, ErrorModule::HTTP, ErrorSummary::InvalidState, + ErrorLevel::Permanent); +const Result ERROR_NOT_IMPLEMENTED = // 0xD960A3F4 + Result(ErrCodes::NotImplemented, ErrorModule::HTTP, ErrorSummary::Internal, + ErrorLevel::Permanent); +const Result ERROR_TOO_MANY_CLIENT_CERTS = // 0xD8A0A0CB + Result(ErrCodes::TooManyClientCerts, ErrorModule::HTTP, ErrorSummary::InvalidState, + ErrorLevel::Permanent); +const Result ERROR_HEADER_NOT_FOUND = Result(ErrCodes::HeaderNotFound, ErrorModule::HTTP, + ErrorSummary::InvalidState, ErrorLevel::Permanent); +const Result ERROR_BUFFER_SMALL = Result(ErrCodes::BufferTooSmall, ErrorModule::HTTP, + ErrorSummary::WouldBlock, ErrorLevel::Permanent); +const Result ERROR_WRONG_CERT_ID = // 0xD8E0B839 + Result(57, ErrorModule::SSL, ErrorSummary::InvalidArgument, ErrorLevel::Permanent); +const Result ERROR_WRONG_CERT_HANDLE = // 0xD8A0A0C9 + Result(201, ErrorModule::HTTP, ErrorSummary::InvalidState, ErrorLevel::Permanent); +const Result ERROR_CERT_ALREADY_SET = // 0xD8A0A03D + Result(61, ErrorModule::HTTP, ErrorSummary::InvalidState, ErrorLevel::Permanent); // Splits URL into its components. Example: https://citra-emu.org:443/index.html // is_https: true; host: citra-emu.org; port: 443; path: /index.html @@ -358,8 +358,8 @@ void HTTP_C::InitializeConnectionSession(Kernel::HLERequestContext& ctx) { auto itr = contexts.find(context_handle); if (itr == contexts.end()) { IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); - rb.Push(ResultCode(ErrCodes::ContextNotFound, ErrorModule::HTTP, ErrorSummary::InvalidState, - ErrorLevel::Permanent)); + rb.Push(Result(ErrCodes::ContextNotFound, ErrorModule::HTTP, ErrorSummary::InvalidState, + ErrorLevel::Permanent)); return; } @@ -462,7 +462,7 @@ void HTTP_C::ReceiveDataImpl(Kernel::HLERequestContext& ctx, bool timeout) { Kernel::MappedBuffer* buffer; bool is_complete; // Output - ResultCode async_res = RESULT_SUCCESS; + Result async_res = RESULT_SUCCESS; }; std::shared_ptr async_data = std::make_shared(); async_data->timeout = timeout; @@ -490,8 +490,8 @@ void HTTP_C::ReceiveDataImpl(Kernel::HLERequestContext& ctx, bool timeout) { std::chrono::nanoseconds(async_data->timeout_nanos)); if (wait_res == std::future_status::timeout) { async_data->async_res = - ResultCode(105, ErrorModule::HTTP, ErrorSummary::NothingHappened, - ErrorLevel::Permanent); + Result(105, ErrorModule::HTTP, ErrorSummary::NothingHappened, + ErrorLevel::Permanent); } } else { http_context.request_future.wait(); @@ -562,8 +562,8 @@ void HTTP_C::CreateContext(Kernel::HLERequestContext& ctx) { LOG_ERROR(Service_HTTP, "Command called with a bound context"); IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); - rb.Push(ResultCode(ErrorDescription::NotImplemented, ErrorModule::HTTP, - ErrorSummary::Internal, ErrorLevel::Permanent)); + rb.Push(Result(ErrorDescription::NotImplemented, ErrorModule::HTTP, ErrorSummary::Internal, + ErrorLevel::Permanent)); rb.PushMappedBuffer(buffer); return; } @@ -574,8 +574,8 @@ void HTTP_C::CreateContext(Kernel::HLERequestContext& ctx) { LOG_ERROR(Service_HTTP, "Tried to open too many HTTP contexts"); IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); - rb.Push(ResultCode(ErrCodes::TooManyContexts, ErrorModule::HTTP, ErrorSummary::InvalidState, - ErrorLevel::Permanent)); + rb.Push(Result(ErrCodes::TooManyContexts, ErrorModule::HTTP, ErrorSummary::InvalidState, + ErrorLevel::Permanent)); rb.PushMappedBuffer(buffer); return; } @@ -584,8 +584,8 @@ void HTTP_C::CreateContext(Kernel::HLERequestContext& ctx) { LOG_ERROR(Service_HTTP, "invalid request method={}", method); IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); - rb.Push(ResultCode(ErrCodes::InvalidRequestMethod, ErrorModule::HTTP, - ErrorSummary::InvalidState, ErrorLevel::Permanent)); + rb.Push(Result(ErrCodes::InvalidRequestMethod, ErrorModule::HTTP, + ErrorSummary::InvalidState, ErrorLevel::Permanent)); rb.PushMappedBuffer(buffer); return; } @@ -687,8 +687,8 @@ void HTTP_C::AddRequestHeader(Kernel::HLERequestContext& ctx) { LOG_ERROR(Service_HTTP, "Tried to add a request header on a context that has already been started."); IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); - rb.Push(ResultCode(ErrCodes::InvalidRequestState, ErrorModule::HTTP, - ErrorSummary::InvalidState, ErrorLevel::Permanent)); + rb.Push(Result(ErrCodes::InvalidRequestState, ErrorModule::HTTP, ErrorSummary::InvalidState, + ErrorLevel::Permanent)); rb.PushMappedBuffer(value_buffer); return; } @@ -728,8 +728,8 @@ void HTTP_C::AddPostDataAscii(Kernel::HLERequestContext& ctx) { LOG_ERROR(Service_HTTP, "Tried to add post data on a context that has already been started."); IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); - rb.Push(ResultCode(ErrCodes::InvalidRequestState, ErrorModule::HTTP, - ErrorSummary::InvalidState, ErrorLevel::Permanent)); + rb.Push(Result(ErrCodes::InvalidRequestState, ErrorModule::HTTP, ErrorSummary::InvalidState, + ErrorLevel::Permanent)); rb.PushMappedBuffer(value_buffer); return; } @@ -760,8 +760,8 @@ void HTTP_C::AddPostDataRaw(Kernel::HLERequestContext& ctx) { LOG_ERROR(Service_HTTP, "Tried to add post data on a context that has already been started."); IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); - rb.Push(ResultCode(ErrCodes::InvalidRequestState, ErrorModule::HTTP, - ErrorSummary::InvalidState, ErrorLevel::Permanent)); + rb.Push(Result(ErrCodes::InvalidRequestState, ErrorModule::HTTP, ErrorSummary::InvalidState, + ErrorLevel::Permanent)); rb.PushMappedBuffer(buffer); return; } @@ -859,7 +859,7 @@ void HTTP_C::GetResponseStatusCodeImpl(Kernel::HLERequestContext& ctx, bool time bool timeout; u64 timeout_nanos = 0; // Output - ResultCode async_res = RESULT_SUCCESS; + Result async_res = RESULT_SUCCESS; }; std::shared_ptr async_data = std::make_shared(); @@ -887,8 +887,8 @@ void HTTP_C::GetResponseStatusCodeImpl(Kernel::HLERequestContext& ctx, bool time if (wait_res == std::future_status::timeout) { LOG_DEBUG(Service_HTTP, "Status code: {}", "timeout"); async_data->async_res = - ResultCode(105, ErrorModule::HTTP, ErrorSummary::NothingHappened, - ErrorLevel::Permanent); + Result(105, ErrorModule::HTTP, ErrorSummary::NothingHappened, + ErrorLevel::Permanent); } } else { http_context.request_future.wait(); @@ -1000,8 +1000,8 @@ void HTTP_C::SetClientCertContext(Kernel::HLERequestContext& ctx) { LOG_ERROR(Service_HTTP, "Tried to set a client cert on a context that has already been started."); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); - rb.Push(ResultCode(ErrCodes::InvalidRequestState, ErrorModule::HTTP, - ErrorSummary::InvalidState, ErrorLevel::Permanent)); + rb.Push(Result(ErrCodes::InvalidRequestState, ErrorModule::HTTP, ErrorSummary::InvalidState, + ErrorLevel::Permanent)); return; } @@ -1049,7 +1049,7 @@ void HTTP_C::OpenClientCertContext(Kernel::HLERequestContext& ctx) { auto* session_data = GetSessionData(ctx.Session()); ASSERT(session_data); - ResultCode result(RESULT_SUCCESS); + Result result(RESULT_SUCCESS); if (!session_data->initialized) { LOG_ERROR(Service_HTTP, "Command called without Initialize"); @@ -1114,7 +1114,7 @@ void HTTP_C::OpenDefaultClientCertContext(Kernel::HLERequestContext& ctx) { if (!ClCertA.init) { LOG_ERROR(Service_HTTP, "called but ClCertA is missing"); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); - rb.Push(static_cast(-1)); + rb.Push(static_cast(-1)); return; } @@ -1262,8 +1262,8 @@ bool HTTP_C::PerformStateChecks(Kernel::HLERequestContext& ctx, IPC::RequestPars LOG_ERROR(Service_HTTP, "Tried to make a request without a bound context"); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); - rb.Push(ResultCode(ErrorDescription::NotImplemented, ErrorModule::HTTP, - ErrorSummary::Internal, ErrorLevel::Permanent)); + rb.Push(Result(ErrorDescription::NotImplemented, ErrorModule::HTTP, ErrorSummary::Internal, + ErrorLevel::Permanent)); return false; } diff --git a/src/core/hle/service/ir/ir_user.cpp b/src/core/hle/service/ir/ir_user.cpp index 856978a1d..e4a466540 100644 --- a/src/core/hle/service/ir/ir_user.cpp +++ b/src/core/hle/service/ir/ir_user.cpp @@ -402,8 +402,8 @@ void IR_USER::SendIrNop(Kernel::HLERequestContext& ctx) { rb.Push(RESULT_SUCCESS); } else { LOG_ERROR(Service_IR, "not connected"); - rb.Push(ResultCode(static_cast(13), ErrorModule::IR, - ErrorSummary::InvalidState, ErrorLevel::Status)); + rb.Push(Result(static_cast(13), ErrorModule::IR, + ErrorSummary::InvalidState, ErrorLevel::Status)); } LOG_TRACE(Service_IR, "called, data={}", fmt::format("{:02x}", fmt::join(buffer, " "))); @@ -419,8 +419,8 @@ void IR_USER::ReleaseReceivedData(Kernel::HLERequestContext& ctx) { rb.Push(RESULT_SUCCESS); } else { LOG_ERROR(Service_IR, "failed to release {} packets", count); - rb.Push(ResultCode(ErrorDescription::NoData, ErrorModule::IR, ErrorSummary::NotFound, - ErrorLevel::Status)); + rb.Push(Result(ErrorDescription::NoData, ErrorModule::IR, ErrorSummary::NotFound, + ErrorLevel::Status)); } LOG_TRACE(Service_IR, "called, count={}", count); diff --git a/src/core/hle/service/ldr_ro/cro_helper.cpp b/src/core/hle/service/ldr_ro/cro_helper.cpp index eb097b2e7..516b3ef77 100644 --- a/src/core/hle/service/ldr_ro/cro_helper.cpp +++ b/src/core/hle/service/ldr_ro/cro_helper.cpp @@ -12,13 +12,13 @@ namespace Service::LDR { -static const ResultCode ERROR_BUFFER_TOO_SMALL = // 0xE0E12C1F - ResultCode(static_cast(31), ErrorModule::RO, ErrorSummary::InvalidArgument, - ErrorLevel::Usage); +static const Result ERROR_BUFFER_TOO_SMALL = // 0xE0E12C1F + Result(static_cast(31), ErrorModule::RO, ErrorSummary::InvalidArgument, + ErrorLevel::Usage); -static constexpr ResultCode CROFormatError(u32 description) { - return ResultCode(static_cast(description), ErrorModule::RO, - ErrorSummary::WrongArgument, ErrorLevel::Permanent); +static constexpr Result CROFormatError(u32 description) { + return Result(static_cast(description), ErrorModule::RO, + ErrorSummary::WrongArgument, ErrorLevel::Permanent); } const std::array CROHelper::ENTRY_SIZE{{ @@ -63,8 +63,8 @@ VAddr CROHelper::SegmentTagToAddress(SegmentTag segment_tag) const { return entry.offset + segment_tag.offset_into_segment; } -ResultCode CROHelper::ApplyRelocation(VAddr target_address, RelocationType relocation_type, - u32 addend, u32 symbol_address, u32 target_future_address) { +Result CROHelper::ApplyRelocation(VAddr target_address, RelocationType relocation_type, u32 addend, + u32 symbol_address, u32 target_future_address) { switch (relocation_type) { case RelocationType::Nothing: @@ -91,7 +91,7 @@ ResultCode CROHelper::ApplyRelocation(VAddr target_address, RelocationType reloc return RESULT_SUCCESS; } -ResultCode CROHelper::ClearRelocation(VAddr target_address, RelocationType relocation_type) { +Result CROHelper::ClearRelocation(VAddr target_address, RelocationType relocation_type) { switch (relocation_type) { case RelocationType::Nothing: break; @@ -114,7 +114,7 @@ ResultCode CROHelper::ClearRelocation(VAddr target_address, RelocationType reloc return RESULT_SUCCESS; } -ResultCode CROHelper::ApplyRelocationBatch(VAddr batch, u32 symbol_address, bool reset) { +Result CROHelper::ApplyRelocationBatch(VAddr batch, u32 symbol_address, bool reset) { if (symbol_address == 0 && !reset) return CROFormatError(0x10); @@ -129,8 +129,8 @@ ResultCode CROHelper::ApplyRelocationBatch(VAddr batch, u32 symbol_address, bool return CROFormatError(0x12); } - ResultCode result = ApplyRelocation(relocation_target, relocation.type, relocation.addend, - symbol_address, relocation_target); + Result result = ApplyRelocation(relocation_target, relocation.type, relocation.addend, + symbol_address, relocation_target); if (result.IsError()) { LOG_ERROR(Service_LDR, "Error applying relocation {:08X}", result.raw); return result; @@ -195,8 +195,8 @@ VAddr CROHelper::FindExportNamedSymbol(const std::string& name) const { return SegmentTagToAddress(symbol_entry.symbol_position); } -ResultCode CROHelper::RebaseHeader(u32 cro_size) { - ResultCode error = CROFormatError(0x11); +Result CROHelper::RebaseHeader(u32 cro_size) { + Result error = CROFormatError(0x11); // verifies magic if (GetField(Magic) != MAGIC_CRO0) @@ -304,7 +304,7 @@ ResultVal CROHelper::RebaseSegmentTable(u32 cro_size, VAddr data_segment_ return prev_data_segment + module_address; } -ResultCode CROHelper::RebaseExportNamedSymbolTable() { +Result CROHelper::RebaseExportNamedSymbolTable() { VAddr export_strings_offset = GetField(ExportStringsOffset); VAddr export_strings_end = export_strings_offset + GetField(ExportStringsSize); @@ -326,7 +326,7 @@ ResultCode CROHelper::RebaseExportNamedSymbolTable() { return RESULT_SUCCESS; } -ResultCode CROHelper::VerifyExportTreeTable() const { +Result CROHelper::VerifyExportTreeTable() const { u32 tree_num = GetField(ExportTreeNum); for (u32 i = 0; i < tree_num; ++i) { ExportTreeEntry entry; @@ -339,7 +339,7 @@ ResultCode CROHelper::VerifyExportTreeTable() const { return RESULT_SUCCESS; } -ResultCode CROHelper::RebaseImportModuleTable() { +Result CROHelper::RebaseImportModuleTable() { VAddr import_strings_offset = GetField(ImportStringsOffset); VAddr import_strings_end = import_strings_offset + GetField(ImportStringsSize); VAddr import_indexed_symbol_table_offset = GetField(ImportIndexedSymbolTableOffset); @@ -385,7 +385,7 @@ ResultCode CROHelper::RebaseImportModuleTable() { return RESULT_SUCCESS; } -ResultCode CROHelper::RebaseImportNamedSymbolTable() { +Result CROHelper::RebaseImportNamedSymbolTable() { VAddr import_strings_offset = GetField(ImportStringsOffset); VAddr import_strings_end = import_strings_offset + GetField(ImportStringsSize); VAddr external_relocation_table_offset = GetField(ExternalRelocationTableOffset); @@ -419,7 +419,7 @@ ResultCode CROHelper::RebaseImportNamedSymbolTable() { return RESULT_SUCCESS; } -ResultCode CROHelper::RebaseImportIndexedSymbolTable() { +Result CROHelper::RebaseImportIndexedSymbolTable() { VAddr external_relocation_table_offset = GetField(ExternalRelocationTableOffset); VAddr external_relocation_table_end = external_relocation_table_offset + @@ -443,7 +443,7 @@ ResultCode CROHelper::RebaseImportIndexedSymbolTable() { return RESULT_SUCCESS; } -ResultCode CROHelper::RebaseImportAnonymousSymbolTable() { +Result CROHelper::RebaseImportAnonymousSymbolTable() { VAddr external_relocation_table_offset = GetField(ExternalRelocationTableOffset); VAddr external_relocation_table_end = external_relocation_table_offset + @@ -471,7 +471,7 @@ VAddr CROHelper::GetOnUnresolvedAddress() { return SegmentTagToAddress(SegmentTag(GetField(OnUnresolvedSegmentTag))); } -ResultCode CROHelper::ResetExternalRelocations() { +Result CROHelper::ResetExternalRelocations() { u32 unresolved_symbol = GetOnUnresolvedAddress(); u32 external_relocation_num = GetField(ExternalRelocationNum); ExternalRelocationEntry relocation; @@ -491,8 +491,8 @@ ResultCode CROHelper::ResetExternalRelocations() { return CROFormatError(0x12); } - ResultCode result = ApplyRelocation(relocation_target, relocation.type, relocation.addend, - unresolved_symbol, relocation_target); + Result result = ApplyRelocation(relocation_target, relocation.type, relocation.addend, + unresolved_symbol, relocation_target); if (result.IsError()) { LOG_ERROR(Service_LDR, "Error applying relocation {:08X}", result.raw); return result; @@ -511,7 +511,7 @@ ResultCode CROHelper::ResetExternalRelocations() { return RESULT_SUCCESS; } -ResultCode CROHelper::ClearExternalRelocations() { +Result CROHelper::ClearExternalRelocations() { u32 external_relocation_num = GetField(ExternalRelocationNum); ExternalRelocationEntry relocation; @@ -524,7 +524,7 @@ ResultCode CROHelper::ClearExternalRelocations() { return CROFormatError(0x12); } - ResultCode result = ClearRelocation(relocation_target, relocation.type); + Result result = ClearRelocation(relocation_target, relocation.type); if (result.IsError()) { LOG_ERROR(Service_LDR, "Error clearing relocation {:08X}", result.raw); return result; @@ -543,7 +543,7 @@ ResultCode CROHelper::ClearExternalRelocations() { return RESULT_SUCCESS; } -ResultCode CROHelper::ApplyStaticAnonymousSymbolToCRS(VAddr crs_address) { +Result CROHelper::ApplyStaticAnonymousSymbolToCRS(VAddr crs_address) { VAddr static_relocation_table_offset = GetField(StaticRelocationTableOffset); VAddr static_relocation_table_end = static_relocation_table_offset + @@ -566,7 +566,7 @@ ResultCode CROHelper::ApplyStaticAnonymousSymbolToCRS(VAddr crs_address) { u32 symbol_address = SegmentTagToAddress(entry.symbol_position); LOG_TRACE(Service_LDR, "CRO \"{}\" exports 0x{:08X} to the static module", ModuleName(), symbol_address); - ResultCode result = crs.ApplyRelocationBatch(batch_address, symbol_address); + Result result = crs.ApplyRelocationBatch(batch_address, symbol_address); if (result.IsError()) { LOG_ERROR(Service_LDR, "Error applying relocation batch {:08X}", result.raw); return result; @@ -575,7 +575,7 @@ ResultCode CROHelper::ApplyStaticAnonymousSymbolToCRS(VAddr crs_address) { return RESULT_SUCCESS; } -ResultCode CROHelper::ApplyInternalRelocations(u32 old_data_segment_address) { +Result CROHelper::ApplyInternalRelocations(u32 old_data_segment_address) { u32 segment_num = GetField(SegmentNum); u32 internal_relocation_num = GetField(InternalRelocationNum); for (u32 i = 0; i < internal_relocation_num; ++i) { @@ -606,8 +606,8 @@ ResultCode CROHelper::ApplyInternalRelocations(u32 old_data_segment_address) { GetEntry(system.Memory(), relocation.symbol_segment, symbol_segment); LOG_TRACE(Service_LDR, "Internally relocates 0x{:08X} with 0x{:08X}", target_address, symbol_segment.offset); - ResultCode result = ApplyRelocation(target_address, relocation.type, relocation.addend, - symbol_segment.offset, target_addressB); + Result result = ApplyRelocation(target_address, relocation.type, relocation.addend, + symbol_segment.offset, target_addressB); if (result.IsError()) { LOG_ERROR(Service_LDR, "Error applying relocation {:08X}", result.raw); return result; @@ -616,7 +616,7 @@ ResultCode CROHelper::ApplyInternalRelocations(u32 old_data_segment_address) { return RESULT_SUCCESS; } -ResultCode CROHelper::ClearInternalRelocations() { +Result CROHelper::ClearInternalRelocations() { u32 internal_relocation_num = GetField(InternalRelocationNum); for (u32 i = 0; i < internal_relocation_num; ++i) { InternalRelocationEntry relocation; @@ -627,7 +627,7 @@ ResultCode CROHelper::ClearInternalRelocations() { return CROFormatError(0x15); } - ResultCode result = ClearRelocation(target_address, relocation.type); + Result result = ClearRelocation(target_address, relocation.type); if (result.IsError()) { LOG_ERROR(Service_LDR, "Error clearing relocation {:08X}", result.raw); return result; @@ -747,7 +747,7 @@ void CROHelper::UnrebaseHeader() { } } -ResultCode CROHelper::ApplyImportNamedSymbol(VAddr crs_address) { +Result CROHelper::ApplyImportNamedSymbol(VAddr crs_address) { u32 import_strings_size = GetField(ImportStringsSize); u32 symbol_import_num = GetField(ImportNamedSymbolNum); for (u32 i = 0; i < symbol_import_num; ++i) { @@ -759,7 +759,7 @@ ResultCode CROHelper::ApplyImportNamedSymbol(VAddr crs_address) { sizeof(ExternalRelocationEntry)); if (!relocation_entry.is_batch_resolved) { - ResultCode result = ForEachAutoLinkCRO( + Result result = ForEachAutoLinkCRO( process, system, crs_address, [&](CROHelper source) -> ResultVal { std::string symbol_name = system.Memory().ReadCString(entry.name_offset, import_strings_size); @@ -769,7 +769,7 @@ ResultCode CROHelper::ApplyImportNamedSymbol(VAddr crs_address) { LOG_TRACE(Service_LDR, "CRO \"{}\" imports \"{}\" from \"{}\"", ModuleName(), symbol_name, source.ModuleName()); - ResultCode result = ApplyRelocationBatch(relocation_addr, symbol_address); + Result result = ApplyRelocationBatch(relocation_addr, symbol_address); if (result.IsError()) { LOG_ERROR(Service_LDR, "Error applying relocation batch {:08X}", result.raw); @@ -789,7 +789,7 @@ ResultCode CROHelper::ApplyImportNamedSymbol(VAddr crs_address) { return RESULT_SUCCESS; } -ResultCode CROHelper::ResetImportNamedSymbol() { +Result CROHelper::ResetImportNamedSymbol() { u32 unresolved_symbol = GetOnUnresolvedAddress(); u32 symbol_import_num = GetField(ImportNamedSymbolNum); @@ -801,7 +801,7 @@ ResultCode CROHelper::ResetImportNamedSymbol() { system.Memory().ReadBlock(process, relocation_addr, &relocation_entry, sizeof(ExternalRelocationEntry)); - ResultCode result = ApplyRelocationBatch(relocation_addr, unresolved_symbol, true); + Result result = ApplyRelocationBatch(relocation_addr, unresolved_symbol, true); if (result.IsError()) { LOG_ERROR(Service_LDR, "Error reseting relocation batch {:08X}", result.raw); return result; @@ -810,7 +810,7 @@ ResultCode CROHelper::ResetImportNamedSymbol() { return RESULT_SUCCESS; } -ResultCode CROHelper::ResetImportIndexedSymbol() { +Result CROHelper::ResetImportIndexedSymbol() { u32 unresolved_symbol = GetOnUnresolvedAddress(); u32 import_num = GetField(ImportIndexedSymbolNum); @@ -822,7 +822,7 @@ ResultCode CROHelper::ResetImportIndexedSymbol() { system.Memory().ReadBlock(process, relocation_addr, &relocation_entry, sizeof(ExternalRelocationEntry)); - ResultCode result = ApplyRelocationBatch(relocation_addr, unresolved_symbol, true); + Result result = ApplyRelocationBatch(relocation_addr, unresolved_symbol, true); if (result.IsError()) { LOG_ERROR(Service_LDR, "Error reseting relocation batch {:08X}", result.raw); return result; @@ -831,7 +831,7 @@ ResultCode CROHelper::ResetImportIndexedSymbol() { return RESULT_SUCCESS; } -ResultCode CROHelper::ResetImportAnonymousSymbol() { +Result CROHelper::ResetImportAnonymousSymbol() { u32 unresolved_symbol = GetOnUnresolvedAddress(); u32 import_num = GetField(ImportAnonymousSymbolNum); @@ -843,7 +843,7 @@ ResultCode CROHelper::ResetImportAnonymousSymbol() { system.Memory().ReadBlock(process, relocation_addr, &relocation_entry, sizeof(ExternalRelocationEntry)); - ResultCode result = ApplyRelocationBatch(relocation_addr, unresolved_symbol, true); + Result result = ApplyRelocationBatch(relocation_addr, unresolved_symbol, true); if (result.IsError()) { LOG_ERROR(Service_LDR, "Error reseting relocation batch {:08X}", result.raw); return result; @@ -852,7 +852,7 @@ ResultCode CROHelper::ResetImportAnonymousSymbol() { return RESULT_SUCCESS; } -ResultCode CROHelper::ApplyModuleImport(VAddr crs_address) { +Result CROHelper::ApplyModuleImport(VAddr crs_address) { u32 import_strings_size = GetField(ImportStringsSize); u32 import_module_num = GetField(ImportModuleNum); @@ -862,7 +862,7 @@ ResultCode CROHelper::ApplyModuleImport(VAddr crs_address) { std::string want_cro_name = system.Memory().ReadCString(entry.name_offset, import_strings_size); - ResultCode result = ForEachAutoLinkCRO( + Result result = ForEachAutoLinkCRO( process, system, crs_address, [&](CROHelper source) -> ResultVal { if (want_cro_name == source.ModuleName()) { LOG_INFO(Service_LDR, "CRO \"{}\" imports {} indexed symbols from \"{}\"", @@ -874,7 +874,7 @@ ResultCode CROHelper::ApplyModuleImport(VAddr crs_address) { source.GetEntry(system.Memory(), im.index, ex); u32 symbol_address = source.SegmentTagToAddress(ex.symbol_position); LOG_TRACE(Service_LDR, " Imports 0x{:08X}", symbol_address); - ResultCode result = + Result result = ApplyRelocationBatch(im.relocation_batch_offset, symbol_address); if (result.IsError()) { LOG_ERROR(Service_LDR, "Error applying relocation batch {:08X}", @@ -889,7 +889,7 @@ ResultCode CROHelper::ApplyModuleImport(VAddr crs_address) { entry.GetImportAnonymousSymbolEntry(process, system.Memory(), j, im); u32 symbol_address = source.SegmentTagToAddress(im.symbol_position); LOG_TRACE(Service_LDR, " Imports 0x{:08X}", symbol_address); - ResultCode result = + Result result = ApplyRelocationBatch(im.relocation_batch_offset, symbol_address); if (result.IsError()) { LOG_ERROR(Service_LDR, "Error applying relocation batch {:08X}", @@ -908,7 +908,7 @@ ResultCode CROHelper::ApplyModuleImport(VAddr crs_address) { return RESULT_SUCCESS; } -ResultCode CROHelper::ApplyExportNamedSymbol(CROHelper target) { +Result CROHelper::ApplyExportNamedSymbol(CROHelper target) { LOG_DEBUG(Service_LDR, "CRO \"{}\" exports named symbols to \"{}\"", ModuleName(), target.ModuleName()); u32 target_import_strings_size = target.GetField(ImportStringsSize); @@ -927,7 +927,7 @@ ResultCode CROHelper::ApplyExportNamedSymbol(CROHelper target) { u32 symbol_address = FindExportNamedSymbol(symbol_name); if (symbol_address != 0) { LOG_TRACE(Service_LDR, " exports symbol \"{}\"", symbol_name); - ResultCode result = target.ApplyRelocationBatch(relocation_addr, symbol_address); + Result result = target.ApplyRelocationBatch(relocation_addr, symbol_address); if (result.IsError()) { LOG_ERROR(Service_LDR, "Error applying relocation batch {:08X}", result.raw); return result; @@ -938,7 +938,7 @@ ResultCode CROHelper::ApplyExportNamedSymbol(CROHelper target) { return RESULT_SUCCESS; } -ResultCode CROHelper::ResetExportNamedSymbol(CROHelper target) { +Result CROHelper::ResetExportNamedSymbol(CROHelper target) { LOG_DEBUG(Service_LDR, "CRO \"{}\" unexports named symbols to \"{}\"", ModuleName(), target.ModuleName()); u32 unresolved_symbol = target.GetOnUnresolvedAddress(); @@ -958,7 +958,7 @@ ResultCode CROHelper::ResetExportNamedSymbol(CROHelper target) { u32 symbol_address = FindExportNamedSymbol(symbol_name); if (symbol_address != 0) { LOG_TRACE(Service_LDR, " unexports symbol \"{}\"", symbol_name); - ResultCode result = + Result result = target.ApplyRelocationBatch(relocation_addr, unresolved_symbol, true); if (result.IsError()) { LOG_ERROR(Service_LDR, "Error applying relocation batch {:08X}", result.raw); @@ -970,7 +970,7 @@ ResultCode CROHelper::ResetExportNamedSymbol(CROHelper target) { return RESULT_SUCCESS; } -ResultCode CROHelper::ApplyModuleExport(CROHelper target) { +Result CROHelper::ApplyModuleExport(CROHelper target) { std::string module_name = ModuleName(); u32 target_import_string_size = target.GetField(ImportStringsSize); u32 target_import_module_num = target.GetField(ImportModuleNum); @@ -991,8 +991,7 @@ ResultCode CROHelper::ApplyModuleExport(CROHelper target) { GetEntry(system.Memory(), im.index, ex); u32 symbol_address = SegmentTagToAddress(ex.symbol_position); LOG_TRACE(Service_LDR, " exports symbol 0x{:08X}", symbol_address); - ResultCode result = - target.ApplyRelocationBatch(im.relocation_batch_offset, symbol_address); + Result result = target.ApplyRelocationBatch(im.relocation_batch_offset, symbol_address); if (result.IsError()) { LOG_ERROR(Service_LDR, "Error applying relocation batch {:08X}", result.raw); return result; @@ -1006,8 +1005,7 @@ ResultCode CROHelper::ApplyModuleExport(CROHelper target) { entry.GetImportAnonymousSymbolEntry(process, system.Memory(), j, im); u32 symbol_address = SegmentTagToAddress(im.symbol_position); LOG_TRACE(Service_LDR, " exports symbol 0x{:08X}", symbol_address); - ResultCode result = - target.ApplyRelocationBatch(im.relocation_batch_offset, symbol_address); + Result result = target.ApplyRelocationBatch(im.relocation_batch_offset, symbol_address); if (result.IsError()) { LOG_ERROR(Service_LDR, "Error applying relocation batch {:08X}", result.raw); return result; @@ -1018,7 +1016,7 @@ ResultCode CROHelper::ApplyModuleExport(CROHelper target) { return RESULT_SUCCESS; } -ResultCode CROHelper::ResetModuleExport(CROHelper target) { +Result CROHelper::ResetModuleExport(CROHelper target) { u32 unresolved_symbol = target.GetOnUnresolvedAddress(); std::string module_name = ModuleName(); @@ -1037,7 +1035,7 @@ ResultCode CROHelper::ResetModuleExport(CROHelper target) { for (u32 j = 0; j < entry.import_indexed_symbol_num; ++j) { ImportIndexedSymbolEntry im; entry.GetImportIndexedSymbolEntry(process, system.Memory(), j, im); - ResultCode result = + Result result = target.ApplyRelocationBatch(im.relocation_batch_offset, unresolved_symbol, true); if (result.IsError()) { LOG_ERROR(Service_LDR, "Error applying relocation batch {:08X}", result.raw); @@ -1050,7 +1048,7 @@ ResultCode CROHelper::ResetModuleExport(CROHelper target) { for (u32 j = 0; j < entry.import_anonymous_symbol_num; ++j) { ImportAnonymousSymbolEntry im; entry.GetImportAnonymousSymbolEntry(process, system.Memory(), j, im); - ResultCode result = + Result result = target.ApplyRelocationBatch(im.relocation_batch_offset, unresolved_symbol, true); if (result.IsError()) { LOG_ERROR(Service_LDR, "Error applying relocation batch {:08X}", result.raw); @@ -1062,7 +1060,7 @@ ResultCode CROHelper::ResetModuleExport(CROHelper target) { return RESULT_SUCCESS; } -ResultCode CROHelper::ApplyExitRelocations(VAddr crs_address) { +Result CROHelper::ApplyExitRelocations(VAddr crs_address) { u32 import_strings_size = GetField(ImportStringsSize); u32 symbol_import_num = GetField(ImportNamedSymbolNum); for (u32 i = 0; i < symbol_import_num; ++i) { @@ -1075,7 +1073,7 @@ ResultCode CROHelper::ApplyExitRelocations(VAddr crs_address) { if (system.Memory().ReadCString(entry.name_offset, import_strings_size) == "__aeabi_atexit") { - ResultCode result = ForEachAutoLinkCRO( + Result result = ForEachAutoLinkCRO( process, system, crs_address, [&](CROHelper source) -> ResultVal { u32 symbol_address = source.FindExportNamedSymbol("nnroAeabiAtexit_"); @@ -1083,7 +1081,7 @@ ResultCode CROHelper::ApplyExitRelocations(VAddr crs_address) { LOG_DEBUG(Service_LDR, "CRO \"{}\" import exit function from \"{}\"", ModuleName(), source.ModuleName()); - ResultCode result = ApplyRelocationBatch(relocation_addr, symbol_address); + Result result = ApplyRelocationBatch(relocation_addr, symbol_address); if (result.IsError()) { LOG_ERROR(Service_LDR, "Error applying relocation batch {:08X}", result.raw); @@ -1111,9 +1109,9 @@ ResultCode CROHelper::ApplyExitRelocations(VAddr crs_address) { * whole string (table) is terminated properly, despite that it is not actually one string. * @param address the virtual address of the string (table) * @param size the size of the string (table), including the terminating 0 - * @returns ResultCode RESULT_SUCCESS if the size matches, otherwise error code. + * @returns Result RESULT_SUCCESS if the size matches, otherwise error code. */ -static ResultCode VerifyStringTableLength(Memory::MemorySystem& memory, VAddr address, u32 size) { +static Result VerifyStringTableLength(Memory::MemorySystem& memory, VAddr address, u32 size) { if (size != 0) { if (memory.Read8(address + size - 1) != 0) return CROFormatError(0x0B); @@ -1121,11 +1119,11 @@ static ResultCode VerifyStringTableLength(Memory::MemorySystem& memory, VAddr ad return RESULT_SUCCESS; } -ResultCode CROHelper::Rebase(VAddr crs_address, u32 cro_size, VAddr data_segment_addresss, - u32 data_segment_size, VAddr bss_segment_address, u32 bss_segment_size, - bool is_crs) { +Result CROHelper::Rebase(VAddr crs_address, u32 cro_size, VAddr data_segment_addresss, + u32 data_segment_size, VAddr bss_segment_address, u32 bss_segment_size, + bool is_crs) { - ResultCode result = RebaseHeader(cro_size); + Result result = RebaseHeader(cro_size); if (result.IsError()) { LOG_ERROR(Service_LDR, "Error rebasing header {:08X}", result.raw); return result; @@ -1248,13 +1246,13 @@ void CROHelper::Unrebase(bool is_crs) { UnrebaseHeader(); } -ResultCode CROHelper::VerifyHash(u32 cro_size, VAddr crr) const { +Result CROHelper::VerifyHash(u32 cro_size, VAddr crr) const { // TODO(wwylele): actually verify the hash return RESULT_SUCCESS; } -ResultCode CROHelper::Link(VAddr crs_address, bool link_on_load_bug_fix) { - ResultCode result = RESULT_SUCCESS; +Result CROHelper::Link(VAddr crs_address, bool link_on_load_bug_fix) { + Result result = RESULT_SUCCESS; { VAddr data_segment_address = 0; @@ -1309,7 +1307,7 @@ ResultCode CROHelper::Link(VAddr crs_address, bool link_on_load_bug_fix) { // Exports symbols to other modules result = ForEachAutoLinkCRO(process, system, crs_address, [this](CROHelper target) -> ResultVal { - ResultCode result = ApplyExportNamedSymbol(target); + Result result = ApplyExportNamedSymbol(target); if (result.IsError()) return result; @@ -1327,10 +1325,10 @@ ResultCode CROHelper::Link(VAddr crs_address, bool link_on_load_bug_fix) { return RESULT_SUCCESS; } -ResultCode CROHelper::Unlink(VAddr crs_address) { +Result CROHelper::Unlink(VAddr crs_address) { // Resets all imported named symbols - ResultCode result = ResetImportNamedSymbol(); + Result result = ResetImportNamedSymbol(); if (result.IsError()) { LOG_ERROR(Service_LDR, "Error resetting symbol import {:08X}", result.raw); return result; @@ -1354,7 +1352,7 @@ ResultCode CROHelper::Unlink(VAddr crs_address) { // Note: the RO service seems only searching in auto-link modules result = ForEachAutoLinkCRO(process, system, crs_address, [this](CROHelper target) -> ResultVal { - ResultCode result = ResetExportNamedSymbol(target); + Result result = ResetExportNamedSymbol(target); if (result.IsError()) return result; @@ -1372,8 +1370,8 @@ ResultCode CROHelper::Unlink(VAddr crs_address) { return RESULT_SUCCESS; } -ResultCode CROHelper::ClearRelocations() { - ResultCode result = ClearExternalRelocations(); +Result CROHelper::ClearRelocations() { + Result result = ClearExternalRelocations(); if (result.IsError()) { LOG_ERROR(Service_LDR, "Error clearing external relocations {:08X}", result.raw); return result; diff --git a/src/core/hle/service/ldr_ro/cro_helper.h b/src/core/hle/service/ldr_ro/cro_helper.h index 7731153ab..37e9231f9 100644 --- a/src/core/hle/service/ldr_ro/cro_helper.h +++ b/src/core/hle/service/ldr_ro/cro_helper.h @@ -51,11 +51,11 @@ public: * @param bss_segment_address the buffer address for .bss segment * @param bss_segment_size the buffer size for .bss segment * @param is_crs true if the module itself is the static module - * @returns ResultCode RESULT_SUCCESS on success, otherwise error code. + * @returns Result RESULT_SUCCESS on success, otherwise error code. */ - ResultCode Rebase(VAddr crs_address, u32 cro_size, VAddr data_segment_address, - u32 data_segment_size, VAddr bss_segment_address, u32 bss_segment_size, - bool is_crs); + Result Rebase(VAddr crs_address, u32 cro_size, VAddr data_segment_address, + u32 data_segment_size, VAddr bss_segment_address, u32 bss_segment_size, + bool is_crs); /** * Unrebases the module. @@ -67,30 +67,30 @@ public: * Verifies module hash by CRR. * @param cro_size the size of the CRO * @param crr the virtual address of the CRR - * @returns ResultCode RESULT_SUCCESS on success, otherwise error code. + * @returns Result RESULT_SUCCESS on success, otherwise error code. */ - ResultCode VerifyHash(u32 cro_size, VAddr crr) const; + Result VerifyHash(u32 cro_size, VAddr crr) const; /** * Links this module with all registered auto-link module. * @param crs_address the virtual address of the static module * @param link_on_load_bug_fix true if links when loading and fixes the bug - * @returns ResultCode RESULT_SUCCESS on success, otherwise error code. + * @returns Result RESULT_SUCCESS on success, otherwise error code. */ - ResultCode Link(VAddr crs_address, bool link_on_load_bug_fix); + Result Link(VAddr crs_address, bool link_on_load_bug_fix); /** * Unlinks this module with other modules. * @param crs_address the virtual address of the static module - * @returns ResultCode RESULT_SUCCESS on success, otherwise error code. + * @returns Result RESULT_SUCCESS on success, otherwise error code. */ - ResultCode Unlink(VAddr crs_address); + Result Unlink(VAddr crs_address); /** * Clears all relocations to zero. - * @returns ResultCode RESULT_SUCCESS on success, otherwise error code. + * @returns Result RESULT_SUCCESS on success, otherwise error code. */ - ResultCode ClearRelocations(); + Result ClearRelocations(); /// Initialize this module as the static module (CRS) void InitCRS(); @@ -465,13 +465,13 @@ private: * CROHelper and returns ResultVal. It should return true to continue the * iteration, * false to stop the iteration, or an error code (which will also stop the iteration). - * @returns ResultCode indicating the result of the operation, RESULT_SUCCESS if all iteration + * @returns Result indicating the result of the operation, RESULT_SUCCESS if all iteration * success, * otherwise error code of the last iteration. */ template - static ResultCode ForEachAutoLinkCRO(Kernel::Process& process, Core::System& system, - VAddr crs_address, FunctionObject func) { + static Result ForEachAutoLinkCRO(Kernel::Process& process, Core::System& system, + VAddr crs_address, FunctionObject func) { VAddr current = crs_address; while (current != 0) { CROHelper cro(current, process, system); @@ -491,18 +491,18 @@ private: * @param symbol_address the symbol address to be relocated with * @param target_future_address the future address of the target. * Usually equals to target_address, but will be different for a target in .data segment - * @returns ResultCode RESULT_SUCCESS on success, otherwise error code. + * @returns Result RESULT_SUCCESS on success, otherwise error code. */ - ResultCode ApplyRelocation(VAddr target_address, RelocationType relocation_type, u32 addend, - u32 symbol_address, u32 target_future_address); + Result ApplyRelocation(VAddr target_address, RelocationType relocation_type, u32 addend, + u32 symbol_address, u32 target_future_address); /** * Clears a relocation to zero * @param target_address where to apply the relocation * @param relocation_type the type of the relocation - * @returns ResultCode RESULT_SUCCESS on success, otherwise error code. + * @returns Result RESULT_SUCCESS on success, otherwise error code. */ - ResultCode ClearRelocation(VAddr target_address, RelocationType relocation_type); + Result ClearRelocation(VAddr target_address, RelocationType relocation_type); /** * Applies or resets a batch of relocations @@ -510,9 +510,9 @@ private: * @param symbol_address the symbol address to be relocated with * @param reset false to set the batch to resolved state, true to reset the batch to unresolved * state - * @returns ResultCode RESULT_SUCCESS on success, otherwise error code. + * @returns Result RESULT_SUCCESS on success, otherwise error code. */ - ResultCode ApplyRelocationBatch(VAddr batch, u32 symbol_address, bool reset = false); + Result ApplyRelocationBatch(VAddr batch, u32 symbol_address, bool reset = false); /** * Finds an exported named symbol in this module. @@ -524,10 +524,10 @@ private: /** * Rebases offsets in module header according to module address. * @param cro_size the size of the CRO file - * @returns ResultCode RESULT_SUCCESS if all offsets are verified as valid, otherwise error + * @returns Result RESULT_SUCCESS if all offsets are verified as valid, otherwise error * code. */ - ResultCode RebaseHeader(u32 cro_size); + Result RebaseHeader(u32 cro_size); /** * Rebases offsets in segment table according to module address. @@ -544,45 +544,45 @@ private: /** * Rebases offsets in exported named symbol table according to module address. - * @returns ResultCode RESULT_SUCCESS if all offsets are verified as valid, otherwise error + * @returns Result RESULT_SUCCESS if all offsets are verified as valid, otherwise error * code. */ - ResultCode RebaseExportNamedSymbolTable(); + Result RebaseExportNamedSymbolTable(); /** * Verifies indices in export tree table. - * @returns ResultCode RESULT_SUCCESS if all indices are verified as valid, otherwise error + * @returns Result RESULT_SUCCESS if all indices are verified as valid, otherwise error * code. */ - ResultCode VerifyExportTreeTable() const; + Result VerifyExportTreeTable() const; /** * Rebases offsets in exported module table according to module address. - * @returns ResultCode RESULT_SUCCESS if all offsets are verified as valid, otherwise error + * @returns Result RESULT_SUCCESS if all offsets are verified as valid, otherwise error * code. */ - ResultCode RebaseImportModuleTable(); + Result RebaseImportModuleTable(); /** * Rebases offsets in imported named symbol table according to module address. - * @returns ResultCode RESULT_SUCCESS if all offsets are verified as valid, otherwise error + * @returns Result RESULT_SUCCESS if all offsets are verified as valid, otherwise error * code. */ - ResultCode RebaseImportNamedSymbolTable(); + Result RebaseImportNamedSymbolTable(); /** * Rebases offsets in imported indexed symbol table according to module address. - * @returns ResultCode RESULT_SUCCESS if all offsets are verified as valid, otherwise error + * @returns Result RESULT_SUCCESS if all offsets are verified as valid, otherwise error * code. */ - ResultCode RebaseImportIndexedSymbolTable(); + Result RebaseImportIndexedSymbolTable(); /** * Rebases offsets in imported anonymous symbol table according to module address. - * @returns ResultCode RESULT_SUCCESS if all offsets are verified as valid, otherwise error + * @returns Result RESULT_SUCCESS if all offsets are verified as valid, otherwise error * code. */ - ResultCode RebaseImportAnonymousSymbolTable(); + Result RebaseImportAnonymousSymbolTable(); /** * Gets the address of OnUnresolved function in this module. @@ -593,35 +593,35 @@ private: /** * Resets all external relocations to unresolved state. - * @returns ResultCode RESULT_SUCCESS on success, otherwise error code. + * @returns Result RESULT_SUCCESS on success, otherwise error code. */ - ResultCode ResetExternalRelocations(); + Result ResetExternalRelocations(); /** * Clears all external relocations to zero. - * @returns ResultCode RESULT_SUCCESS on success, otherwise error code. + * @returns Result RESULT_SUCCESS on success, otherwise error code. */ - ResultCode ClearExternalRelocations(); + Result ClearExternalRelocations(); /** * Applies all static anonymous symbol to the static module. * @param crs_address the virtual address of the static module - * @returns ResultCode RESULT_SUCCESS on success, otherwise error code. + * @returns Result RESULT_SUCCESS on success, otherwise error code. */ - ResultCode ApplyStaticAnonymousSymbolToCRS(VAddr crs_address); + Result ApplyStaticAnonymousSymbolToCRS(VAddr crs_address); /** * Applies all internal relocations to the module itself. * @param old_data_segment_address the virtual address of data segment in CRO buffer - * @returns ResultCode RESULT_SUCCESS on success, otherwise error code. + * @returns Result RESULT_SUCCESS on success, otherwise error code. */ - ResultCode ApplyInternalRelocations(u32 old_data_segment_address); + Result ApplyInternalRelocations(u32 old_data_segment_address); /** * Clears all internal relocations to zero. - * @returns ResultCode RESULT_SUCCESS on success, otherwise error code. + * @returns Result RESULT_SUCCESS on success, otherwise error code. */ - ResultCode ClearInternalRelocations(); + Result ClearInternalRelocations(); /// Unrebases offsets in imported anonymous symbol table void UnrebaseImportAnonymousSymbolTable(); @@ -648,71 +648,71 @@ private: * Looks up all imported named symbols of this module in all registered auto-link modules, and * resolves them if found. * @param crs_address the virtual address of the static module - * @returns ResultCode RESULT_SUCCESS on success, otherwise error code. + * @returns Result RESULT_SUCCESS on success, otherwise error code. */ - ResultCode ApplyImportNamedSymbol(VAddr crs_address); + Result ApplyImportNamedSymbol(VAddr crs_address); /** * Resets all imported named symbols of this module to unresolved state. - * @returns ResultCode RESULT_SUCCESS on success, otherwise error code. + * @returns Result RESULT_SUCCESS on success, otherwise error code. */ - ResultCode ResetImportNamedSymbol(); + Result ResetImportNamedSymbol(); /** * Resets all imported indexed symbols of this module to unresolved state. - * @returns ResultCode RESULT_SUCCESS on success, otherwise error code. + * @returns Result RESULT_SUCCESS on success, otherwise error code. */ - ResultCode ResetImportIndexedSymbol(); + Result ResetImportIndexedSymbol(); /** * Resets all imported anonymous symbols of this module to unresolved state. - * @returns ResultCode RESULT_SUCCESS on success, otherwise error code. + * @returns Result RESULT_SUCCESS on success, otherwise error code. */ - ResultCode ResetImportAnonymousSymbol(); + Result ResetImportAnonymousSymbol(); /** * Finds registered auto-link modules that this module imports, and resolves indexed and * anonymous symbols exported by them. * @param crs_address the virtual address of the static module - * @returns ResultCode RESULT_SUCCESS on success, otherwise error code. + * @returns Result RESULT_SUCCESS on success, otherwise error code. */ - ResultCode ApplyModuleImport(VAddr crs_address); + Result ApplyModuleImport(VAddr crs_address); /** * Resolves target module's imported named symbols that exported by this module. * @param target the module to resolve. - * @returns ResultCode RESULT_SUCCESS on success, otherwise error code. + * @returns Result RESULT_SUCCESS on success, otherwise error code. */ - ResultCode ApplyExportNamedSymbol(CROHelper target); + Result ApplyExportNamedSymbol(CROHelper target); /** * Resets target's named symbols imported from this module to unresolved state. * @param target the module to reset. - * @returns ResultCode RESULT_SUCCESS on success, otherwise error code. + * @returns Result RESULT_SUCCESS on success, otherwise error code. */ - ResultCode ResetExportNamedSymbol(CROHelper target); + Result ResetExportNamedSymbol(CROHelper target); /** * Resolves imported indexed and anonymous symbols in the target module which imports this * module. * @param target the module to resolve. - * @returns ResultCode RESULT_SUCCESS on success, otherwise error code. + * @returns Result RESULT_SUCCESS on success, otherwise error code. */ - ResultCode ApplyModuleExport(CROHelper target); + Result ApplyModuleExport(CROHelper target); /** * Resets target's indexed and anonymous symbol imported from this module to unresolved state. * @param target the module to reset. - * @returns ResultCode RESULT_SUCCESS on success, otherwise error code. + * @returns Result RESULT_SUCCESS on success, otherwise error code. */ - ResultCode ResetModuleExport(CROHelper target); + Result ResetModuleExport(CROHelper target); /** * Resolves the exit function in this module * @param crs_address the virtual address of the static module. - * @returns ResultCode RESULT_SUCCESS on success, otherwise error code. + * @returns Result RESULT_SUCCESS on success, otherwise error code. */ - ResultCode ApplyExitRelocations(VAddr crs_address); + Result ApplyExitRelocations(VAddr crs_address); }; } // namespace Service::LDR diff --git a/src/core/hle/service/ldr_ro/ldr_ro.cpp b/src/core/hle/service/ldr_ro/ldr_ro.cpp index 9803cec76..7ce349790 100644 --- a/src/core/hle/service/ldr_ro/ldr_ro.cpp +++ b/src/core/hle/service/ldr_ro/ldr_ro.cpp @@ -19,30 +19,30 @@ SERIALIZE_EXPORT_IMPL(Service::LDR::ClientSlot) namespace Service::LDR { -static const ResultCode ERROR_ALREADY_INITIALIZED = // 0xD9612FF9 - ResultCode(ErrorDescription::AlreadyInitialized, ErrorModule::RO, ErrorSummary::Internal, - ErrorLevel::Permanent); -static const ResultCode ERROR_NOT_INITIALIZED = // 0xD9612FF8 - ResultCode(ErrorDescription::NotInitialized, ErrorModule::RO, ErrorSummary::Internal, - ErrorLevel::Permanent); -static const ResultCode ERROR_BUFFER_TOO_SMALL = // 0xE0E12C1F - ResultCode(static_cast(31), ErrorModule::RO, ErrorSummary::InvalidArgument, - ErrorLevel::Usage); -static const ResultCode ERROR_MISALIGNED_ADDRESS = // 0xD9012FF1 - ResultCode(ErrorDescription::MisalignedAddress, ErrorModule::RO, ErrorSummary::WrongArgument, - ErrorLevel::Permanent); -static const ResultCode ERROR_MISALIGNED_SIZE = // 0xD9012FF2 - ResultCode(ErrorDescription::MisalignedSize, ErrorModule::RO, ErrorSummary::WrongArgument, - ErrorLevel::Permanent); -static const ResultCode ERROR_ILLEGAL_ADDRESS = // 0xE1612C0F - ResultCode(static_cast(15), ErrorModule::RO, ErrorSummary::Internal, - ErrorLevel::Usage); -static const ResultCode ERROR_INVALID_MEMORY_STATE = // 0xD8A12C08 - ResultCode(static_cast(8), ErrorModule::RO, ErrorSummary::InvalidState, - ErrorLevel::Permanent); -static const ResultCode ERROR_NOT_LOADED = // 0xD8A12C0D - ResultCode(static_cast(13), ErrorModule::RO, ErrorSummary::InvalidState, - ErrorLevel::Permanent); +static const Result ERROR_ALREADY_INITIALIZED = // 0xD9612FF9 + Result(ErrorDescription::AlreadyInitialized, ErrorModule::RO, ErrorSummary::Internal, + ErrorLevel::Permanent); +static const Result ERROR_NOT_INITIALIZED = // 0xD9612FF8 + Result(ErrorDescription::NotInitialized, ErrorModule::RO, ErrorSummary::Internal, + ErrorLevel::Permanent); +static const Result ERROR_BUFFER_TOO_SMALL = // 0xE0E12C1F + Result(static_cast(31), ErrorModule::RO, ErrorSummary::InvalidArgument, + ErrorLevel::Usage); +static const Result ERROR_MISALIGNED_ADDRESS = // 0xD9012FF1 + Result(ErrorDescription::MisalignedAddress, ErrorModule::RO, ErrorSummary::WrongArgument, + ErrorLevel::Permanent); +static const Result ERROR_MISALIGNED_SIZE = // 0xD9012FF2 + Result(ErrorDescription::MisalignedSize, ErrorModule::RO, ErrorSummary::WrongArgument, + ErrorLevel::Permanent); +static const Result ERROR_ILLEGAL_ADDRESS = // 0xE1612C0F + Result(static_cast(15), ErrorModule::RO, ErrorSummary::Internal, + ErrorLevel::Usage); +static const Result ERROR_INVALID_MEMORY_STATE = // 0xD8A12C08 + Result(static_cast(8), ErrorModule::RO, ErrorSummary::InvalidState, + ErrorLevel::Permanent); +static const Result ERROR_NOT_LOADED = // 0xD8A12C0D + Result(static_cast(13), ErrorModule::RO, ErrorSummary::InvalidState, + ErrorLevel::Permanent); static bool VerifyBufferState(Kernel::Process& process, VAddr buffer_ptr, u32 size) { auto vma = process.vm_manager.FindVMA(buffer_ptr); @@ -118,7 +118,7 @@ void RO::Initialize(Kernel::HLERequestContext& ctx) { return; } - ResultCode result = RESULT_SUCCESS; + Result result = RESULT_SUCCESS; result = process->Map(crs_address, crs_buffer_ptr, crs_size, Kernel::VMAPermission::Read, true); if (result.IsError()) { @@ -245,13 +245,13 @@ void RO::LoadCRO(Kernel::HLERequestContext& ctx, bool link_on_load_bug_fix) { if (zero) { LOG_ERROR(Service_LDR, "Zero is not zero {}", zero); - rb.Push(ResultCode(static_cast(29), ErrorModule::RO, - ErrorSummary::Internal, ErrorLevel::Usage)); + rb.Push(Result(static_cast(29), ErrorModule::RO, ErrorSummary::Internal, + ErrorLevel::Usage)); rb.Push(0); return; } - ResultCode result = RESULT_SUCCESS; + Result result = RESULT_SUCCESS; result = process->Map(cro_address, cro_buffer_ptr, cro_size, Kernel::VMAPermission::Read, true); if (result.IsError()) { @@ -372,7 +372,7 @@ void RO::UnloadCRO(Kernel::HLERequestContext& ctx) { cro.Unregister(slot->loaded_crs); - ResultCode result = cro.Unlink(slot->loaded_crs); + Result result = cro.Unlink(slot->loaded_crs); if (result.IsError()) { LOG_ERROR(Service_LDR, "Error unlinking CRO {:08X}", result.raw); rb.Push(result); @@ -435,7 +435,7 @@ void RO::LinkCRO(Kernel::HLERequestContext& ctx) { LOG_INFO(Service_LDR, "Linking CRO \"{}\"", cro.ModuleName()); - ResultCode result = cro.Link(slot->loaded_crs, false); + Result result = cro.Link(slot->loaded_crs, false); if (result.IsError()) { LOG_ERROR(Service_LDR, "Error linking CRO {:08X}", result.raw); } @@ -475,7 +475,7 @@ void RO::UnlinkCRO(Kernel::HLERequestContext& ctx) { LOG_INFO(Service_LDR, "Unlinking CRO \"{}\"", cro.ModuleName()); - ResultCode result = cro.Unlink(slot->loaded_crs); + Result result = cro.Unlink(slot->loaded_crs); if (result.IsError()) { LOG_ERROR(Service_LDR, "Error unlinking CRO {:08X}", result.raw); } @@ -502,7 +502,7 @@ void RO::Shutdown(Kernel::HLERequestContext& ctx) { CROHelper crs(slot->loaded_crs, *process, system); crs.Unrebase(true); - ResultCode result = RESULT_SUCCESS; + Result result = RESULT_SUCCESS; result = process->Unmap(slot->loaded_crs, crs_buffer_ptr, crs.GetFileSize(), Kernel::VMAPermission::ReadWrite, true); diff --git a/src/core/hle/service/nfc/nfc.cpp b/src/core/hle/service/nfc/nfc.cpp index cd32fc389..f7beefb45 100644 --- a/src/core/hle/service/nfc/nfc.cpp +++ b/src/core/hle/service/nfc/nfc.cpp @@ -34,7 +34,7 @@ void Module::Interface::Initialize(Kernel::HLERequestContext& ctx) { return; } - ResultCode result = RESULT_SUCCESS; + Result result = RESULT_SUCCESS; switch (communication_mode) { case CommunicationMode::Ntag: case CommunicationMode::Amiibo: @@ -68,7 +68,7 @@ void Module::Interface::Finalize(Kernel::HLERequestContext& ctx) { return; } - ResultCode result = RESULT_SUCCESS; + Result result = RESULT_SUCCESS; switch (communication_mode) { case CommunicationMode::Ntag: case CommunicationMode::Amiibo: @@ -129,7 +129,7 @@ void Module::Interface::StartDetection(Kernel::HLERequestContext& ctx) { LOG_INFO(Service_NFC, "called, in_val={:04x}", in_val); - ResultCode result = RESULT_SUCCESS; + Result result = RESULT_SUCCESS; switch (nfc->nfc_mode) { case CommunicationMode::Ntag: case CommunicationMode::Amiibo: @@ -150,7 +150,7 @@ void Module::Interface::StopDetection(Kernel::HLERequestContext& ctx) { LOG_INFO(Service_NFC, "called"); - ResultCode result = RESULT_SUCCESS; + Result result = RESULT_SUCCESS; switch (nfc->nfc_mode) { case CommunicationMode::Ntag: case CommunicationMode::Amiibo: @@ -175,7 +175,7 @@ void Module::Interface::Mount(Kernel::HLERequestContext& ctx) { nfc->device->RescheduleTagRemoveEvent(); - ResultCode result = RESULT_SUCCESS; + Result result = RESULT_SUCCESS; switch (nfc->nfc_mode) { case CommunicationMode::Ntag: result = nfc->device->Mount(); @@ -197,7 +197,7 @@ void Module::Interface::Unmount(Kernel::HLERequestContext& ctx) { LOG_INFO(Service_NFC, "called"); - ResultCode result = RESULT_SUCCESS; + Result result = RESULT_SUCCESS; switch (nfc->nfc_mode) { case CommunicationMode::Ntag: case CommunicationMode::Amiibo: @@ -217,7 +217,7 @@ void Module::Interface::Flush(Kernel::HLERequestContext& ctx) { LOG_INFO(Service_NFC, "called"); - ResultCode result = RESULT_SUCCESS; + Result result = RESULT_SUCCESS; switch (nfc->nfc_mode) { case CommunicationMode::Ntag: LOG_ERROR(Service_NFC, "CommunicationMode {} not implemented", nfc->nfc_mode); @@ -514,7 +514,7 @@ void Module::Interface::MountRom(Kernel::HLERequestContext& ctx) { LOG_INFO(Service_NFC, "called"); - ResultCode result = RESULT_SUCCESS; + Result result = RESULT_SUCCESS; switch (nfc->nfc_mode) { case CommunicationMode::Ntag: result = nfc->device->PartiallyMount(); diff --git a/src/core/hle/service/nfc/nfc_device.cpp b/src/core/hle/service/nfc/nfc_device.cpp index 107ff8101..c448e60e5 100644 --- a/src/core/hle/service/nfc/nfc_device.cpp +++ b/src/core/hle/service/nfc/nfc_device.cpp @@ -166,7 +166,7 @@ void NfcDevice::Finalize() { is_initalized = false; } -ResultCode NfcDevice::StartCommunication() { +Result NfcDevice::StartCommunication() { const auto connection_result = CheckConnectionState(); if (connection_result.IsError()) { return connection_result; @@ -184,7 +184,7 @@ ResultCode NfcDevice::StartCommunication() { return RESULT_SUCCESS; } -ResultCode NfcDevice::StopCommunication() { +Result NfcDevice::StopCommunication() { const auto connection_result = CheckConnectionState(); if (connection_result.IsError()) { return connection_result; @@ -204,7 +204,7 @@ ResultCode NfcDevice::StopCommunication() { return RESULT_SUCCESS; } -ResultCode NfcDevice::StartDetection(TagProtocol allowed_protocol) { +Result NfcDevice::StartDetection(TagProtocol allowed_protocol) { const auto connection_result = CheckConnectionState(); if (connection_result.IsError()) { return connection_result; @@ -230,7 +230,7 @@ ResultCode NfcDevice::StartDetection(TagProtocol allowed_protocol) { return RESULT_SUCCESS; } -ResultCode NfcDevice::StopDetection() { +Result NfcDevice::StopDetection() { const auto connection_result = CheckConnectionState(); if (connection_result.IsError()) { return connection_result; @@ -257,7 +257,7 @@ ResultCode NfcDevice::StopDetection() { return ResultInvalidOperation; } -ResultCode NfcDevice::Flush() { +Result NfcDevice::Flush() { if (device_state != DeviceState::TagMounted) { LOG_ERROR(Service_NFC, "Wrong device state {}", device_state); const auto connection_result = CheckConnectionState(); @@ -327,7 +327,7 @@ ResultCode NfcDevice::Flush() { return RESULT_SUCCESS; } -ResultCode NfcDevice::Mount() { +Result NfcDevice::Mount() { if (device_state != DeviceState::TagFound) { LOG_ERROR(Service_NFC, "Wrong device state {}", device_state); const auto connection_result = CheckConnectionState(); @@ -357,7 +357,7 @@ ResultCode NfcDevice::Mount() { return RESULT_SUCCESS; } -ResultCode NfcDevice::MountAmiibo() { +Result NfcDevice::MountAmiibo() { TagInfo tag_info{}; const auto result = GetTagInfo(tag_info); @@ -372,7 +372,7 @@ ResultCode NfcDevice::MountAmiibo() { return Mount(); } -ResultCode NfcDevice::PartiallyMount() { +Result NfcDevice::PartiallyMount() { if (device_state != DeviceState::TagFound) { LOG_ERROR(Service_NFC, "Wrong device state {}", device_state); const auto connection_result = CheckConnectionState(); @@ -402,7 +402,7 @@ ResultCode NfcDevice::PartiallyMount() { return RESULT_SUCCESS; } -ResultCode NfcDevice::PartiallyMountAmiibo() { +Result NfcDevice::PartiallyMountAmiibo() { TagInfo tag_info{}; const auto result = GetTagInfo(tag_info); @@ -416,7 +416,7 @@ ResultCode NfcDevice::PartiallyMountAmiibo() { return PartiallyMount(); } -ResultCode NfcDevice::ResetTagScanState() { +Result NfcDevice::ResetTagScanState() { if (device_state != DeviceState::TagMounted && device_state != DeviceState::TagPartiallyMounted) { LOG_ERROR(Service_NFC, "Wrong device state {}", device_state); @@ -433,7 +433,7 @@ ResultCode NfcDevice::ResetTagScanState() { return RESULT_SUCCESS; } -ResultCode NfcDevice::GetTagInfo2(TagInfo2& tag_info) const { +Result NfcDevice::GetTagInfo2(TagInfo2& tag_info) const { tag_info = { .uuid_length = static_cast(encrypted_tag.file.uuid.uid.size()), .tag_type = PackedTagType::Type2, @@ -446,7 +446,7 @@ ResultCode NfcDevice::GetTagInfo2(TagInfo2& tag_info) const { return RESULT_SUCCESS; } -ResultCode NfcDevice::GetTagInfo(TagInfo& tag_info) const { +Result NfcDevice::GetTagInfo(TagInfo& tag_info) const { if (device_state != DeviceState::TagFound && device_state != DeviceState::TagMounted && device_state != DeviceState::TagPartiallyMounted) { LOG_ERROR(Service_NFC, "Wrong device state {}", device_state); @@ -468,7 +468,7 @@ ResultCode NfcDevice::GetTagInfo(TagInfo& tag_info) const { return RESULT_SUCCESS; } -ResultCode NfcDevice::GetCommonInfo(CommonInfo& common_info) const { +Result NfcDevice::GetCommonInfo(CommonInfo& common_info) const { if (device_state != DeviceState::TagMounted) { LOG_ERROR(Service_NFC, "Wrong device state {}", device_state); const auto connection_result = CheckConnectionState(); @@ -497,7 +497,7 @@ ResultCode NfcDevice::GetCommonInfo(CommonInfo& common_info) const { return RESULT_SUCCESS; } -ResultCode NfcDevice::GetModelInfo(ModelInfo& model_info) const { +Result NfcDevice::GetModelInfo(ModelInfo& model_info) const { if (device_state != DeviceState::TagMounted && device_state != DeviceState::TagPartiallyMounted) { LOG_ERROR(Service_NFC, "Wrong device state {}", device_state); @@ -520,7 +520,7 @@ ResultCode NfcDevice::GetModelInfo(ModelInfo& model_info) const { return RESULT_SUCCESS; } -ResultCode NfcDevice::GetRegisterInfo(RegisterInfo& register_info) const { +Result NfcDevice::GetRegisterInfo(RegisterInfo& register_info) const { if (device_state != DeviceState::TagMounted) { LOG_ERROR(Service_NFC, "Wrong device state {}", device_state); const auto connection_result = CheckConnectionState(); @@ -548,7 +548,7 @@ ResultCode NfcDevice::GetRegisterInfo(RegisterInfo& register_info) const { return RESULT_SUCCESS; } -ResultCode NfcDevice::GetAdminInfo(AdminInfo& admin_info) const { +Result NfcDevice::GetAdminInfo(AdminInfo& admin_info) const { if (device_state != DeviceState::TagMounted) { LOG_ERROR(Service_NFC, "Wrong device state {}", device_state); const auto connection_result = CheckConnectionState(); @@ -607,7 +607,7 @@ ResultCode NfcDevice::GetAdminInfo(AdminInfo& admin_info) const { return RESULT_SUCCESS; } -ResultCode NfcDevice::DeleteRegisterInfo() { +Result NfcDevice::DeleteRegisterInfo() { // This is a hack to get around a HW issue if (device_state == DeviceState::TagFound) { Mount(); @@ -645,7 +645,7 @@ ResultCode NfcDevice::DeleteRegisterInfo() { return Flush(); } -ResultCode NfcDevice::SetRegisterInfoPrivate(const RegisterInfoPrivate& register_info) { +Result NfcDevice::SetRegisterInfoPrivate(const RegisterInfoPrivate& register_info) { if (device_state != DeviceState::TagMounted) { LOG_ERROR(Service_NFC, "Wrong device state {}", device_state); const auto connection_result = CheckConnectionState(); @@ -677,7 +677,7 @@ ResultCode NfcDevice::SetRegisterInfoPrivate(const RegisterInfoPrivate& register return Flush(); } -ResultCode NfcDevice::RestoreAmiibo() { +Result NfcDevice::RestoreAmiibo() { if (device_state != DeviceState::TagMounted) { LOG_ERROR(Service_NFC, "Wrong device state {}", device_state); const auto connection_result = CheckConnectionState(); @@ -692,22 +692,22 @@ ResultCode NfcDevice::RestoreAmiibo() { return RESULT_SUCCESS; } -ResultCode NfcDevice::Format() { - auto ResultCode = DeleteApplicationArea(); - auto ResultCode2 = DeleteRegisterInfo(); +Result NfcDevice::Format() { + auto Result = DeleteApplicationArea(); + auto Result2 = DeleteRegisterInfo(); - if (ResultCode.IsError()) { - return ResultCode; + if (Result.IsError()) { + return Result; } - if (ResultCode2.IsError()) { - return ResultCode2; + if (Result2.IsError()) { + return Result2; } return RESULT_SUCCESS; } -ResultCode NfcDevice::OpenApplicationArea(u32 access_id) { +Result NfcDevice::OpenApplicationArea(u32 access_id) { if (device_state != DeviceState::TagMounted) { LOG_ERROR(Service_NFC, "Wrong device state {}", device_state); const auto connection_result = CheckConnectionState(); @@ -732,7 +732,7 @@ ResultCode NfcDevice::OpenApplicationArea(u32 access_id) { return RESULT_SUCCESS; } -ResultCode NfcDevice::GetApplicationAreaId(u32& application_area_id) const { +Result NfcDevice::GetApplicationAreaId(u32& application_area_id) const { application_area_id = {}; if (device_state != DeviceState::TagMounted) { @@ -754,7 +754,7 @@ ResultCode NfcDevice::GetApplicationAreaId(u32& application_area_id) const { return RESULT_SUCCESS; } -ResultCode NfcDevice::GetApplicationArea(std::vector& data) const { +Result NfcDevice::GetApplicationArea(std::vector& data) const { if (device_state != DeviceState::TagMounted) { LOG_ERROR(Service_NFC, "Wrong device state {}", device_state); const auto connection_result = CheckConnectionState(); @@ -783,7 +783,7 @@ ResultCode NfcDevice::GetApplicationArea(std::vector& data) const { return RESULT_SUCCESS; } -ResultCode NfcDevice::SetApplicationArea(std::span data) { +Result NfcDevice::SetApplicationArea(std::span data) { if (device_state != DeviceState::TagMounted) { LOG_ERROR(Service_NFC, "Wrong device state {}", device_state); const auto connection_result = CheckConnectionState(); @@ -831,7 +831,7 @@ ResultCode NfcDevice::SetApplicationArea(std::span data) { return RESULT_SUCCESS; } -ResultCode NfcDevice::CreateApplicationArea(u32 access_id, std::span data) { +Result NfcDevice::CreateApplicationArea(u32 access_id, std::span data) { if (device_state != DeviceState::TagMounted) { LOG_ERROR(Service_NFC, "Wrong device state {}", device_state); const auto connection_result = CheckConnectionState(); @@ -849,7 +849,7 @@ ResultCode NfcDevice::CreateApplicationArea(u32 access_id, std::span d return RecreateApplicationArea(access_id, data); } -ResultCode NfcDevice::RecreateApplicationArea(u32 access_id, std::span data) { +Result NfcDevice::RecreateApplicationArea(u32 access_id, std::span data) { if (device_state != DeviceState::TagMounted) { LOG_ERROR(Service_NFC, "Wrong device state {}", device_state); const auto connection_result = CheckConnectionState(); @@ -900,7 +900,7 @@ ResultCode NfcDevice::RecreateApplicationArea(u32 access_id, std::span return Flush(); } -ResultCode NfcDevice::DeleteApplicationArea() { +Result NfcDevice::DeleteApplicationArea() { // This is a hack to get around a HW issue if (device_state == DeviceState::TagFound) { Mount(); @@ -943,7 +943,7 @@ ResultCode NfcDevice::DeleteApplicationArea() { return Flush(); } -ResultCode NfcDevice::ApplicationAreaExist(bool& has_application_area) { +Result NfcDevice::ApplicationAreaExist(bool& has_application_area) { if (device_state != DeviceState::TagMounted) { LOG_ERROR(Service_NFC, "Wrong device state {}", device_state); const auto connection_result = CheckConnectionState(); @@ -966,7 +966,7 @@ DeviceState NfcDevice::GetCurrentState() const { return device_state; } -ResultCode NfcDevice::GetCommunicationStatus(CommunicationState& status) const { +Result NfcDevice::GetCommunicationStatus(CommunicationState& status) const { if (communication_state == CommunicationState::Idle || communication_state == CommunicationState::SearchingForAdapter) { status = communication_state; @@ -982,7 +982,7 @@ ResultCode NfcDevice::GetCommunicationStatus(CommunicationState& status) const { return ResultInvalidOperation; } -ResultCode NfcDevice::CheckConnectionState() const { +Result NfcDevice::CheckConnectionState() const { if (connection_state == ConnectionState::Lost) { return ResultSleep; } diff --git a/src/core/hle/service/nfc/nfc_device.h b/src/core/hle/service/nfc/nfc_device.h index b24101048..0ca204c4c 100644 --- a/src/core/hle/service/nfc/nfc_device.h +++ b/src/core/hle/service/nfc/nfc_device.h @@ -31,42 +31,42 @@ public: void Initialize(); void Finalize(); - ResultCode StartCommunication(); - ResultCode StopCommunication(); - ResultCode StartDetection(TagProtocol allowed_protocol); - ResultCode StopDetection(); - ResultCode Mount(); - ResultCode MountAmiibo(); - ResultCode PartiallyMount(); - ResultCode PartiallyMountAmiibo(); - ResultCode ResetTagScanState(); - ResultCode Flush(); + Result StartCommunication(); + Result StopCommunication(); + Result StartDetection(TagProtocol allowed_protocol); + Result StopDetection(); + Result Mount(); + Result MountAmiibo(); + Result PartiallyMount(); + Result PartiallyMountAmiibo(); + Result ResetTagScanState(); + Result Flush(); - ResultCode GetTagInfo2(TagInfo2& tag_info) const; - ResultCode GetTagInfo(TagInfo& tag_info) const; - ResultCode GetCommonInfo(CommonInfo& common_info) const; - ResultCode GetModelInfo(ModelInfo& model_info) const; - ResultCode GetRegisterInfo(RegisterInfo& register_info) const; - ResultCode GetAdminInfo(AdminInfo& admin_info) const; + Result GetTagInfo2(TagInfo2& tag_info) const; + Result GetTagInfo(TagInfo& tag_info) const; + Result GetCommonInfo(CommonInfo& common_info) const; + Result GetModelInfo(ModelInfo& model_info) const; + Result GetRegisterInfo(RegisterInfo& register_info) const; + Result GetAdminInfo(AdminInfo& admin_info) const; - ResultCode DeleteRegisterInfo(); - ResultCode SetRegisterInfoPrivate(const RegisterInfoPrivate& register_info); - ResultCode RestoreAmiibo(); - ResultCode Format(); + Result DeleteRegisterInfo(); + Result SetRegisterInfoPrivate(const RegisterInfoPrivate& register_info); + Result RestoreAmiibo(); + Result Format(); - ResultCode OpenApplicationArea(u32 access_id); - ResultCode GetApplicationAreaId(u32& application_area_id) const; - ResultCode GetApplicationArea(std::vector& data) const; - ResultCode SetApplicationArea(std::span data); - ResultCode CreateApplicationArea(u32 access_id, std::span data); - ResultCode RecreateApplicationArea(u32 access_id, std::span data); - ResultCode DeleteApplicationArea(); - ResultCode ApplicationAreaExist(bool& has_application_area); + Result OpenApplicationArea(u32 access_id); + Result GetApplicationAreaId(u32& application_area_id) const; + Result GetApplicationArea(std::vector& data) const; + Result SetApplicationArea(std::span data); + Result CreateApplicationArea(u32 access_id, std::span data); + Result RecreateApplicationArea(u32 access_id, std::span data); + Result DeleteApplicationArea(); + Result ApplicationAreaExist(bool& has_application_area); constexpr u32 GetApplicationAreaSize() const; DeviceState GetCurrentState() const; - ResultCode GetCommunicationStatus(CommunicationState& status) const; - ResultCode CheckConnectionState() const; + Result GetCommunicationStatus(CommunicationState& status) const; + Result CheckConnectionState() const; std::shared_ptr GetActivateEvent() const; std::shared_ptr GetDeactivateEvent() const; diff --git a/src/core/hle/service/nfc/nfc_results.h b/src/core/hle/service/nfc/nfc_results.h index da729ea68..7307499d3 100644 --- a/src/core/hle/service/nfc/nfc_results.h +++ b/src/core/hle/service/nfc/nfc_results.h @@ -43,29 +43,29 @@ enum { }; } // namespace ErrCodes -constexpr ResultCode ResultInvalidArgumentValue(ErrCodes::InvalidArgumentValue, ErrorModule::NFC, - ErrorSummary::InvalidArgument, ErrorLevel::Status); -constexpr ResultCode ResultInvalidArgument(ErrCodes::InvalidArgument, ErrorModule::NFC, - ErrorSummary::InvalidArgument, ErrorLevel::Status); -constexpr ResultCode ResultInvalidOperation(ErrCodes::InvalidOperation, ErrorModule::NFC, - ErrorSummary::InvalidState, ErrorLevel::Status); -constexpr ResultCode ResultNotSupported(ErrCodes::NotSupported, ErrorModule::NFC, +constexpr Result ResultInvalidArgumentValue(ErrCodes::InvalidArgumentValue, ErrorModule::NFC, + ErrorSummary::InvalidArgument, ErrorLevel::Status); +constexpr Result ResultInvalidArgument(ErrCodes::InvalidArgument, ErrorModule::NFC, + ErrorSummary::InvalidArgument, ErrorLevel::Status); +constexpr Result ResultInvalidOperation(ErrCodes::InvalidOperation, ErrorModule::NFC, ErrorSummary::InvalidState, ErrorLevel::Status); -constexpr ResultCode ResultNeedFormat(ErrCodes::NeedFormat, ErrorModule::NFC, +constexpr Result ResultNotSupported(ErrCodes::NotSupported, ErrorModule::NFC, + ErrorSummary::InvalidState, ErrorLevel::Status); +constexpr Result ResultNeedFormat(ErrCodes::NeedFormat, ErrorModule::NFC, + ErrorSummary::InvalidState, ErrorLevel::Status); +constexpr Result ResultOperationFailed(ErrCodes::OperationFailed, ErrorModule::NFC, + ErrorSummary::InvalidState, ErrorLevel::Status); +constexpr Result ResultNeedCreate(ErrCodes::NeedCreate, ErrorModule::NFC, + ErrorSummary::InvalidState, ErrorLevel::Status); +constexpr Result ResultNeedRegister(ErrCodes::NeedRegister, ErrorModule::NFC, + ErrorSummary::InvalidState, ErrorLevel::Status); +constexpr Result ResultAlreadyCreated(ErrCodes::AlreadyCreated, ErrorModule::NFC, ErrorSummary::InvalidState, ErrorLevel::Status); -constexpr ResultCode ResultOperationFailed(ErrCodes::OperationFailed, ErrorModule::NFC, - ErrorSummary::InvalidState, ErrorLevel::Status); -constexpr ResultCode ResultNeedCreate(ErrCodes::NeedCreate, ErrorModule::NFC, - ErrorSummary::InvalidState, ErrorLevel::Status); -constexpr ResultCode ResultNeedRegister(ErrCodes::NeedRegister, ErrorModule::NFC, +constexpr Result ResultAccessIdMisMatch(ErrCodes::AccessIdMisMatch, ErrorModule::NFC, ErrorSummary::InvalidState, ErrorLevel::Status); -constexpr ResultCode ResultAlreadyCreated(ErrCodes::AlreadyCreated, ErrorModule::NFC, - ErrorSummary::InvalidState, ErrorLevel::Status); -constexpr ResultCode ResultAccessIdMisMatch(ErrCodes::AccessIdMisMatch, ErrorModule::NFC, - ErrorSummary::InvalidState, ErrorLevel::Status); -constexpr ResultCode ResultSleep(ErrCodes::Sleep, ErrorModule::NFC, ErrorSummary::InvalidState, - ErrorLevel::Status); -constexpr ResultCode ResultWifiOff(ErrCodes::WifiOff, ErrorModule::NFC, ErrorSummary::InvalidState, - ErrorLevel::Status); +constexpr Result ResultSleep(ErrCodes::Sleep, ErrorModule::NFC, ErrorSummary::InvalidState, + ErrorLevel::Status); +constexpr Result ResultWifiOff(ErrCodes::WifiOff, ErrorModule::NFC, ErrorSummary::InvalidState, + ErrorLevel::Status); } // namespace Service::NFC diff --git a/src/core/hle/service/nim/nim_u.cpp b/src/core/hle/service/nim/nim_u.cpp index 1462c0b02..39081e337 100644 --- a/src/core/hle/service/nim/nim_u.cpp +++ b/src/core/hle/service/nim/nim_u.cpp @@ -312,8 +312,8 @@ void NIM_U::UnregisterTask(Kernel::HLERequestContext& ctx) { const u32 process_id = rp.PopPID(); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); - rb.Push(ResultCode(ErrorDescription::NotFound, ErrorModule::NIM, ErrorSummary::NotFound, - ErrorLevel::Status)); + rb.Push(Result(ErrorDescription::NotFound, ErrorModule::NIM, ErrorSummary::NotFound, + ErrorLevel::Status)); LOG_WARNING(Service_NIM, "(STUBBED) called title_id={:016X}, process_id={:08X}", title_id, process_id); @@ -339,8 +339,8 @@ void NIM_U::FindTaskInfo(Kernel::HLERequestContext& ctx) { std::vector buffer(0x120, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); - rb.Push(ResultCode(ErrorDescription::NotFound, ErrorModule::NIM, ErrorSummary::NotFound, - ErrorLevel::Status)); + rb.Push(Result(ErrorDescription::NotFound, ErrorModule::NIM, ErrorSummary::NotFound, + ErrorLevel::Status)); rb.PushStaticBuffer(std::move(buffer), 0); LOG_WARNING(Service_NIM, "(STUBBED) called title_id={:016X}", title_id); diff --git a/src/core/hle/service/nwm/nwm_uds.cpp b/src/core/hle/service/nwm/nwm_uds.cpp index 60a1e445e..19cf66bee 100644 --- a/src/core/hle/service/nwm/nwm_uds.cpp +++ b/src/core/hle/service/nwm/nwm_uds.cpp @@ -728,8 +728,8 @@ void NWM_UDS::GetNodeInformation(Kernel::HLERequestContext& ctx) { if (!initialized) { IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); - rb.Push(ResultCode(ErrorDescription::NotInitialized, ErrorModule::UDS, - ErrorSummary::StatusChanged, ErrorLevel::Status)); + rb.Push(Result(ErrorDescription::NotInitialized, ErrorModule::UDS, + ErrorSummary::StatusChanged, ErrorLevel::Status)); return; } @@ -741,8 +741,8 @@ void NWM_UDS::GetNodeInformation(Kernel::HLERequestContext& ctx) { }); if (itr == node_info.end()) { IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); - rb.Push(ResultCode(ErrorDescription::NotFound, ErrorModule::UDS, - ErrorSummary::WrongArgument, ErrorLevel::Status)); + rb.Push(Result(ErrorDescription::NotFound, ErrorModule::UDS, + ErrorSummary::WrongArgument, ErrorLevel::Status)); return; } @@ -765,8 +765,8 @@ void NWM_UDS::Bind(Kernel::HLERequestContext& ctx) { if (data_channel == 0 || bind_node_id == 0) { IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); - rb.Push(ResultCode(ErrorDescription::NotAuthorized, ErrorModule::UDS, - ErrorSummary::WrongArgument, ErrorLevel::Usage)); + rb.Push(Result(ErrorDescription::NotAuthorized, ErrorModule::UDS, + ErrorSummary::WrongArgument, ErrorLevel::Usage)); LOG_WARNING(Service_NWM, "data_channel = {}, bind_node_id = {}", data_channel, bind_node_id); return; @@ -775,8 +775,8 @@ void NWM_UDS::Bind(Kernel::HLERequestContext& ctx) { constexpr std::size_t MaxBindNodes = 16; if (channel_data.size() >= MaxBindNodes) { IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); - rb.Push(ResultCode(ErrorDescription::OutOfMemory, ErrorModule::UDS, - ErrorSummary::OutOfResource, ErrorLevel::Status)); + rb.Push(Result(ErrorDescription::OutOfMemory, ErrorModule::UDS, ErrorSummary::OutOfResource, + ErrorLevel::Status)); LOG_WARNING(Service_NWM, "max bind nodes"); return; } @@ -784,8 +784,8 @@ void NWM_UDS::Bind(Kernel::HLERequestContext& ctx) { constexpr u32 MinRecvBufferSize = 0x5F4; if (recv_buffer_size < MinRecvBufferSize) { IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); - rb.Push(ResultCode(ErrorDescription::TooLarge, ErrorModule::UDS, - ErrorSummary::WrongArgument, ErrorLevel::Usage)); + rb.Push(Result(ErrorDescription::TooLarge, ErrorModule::UDS, ErrorSummary::WrongArgument, + ErrorLevel::Usage)); LOG_WARNING(Service_NWM, "MinRecvBufferSize"); return; } @@ -810,8 +810,8 @@ void NWM_UDS::Unbind(Kernel::HLERequestContext& ctx) { u32 bind_node_id = rp.Pop(); if (bind_node_id == 0) { IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); - rb.Push(ResultCode(ErrorDescription::NotAuthorized, ErrorModule::UDS, - ErrorSummary::WrongArgument, ErrorLevel::Usage)); + rb.Push(Result(ErrorDescription::NotAuthorized, ErrorModule::UDS, + ErrorSummary::WrongArgument, ErrorLevel::Usage)); return; } @@ -837,8 +837,8 @@ void NWM_UDS::Unbind(Kernel::HLERequestContext& ctx) { rb.Push(0); } -ResultCode NWM_UDS::BeginHostingNetwork(std::span network_info_buffer, - std::vector passphrase) { +Result NWM_UDS::BeginHostingNetwork(std::span network_info_buffer, + std::vector passphrase) { // TODO(Subv): Store the passphrase and verify it when attempting a connection. { @@ -950,16 +950,16 @@ void NWM_UDS::EjectClient(Kernel::HLERequestContext& ctx) { // The host can not be kicked. if (network_node_id == 1) { - rb.Push(ResultCode(ErrorDescription::NotAuthorized, ErrorModule::UDS, - ErrorSummary::WrongArgument, ErrorLevel::Usage)); + rb.Push(Result(ErrorDescription::NotAuthorized, ErrorModule::UDS, + ErrorSummary::WrongArgument, ErrorLevel::Usage)); return; } std::scoped_lock lock(connection_status_mutex); if (connection_status.status != NetworkStatus::ConnectedAsHost) { // Only the host can kick people. - rb.Push(ResultCode(ErrorDescription::NotAuthorized, ErrorModule::UDS, - ErrorSummary::InvalidState, ErrorLevel::Usage)); + rb.Push(Result(ErrorDescription::NotAuthorized, ErrorModule::UDS, + ErrorSummary::InvalidState, ErrorLevel::Usage)); LOG_WARNING(Service_NWM, "called with status {}", connection_status.status); return; } @@ -1009,8 +1009,8 @@ void NWM_UDS::DestroyNetwork(Kernel::HLERequestContext& ctx) { std::scoped_lock lock(connection_status_mutex); if (connection_status.status != NetworkStatus::ConnectedAsHost) { IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); - rb.Push(ResultCode(ErrCodes::WrongStatus, ErrorModule::UDS, ErrorSummary::InvalidState, - ErrorLevel::Status)); + rb.Push(Result(ErrCodes::WrongStatus, ErrorModule::UDS, ErrorSummary::InvalidState, + ErrorLevel::Status)); LOG_WARNING(Service_NWM, "called with status {}", static_cast(connection_status.status)); return; @@ -1053,8 +1053,8 @@ void NWM_UDS::DisconnectNetwork(Kernel::HLERequestContext& ctx) { connection_status.network_node_id = tmp_node_id; node_map.clear(); LOG_DEBUG(Service_NWM, "called as a host"); - rb.Push(ResultCode(ErrCodes::WrongStatus, ErrorModule::UDS, ErrorSummary::InvalidState, - ErrorLevel::Status)); + rb.Push(Result(ErrCodes::WrongStatus, ErrorModule::UDS, ErrorSummary::InvalidState, + ErrorLevel::Status)); return; } u16_le tmp_node_id = connection_status.network_node_id; @@ -1101,23 +1101,23 @@ void NWM_UDS::SendTo(Kernel::HLERequestContext& ctx) { std::scoped_lock lock(connection_status_mutex); if (connection_status.status != NetworkStatus::ConnectedAsClient && connection_status.status != NetworkStatus::ConnectedAsHost) { - rb.Push(ResultCode(ErrorDescription::NotAuthorized, ErrorModule::UDS, - ErrorSummary::InvalidState, ErrorLevel::Status)); + rb.Push(Result(ErrorDescription::NotAuthorized, ErrorModule::UDS, + ErrorSummary::InvalidState, ErrorLevel::Status)); return; } // There should never be a dest_node_id of 0 if (dest_node_id == 0) { - rb.Push(ResultCode(ErrorDescription::NotFound, ErrorModule::UDS, - ErrorSummary::WrongArgument, ErrorLevel::Status)); + rb.Push(Result(ErrorDescription::NotFound, ErrorModule::UDS, ErrorSummary::WrongArgument, + ErrorLevel::Status)); LOG_ERROR(Service_NWM, "dest_node_id is 0"); return; } if (dest_node_id == connection_status.network_node_id) { LOG_ERROR(Service_NWM, "tried to send packet to itself"); - rb.Push(ResultCode(ErrorDescription::NotFound, ErrorModule::UDS, - ErrorSummary::WrongArgument, ErrorLevel::Status)); + rb.Push(Result(ErrorDescription::NotFound, ErrorModule::UDS, ErrorSummary::WrongArgument, + ErrorLevel::Status)); return; } @@ -1127,15 +1127,15 @@ void NWM_UDS::SendTo(Kernel::HLERequestContext& ctx) { auto dest_address = GetNodeMacAddress(dest_node_id, flags); if (!dest_address) { - rb.Push(ResultCode(ErrorDescription::NotFound, ErrorModule::UDS, - ErrorSummary::WrongArgument, ErrorLevel::Status)); + rb.Push(Result(ErrorDescription::NotFound, ErrorModule::UDS, ErrorSummary::WrongArgument, + ErrorLevel::Status)); return; } constexpr std::size_t MaxSize = 0x5C6; if (data_size > MaxSize) { - rb.Push(ResultCode(ErrorDescription::TooLarge, ErrorModule::UDS, - ErrorSummary::WrongArgument, ErrorLevel::Usage)); + rb.Push(Result(ErrorDescription::TooLarge, ErrorModule::UDS, ErrorSummary::WrongArgument, + ErrorLevel::Usage)); return; } @@ -1175,8 +1175,8 @@ void NWM_UDS::PullPacket(Kernel::HLERequestContext& ctx) { connection_status.status != NetworkStatus::ConnectedAsClient && connection_status.status != NetworkStatus::ConnectedAsSpectator) { IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); - rb.Push(ResultCode(ErrorDescription::NotAuthorized, ErrorModule::UDS, - ErrorSummary::InvalidState, ErrorLevel::Status)); + rb.Push(Result(ErrorDescription::NotAuthorized, ErrorModule::UDS, + ErrorSummary::InvalidState, ErrorLevel::Status)); return; } @@ -1187,8 +1187,8 @@ void NWM_UDS::PullPacket(Kernel::HLERequestContext& ctx) { if (channel == channel_data.end()) { IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); - rb.Push(ResultCode(ErrorDescription::NotAuthorized, ErrorModule::UDS, - ErrorSummary::WrongArgument, ErrorLevel::Usage)); + rb.Push(Result(ErrorDescription::NotAuthorized, ErrorModule::UDS, + ErrorSummary::WrongArgument, ErrorLevel::Usage)); return; } @@ -1209,8 +1209,8 @@ void NWM_UDS::PullPacket(Kernel::HLERequestContext& ctx) { if (data_size > max_out_buff_size) { IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); - rb.Push(ResultCode(ErrorDescription::TooLarge, ErrorModule::UDS, - ErrorSummary::WrongArgument, ErrorLevel::Usage)); + rb.Push(Result(ErrorDescription::TooLarge, ErrorModule::UDS, ErrorSummary::WrongArgument, + ErrorLevel::Usage)); return; } @@ -1331,8 +1331,8 @@ void NWM_UDS::SetApplicationData(Kernel::HLERequestContext& ctx) { IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); if (size > ApplicationDataSize) { - rb.Push(ResultCode(ErrorDescription::TooLarge, ErrorModule::UDS, - ErrorSummary::WrongArgument, ErrorLevel::Usage)); + rb.Push(Result(ErrorDescription::TooLarge, ErrorModule::UDS, ErrorSummary::WrongArgument, + ErrorLevel::Usage)); return; } diff --git a/src/core/hle/service/nwm/nwm_uds.h b/src/core/hle/service/nwm/nwm_uds.h index ed8bf0791..e3f2e588f 100644 --- a/src/core/hle/service/nwm/nwm_uds.h +++ b/src/core/hle/service/nwm/nwm_uds.h @@ -449,8 +449,7 @@ private: u32 sharedmem_size, const NodeInfo& node, u16 version, std::shared_ptr sharedmem); - ResultCode BeginHostingNetwork(std::span network_info_buffer, - std::vector passphrase); + Result BeginHostingNetwork(std::span network_info_buffer, std::vector passphrase); void ConnectToNetwork(Kernel::HLERequestContext& ctx, u16 command_id, std::span network_info_buffer, u8 connection_type, diff --git a/src/core/hle/service/ps/ps_ps.cpp b/src/core/hle/service/ps/ps_ps.cpp index 64f0a4355..11c3dc0ac 100644 --- a/src/core/hle/service/ps/ps_ps.cpp +++ b/src/core/hle/service/ps/ps_ps.cpp @@ -77,8 +77,8 @@ void PS_PS::EncryptDecryptAes(Kernel::HLERequestContext& ctx) { if (algorithm == AlgorithmType::CCM_Encrypt || algorithm == AlgorithmType::CCM_Decrypt) { // AES-CCM is not supported with this function IPC::RequestBuilder rb = rp.MakeBuilder(1, 4); - rb.Push(ResultCode(ErrorDescription::InvalidSection, ErrorModule::PS, - ErrorSummary::WrongArgument, ErrorLevel::Status)); + rb.Push(Result(ErrorDescription::InvalidSection, ErrorModule::PS, + ErrorSummary::WrongArgument, ErrorLevel::Status)); rb.PushMappedBuffer(source); rb.PushMappedBuffer(destination); return; diff --git a/src/core/hle/service/sm/sm.cpp b/src/core/hle/service/sm/sm.cpp index a60b4b07e..7ab9dffc5 100644 --- a/src/core/hle/service/sm/sm.cpp +++ b/src/core/hle/service/sm/sm.cpp @@ -12,7 +12,7 @@ namespace Service::SM { -static ResultCode ValidateServiceName(const std::string& name) { +static Result ValidateServiceName(const std::string& name) { R_UNLESS(name.size() > 0 && name.size() <= 8, ERR_INVALID_NAME_SIZE); R_UNLESS(name.find('\0') == std::string::npos, ERR_NAME_CONTAINS_NUL); return RESULT_SUCCESS; @@ -28,8 +28,8 @@ void ServiceManager::InstallInterfaces(Core::System& system) { system.ServiceManager().srv_interface = srv; } -ResultCode ServiceManager::RegisterService(std::shared_ptr& server_port, - std::string name, u32 max_sessions) { +Result ServiceManager::RegisterService(std::shared_ptr& server_port, + std::string name, u32 max_sessions) { R_TRY(ValidateServiceName(name)); R_UNLESS(registered_services.find(name) == registered_services.end(), ERR_ALREADY_REGISTERED); @@ -41,8 +41,8 @@ ResultCode ServiceManager::RegisterService(std::shared_ptr& return RESULT_SUCCESS; } -ResultCode ServiceManager::GetServicePort(std::shared_ptr& out_port, - const std::string& name) { +Result ServiceManager::GetServicePort(std::shared_ptr& out_port, + const std::string& name) { R_TRY(ValidateServiceName(name)); auto it = registered_services.find(name); @@ -52,8 +52,8 @@ ResultCode ServiceManager::GetServicePort(std::shared_ptr& o return RESULT_SUCCESS; } -ResultCode ServiceManager::ConnectToService(std::shared_ptr& session, - const std::string& name) { +Result ServiceManager::ConnectToService(std::shared_ptr& session, + const std::string& name) { std::shared_ptr client_port; R_TRY(GetServicePort(client_port, name)); return client_port->Connect(session); diff --git a/src/core/hle/service/sm/sm.h b/src/core/hle/service/sm/sm.h index 9ea32065f..6a5f774e2 100644 --- a/src/core/hle/service/sm/sm.h +++ b/src/core/hle/service/sm/sm.h @@ -31,19 +31,19 @@ namespace Service::SM { class SRV; -constexpr ResultCode ERR_SERVICE_NOT_REGISTERED(1, ErrorModule::SRV, ErrorSummary::WouldBlock, - ErrorLevel::Temporary); // 0xD0406401 -constexpr ResultCode ERR_MAX_CONNECTIONS_REACHED(2, ErrorModule::SRV, ErrorSummary::WouldBlock, - ErrorLevel::Temporary); // 0xD0406402 -constexpr ResultCode ERR_INVALID_NAME_SIZE(5, ErrorModule::SRV, ErrorSummary::WrongArgument, - ErrorLevel::Permanent); // 0xD9006405 -constexpr ResultCode ERR_ACCESS_DENIED(6, ErrorModule::SRV, ErrorSummary::InvalidArgument, - ErrorLevel::Permanent); // 0xD8E06406 -constexpr ResultCode ERR_NAME_CONTAINS_NUL(7, ErrorModule::SRV, ErrorSummary::WrongArgument, - ErrorLevel::Permanent); // 0xD9006407 -constexpr ResultCode ERR_ALREADY_REGISTERED(ErrorDescription::AlreadyExists, ErrorModule::OS, - ErrorSummary::WrongArgument, - ErrorLevel::Permanent); // 0xD9001BFC +constexpr Result ERR_SERVICE_NOT_REGISTERED(1, ErrorModule::SRV, ErrorSummary::WouldBlock, + ErrorLevel::Temporary); // 0xD0406401 +constexpr Result ERR_MAX_CONNECTIONS_REACHED(2, ErrorModule::SRV, ErrorSummary::WouldBlock, + ErrorLevel::Temporary); // 0xD0406402 +constexpr Result ERR_INVALID_NAME_SIZE(5, ErrorModule::SRV, ErrorSummary::WrongArgument, + ErrorLevel::Permanent); // 0xD9006405 +constexpr Result ERR_ACCESS_DENIED(6, ErrorModule::SRV, ErrorSummary::InvalidArgument, + ErrorLevel::Permanent); // 0xD8E06406 +constexpr Result ERR_NAME_CONTAINS_NUL(7, ErrorModule::SRV, ErrorSummary::WrongArgument, + ErrorLevel::Permanent); // 0xD9006407 +constexpr Result ERR_ALREADY_REGISTERED(ErrorDescription::AlreadyExists, ErrorModule::OS, + ErrorSummary::WrongArgument, + ErrorLevel::Permanent); // 0xD9001BFC class ServiceManager { public: @@ -51,12 +51,11 @@ public: explicit ServiceManager(Core::System& system); - ResultCode RegisterService(std::shared_ptr& out_port, std::string name, - u32 max_sessions); - ResultCode GetServicePort(std::shared_ptr& out_port, - const std::string& name); - ResultCode ConnectToService(std::shared_ptr& out_session, - const std::string& name); + Result RegisterService(std::shared_ptr& out_port, std::string name, + u32 max_sessions); + Result GetServicePort(std::shared_ptr& out_port, const std::string& name); + Result ConnectToService(std::shared_ptr& out_session, + const std::string& name); // For IPC Recorder std::string GetServiceNameByPortId(u32 port) const; diff --git a/src/core/hle/service/sm/srv.cpp b/src/core/hle/service/sm/srv.cpp index 61c4cd456..f4bc00639 100644 --- a/src/core/hle/service/sm/srv.cpp +++ b/src/core/hle/service/sm/srv.cpp @@ -45,7 +45,7 @@ constexpr int MAX_PENDING_NOTIFICATIONS = 16; * 1: ProcessId Header (must be 0x20) * Outputs: * 0: 0x00010040 - * 1: ResultCode + * 1: Result */ void SRV::RegisterClient(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp(ctx); @@ -69,7 +69,7 @@ void SRV::RegisterClient(Kernel::HLERequestContext& ctx) { * 0: 0x00020000 * Outputs: * 0: 0x00020042 - * 1: ResultCode + * 1: Result * 2: Translation descriptor: 0x20 * 3: Handle to semaphore signaled on process notification */ @@ -136,7 +136,7 @@ private: * 3: Name length * 4: Flags (bit0: if not set, return port-handle if session-handle unavailable) * Outputs: - * 1: ResultCode + * 1: Result * 3: Service handle */ void SRV::GetServiceHandle(Kernel::HLERequestContext& ctx) { @@ -201,7 +201,7 @@ void SRV::GetServiceHandle(Kernel::HLERequestContext& ctx) { * 1: Notification ID * Outputs: * 0: 0x00090040 - * 1: ResultCode + * 1: Result */ void SRV::Subscribe(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp(ctx); @@ -219,7 +219,7 @@ void SRV::Subscribe(Kernel::HLERequestContext& ctx) { * 1: Notification ID * Outputs: * 0: 0x000A0040 - * 1: ResultCode + * 1: Result */ void SRV::Unsubscribe(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp(ctx); @@ -238,7 +238,7 @@ void SRV::Unsubscribe(Kernel::HLERequestContext& ctx) { * 2: Flags (bit0: only fire if not fired, bit1: report errors) * Outputs: * 0: 0x000C0040 - * 1: ResultCode + * 1: Result */ void SRV::PublishToSubscriber(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp(ctx); diff --git a/src/core/hle/service/soc/soc_u.h b/src/core/hle/service/soc/soc_u.h index 0aebd723c..c70a831e8 100644 --- a/src/core/hle/service/soc/soc_u.h +++ b/src/core/hle/service/soc/soc_u.h @@ -61,14 +61,14 @@ public: std::optional GetDefaultInterfaceInfo(); private: - static constexpr ResultCode ERR_WRONG_PROCESS = - ResultCode(4, ErrorModule::SOC, ErrorSummary::InvalidState, ErrorLevel::Status); - static constexpr ResultCode ERR_NOT_INITIALIZED = - ResultCode(6, ErrorModule::SOC, ErrorSummary::InvalidArgument, ErrorLevel::Permanent); - static constexpr ResultCode ERR_INVALID_SOCKET_DESCRIPTOR = - ResultCode(7, ErrorModule::SOC, ErrorSummary::InvalidArgument, ErrorLevel::Permanent); - static constexpr ResultCode ERR_ALREADY_INITIALIZED = - ResultCode(11, ErrorModule::SOC, ErrorSummary::InvalidState, ErrorLevel::Status); + static constexpr Result ERR_WRONG_PROCESS = + Result(4, ErrorModule::SOC, ErrorSummary::InvalidState, ErrorLevel::Status); + static constexpr Result ERR_NOT_INITIALIZED = + Result(6, ErrorModule::SOC, ErrorSummary::InvalidArgument, ErrorLevel::Permanent); + static constexpr Result ERR_INVALID_SOCKET_DESCRIPTOR = + Result(7, ErrorModule::SOC, ErrorSummary::InvalidArgument, ErrorLevel::Permanent); + static constexpr Result ERR_ALREADY_INITIALIZED = + Result(11, ErrorModule::SOC, ErrorSummary::InvalidState, ErrorLevel::Status); static constexpr u32 SOC_ERR_INAVLID_ENUM_VALUE = 0xFFFF8025;