kernel: Update to use atmosphere macros and correct Result (#7242)

* kernel: Switch to atmosphere style macros

* code: Rename ResultCode to Result

* code: Result constants are lower case

* Address review comments

* core: Remove CASCADE_CODE

* R_TRY replaces completely

* core: Run clang format
This commit is contained in:
GPUCode 2023-12-31 19:01:40 +02:00 committed by GitHub
parent 811303ea54
commit 5a7f615da1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
132 changed files with 2807 additions and 2995 deletions

View file

@ -49,7 +49,7 @@ QString IPCRecorderWidget::GetStatusStr(const IPCDebugger::RequestRecord& record
case IPCDebugger::RequestStatus::Handling: case IPCDebugger::RequestStatus::Handling:
return tr("Handling"); return tr("Handling");
case IPCDebugger::RequestStatus::Handled: case IPCDebugger::RequestStatus::Handled:
if (record.translated_reply_cmdbuf[1] == RESULT_SUCCESS.raw) { if (record.translated_reply_cmdbuf[1] == ResultSuccess.raw) {
return tr("Success"); return tr("Success");
} }
return tr("Error"); return tr("Error");
@ -88,7 +88,7 @@ void IPCRecorderWidget::OnEntryUpdated(IPCDebugger::RequestRecord record) {
if (record.status == IPCDebugger::RequestStatus::HLEUnimplemented || if (record.status == IPCDebugger::RequestStatus::HLEUnimplemented ||
(record.status == IPCDebugger::RequestStatus::Handled && (record.status == IPCDebugger::RequestStatus::Handled &&
record.translated_reply_cmdbuf[1] != RESULT_SUCCESS.raw)) { // Unimplemented / Error record.translated_reply_cmdbuf[1] != ResultSuccess.raw)) { // Unimplemented / Error
auto item = ui->main->invisibleRootItem()->child(row_id); auto item = ui->main->invisibleRootItem()->child(row_id);
for (int column = 0; column < item->columnCount(); ++column) { for (int column = 0; column < item->columnCount(); ++column) {

View file

@ -127,7 +127,7 @@ public:
* @param path Path relative to the archive * @param path Path relative to the archive
* @return Result of the operation * @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 * Rename a File specified by its path
@ -135,21 +135,21 @@ public:
* @param dest_path Destination path relative to the archive * @param dest_path Destination path relative to the archive
* @return Result of the operation * @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 * Delete a directory specified by its path
* @param path Path relative to the archive * @param path Path relative to the archive
* @return Result of the operation * @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 * Delete a directory specified by its path and anything under it
* @param path Path relative to the archive * @param path Path relative to the archive
* @return Result of the operation * @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 * Create a file specified by its path
@ -157,14 +157,14 @@ public:
* @param size The size of the new file, filled with zeroes * @param size The size of the new file, filled with zeroes
* @return Result of the operation * @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 * Create a directory specified by its path
* @param path Path relative to the archive * @param path Path relative to the archive
* @return Result of the operation * @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 * Rename a Directory specified by its path
@ -172,7 +172,7 @@ public:
* @param dest_path Destination path relative to the archive * @param dest_path Destination path relative to the archive
* @return Result of the operation * @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 * Open a directory specified by its path
@ -229,10 +229,10 @@ public:
* @param path Path to the archive * @param path Path to the archive
* @param format_info Format information for the new archive * @param format_info Format information for the new archive
* @param program_id the program ID of the client that requests the operation * @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, virtual Result Format(const Path& path, const FileSys::ArchiveFormatInfo& format_info,
u64 program_id) = 0; u64 program_id) = 0;
/** /**
* Retrieves the format info about the archive with the specified path * Retrieves the format info about the archive with the specified path

View file

@ -40,7 +40,7 @@ public:
ResultVal<std::size_t> Write(u64 offset, std::size_t length, bool flush, ResultVal<std::size_t> Write(u64 offset, std::size_t length, bool flush,
const u8* buffer) override { const u8* buffer) override {
if (offset > size) { if (offset > size) {
return ERR_WRITE_BEYOND_END; return ResultWriteBeyondEnd;
} else if (offset == size) { } else if (offset == size) {
return 0ULL; return 0ULL;
} }
@ -108,17 +108,17 @@ public:
if (!path_parser.IsValid()) { if (!path_parser.IsValid()) {
LOG_ERROR(Service_FS, "Invalid path {}", path.DebugStr()); LOG_ERROR(Service_FS, "Invalid path {}", path.DebugStr());
return ERROR_INVALID_PATH; return ResultInvalidPath;
} }
if (mode.hex == 0) { if (mode.hex == 0) {
LOG_ERROR(Service_FS, "Empty open mode"); LOG_ERROR(Service_FS, "Empty open mode");
return ERROR_UNSUPPORTED_OPEN_FLAGS; return ResultUnsupportedOpenFlags;
} }
if (mode.create_flag) { if (mode.create_flag) {
LOG_ERROR(Service_FS, "Create flag is not supported"); LOG_ERROR(Service_FS, "Create flag is not supported");
return ERROR_UNSUPPORTED_OPEN_FLAGS; return ResultUnsupportedOpenFlags;
} }
const auto full_path = path_parser.BuildHostPath(mount_point); const auto full_path = path_parser.BuildHostPath(mount_point);
@ -126,17 +126,17 @@ public:
switch (path_parser.GetHostStatus(mount_point)) { switch (path_parser.GetHostStatus(mount_point)) {
case PathParser::InvalidMountPoint: case PathParser::InvalidMountPoint:
LOG_CRITICAL(Service_FS, "(unreachable) Invalid mount point {}", mount_point); LOG_CRITICAL(Service_FS, "(unreachable) Invalid mount point {}", mount_point);
return ERROR_FILE_NOT_FOUND; return ResultFileNotFound;
case PathParser::PathNotFound: case PathParser::PathNotFound:
LOG_ERROR(Service_FS, "Path not found {}", full_path); LOG_ERROR(Service_FS, "Path not found {}", full_path);
return ERROR_PATH_NOT_FOUND; return ResultPathNotFound;
case PathParser::FileInPath: case PathParser::FileInPath:
case PathParser::DirectoryFound: case PathParser::DirectoryFound:
LOG_ERROR(Service_FS, "Unexpected file or directory in {}", full_path); LOG_ERROR(Service_FS, "Unexpected file or directory in {}", full_path);
return ERROR_UNEXPECTED_FILE_OR_DIRECTORY; return ResultUnexpectedFileOrDirectory;
case PathParser::NotFound: case PathParser::NotFound:
LOG_ERROR(Service_FS, "{} not found", full_path); LOG_ERROR(Service_FS, "{} not found", full_path);
return ERROR_FILE_NOT_FOUND; return ResultFileNotFound;
case PathParser::FileFound: case PathParser::FileFound:
break; // Expected 'success' case break; // Expected 'success' case
} }
@ -144,7 +144,7 @@ public:
FileUtil::IOFile file(full_path, "r+b"); FileUtil::IOFile file(full_path, "r+b");
if (!file.IsOpen()) { if (!file.IsOpen()) {
LOG_CRITICAL(Service_FS, "(unreachable) Unknown error opening {}", full_path); LOG_CRITICAL(Service_FS, "(unreachable) Unknown error opening {}", full_path);
return ERROR_FILE_NOT_FOUND; return ResultFileNotFound;
} }
Mode rwmode; Mode rwmode;
@ -155,10 +155,10 @@ public:
std::move(delay_generator)); 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) { if (size == 0) {
LOG_ERROR(Service_FS, "Zero-size file is not supported"); LOG_ERROR(Service_FS, "Zero-size file is not supported");
return ERROR_UNSUPPORTED_OPEN_FLAGS; return ResultUnsupportedOpenFlags;
} }
return SaveDataArchive::CreateFile(path, size); return SaveDataArchive::CreateFile(path, size);
} }
@ -250,18 +250,18 @@ ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_ExtSaveData::Open(cons
// TODO(Subv): Verify the archive behavior of SharedExtSaveData compared to ExtSaveData. // TODO(Subv): Verify the archive behavior of SharedExtSaveData compared to ExtSaveData.
// ExtSaveData seems to return FS_NotFound (120) when the archive doesn't exist. // ExtSaveData seems to return FS_NotFound (120) when the archive doesn't exist.
if (type != ExtSaveDataType::Shared) { if (type != ExtSaveDataType::Shared) {
return ERR_NOT_FOUND_INVALID_STATE; return ResultNotFoundInvalidState;
} else { } else {
return ERR_NOT_FORMATTED; return ResultNotFormatted;
} }
} }
std::unique_ptr<DelayGenerator> delay_generator = std::make_unique<ExtSaveDataDelayGenerator>(); std::unique_ptr<DelayGenerator> delay_generator = std::make_unique<ExtSaveDataDelayGenerator>();
return std::make_unique<ExtSaveDataArchive>(fullpath, std::move(delay_generator)); return std::make_unique<ExtSaveDataArchive>(fullpath, std::move(delay_generator));
} }
ResultCode ArchiveFactory_ExtSaveData::Format(const Path& path, Result ArchiveFactory_ExtSaveData::Format(const Path& path,
const FileSys::ArchiveFormatInfo& format_info, const FileSys::ArchiveFormatInfo& format_info,
u64 program_id) { u64 program_id) {
auto corrected_path = GetCorrectedPath(path); auto corrected_path = GetCorrectedPath(path);
// These folders are always created with the ExtSaveData // These folders are always created with the ExtSaveData
@ -276,11 +276,11 @@ ResultCode ArchiveFactory_ExtSaveData::Format(const Path& path,
if (!file.IsOpen()) { if (!file.IsOpen()) {
// TODO(Subv): Find the correct error code // TODO(Subv): Find the correct error code
return RESULT_UNKNOWN; return ResultUnknown;
} }
file.WriteBytes(&format_info, sizeof(format_info)); file.WriteBytes(&format_info, sizeof(format_info));
return RESULT_SUCCESS; return ResultSuccess;
} }
ResultVal<ArchiveFormatInfo> ArchiveFactory_ExtSaveData::GetFormatInfo(const Path& path, ResultVal<ArchiveFormatInfo> ArchiveFactory_ExtSaveData::GetFormatInfo(const Path& path,
@ -291,7 +291,7 @@ ResultVal<ArchiveFormatInfo> ArchiveFactory_ExtSaveData::GetFormatInfo(const Pat
if (!file.IsOpen()) { if (!file.IsOpen()) {
LOG_ERROR(Service_FS, "Could not open metadata information for archive"); LOG_ERROR(Service_FS, "Could not open metadata information for archive");
// TODO(Subv): Verify error code // TODO(Subv): Verify error code
return ERR_NOT_FORMATTED; return ResultNotFormatted;
} }
ArchiveFormatInfo info = {}; ArchiveFormatInfo info = {};

View file

@ -31,8 +31,8 @@ public:
} }
ResultVal<std::unique_ptr<ArchiveBackend>> Open(const Path& path, u64 program_id) override; ResultVal<std::unique_ptr<ArchiveBackend>> Open(const Path& path, u64 program_id) override;
ResultCode Format(const Path& path, const FileSys::ArchiveFormatInfo& format_info, Result Format(const Path& path, const FileSys::ArchiveFormatInfo& format_info,
u64 program_id) override; u64 program_id) override;
ResultVal<ArchiveFormatInfo> GetFormatInfo(const Path& path, u64 program_id) const override; ResultVal<ArchiveFormatInfo> GetFormatInfo(const Path& path, u64 program_id) const override;
const std::string& GetMountPoint() const { const std::string& GetMountPoint() const {

View file

@ -73,13 +73,13 @@ ResultVal<std::unique_ptr<FileBackend>> NCCHArchive::OpenFile(const Path& path,
const Mode& mode) const { const Mode& mode) const {
if (path.GetType() != LowPathType::Binary) { if (path.GetType() != LowPathType::Binary) {
LOG_ERROR(Service_FS, "Path need to be Binary"); LOG_ERROR(Service_FS, "Path need to be Binary");
return ERROR_INVALID_PATH; return ResultInvalidPath;
} }
std::vector<u8> binary = path.AsBinary(); std::vector<u8> binary = path.AsBinary();
if (binary.size() != sizeof(NCCHFilePath)) { if (binary.size() != sizeof(NCCHFilePath)) {
LOG_ERROR(Service_FS, "Wrong path size {}", binary.size()); LOG_ERROR(Service_FS, "Wrong path size {}", binary.size());
return ERROR_INVALID_PATH; return ResultInvalidPath;
} }
NCCHFilePath openfile_path; NCCHFilePath openfile_path;
@ -174,63 +174,63 @@ ResultVal<std::unique_ptr<FileBackend>> NCCHArchive::OpenFile(const Path& path,
return std::make_unique<IVFCFileInMemory>(std::move(archive_data), romfs_offset, return std::make_unique<IVFCFileInMemory>(std::move(archive_data), romfs_offset,
romfs_size, std::move(delay_generator)); romfs_size, std::move(delay_generator));
} }
return ERROR_NOT_FOUND; return ResultNotFound;
} }
return file; 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()); LOG_CRITICAL(Service_FS, "Attempted to delete a file from an NCCH archive ({}).", GetName());
// TODO(Subv): Verify error code // TODO(Subv): Verify error code
return ResultCode(ErrorDescription::NoData, ErrorModule::FS, ErrorSummary::Canceled, return Result(ErrorDescription::NoData, ErrorModule::FS, ErrorSummary::Canceled,
ErrorLevel::Status); 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()); LOG_CRITICAL(Service_FS, "Attempted to rename a file within an NCCH archive ({}).", GetName());
// TODO(wwylele): Use correct error code // TODO(wwylele): Use correct error code
return RESULT_UNKNOWN; return ResultUnknown;
} }
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 ({}).", LOG_CRITICAL(Service_FS, "Attempted to delete a directory from an NCCH archive ({}).",
GetName()); GetName());
// TODO(wwylele): Use correct error code // TODO(wwylele): Use correct error code
return RESULT_UNKNOWN; return ResultUnknown;
} }
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 ({}).", LOG_CRITICAL(Service_FS, "Attempted to delete a directory from an NCCH archive ({}).",
GetName()); GetName());
// TODO(wwylele): Use correct error code // TODO(wwylele): Use correct error code
return RESULT_UNKNOWN; return ResultUnknown;
} }
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()); LOG_CRITICAL(Service_FS, "Attempted to create a file in an NCCH archive ({}).", GetName());
// TODO: Verify error code // TODO: Verify error code
return ResultCode(ErrorDescription::NotAuthorized, ErrorModule::FS, ErrorSummary::NotSupported, return Result(ErrorDescription::NotAuthorized, ErrorModule::FS, ErrorSummary::NotSupported,
ErrorLevel::Permanent); 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()); LOG_CRITICAL(Service_FS, "Attempted to create a directory in an NCCH archive ({}).", GetName());
// TODO(wwylele): Use correct error code // TODO(wwylele): Use correct error code
return RESULT_UNKNOWN; return ResultUnknown;
} }
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()); LOG_CRITICAL(Service_FS, "Attempted to rename a file within an NCCH archive ({}).", GetName());
// TODO(wwylele): Use correct error code // TODO(wwylele): Use correct error code
return RESULT_UNKNOWN; return ResultUnknown;
} }
ResultVal<std::unique_ptr<DirectoryBackend>> NCCHArchive::OpenDirectory(const Path& path) const { ResultVal<std::unique_ptr<DirectoryBackend>> NCCHArchive::OpenDirectory(const Path& path) const {
LOG_CRITICAL(Service_FS, "Attempted to open a directory within an NCCH archive ({}).", LOG_CRITICAL(Service_FS, "Attempted to open a directory within an NCCH archive ({}).",
GetName().c_str()); GetName().c_str());
// TODO(shinyquagsire23): Use correct error code // TODO(shinyquagsire23): Use correct error code
return RESULT_UNKNOWN; return ResultUnknown;
} }
u64 NCCHArchive::GetFreeBytes() const { u64 NCCHArchive::GetFreeBytes() const {
@ -276,13 +276,13 @@ ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_NCCH::Open(const Path&
u64 program_id) { u64 program_id) {
if (path.GetType() != LowPathType::Binary) { if (path.GetType() != LowPathType::Binary) {
LOG_ERROR(Service_FS, "Path need to be Binary"); LOG_ERROR(Service_FS, "Path need to be Binary");
return ERROR_INVALID_PATH; return ResultInvalidPath;
} }
std::vector<u8> binary = path.AsBinary(); std::vector<u8> binary = path.AsBinary();
if (binary.size() != sizeof(NCCHArchivePath)) { if (binary.size() != sizeof(NCCHArchivePath)) {
LOG_ERROR(Service_FS, "Wrong path size {}", binary.size()); LOG_ERROR(Service_FS, "Wrong path size {}", binary.size());
return ERROR_INVALID_PATH; return ResultInvalidPath;
} }
NCCHArchivePath open_path; NCCHArchivePath open_path;
@ -292,20 +292,19 @@ ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_NCCH::Open(const Path&
open_path.tid, static_cast<Service::FS::MediaType>(open_path.media_type & 0xFF)); open_path.tid, static_cast<Service::FS::MediaType>(open_path.media_type & 0xFF));
} }
ResultCode ArchiveFactory_NCCH::Format(const Path& path, Result ArchiveFactory_NCCH::Format(const Path& path, const FileSys::ArchiveFormatInfo& format_info,
const FileSys::ArchiveFormatInfo& format_info, u64 program_id) {
u64 program_id) {
LOG_ERROR(Service_FS, "Attempted to format a NCCH archive."); LOG_ERROR(Service_FS, "Attempted to format a NCCH archive.");
// TODO: Verify error code // TODO: Verify error code
return ResultCode(ErrorDescription::NotAuthorized, ErrorModule::FS, ErrorSummary::NotSupported, return Result(ErrorDescription::NotAuthorized, ErrorModule::FS, ErrorSummary::NotSupported,
ErrorLevel::Permanent); ErrorLevel::Permanent);
} }
ResultVal<ArchiveFormatInfo> ArchiveFactory_NCCH::GetFormatInfo(const Path& path, ResultVal<ArchiveFormatInfo> ArchiveFactory_NCCH::GetFormatInfo(const Path& path,
u64 program_id) const { u64 program_id) const {
// TODO(Subv): Implement // TODO(Subv): Implement
LOG_ERROR(Service_FS, "Unimplemented GetFormatInfo archive {}", GetName()); LOG_ERROR(Service_FS, "Unimplemented GetFormatInfo archive {}", GetName());
return RESULT_UNKNOWN; return ResultUnknown;
} }
} // namespace FileSys } // namespace FileSys

View file

@ -50,13 +50,13 @@ public:
ResultVal<std::unique_ptr<FileBackend>> OpenFile(const Path& path, ResultVal<std::unique_ptr<FileBackend>> OpenFile(const Path& path,
const Mode& mode) const override; const Mode& mode) const override;
ResultCode DeleteFile(const Path& path) const override; Result DeleteFile(const Path& path) const override;
ResultCode RenameFile(const Path& src_path, const Path& dest_path) const override; Result RenameFile(const Path& src_path, const Path& dest_path) const override;
ResultCode DeleteDirectory(const Path& path) const override; Result DeleteDirectory(const Path& path) const override;
ResultCode DeleteDirectoryRecursively(const Path& path) const override; Result DeleteDirectoryRecursively(const Path& path) const override;
ResultCode CreateFile(const Path& path, u64 size) const override; Result CreateFile(const Path& path, u64 size) const override;
ResultCode CreateDirectory(const Path& path) const override; Result CreateDirectory(const Path& path) const override;
ResultCode RenameDirectory(const Path& src_path, const Path& dest_path) const override; Result RenameDirectory(const Path& src_path, const Path& dest_path) const override;
ResultVal<std::unique_ptr<DirectoryBackend>> OpenDirectory(const Path& path) const override; ResultVal<std::unique_ptr<DirectoryBackend>> OpenDirectory(const Path& path) const override;
u64 GetFreeBytes() const override; u64 GetFreeBytes() const override;
@ -114,8 +114,8 @@ public:
} }
ResultVal<std::unique_ptr<ArchiveBackend>> Open(const Path& path, u64 program_id) override; ResultVal<std::unique_ptr<ArchiveBackend>> Open(const Path& path, u64 program_id) override;
ResultCode Format(const Path& path, const FileSys::ArchiveFormatInfo& format_info, Result Format(const Path& path, const FileSys::ArchiveFormatInfo& format_info,
u64 program_id) override; u64 program_id) override;
ResultVal<ArchiveFormatInfo> GetFormatInfo(const Path& path, u64 program_id) const override; ResultVal<ArchiveFormatInfo> GetFormatInfo(const Path& path, u64 program_id) const override;
private: private:

View file

@ -25,14 +25,14 @@ template <typename T>
ResultVal<std::tuple<MediaType, u64>> ParsePath(const Path& path, T program_id_reader) { ResultVal<std::tuple<MediaType, u64>> ParsePath(const Path& path, T program_id_reader) {
if (path.GetType() != LowPathType::Binary) { if (path.GetType() != LowPathType::Binary) {
LOG_ERROR(Service_FS, "Wrong path type {}", path.GetType()); LOG_ERROR(Service_FS, "Wrong path type {}", path.GetType());
return ERROR_INVALID_PATH; return ResultInvalidPath;
} }
std::vector<u8> vec_data = path.AsBinary(); std::vector<u8> vec_data = path.AsBinary();
if (vec_data.size() != 12) { if (vec_data.size() != 12) {
LOG_ERROR(Service_FS, "Wrong path length {}", vec_data.size()); LOG_ERROR(Service_FS, "Wrong path length {}", vec_data.size());
return ERROR_INVALID_PATH; return ResultInvalidPath;
} }
const u32* data = reinterpret_cast<const u32*>(vec_data.data()); const u32* data = reinterpret_cast<const u32*>(vec_data.data());
@ -42,7 +42,7 @@ ResultVal<std::tuple<MediaType, u64>> ParsePath(const Path& path, T program_id_r
LOG_ERROR(Service_FS, "Unsupported media type {}", media_type); LOG_ERROR(Service_FS, "Unsupported media type {}", media_type);
// Note: this is strange, but the error code was verified with a real 3DS // Note: this is strange, but the error code was verified with a real 3DS
return ERROR_UNSUPPORTED_OPEN_FLAGS; return ResultUnsupportedOpenFlags;
} }
return std::make_tuple(media_type, program_id_reader(data)); return std::make_tuple(media_type, program_id_reader(data));
@ -72,16 +72,17 @@ ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_OtherSaveDataPermitted
if (media_type == MediaType::GameCard) { if (media_type == MediaType::GameCard) {
LOG_WARNING(Service_FS, "(stubbed) Unimplemented media type GameCard"); LOG_WARNING(Service_FS, "(stubbed) Unimplemented media type GameCard");
return ERROR_GAMECARD_NOT_INSERTED; return ResultGamecardNotInserted;
} }
return sd_savedata_source->Open(program_id); return sd_savedata_source->Open(program_id);
} }
ResultCode ArchiveFactory_OtherSaveDataPermitted::Format( Result ArchiveFactory_OtherSaveDataPermitted::Format(const Path& path,
const Path& path, const FileSys::ArchiveFormatInfo& format_info, u64 program_id) { const FileSys::ArchiveFormatInfo& format_info,
u64 program_id) {
LOG_ERROR(Service_FS, "Attempted to format a OtherSaveDataPermitted archive."); LOG_ERROR(Service_FS, "Attempted to format a OtherSaveDataPermitted archive.");
return ERROR_INVALID_PATH; return ResultInvalidPath;
} }
ResultVal<ArchiveFormatInfo> ArchiveFactory_OtherSaveDataPermitted::GetFormatInfo( ResultVal<ArchiveFormatInfo> ArchiveFactory_OtherSaveDataPermitted::GetFormatInfo(
@ -92,7 +93,7 @@ ResultVal<ArchiveFormatInfo> ArchiveFactory_OtherSaveDataPermitted::GetFormatInf
if (media_type == MediaType::GameCard) { if (media_type == MediaType::GameCard) {
LOG_WARNING(Service_FS, "(stubbed) Unimplemented media type GameCard"); LOG_WARNING(Service_FS, "(stubbed) Unimplemented media type GameCard");
return ERROR_GAMECARD_NOT_INSERTED; return ResultGamecardNotInserted;
} }
return sd_savedata_source->GetFormatInfo(program_id); return sd_savedata_source->GetFormatInfo(program_id);
@ -110,21 +111,22 @@ ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_OtherSaveDataGeneral::
if (media_type == MediaType::GameCard) { if (media_type == MediaType::GameCard) {
LOG_WARNING(Service_FS, "(stubbed) Unimplemented media type GameCard"); LOG_WARNING(Service_FS, "(stubbed) Unimplemented media type GameCard");
return ERROR_GAMECARD_NOT_INSERTED; return ResultGamecardNotInserted;
} }
return sd_savedata_source->Open(program_id); return sd_savedata_source->Open(program_id);
} }
ResultCode ArchiveFactory_OtherSaveDataGeneral::Format( Result ArchiveFactory_OtherSaveDataGeneral::Format(const Path& path,
const Path& path, const FileSys::ArchiveFormatInfo& format_info, u64 /*client_program_id*/) { const FileSys::ArchiveFormatInfo& format_info,
u64 /*client_program_id*/) {
MediaType media_type; MediaType media_type;
u64 program_id; u64 program_id;
CASCADE_RESULT(std::tie(media_type, program_id), ParsePathGeneral(path)); CASCADE_RESULT(std::tie(media_type, program_id), ParsePathGeneral(path));
if (media_type == MediaType::GameCard) { if (media_type == MediaType::GameCard) {
LOG_WARNING(Service_FS, "(stubbed) Unimplemented media type GameCard"); LOG_WARNING(Service_FS, "(stubbed) Unimplemented media type GameCard");
return ERROR_GAMECARD_NOT_INSERTED; return ResultGamecardNotInserted;
} }
return sd_savedata_source->Format(program_id, format_info); return sd_savedata_source->Format(program_id, format_info);
@ -138,7 +140,7 @@ ResultVal<ArchiveFormatInfo> ArchiveFactory_OtherSaveDataGeneral::GetFormatInfo(
if (media_type == MediaType::GameCard) { if (media_type == MediaType::GameCard) {
LOG_WARNING(Service_FS, "(stubbed) Unimplemented media type GameCard"); LOG_WARNING(Service_FS, "(stubbed) Unimplemented media type GameCard");
return ERROR_GAMECARD_NOT_INSERTED; return ResultGamecardNotInserted;
} }
return sd_savedata_source->GetFormatInfo(program_id); return sd_savedata_source->GetFormatInfo(program_id);

View file

@ -22,8 +22,8 @@ public:
} }
ResultVal<std::unique_ptr<ArchiveBackend>> Open(const Path& path, u64 program_id) override; ResultVal<std::unique_ptr<ArchiveBackend>> Open(const Path& path, u64 program_id) override;
ResultCode Format(const Path& path, const FileSys::ArchiveFormatInfo& format_info, Result Format(const Path& path, const FileSys::ArchiveFormatInfo& format_info,
u64 program_id) override; u64 program_id) override;
ResultVal<ArchiveFormatInfo> GetFormatInfo(const Path& path, u64 program_id) const override; ResultVal<ArchiveFormatInfo> GetFormatInfo(const Path& path, u64 program_id) const override;
private: private:
@ -49,8 +49,8 @@ public:
} }
ResultVal<std::unique_ptr<ArchiveBackend>> Open(const Path& path, u64 program_id) override; ResultVal<std::unique_ptr<ArchiveBackend>> Open(const Path& path, u64 program_id) override;
ResultCode Format(const Path& path, const FileSys::ArchiveFormatInfo& format_info, Result Format(const Path& path, const FileSys::ArchiveFormatInfo& format_info,
u64 program_id) override; u64 program_id) override;
ResultVal<ArchiveFormatInfo> GetFormatInfo(const Path& path, u64 program_id) const override; ResultVal<ArchiveFormatInfo> GetFormatInfo(const Path& path, u64 program_id) const override;
private: private:

View file

@ -21,9 +21,9 @@ ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_SaveData::Open(const P
return sd_savedata_source->Open(program_id); return sd_savedata_source->Open(program_id);
} }
ResultCode ArchiveFactory_SaveData::Format(const Path& path, Result ArchiveFactory_SaveData::Format(const Path& path,
const FileSys::ArchiveFormatInfo& format_info, const FileSys::ArchiveFormatInfo& format_info,
u64 program_id) { u64 program_id) {
return sd_savedata_source->Format(program_id, format_info); return sd_savedata_source->Format(program_id, format_info);
} }

View file

@ -20,8 +20,8 @@ public:
} }
ResultVal<std::unique_ptr<ArchiveBackend>> Open(const Path& path, u64 program_id) override; ResultVal<std::unique_ptr<ArchiveBackend>> Open(const Path& path, u64 program_id) override;
ResultCode Format(const Path& path, const FileSys::ArchiveFormatInfo& format_info, Result Format(const Path& path, const FileSys::ArchiveFormatInfo& format_info,
u64 program_id) override; u64 program_id) override;
ResultVal<ArchiveFormatInfo> GetFormatInfo(const Path& path, u64 program_id) const override; ResultVal<ArchiveFormatInfo> GetFormatInfo(const Path& path, u64 program_id) const override;

View file

@ -62,17 +62,17 @@ ResultVal<std::unique_ptr<FileBackend>> SDMCArchive::OpenFileBase(const Path& pa
if (!path_parser.IsValid()) { if (!path_parser.IsValid()) {
LOG_ERROR(Service_FS, "Invalid path {}", path.DebugStr()); LOG_ERROR(Service_FS, "Invalid path {}", path.DebugStr());
return ERROR_INVALID_PATH; return ResultInvalidPath;
} }
if (mode.hex == 0) { if (mode.hex == 0) {
LOG_ERROR(Service_FS, "Empty open mode"); LOG_ERROR(Service_FS, "Empty open mode");
return ERROR_INVALID_OPEN_FLAGS; return ResultInvalidOpenFlags;
} }
if (mode.create_flag && !mode.write_flag) { if (mode.create_flag && !mode.write_flag) {
LOG_ERROR(Service_FS, "Create flag set but write flag not set"); LOG_ERROR(Service_FS, "Create flag set but write flag not set");
return ERROR_INVALID_OPEN_FLAGS; return ResultInvalidOpenFlags;
} }
const auto full_path = path_parser.BuildHostPath(mount_point); const auto full_path = path_parser.BuildHostPath(mount_point);
@ -80,19 +80,19 @@ ResultVal<std::unique_ptr<FileBackend>> SDMCArchive::OpenFileBase(const Path& pa
switch (path_parser.GetHostStatus(mount_point)) { switch (path_parser.GetHostStatus(mount_point)) {
case PathParser::InvalidMountPoint: case PathParser::InvalidMountPoint:
LOG_CRITICAL(Service_FS, "(unreachable) Invalid mount point {}", mount_point); LOG_CRITICAL(Service_FS, "(unreachable) Invalid mount point {}", mount_point);
return ERROR_NOT_FOUND; return ResultNotFound;
case PathParser::PathNotFound: case PathParser::PathNotFound:
case PathParser::FileInPath: case PathParser::FileInPath:
LOG_ERROR(Service_FS, "Path not found {}", full_path); LOG_ERROR(Service_FS, "Path not found {}", full_path);
return ERROR_NOT_FOUND; return ResultNotFound;
case PathParser::DirectoryFound: case PathParser::DirectoryFound:
LOG_ERROR(Service_FS, "{} is not a file", full_path); LOG_ERROR(Service_FS, "{} is not a file", full_path);
return ERROR_UNEXPECTED_FILE_OR_DIRECTORY_SDMC; return ResultUnexpectedFileOrDirectorySdmc;
case PathParser::NotFound: case PathParser::NotFound:
if (!mode.create_flag) { if (!mode.create_flag) {
LOG_ERROR(Service_FS, "Non-existing file {} can't be open without mode create.", LOG_ERROR(Service_FS, "Non-existing file {} can't be open without mode create.",
full_path); full_path);
return ERROR_NOT_FOUND; return ResultNotFound;
} else { } else {
// Create the file // Create the file
FileUtil::CreateEmptyFile(full_path); FileUtil::CreateEmptyFile(full_path);
@ -105,19 +105,19 @@ ResultVal<std::unique_ptr<FileBackend>> SDMCArchive::OpenFileBase(const Path& pa
FileUtil::IOFile file(full_path, mode.write_flag ? "r+b" : "rb"); FileUtil::IOFile file(full_path, mode.write_flag ? "r+b" : "rb");
if (!file.IsOpen()) { if (!file.IsOpen()) {
LOG_CRITICAL(Service_FS, "Error opening {}: {}", full_path, Common::GetLastErrorMsg()); LOG_CRITICAL(Service_FS, "Error opening {}: {}", full_path, Common::GetLastErrorMsg());
return ERROR_NOT_FOUND; return ResultNotFound;
} }
std::unique_ptr<DelayGenerator> delay_generator = std::make_unique<SDMCDelayGenerator>(); std::unique_ptr<DelayGenerator> delay_generator = std::make_unique<SDMCDelayGenerator>();
return std::make_unique<DiskFile>(std::move(file), mode, std::move(delay_generator)); return std::make_unique<DiskFile>(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); const PathParser path_parser(path);
if (!path_parser.IsValid()) { if (!path_parser.IsValid()) {
LOG_ERROR(Service_FS, "Invalid path {}", path.DebugStr()); LOG_ERROR(Service_FS, "Invalid path {}", path.DebugStr());
return ERROR_INVALID_PATH; return ResultInvalidPath;
} }
const auto full_path = path_parser.BuildHostPath(mount_point); const auto full_path = path_parser.BuildHostPath(mount_point);
@ -125,110 +125,109 @@ ResultCode SDMCArchive::DeleteFile(const Path& path) const {
switch (path_parser.GetHostStatus(mount_point)) { switch (path_parser.GetHostStatus(mount_point)) {
case PathParser::InvalidMountPoint: case PathParser::InvalidMountPoint:
LOG_CRITICAL(Service_FS, "(unreachable) Invalid mount point {}", mount_point); LOG_CRITICAL(Service_FS, "(unreachable) Invalid mount point {}", mount_point);
return ERROR_NOT_FOUND; return ResultNotFound;
case PathParser::PathNotFound: case PathParser::PathNotFound:
case PathParser::FileInPath: case PathParser::FileInPath:
case PathParser::NotFound: case PathParser::NotFound:
LOG_DEBUG(Service_FS, "{} not found", full_path); LOG_DEBUG(Service_FS, "{} not found", full_path);
return ERROR_NOT_FOUND; return ResultNotFound;
case PathParser::DirectoryFound: case PathParser::DirectoryFound:
LOG_ERROR(Service_FS, "{} is not a file", full_path); LOG_ERROR(Service_FS, "{} is not a file", full_path);
return ERROR_UNEXPECTED_FILE_OR_DIRECTORY_SDMC; return ResultUnexpectedFileOrDirectorySdmc;
case PathParser::FileFound: case PathParser::FileFound:
break; // Expected 'success' case break; // Expected 'success' case
} }
if (FileUtil::Delete(full_path)) { if (FileUtil::Delete(full_path)) {
return RESULT_SUCCESS; return ResultSuccess;
} }
LOG_CRITICAL(Service_FS, "(unreachable) Unknown error deleting {}", full_path); LOG_CRITICAL(Service_FS, "(unreachable) Unknown error deleting {}", full_path);
return ERROR_NOT_FOUND; return ResultNotFound;
} }
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); const PathParser path_parser_src(src_path);
// TODO: Verify these return codes with HW // TODO: Verify these return codes with HW
if (!path_parser_src.IsValid()) { if (!path_parser_src.IsValid()) {
LOG_ERROR(Service_FS, "Invalid src path {}", src_path.DebugStr()); LOG_ERROR(Service_FS, "Invalid src path {}", src_path.DebugStr());
return ERROR_INVALID_PATH; return ResultInvalidPath;
} }
const PathParser path_parser_dest(dest_path); const PathParser path_parser_dest(dest_path);
if (!path_parser_dest.IsValid()) { if (!path_parser_dest.IsValid()) {
LOG_ERROR(Service_FS, "Invalid dest path {}", dest_path.DebugStr()); LOG_ERROR(Service_FS, "Invalid dest path {}", dest_path.DebugStr());
return ERROR_INVALID_PATH; return ResultInvalidPath;
} }
const auto src_path_full = path_parser_src.BuildHostPath(mount_point); const auto src_path_full = path_parser_src.BuildHostPath(mount_point);
const auto dest_path_full = path_parser_dest.BuildHostPath(mount_point); const auto dest_path_full = path_parser_dest.BuildHostPath(mount_point);
if (FileUtil::Rename(src_path_full, dest_path_full)) { if (FileUtil::Rename(src_path_full, dest_path_full)) {
return RESULT_SUCCESS; return ResultSuccess;
} }
// TODO(yuriks): This code probably isn't right, it'll return a Status even if the file didn't // TODO(yuriks): This code probably isn't right, it'll return a Status even if the file didn't
// exist or similar. Verify. // exist or similar. Verify.
return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description return Result(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description
ErrorSummary::NothingHappened, ErrorLevel::Status); ErrorSummary::NothingHappened, ErrorLevel::Status);
} }
template <typename T> template <typename T>
static ResultCode DeleteDirectoryHelper(const Path& path, const std::string& mount_point, static Result DeleteDirectoryHelper(const Path& path, const std::string& mount_point, T deleter) {
T deleter) {
const PathParser path_parser(path); const PathParser path_parser(path);
if (!path_parser.IsValid()) { if (!path_parser.IsValid()) {
LOG_ERROR(Service_FS, "Invalid path {}", path.DebugStr()); LOG_ERROR(Service_FS, "Invalid path {}", path.DebugStr());
return ERROR_INVALID_PATH; return ResultInvalidPath;
} }
if (path_parser.IsRootDirectory()) if (path_parser.IsRootDirectory())
return ERROR_NOT_FOUND; return ResultNotFound;
const auto full_path = path_parser.BuildHostPath(mount_point); const auto full_path = path_parser.BuildHostPath(mount_point);
switch (path_parser.GetHostStatus(mount_point)) { switch (path_parser.GetHostStatus(mount_point)) {
case PathParser::InvalidMountPoint: case PathParser::InvalidMountPoint:
LOG_CRITICAL(Service_FS, "(unreachable) Invalid mount point {}", mount_point); LOG_CRITICAL(Service_FS, "(unreachable) Invalid mount point {}", mount_point);
return ERROR_NOT_FOUND; return ResultNotFound;
case PathParser::PathNotFound: case PathParser::PathNotFound:
case PathParser::NotFound: case PathParser::NotFound:
LOG_ERROR(Service_FS, "Path not found {}", full_path); LOG_ERROR(Service_FS, "Path not found {}", full_path);
return ERROR_NOT_FOUND; return ResultNotFound;
case PathParser::FileInPath: case PathParser::FileInPath:
case PathParser::FileFound: case PathParser::FileFound:
LOG_ERROR(Service_FS, "Unexpected file in path {}", full_path); LOG_ERROR(Service_FS, "Unexpected file in path {}", full_path);
return ERROR_UNEXPECTED_FILE_OR_DIRECTORY_SDMC; return ResultUnexpectedFileOrDirectorySdmc;
case PathParser::DirectoryFound: case PathParser::DirectoryFound:
break; // Expected 'success' case break; // Expected 'success' case
} }
if (deleter(full_path)) { if (deleter(full_path)) {
return RESULT_SUCCESS; return ResultSuccess;
} }
LOG_ERROR(Service_FS, "Directory not empty {}", full_path); LOG_ERROR(Service_FS, "Directory not empty {}", full_path);
return ERROR_UNEXPECTED_FILE_OR_DIRECTORY_SDMC; return ResultUnexpectedFileOrDirectorySdmc;
} }
ResultCode SDMCArchive::DeleteDirectory(const Path& path) const { Result SDMCArchive::DeleteDirectory(const Path& path) const {
return DeleteDirectoryHelper(path, mount_point, FileUtil::DeleteDir); return DeleteDirectoryHelper(path, mount_point, FileUtil::DeleteDir);
} }
ResultCode SDMCArchive::DeleteDirectoryRecursively(const Path& path) const { Result SDMCArchive::DeleteDirectoryRecursively(const Path& path) const {
return DeleteDirectoryHelper( return DeleteDirectoryHelper(
path, mount_point, [](const std::string& p) { return FileUtil::DeleteDirRecursively(p); }); 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); const PathParser path_parser(path);
if (!path_parser.IsValid()) { if (!path_parser.IsValid()) {
LOG_ERROR(Service_FS, "Invalid path {}", path.DebugStr()); LOG_ERROR(Service_FS, "Invalid path {}", path.DebugStr());
return ERROR_INVALID_PATH; return ResultInvalidPath;
} }
const auto full_path = path_parser.BuildHostPath(mount_point); const auto full_path = path_parser.BuildHostPath(mount_point);
@ -236,44 +235,44 @@ ResultCode SDMCArchive::CreateFile(const FileSys::Path& path, u64 size) const {
switch (path_parser.GetHostStatus(mount_point)) { switch (path_parser.GetHostStatus(mount_point)) {
case PathParser::InvalidMountPoint: case PathParser::InvalidMountPoint:
LOG_CRITICAL(Service_FS, "(unreachable) Invalid mount point {}", mount_point); LOG_CRITICAL(Service_FS, "(unreachable) Invalid mount point {}", mount_point);
return ERROR_NOT_FOUND; return ResultNotFound;
case PathParser::PathNotFound: case PathParser::PathNotFound:
case PathParser::FileInPath: case PathParser::FileInPath:
LOG_ERROR(Service_FS, "Path not found {}", full_path); LOG_ERROR(Service_FS, "Path not found {}", full_path);
return ERROR_NOT_FOUND; return ResultNotFound;
case PathParser::DirectoryFound: case PathParser::DirectoryFound:
LOG_ERROR(Service_FS, "{} already exists", full_path); LOG_ERROR(Service_FS, "{} already exists", full_path);
return ERROR_UNEXPECTED_FILE_OR_DIRECTORY_SDMC; return ResultUnexpectedFileOrDirectorySdmc;
case PathParser::FileFound: case PathParser::FileFound:
LOG_ERROR(Service_FS, "{} already exists", full_path); LOG_ERROR(Service_FS, "{} already exists", full_path);
return ERROR_ALREADY_EXISTS; return ResultAlreadyExists;
case PathParser::NotFound: case PathParser::NotFound:
break; // Expected 'success' case break; // Expected 'success' case
} }
if (size == 0) { if (size == 0) {
FileUtil::CreateEmptyFile(full_path); FileUtil::CreateEmptyFile(full_path);
return RESULT_SUCCESS; return ResultSuccess;
} }
FileUtil::IOFile file(full_path, "wb"); FileUtil::IOFile file(full_path, "wb");
// Creates a sparse file (or a normal file on filesystems without the concept of sparse files) // Creates a sparse file (or a normal file on filesystems without the concept of sparse files)
// We do this by seeking to the right size, then writing a single null byte. // We do this by seeking to the right size, then writing a single null byte.
if (file.Seek(size - 1, SEEK_SET) && file.WriteBytes("", 1) == 1) { if (file.Seek(size - 1, SEEK_SET) && file.WriteBytes("", 1) == 1) {
return RESULT_SUCCESS; return ResultSuccess;
} }
LOG_ERROR(Service_FS, "Too large file"); LOG_ERROR(Service_FS, "Too large file");
return ResultCode(ErrorDescription::TooLarge, ErrorModule::FS, ErrorSummary::OutOfResource, return Result(ErrorDescription::TooLarge, ErrorModule::FS, ErrorSummary::OutOfResource,
ErrorLevel::Info); ErrorLevel::Info);
} }
ResultCode SDMCArchive::CreateDirectory(const Path& path) const { Result SDMCArchive::CreateDirectory(const Path& path) const {
const PathParser path_parser(path); const PathParser path_parser(path);
if (!path_parser.IsValid()) { if (!path_parser.IsValid()) {
LOG_ERROR(Service_FS, "Invalid path {}", path.DebugStr()); LOG_ERROR(Service_FS, "Invalid path {}", path.DebugStr());
return ERROR_INVALID_PATH; return ResultInvalidPath;
} }
const auto full_path = path_parser.BuildHostPath(mount_point); const auto full_path = path_parser.BuildHostPath(mount_point);
@ -281,55 +280,55 @@ ResultCode SDMCArchive::CreateDirectory(const Path& path) const {
switch (path_parser.GetHostStatus(mount_point)) { switch (path_parser.GetHostStatus(mount_point)) {
case PathParser::InvalidMountPoint: case PathParser::InvalidMountPoint:
LOG_CRITICAL(Service_FS, "(unreachable) Invalid mount point {}", mount_point); LOG_CRITICAL(Service_FS, "(unreachable) Invalid mount point {}", mount_point);
return ERROR_NOT_FOUND; return ResultNotFound;
case PathParser::PathNotFound: case PathParser::PathNotFound:
case PathParser::FileInPath: case PathParser::FileInPath:
LOG_ERROR(Service_FS, "Path not found {}", full_path); LOG_ERROR(Service_FS, "Path not found {}", full_path);
return ERROR_NOT_FOUND; return ResultNotFound;
case PathParser::DirectoryFound: case PathParser::DirectoryFound:
case PathParser::FileFound: case PathParser::FileFound:
LOG_DEBUG(Service_FS, "{} already exists", full_path); LOG_DEBUG(Service_FS, "{} already exists", full_path);
return ERROR_ALREADY_EXISTS; return ResultAlreadyExists;
case PathParser::NotFound: case PathParser::NotFound:
break; // Expected 'success' case break; // Expected 'success' case
} }
if (FileUtil::CreateDir(mount_point + path.AsString())) { if (FileUtil::CreateDir(mount_point + path.AsString())) {
return RESULT_SUCCESS; return ResultSuccess;
} }
LOG_CRITICAL(Service_FS, "(unreachable) Unknown error creating {}", mount_point); LOG_CRITICAL(Service_FS, "(unreachable) Unknown error creating {}", mount_point);
return ResultCode(ErrorDescription::NoData, ErrorModule::FS, ErrorSummary::Canceled, return Result(ErrorDescription::NoData, ErrorModule::FS, ErrorSummary::Canceled,
ErrorLevel::Status); 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); const PathParser path_parser_src(src_path);
// TODO: Verify these return codes with HW // TODO: Verify these return codes with HW
if (!path_parser_src.IsValid()) { if (!path_parser_src.IsValid()) {
LOG_ERROR(Service_FS, "Invalid src path {}", src_path.DebugStr()); LOG_ERROR(Service_FS, "Invalid src path {}", src_path.DebugStr());
return ERROR_INVALID_PATH; return ResultInvalidPath;
} }
const PathParser path_parser_dest(dest_path); const PathParser path_parser_dest(dest_path);
if (!path_parser_dest.IsValid()) { if (!path_parser_dest.IsValid()) {
LOG_ERROR(Service_FS, "Invalid dest path {}", dest_path.DebugStr()); LOG_ERROR(Service_FS, "Invalid dest path {}", dest_path.DebugStr());
return ERROR_INVALID_PATH; return ResultInvalidPath;
} }
const auto src_path_full = path_parser_src.BuildHostPath(mount_point); const auto src_path_full = path_parser_src.BuildHostPath(mount_point);
const auto dest_path_full = path_parser_dest.BuildHostPath(mount_point); const auto dest_path_full = path_parser_dest.BuildHostPath(mount_point);
if (FileUtil::Rename(src_path_full, dest_path_full)) { if (FileUtil::Rename(src_path_full, dest_path_full)) {
return RESULT_SUCCESS; return ResultSuccess;
} }
// TODO(yuriks): This code probably isn't right, it'll return a Status even if the file didn't // TODO(yuriks): This code probably isn't right, it'll return a Status even if the file didn't
// exist or similar. Verify. // exist or similar. Verify.
return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description return Result(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description
ErrorSummary::NothingHappened, ErrorLevel::Status); ErrorSummary::NothingHappened, ErrorLevel::Status);
} }
ResultVal<std::unique_ptr<DirectoryBackend>> SDMCArchive::OpenDirectory(const Path& path) const { ResultVal<std::unique_ptr<DirectoryBackend>> SDMCArchive::OpenDirectory(const Path& path) const {
@ -337,7 +336,7 @@ ResultVal<std::unique_ptr<DirectoryBackend>> SDMCArchive::OpenDirectory(const Pa
if (!path_parser.IsValid()) { if (!path_parser.IsValid()) {
LOG_ERROR(Service_FS, "Invalid path {}", path.DebugStr()); LOG_ERROR(Service_FS, "Invalid path {}", path.DebugStr());
return ERROR_INVALID_PATH; return ResultInvalidPath;
} }
const auto full_path = path_parser.BuildHostPath(mount_point); const auto full_path = path_parser.BuildHostPath(mount_point);
@ -345,15 +344,15 @@ ResultVal<std::unique_ptr<DirectoryBackend>> SDMCArchive::OpenDirectory(const Pa
switch (path_parser.GetHostStatus(mount_point)) { switch (path_parser.GetHostStatus(mount_point)) {
case PathParser::InvalidMountPoint: case PathParser::InvalidMountPoint:
LOG_CRITICAL(Service_FS, "(unreachable) Invalid mount point {}", mount_point); LOG_CRITICAL(Service_FS, "(unreachable) Invalid mount point {}", mount_point);
return ERROR_NOT_FOUND; return ResultNotFound;
case PathParser::PathNotFound: case PathParser::PathNotFound:
case PathParser::NotFound: case PathParser::NotFound:
case PathParser::FileFound: case PathParser::FileFound:
LOG_ERROR(Service_FS, "{} not found", full_path); LOG_ERROR(Service_FS, "{} not found", full_path);
return ERROR_NOT_FOUND; return ResultNotFound;
case PathParser::FileInPath: case PathParser::FileInPath:
LOG_ERROR(Service_FS, "Unexpected file in path {}", full_path); LOG_ERROR(Service_FS, "Unexpected file in path {}", full_path);
return ERROR_UNEXPECTED_FILE_OR_DIRECTORY_SDMC; return ResultUnexpectedFileOrDirectorySdmc;
case PathParser::DirectoryFound: case PathParser::DirectoryFound:
break; // Expected 'success' case break; // Expected 'success' case
} }
@ -392,18 +391,17 @@ ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_SDMC::Open(const Path&
return std::make_unique<SDMCArchive>(sdmc_directory, std::move(delay_generator)); return std::make_unique<SDMCArchive>(sdmc_directory, std::move(delay_generator));
} }
ResultCode ArchiveFactory_SDMC::Format(const Path& path, Result ArchiveFactory_SDMC::Format(const Path& path, const FileSys::ArchiveFormatInfo& format_info,
const FileSys::ArchiveFormatInfo& format_info, u64 program_id) {
u64 program_id) {
// This is kind of an undesirable operation, so let's just ignore it. :) // This is kind of an undesirable operation, so let's just ignore it. :)
return RESULT_SUCCESS; return ResultSuccess;
} }
ResultVal<ArchiveFormatInfo> ArchiveFactory_SDMC::GetFormatInfo(const Path& path, ResultVal<ArchiveFormatInfo> ArchiveFactory_SDMC::GetFormatInfo(const Path& path,
u64 program_id) const { u64 program_id) const {
// TODO(Subv): Implement // TODO(Subv): Implement
LOG_ERROR(Service_FS, "Unimplemented GetFormatInfo archive {}", GetName()); LOG_ERROR(Service_FS, "Unimplemented GetFormatInfo archive {}", GetName());
return RESULT_UNKNOWN; return ResultUnknown;
} }
} // namespace FileSys } // namespace FileSys

View file

@ -29,13 +29,13 @@ public:
ResultVal<std::unique_ptr<FileBackend>> OpenFile(const Path& path, ResultVal<std::unique_ptr<FileBackend>> OpenFile(const Path& path,
const Mode& mode) const override; const Mode& mode) const override;
ResultCode DeleteFile(const Path& path) const override; Result DeleteFile(const Path& path) const override;
ResultCode RenameFile(const Path& src_path, const Path& dest_path) const override; Result RenameFile(const Path& src_path, const Path& dest_path) const override;
ResultCode DeleteDirectory(const Path& path) const override; Result DeleteDirectory(const Path& path) const override;
ResultCode DeleteDirectoryRecursively(const Path& path) const override; Result DeleteDirectoryRecursively(const Path& path) const override;
ResultCode CreateFile(const Path& path, u64 size) const override; Result CreateFile(const Path& path, u64 size) const override;
ResultCode CreateDirectory(const Path& path) const override; Result CreateDirectory(const Path& path) const override;
ResultCode RenameDirectory(const Path& src_path, const Path& dest_path) const override; Result RenameDirectory(const Path& src_path, const Path& dest_path) const override;
ResultVal<std::unique_ptr<DirectoryBackend>> OpenDirectory(const Path& path) const override; ResultVal<std::unique_ptr<DirectoryBackend>> OpenDirectory(const Path& path) const override;
u64 GetFreeBytes() const override; u64 GetFreeBytes() const override;
@ -68,8 +68,8 @@ public:
} }
ResultVal<std::unique_ptr<ArchiveBackend>> Open(const Path& path, u64 program_id) override; ResultVal<std::unique_ptr<ArchiveBackend>> Open(const Path& path, u64 program_id) override;
ResultCode Format(const Path& path, const FileSys::ArchiveFormatInfo& format_info, Result Format(const Path& path, const FileSys::ArchiveFormatInfo& format_info,
u64 program_id) override; u64 program_id) override;
ResultVal<ArchiveFormatInfo> GetFormatInfo(const Path& path, u64 program_id) const override; ResultVal<ArchiveFormatInfo> GetFormatInfo(const Path& path, u64 program_id) const override;
private: private:

View file

@ -44,7 +44,7 @@ ResultVal<std::unique_ptr<FileBackend>> SDMCWriteOnlyArchive::OpenFile(const Pat
const Mode& mode) const { const Mode& mode) const {
if (mode.read_flag) { if (mode.read_flag) {
LOG_ERROR(Service_FS, "Read flag is not supported"); LOG_ERROR(Service_FS, "Read flag is not supported");
return ERROR_INVALID_READ_FLAG; return ResultInvalidReadFlag;
} }
return SDMCArchive::OpenFileBase(path, mode); return SDMCArchive::OpenFileBase(path, mode);
} }
@ -52,7 +52,7 @@ ResultVal<std::unique_ptr<FileBackend>> SDMCWriteOnlyArchive::OpenFile(const Pat
ResultVal<std::unique_ptr<DirectoryBackend>> SDMCWriteOnlyArchive::OpenDirectory( ResultVal<std::unique_ptr<DirectoryBackend>> SDMCWriteOnlyArchive::OpenDirectory(
const Path& path) const { const Path& path) const {
LOG_ERROR(Service_FS, "Not supported"); LOG_ERROR(Service_FS, "Not supported");
return ERROR_UNSUPPORTED_OPEN_FLAGS; return ResultUnsupportedOpenFlags;
} }
ArchiveFactory_SDMCWriteOnly::ArchiveFactory_SDMCWriteOnly(const std::string& mount_point) ArchiveFactory_SDMCWriteOnly::ArchiveFactory_SDMCWriteOnly(const std::string& mount_point)
@ -81,19 +81,19 @@ ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_SDMCWriteOnly::Open(co
return std::make_unique<SDMCWriteOnlyArchive>(sdmc_directory, std::move(delay_generator)); return std::make_unique<SDMCWriteOnlyArchive>(sdmc_directory, std::move(delay_generator));
} }
ResultCode ArchiveFactory_SDMCWriteOnly::Format(const Path& path, Result ArchiveFactory_SDMCWriteOnly::Format(const Path& path,
const FileSys::ArchiveFormatInfo& format_info, const FileSys::ArchiveFormatInfo& format_info,
u64 program_id) { u64 program_id) {
// TODO(wwylele): hwtest this // TODO(wwylele): hwtest this
LOG_ERROR(Service_FS, "Attempted to format a SDMC write-only archive."); LOG_ERROR(Service_FS, "Attempted to format a SDMC write-only archive.");
return RESULT_UNKNOWN; return ResultUnknown;
} }
ResultVal<ArchiveFormatInfo> ArchiveFactory_SDMCWriteOnly::GetFormatInfo(const Path& path, ResultVal<ArchiveFormatInfo> ArchiveFactory_SDMCWriteOnly::GetFormatInfo(const Path& path,
u64 program_id) const { u64 program_id) const {
// TODO(Subv): Implement // TODO(Subv): Implement
LOG_ERROR(Service_FS, "Unimplemented GetFormatInfo archive {}", GetName()); LOG_ERROR(Service_FS, "Unimplemented GetFormatInfo archive {}", GetName());
return RESULT_UNKNOWN; return ResultUnknown;
} }
} // namespace FileSys } // namespace FileSys

View file

@ -54,8 +54,8 @@ public:
} }
ResultVal<std::unique_ptr<ArchiveBackend>> Open(const Path& path, u64 program_id) override; ResultVal<std::unique_ptr<ArchiveBackend>> Open(const Path& path, u64 program_id) override;
ResultCode Format(const Path& path, const FileSys::ArchiveFormatInfo& format_info, Result Format(const Path& path, const FileSys::ArchiveFormatInfo& format_info,
u64 program_id) override; u64 program_id) override;
ResultVal<ArchiveFormatInfo> GetFormatInfo(const Path& path, u64 program_id) const override; ResultVal<ArchiveFormatInfo> GetFormatInfo(const Path& path, u64 program_id) const override;
private: private:

View file

@ -39,12 +39,12 @@ public:
ResultVal<std::size_t> Read(u64 offset, std::size_t length, u8* buffer) const override { ResultVal<std::size_t> Read(u64 offset, std::size_t length, u8* buffer) const override {
if (offset != 0) { if (offset != 0) {
LOG_ERROR(Service_FS, "offset must be zero!"); LOG_ERROR(Service_FS, "offset must be zero!");
return ERROR_UNSUPPORTED_OPEN_FLAGS; return ResultUnsupportedOpenFlags;
} }
if (length != data->size()) { if (length != data->size()) {
LOG_ERROR(Service_FS, "size must match the file size!"); LOG_ERROR(Service_FS, "size must match the file size!");
return ERROR_INCORRECT_EXEFS_READ_SIZE; return ResultIncorrectExefsReadSize;
} }
std::memcpy(buffer, data->data(), data->size()); std::memcpy(buffer, data->data(), data->size());
@ -54,7 +54,7 @@ public:
ResultVal<std::size_t> Write(u64 offset, std::size_t length, bool flush, ResultVal<std::size_t> Write(u64 offset, std::size_t length, bool flush,
const u8* buffer) override { const u8* buffer) override {
LOG_ERROR(Service_FS, "The file is read-only!"); LOG_ERROR(Service_FS, "The file is read-only!");
return ERROR_UNSUPPORTED_OPEN_FLAGS; return ResultUnsupportedOpenFlags;
} }
u64 GetSize() const override { u64 GetSize() const override {
@ -99,13 +99,13 @@ public:
if (path.GetType() != LowPathType::Binary) { if (path.GetType() != LowPathType::Binary) {
LOG_ERROR(Service_FS, "Path need to be Binary"); LOG_ERROR(Service_FS, "Path need to be Binary");
return ERROR_INVALID_PATH; return ResultInvalidPath;
} }
std::vector<u8> binary = path.AsBinary(); std::vector<u8> binary = path.AsBinary();
if (binary.size() != sizeof(SelfNCCHFilePath)) { if (binary.size() != sizeof(SelfNCCHFilePath)) {
LOG_ERROR(Service_FS, "Wrong path size {}", binary.size()); LOG_ERROR(Service_FS, "Wrong path size {}", binary.size());
return ERROR_INVALID_PATH; return ResultInvalidPath;
} }
SelfNCCHFilePath file_path; SelfNCCHFilePath file_path;
@ -120,7 +120,7 @@ public:
case SelfNCCHFilePathType::Code: case SelfNCCHFilePathType::Code:
LOG_ERROR(Service_FS, "Reading the code section is not supported!"); LOG_ERROR(Service_FS, "Reading the code section is not supported!");
return ERROR_COMMAND_NOT_ALLOWED; return ResultCommandNotAllowed;
case SelfNCCHFilePathType::ExeFS: { case SelfNCCHFilePathType::ExeFS: {
const auto& raw = file_path.exefs_filename; const auto& raw = file_path.exefs_filename;
@ -130,48 +130,48 @@ public:
} }
default: default:
LOG_ERROR(Service_FS, "Unknown file type {}!", file_path.type); LOG_ERROR(Service_FS, "Unknown file type {}!", file_path.type);
return ERROR_INVALID_PATH; return ResultInvalidPath;
} }
} }
ResultCode DeleteFile(const Path& path) const override { Result DeleteFile(const Path& path) const override {
LOG_ERROR(Service_FS, "Unsupported"); LOG_ERROR(Service_FS, "Unsupported");
return ERROR_UNSUPPORTED_OPEN_FLAGS; return ResultUnsupportedOpenFlags;
} }
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"); LOG_ERROR(Service_FS, "Unsupported");
return ERROR_UNSUPPORTED_OPEN_FLAGS; return ResultUnsupportedOpenFlags;
} }
ResultCode DeleteDirectory(const Path& path) const override { Result DeleteDirectory(const Path& path) const override {
LOG_ERROR(Service_FS, "Unsupported"); LOG_ERROR(Service_FS, "Unsupported");
return ERROR_UNSUPPORTED_OPEN_FLAGS; return ResultUnsupportedOpenFlags;
} }
ResultCode DeleteDirectoryRecursively(const Path& path) const override { Result DeleteDirectoryRecursively(const Path& path) const override {
LOG_ERROR(Service_FS, "Unsupported"); LOG_ERROR(Service_FS, "Unsupported");
return ERROR_UNSUPPORTED_OPEN_FLAGS; return ResultUnsupportedOpenFlags;
} }
ResultCode CreateFile(const Path& path, u64 size) const override { Result CreateFile(const Path& path, u64 size) const override {
LOG_ERROR(Service_FS, "Unsupported"); LOG_ERROR(Service_FS, "Unsupported");
return ERROR_UNSUPPORTED_OPEN_FLAGS; return ResultUnsupportedOpenFlags;
} }
ResultCode CreateDirectory(const Path& path) const override { Result CreateDirectory(const Path& path) const override {
LOG_ERROR(Service_FS, "Unsupported"); LOG_ERROR(Service_FS, "Unsupported");
return ERROR_UNSUPPORTED_OPEN_FLAGS; return ResultUnsupportedOpenFlags;
} }
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"); LOG_ERROR(Service_FS, "Unsupported");
return ERROR_UNSUPPORTED_OPEN_FLAGS; return ResultUnsupportedOpenFlags;
} }
ResultVal<std::unique_ptr<DirectoryBackend>> OpenDirectory(const Path& path) const override { ResultVal<std::unique_ptr<DirectoryBackend>> OpenDirectory(const Path& path) const override {
LOG_ERROR(Service_FS, "Unsupported"); LOG_ERROR(Service_FS, "Unsupported");
return ERROR_UNSUPPORTED_OPEN_FLAGS; return ResultUnsupportedOpenFlags;
} }
u64 GetFreeBytes() const override { u64 GetFreeBytes() const override {
@ -186,7 +186,7 @@ private:
return std::make_unique<IVFCFile>(ncch_data.romfs_file, std::move(delay_generator)); return std::make_unique<IVFCFile>(ncch_data.romfs_file, std::move(delay_generator));
} else { } else {
LOG_INFO(Service_FS, "Unable to read RomFS"); LOG_INFO(Service_FS, "Unable to read RomFS");
return ERROR_ROMFS_NOT_FOUND; return ResultRomfsNotFound;
} }
} }
@ -198,7 +198,7 @@ private:
std::move(delay_generator)); std::move(delay_generator));
} else { } else {
LOG_INFO(Service_FS, "Unable to read update RomFS"); LOG_INFO(Service_FS, "Unable to read update RomFS");
return ERROR_ROMFS_NOT_FOUND; return ResultRomfsNotFound;
} }
} }
@ -209,7 +209,7 @@ private:
} }
LOG_WARNING(Service_FS, "Unable to read icon"); LOG_WARNING(Service_FS, "Unable to read icon");
return ERROR_EXEFS_SECTION_NOT_FOUND; return ResultExefsSectionNotFound;
} }
if (filename == "logo") { if (filename == "logo") {
@ -218,7 +218,7 @@ private:
} }
LOG_WARNING(Service_FS, "Unable to read logo"); LOG_WARNING(Service_FS, "Unable to read logo");
return ERROR_EXEFS_SECTION_NOT_FOUND; return ResultExefsSectionNotFound;
} }
if (filename == "banner") { if (filename == "banner") {
@ -227,11 +227,11 @@ private:
} }
LOG_WARNING(Service_FS, "Unable to read banner"); LOG_WARNING(Service_FS, "Unable to read banner");
return ERROR_EXEFS_SECTION_NOT_FOUND; return ResultExefsSectionNotFound;
} }
LOG_ERROR(Service_FS, "Unknown ExeFS section {}!", filename); LOG_ERROR(Service_FS, "Unknown ExeFS section {}!", filename);
return ERROR_INVALID_PATH; return ResultInvalidPath;
} }
NCCHData ncch_data; NCCHData ncch_data;
@ -296,16 +296,16 @@ ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_SelfNCCH::Open(const P
return std::make_unique<SelfNCCHArchive>(ncch_data[program_id]); return std::make_unique<SelfNCCHArchive>(ncch_data[program_id]);
} }
ResultCode ArchiveFactory_SelfNCCH::Format(const Path&, const FileSys::ArchiveFormatInfo&, Result ArchiveFactory_SelfNCCH::Format(const Path&, const FileSys::ArchiveFormatInfo&,
u64 program_id) { u64 program_id) {
LOG_ERROR(Service_FS, "Attempted to format a SelfNCCH archive."); LOG_ERROR(Service_FS, "Attempted to format a SelfNCCH archive.");
return ERROR_INVALID_PATH; return ResultInvalidPath;
} }
ResultVal<ArchiveFormatInfo> ArchiveFactory_SelfNCCH::GetFormatInfo(const Path&, ResultVal<ArchiveFormatInfo> ArchiveFactory_SelfNCCH::GetFormatInfo(const Path&,
u64 program_id) const { u64 program_id) const {
LOG_ERROR(Service_FS, "Attempted to get format info of a SelfNCCH archive"); LOG_ERROR(Service_FS, "Attempted to get format info of a SelfNCCH archive");
return ERROR_INVALID_PATH; return ResultInvalidPath;
} }
} // namespace FileSys } // namespace FileSys

View file

@ -50,8 +50,8 @@ public:
return "SelfNCCH"; return "SelfNCCH";
} }
ResultVal<std::unique_ptr<ArchiveBackend>> Open(const Path& path, u64 program_id) override; ResultVal<std::unique_ptr<ArchiveBackend>> Open(const Path& path, u64 program_id) override;
ResultCode Format(const Path& path, const FileSys::ArchiveFormatInfo& format_info, Result Format(const Path& path, const FileSys::ArchiveFormatInfo& format_info,
u64 program_id) override; u64 program_id) override;
ResultVal<ArchiveFormatInfo> GetFormatInfo(const Path& path, u64 program_id) const override; ResultVal<ArchiveFormatInfo> GetFormatInfo(const Path& path, u64 program_id) const override;
private: private:

View file

@ -47,14 +47,14 @@ ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveSource_SDSaveData::Open(u64 pr
// save file/directory structure expected by the game has not yet been initialized. // save file/directory structure expected by the game has not yet been initialized.
// Returning the NotFormatted error code will signal the game to provision the SaveData // Returning the NotFormatted error code will signal the game to provision the SaveData
// archive with the files and folders that it expects. // archive with the files and folders that it expects.
return ERR_NOT_FORMATTED; return ResultNotFormatted;
} }
return std::make_unique<SaveDataArchive>(std::move(concrete_mount_point)); return std::make_unique<SaveDataArchive>(std::move(concrete_mount_point));
} }
ResultCode ArchiveSource_SDSaveData::Format(u64 program_id, Result ArchiveSource_SDSaveData::Format(u64 program_id,
const FileSys::ArchiveFormatInfo& format_info) { const FileSys::ArchiveFormatInfo& format_info) {
std::string concrete_mount_point = GetSaveDataPath(mount_point, program_id); std::string concrete_mount_point = GetSaveDataPath(mount_point, program_id);
FileUtil::DeleteDirRecursively(concrete_mount_point); FileUtil::DeleteDirRecursively(concrete_mount_point);
FileUtil::CreateFullPath(concrete_mount_point); FileUtil::CreateFullPath(concrete_mount_point);
@ -65,9 +65,9 @@ ResultCode ArchiveSource_SDSaveData::Format(u64 program_id,
if (file.IsOpen()) { if (file.IsOpen()) {
file.WriteBytes(&format_info, sizeof(format_info)); file.WriteBytes(&format_info, sizeof(format_info));
return RESULT_SUCCESS; return ResultSuccess;
} }
return RESULT_SUCCESS; return ResultSuccess;
} }
ResultVal<ArchiveFormatInfo> ArchiveSource_SDSaveData::GetFormatInfo(u64 program_id) const { ResultVal<ArchiveFormatInfo> ArchiveSource_SDSaveData::GetFormatInfo(u64 program_id) const {
@ -77,7 +77,7 @@ ResultVal<ArchiveFormatInfo> ArchiveSource_SDSaveData::GetFormatInfo(u64 program
if (!file.IsOpen()) { if (!file.IsOpen()) {
LOG_ERROR(Service_FS, "Could not open metadata information for archive"); LOG_ERROR(Service_FS, "Could not open metadata information for archive");
// TODO(Subv): Verify error code // TODO(Subv): Verify error code
return ERR_NOT_FORMATTED; return ResultNotFormatted;
} }
ArchiveFormatInfo info = {}; ArchiveFormatInfo info = {};

View file

@ -19,7 +19,7 @@ public:
explicit ArchiveSource_SDSaveData(const std::string& mount_point); explicit ArchiveSource_SDSaveData(const std::string& mount_point);
ResultVal<std::unique_ptr<ArchiveBackend>> Open(u64 program_id); ResultVal<std::unique_ptr<ArchiveBackend>> 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<ArchiveFormatInfo> GetFormatInfo(u64 program_id) const; ResultVal<ArchiveFormatInfo> GetFormatInfo(u64 program_id) const;
static std::string GetSaveDataPathFor(const std::string& mount_point, u64 program_id); static std::string GetSaveDataPathFor(const std::string& mount_point, u64 program_id);

View file

@ -57,25 +57,25 @@ ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_SystemSaveData::Open(c
std::string fullpath = GetSystemSaveDataPath(base_path, path); std::string fullpath = GetSystemSaveDataPath(base_path, path);
if (!FileUtil::Exists(fullpath)) { if (!FileUtil::Exists(fullpath)) {
// TODO(Subv): Check error code, this one is probably wrong // TODO(Subv): Check error code, this one is probably wrong
return ERROR_NOT_FOUND; return ResultNotFound;
} }
return std::make_unique<SaveDataArchive>(fullpath); return std::make_unique<SaveDataArchive>(fullpath);
} }
ResultCode ArchiveFactory_SystemSaveData::Format(const Path& path, Result ArchiveFactory_SystemSaveData::Format(const Path& path,
const FileSys::ArchiveFormatInfo& format_info, const FileSys::ArchiveFormatInfo& format_info,
u64 program_id) { u64 program_id) {
std::string fullpath = GetSystemSaveDataPath(base_path, path); std::string fullpath = GetSystemSaveDataPath(base_path, path);
FileUtil::DeleteDirRecursively(fullpath); FileUtil::DeleteDirRecursively(fullpath);
FileUtil::CreateFullPath(fullpath); FileUtil::CreateFullPath(fullpath);
return RESULT_SUCCESS; return ResultSuccess;
} }
ResultVal<ArchiveFormatInfo> ArchiveFactory_SystemSaveData::GetFormatInfo(const Path& path, ResultVal<ArchiveFormatInfo> ArchiveFactory_SystemSaveData::GetFormatInfo(const Path& path,
u64 program_id) const { u64 program_id) const {
// TODO(Subv): Implement // TODO(Subv): Implement
LOG_ERROR(Service_FS, "Unimplemented GetFormatInfo archive {}", GetName()); LOG_ERROR(Service_FS, "Unimplemented GetFormatInfo archive {}", GetName());
return RESULT_UNKNOWN; return ResultUnknown;
} }
} // namespace FileSys } // namespace FileSys

View file

@ -20,8 +20,8 @@ public:
explicit ArchiveFactory_SystemSaveData(const std::string& mount_point); explicit ArchiveFactory_SystemSaveData(const std::string& mount_point);
ResultVal<std::unique_ptr<ArchiveBackend>> Open(const Path& path, u64 program_id) override; ResultVal<std::unique_ptr<ArchiveBackend>> Open(const Path& path, u64 program_id) override;
ResultCode Format(const Path& path, const FileSys::ArchiveFormatInfo& format_info, Result Format(const Path& path, const FileSys::ArchiveFormatInfo& format_info,
u64 program_id) override; u64 program_id) override;
ResultVal<ArchiveFormatInfo> GetFormatInfo(const Path& path, u64 program_id) const override; ResultVal<ArchiveFormatInfo> GetFormatInfo(const Path& path, u64 program_id) const override;
std::string GetName() const override { std::string GetName() const override {

View file

@ -19,7 +19,7 @@ namespace FileSys {
ResultVal<std::size_t> DiskFile::Read(const u64 offset, const std::size_t length, ResultVal<std::size_t> DiskFile::Read(const u64 offset, const std::size_t length,
u8* buffer) const { u8* buffer) const {
if (!mode.read_flag) if (!mode.read_flag)
return ERROR_INVALID_OPEN_FLAGS; return ResultInvalidOpenFlags;
file->Seek(offset, SEEK_SET); file->Seek(offset, SEEK_SET);
return file->ReadBytes(buffer, length); return file->ReadBytes(buffer, length);
@ -28,7 +28,7 @@ ResultVal<std::size_t> DiskFile::Read(const u64 offset, const std::size_t length
ResultVal<std::size_t> DiskFile::Write(const u64 offset, const std::size_t length, const bool flush, ResultVal<std::size_t> DiskFile::Write(const u64 offset, const std::size_t length, const bool flush,
const u8* buffer) { const u8* buffer) {
if (!mode.write_flag) if (!mode.write_flag)
return ERROR_INVALID_OPEN_FLAGS; return ResultInvalidOpenFlags;
file->Seek(offset, SEEK_SET); file->Seek(offset, SEEK_SET);
std::size_t written = file->WriteBytes(buffer, length); std::size_t written = file->WriteBytes(buffer, length);

View file

@ -35,63 +35,60 @@ enum {
}; };
} }
constexpr ResultCode ERROR_INVALID_PATH(ErrCodes::InvalidPath, ErrorModule::FS, constexpr Result ResultInvalidPath(ErrCodes::InvalidPath, ErrorModule::FS,
ErrorSummary::InvalidArgument, ErrorLevel::Usage); ErrorSummary::InvalidArgument, ErrorLevel::Usage);
constexpr ResultCode ERROR_UNSUPPORTED_OPEN_FLAGS(ErrCodes::UnsupportedOpenFlags, ErrorModule::FS, constexpr Result ResultUnsupportedOpenFlags(ErrCodes::UnsupportedOpenFlags, ErrorModule::FS,
ErrorSummary::NotSupported, ErrorLevel::Usage); ErrorSummary::NotSupported, ErrorLevel::Usage);
constexpr ResultCode ERROR_INVALID_OPEN_FLAGS(ErrCodes::InvalidOpenFlags, ErrorModule::FS, constexpr Result ResultInvalidOpenFlags(ErrCodes::InvalidOpenFlags, ErrorModule::FS,
ErrorSummary::Canceled, ErrorLevel::Status); ErrorSummary::Canceled, ErrorLevel::Status);
constexpr ResultCode ERROR_INVALID_READ_FLAG(ErrCodes::InvalidReadFlag, ErrorModule::FS, constexpr Result ResultInvalidReadFlag(ErrCodes::InvalidReadFlag, ErrorModule::FS,
ErrorSummary::InvalidArgument, ErrorLevel::Usage); ErrorSummary::InvalidArgument, ErrorLevel::Usage);
constexpr ResultCode ERROR_FILE_NOT_FOUND(ErrCodes::FileNotFound, ErrorModule::FS, constexpr Result ResultFileNotFound(ErrCodes::FileNotFound, ErrorModule::FS, ErrorSummary::NotFound,
ErrorSummary::NotFound, ErrorLevel::Status); ErrorLevel::Status);
constexpr ResultCode ERROR_PATH_NOT_FOUND(ErrCodes::PathNotFound, ErrorModule::FS, constexpr Result ResultPathNotFound(ErrCodes::PathNotFound, ErrorModule::FS, ErrorSummary::NotFound,
ErrorSummary::NotFound, ErrorLevel::Status); ErrorLevel::Status);
constexpr ResultCode ERROR_NOT_FOUND(ErrCodes::NotFound, ErrorModule::FS, ErrorSummary::NotFound, constexpr Result ResultNotFound(ErrCodes::NotFound, ErrorModule::FS, ErrorSummary::NotFound,
ErrorLevel::Status); ErrorLevel::Status);
constexpr ResultCode ERROR_UNEXPECTED_FILE_OR_DIRECTORY(ErrCodes::UnexpectedFileOrDirectory, constexpr Result ResultUnexpectedFileOrDirectory(ErrCodes::UnexpectedFileOrDirectory,
ErrorModule::FS, ErrorSummary::NotSupported, ErrorModule::FS, ErrorSummary::NotSupported,
ErrorLevel::Usage); ErrorLevel::Usage);
constexpr ResultCode ERROR_UNEXPECTED_FILE_OR_DIRECTORY_SDMC(ErrCodes::NotAFile, ErrorModule::FS, constexpr Result ResultUnexpectedFileOrDirectorySdmc(ErrCodes::NotAFile, ErrorModule::FS,
ErrorSummary::Canceled, ErrorSummary::Canceled, ErrorLevel::Status);
ErrorLevel::Status); constexpr Result ResultDirectoryAlreadyExists(ErrCodes::DirectoryAlreadyExists, ErrorModule::FS,
constexpr ResultCode ERROR_DIRECTORY_ALREADY_EXISTS(ErrCodes::DirectoryAlreadyExists, ErrorSummary::NothingHappened, ErrorLevel::Status);
ErrorModule::FS, ErrorSummary::NothingHappened, constexpr Result ResultFileAlreadyExists(ErrCodes::FileAlreadyExists, ErrorModule::FS,
ErrorLevel::Status); ErrorSummary::NothingHappened, ErrorLevel::Status);
constexpr ResultCode ERROR_FILE_ALREADY_EXISTS(ErrCodes::FileAlreadyExists, ErrorModule::FS, constexpr Result ResultAlreadyExists(ErrCodes::AlreadyExists, ErrorModule::FS,
ErrorSummary::NothingHappened, ErrorLevel::Status); ErrorSummary::NothingHappened, ErrorLevel::Status);
constexpr ResultCode ERROR_ALREADY_EXISTS(ErrCodes::AlreadyExists, ErrorModule::FS, constexpr Result ResultDirectoryNotEmpty(ErrCodes::DirectoryNotEmpty, ErrorModule::FS,
ErrorSummary::NothingHappened, ErrorLevel::Status); ErrorSummary::Canceled, ErrorLevel::Status);
constexpr ResultCode ERROR_DIRECTORY_NOT_EMPTY(ErrCodes::DirectoryNotEmpty, ErrorModule::FS, constexpr Result ResultGamecardNotInserted(ErrCodes::GameCardNotInserted, 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); ErrorSummary::NotFound, ErrorLevel::Status);
constexpr ResultCode ERROR_COMMAND_NOT_ALLOWED(ErrCodes::CommandNotAllowed, ErrorModule::FS, constexpr Result ResultIncorrectExefsReadSize(ErrCodes::IncorrectExeFSReadSize, ErrorModule::FS,
ErrorSummary::WrongArgument, ErrorLevel::Permanent); ErrorSummary::NotSupported, ErrorLevel::Usage);
constexpr ResultCode ERROR_EXEFS_SECTION_NOT_FOUND(ErrCodes::ExeFSSectionNotFound, ErrorModule::FS, constexpr Result ResultRomfsNotFound(ErrCodes::RomFSNotFound, ErrorModule::FS,
ErrorSummary::NotFound, ErrorLevel::Status); ErrorSummary::NotFound, ErrorLevel::Status);
constexpr ResultCode ERROR_INSUFFICIENT_SPACE(ErrCodes::InsufficientSpace, ErrorModule::FS, constexpr Result ResultCommandNotAllowed(ErrCodes::CommandNotAllowed, ErrorModule::FS,
ErrorSummary::OutOfResource, ErrorLevel::Status); ErrorSummary::WrongArgument, ErrorLevel::Permanent);
constexpr Result ResultExefsSectionNotFound(ErrCodes::ExeFSSectionNotFound, ErrorModule::FS,
ErrorSummary::NotFound, ErrorLevel::Status);
constexpr Result ResultInsufficientSpace(ErrCodes::InsufficientSpace, ErrorModule::FS,
ErrorSummary::OutOfResource, ErrorLevel::Status);
/// Returned when a function is passed an invalid archive handle. /// Returned when a function is passed an invalid archive handle.
constexpr ResultCode ERR_INVALID_ARCHIVE_HANDLE(ErrCodes::ArchiveNotMounted, ErrorModule::FS, constexpr Result ResultInvalidArchiveHandle(ErrCodes::ArchiveNotMounted, ErrorModule::FS,
ErrorSummary::NotFound, ErrorSummary::NotFound,
ErrorLevel::Status); // 0xC8804465 ErrorLevel::Status); // 0xC8804465
constexpr ResultCode ERR_WRITE_BEYOND_END(ErrCodes::WriteBeyondEnd, ErrorModule::FS, constexpr Result ResultWriteBeyondEnd(ErrCodes::WriteBeyondEnd, ErrorModule::FS,
ErrorSummary::InvalidArgument, ErrorLevel::Usage); ErrorSummary::InvalidArgument, ErrorLevel::Usage);
/** /**
* Variant of ERROR_NOT_FOUND returned in some places in the code. Unknown if these usages are * Variant of ResultNotFound returned in some places in the code. Unknown if these usages are
* correct or a bug. * correct or a bug.
*/ */
constexpr ResultCode ERR_NOT_FOUND_INVALID_STATE(ErrCodes::NotFound, ErrorModule::FS, constexpr Result ResultNotFoundInvalidState(ErrCodes::NotFound, ErrorModule::FS,
ErrorSummary::InvalidState, ErrorLevel::Status); ErrorSummary::InvalidState, ErrorLevel::Status);
constexpr ResultCode ERR_NOT_FORMATTED(ErrCodes::NotFormatted, ErrorModule::FS, constexpr Result ResultNotFormatted(ErrCodes::NotFormatted, ErrorModule::FS,
ErrorSummary::InvalidState, ErrorLevel::Status); ErrorSummary::InvalidState, ErrorLevel::Status);
} // namespace FileSys } // namespace FileSys

View file

@ -34,50 +34,50 @@ ResultVal<std::unique_ptr<FileBackend>> IVFCArchive::OpenFile(const Path& path,
return std::make_unique<IVFCFile>(romfs_file, std::move(delay_generator)); return std::make_unique<IVFCFile>(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()); LOG_CRITICAL(Service_FS, "Attempted to delete a file from an IVFC archive ({}).", GetName());
// TODO(Subv): Verify error code // TODO(Subv): Verify error code
return ResultCode(ErrorDescription::NoData, ErrorModule::FS, ErrorSummary::Canceled, return Result(ErrorDescription::NoData, ErrorModule::FS, ErrorSummary::Canceled,
ErrorLevel::Status); 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()); LOG_CRITICAL(Service_FS, "Attempted to rename a file within an IVFC archive ({}).", GetName());
// TODO(wwylele): Use correct error code // TODO(wwylele): Use correct error code
return RESULT_UNKNOWN; return ResultUnknown;
} }
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 ({}).", LOG_CRITICAL(Service_FS, "Attempted to delete a directory from an IVFC archive ({}).",
GetName()); GetName());
// TODO(wwylele): Use correct error code // TODO(wwylele): Use correct error code
return RESULT_UNKNOWN; return ResultUnknown;
} }
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 ({}).", LOG_CRITICAL(Service_FS, "Attempted to delete a directory from an IVFC archive ({}).",
GetName()); GetName());
// TODO(wwylele): Use correct error code // TODO(wwylele): Use correct error code
return RESULT_UNKNOWN; return ResultUnknown;
} }
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()); LOG_CRITICAL(Service_FS, "Attempted to create a file in an IVFC archive ({}).", GetName());
// TODO: Verify error code // TODO: Verify error code
return ResultCode(ErrorDescription::NotAuthorized, ErrorModule::FS, ErrorSummary::NotSupported, return Result(ErrorDescription::NotAuthorized, ErrorModule::FS, ErrorSummary::NotSupported,
ErrorLevel::Permanent); 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()); LOG_CRITICAL(Service_FS, "Attempted to create a directory in an IVFC archive ({}).", GetName());
// TODO(wwylele): Use correct error code // TODO(wwylele): Use correct error code
return RESULT_UNKNOWN; return ResultUnknown;
} }
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()); LOG_CRITICAL(Service_FS, "Attempted to rename a file within an IVFC archive ({}).", GetName());
// TODO(wwylele): Use correct error code // TODO(wwylele): Use correct error code
return RESULT_UNKNOWN; return ResultUnknown;
} }
ResultVal<std::unique_ptr<DirectoryBackend>> IVFCArchive::OpenDirectory(const Path& path) const { ResultVal<std::unique_ptr<DirectoryBackend>> IVFCArchive::OpenDirectory(const Path& path) const {

View file

@ -103,13 +103,13 @@ public:
ResultVal<std::unique_ptr<FileBackend>> OpenFile(const Path& path, ResultVal<std::unique_ptr<FileBackend>> OpenFile(const Path& path,
const Mode& mode) const override; const Mode& mode) const override;
ResultCode DeleteFile(const Path& path) const override; Result DeleteFile(const Path& path) const override;
ResultCode RenameFile(const Path& src_path, const Path& dest_path) const override; Result RenameFile(const Path& src_path, const Path& dest_path) const override;
ResultCode DeleteDirectory(const Path& path) const override; Result DeleteDirectory(const Path& path) const override;
ResultCode DeleteDirectoryRecursively(const Path& path) const override; Result DeleteDirectoryRecursively(const Path& path) const override;
ResultCode CreateFile(const Path& path, u64 size) const override; Result CreateFile(const Path& path, u64 size) const override;
ResultCode CreateDirectory(const Path& path) const override; Result CreateDirectory(const Path& path) const override;
ResultCode RenameDirectory(const Path& src_path, const Path& dest_path) const override; Result RenameDirectory(const Path& src_path, const Path& dest_path) const override;
ResultVal<std::unique_ptr<DirectoryBackend>> OpenDirectory(const Path& path) const override; ResultVal<std::unique_ptr<DirectoryBackend>> OpenDirectory(const Path& path) const override;
u64 GetFreeBytes() const override; u64 GetFreeBytes() const override;

View file

@ -43,17 +43,17 @@ ResultVal<std::unique_ptr<FileBackend>> SaveDataArchive::OpenFile(const Path& pa
if (!path_parser.IsValid()) { if (!path_parser.IsValid()) {
LOG_ERROR(Service_FS, "Invalid path {}", path.DebugStr()); LOG_ERROR(Service_FS, "Invalid path {}", path.DebugStr());
return ERROR_INVALID_PATH; return ResultInvalidPath;
} }
if (mode.hex == 0) { if (mode.hex == 0) {
LOG_ERROR(Service_FS, "Empty open mode"); LOG_ERROR(Service_FS, "Empty open mode");
return ERROR_UNSUPPORTED_OPEN_FLAGS; return ResultUnsupportedOpenFlags;
} }
if (mode.create_flag && !mode.write_flag) { if (mode.create_flag && !mode.write_flag) {
LOG_ERROR(Service_FS, "Create flag set but write flag not set"); LOG_ERROR(Service_FS, "Create flag set but write flag not set");
return ERROR_UNSUPPORTED_OPEN_FLAGS; return ResultUnsupportedOpenFlags;
} }
const auto full_path = path_parser.BuildHostPath(mount_point); const auto full_path = path_parser.BuildHostPath(mount_point);
@ -61,19 +61,19 @@ ResultVal<std::unique_ptr<FileBackend>> SaveDataArchive::OpenFile(const Path& pa
switch (path_parser.GetHostStatus(mount_point)) { switch (path_parser.GetHostStatus(mount_point)) {
case PathParser::InvalidMountPoint: case PathParser::InvalidMountPoint:
LOG_CRITICAL(Service_FS, "(unreachable) Invalid mount point {}", mount_point); LOG_CRITICAL(Service_FS, "(unreachable) Invalid mount point {}", mount_point);
return ERROR_FILE_NOT_FOUND; return ResultFileNotFound;
case PathParser::PathNotFound: case PathParser::PathNotFound:
LOG_ERROR(Service_FS, "Path not found {}", full_path); LOG_ERROR(Service_FS, "Path not found {}", full_path);
return ERROR_PATH_NOT_FOUND; return ResultPathNotFound;
case PathParser::FileInPath: case PathParser::FileInPath:
case PathParser::DirectoryFound: case PathParser::DirectoryFound:
LOG_ERROR(Service_FS, "Unexpected file or directory in {}", full_path); LOG_ERROR(Service_FS, "Unexpected file or directory in {}", full_path);
return ERROR_UNEXPECTED_FILE_OR_DIRECTORY; return ResultUnexpectedFileOrDirectory;
case PathParser::NotFound: case PathParser::NotFound:
if (!mode.create_flag) { if (!mode.create_flag) {
LOG_ERROR(Service_FS, "Non-existing file {} can't be open without mode create.", LOG_ERROR(Service_FS, "Non-existing file {} can't be open without mode create.",
full_path); full_path);
return ERROR_FILE_NOT_FOUND; return ResultFileNotFound;
} else { } else {
// Create the file // Create the file
FileUtil::CreateEmptyFile(full_path); FileUtil::CreateEmptyFile(full_path);
@ -86,19 +86,19 @@ ResultVal<std::unique_ptr<FileBackend>> SaveDataArchive::OpenFile(const Path& pa
FileUtil::IOFile file(full_path, mode.write_flag ? "r+b" : "rb"); FileUtil::IOFile file(full_path, mode.write_flag ? "r+b" : "rb");
if (!file.IsOpen()) { if (!file.IsOpen()) {
LOG_CRITICAL(Service_FS, "(unreachable) Unknown error opening {}", full_path); LOG_CRITICAL(Service_FS, "(unreachable) Unknown error opening {}", full_path);
return ERROR_FILE_NOT_FOUND; return ResultFileNotFound;
} }
std::unique_ptr<DelayGenerator> delay_generator = std::make_unique<SaveDataDelayGenerator>(); std::unique_ptr<DelayGenerator> delay_generator = std::make_unique<SaveDataDelayGenerator>();
return std::make_unique<DiskFile>(std::move(file), mode, std::move(delay_generator)); return std::make_unique<DiskFile>(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); const PathParser path_parser(path);
if (!path_parser.IsValid()) { if (!path_parser.IsValid()) {
LOG_ERROR(Service_FS, "Invalid path {}", path.DebugStr()); LOG_ERROR(Service_FS, "Invalid path {}", path.DebugStr());
return ERROR_INVALID_PATH; return ResultInvalidPath;
} }
const auto full_path = path_parser.BuildHostPath(mount_point); const auto full_path = path_parser.BuildHostPath(mount_point);
@ -106,110 +106,109 @@ ResultCode SaveDataArchive::DeleteFile(const Path& path) const {
switch (path_parser.GetHostStatus(mount_point)) { switch (path_parser.GetHostStatus(mount_point)) {
case PathParser::InvalidMountPoint: case PathParser::InvalidMountPoint:
LOG_CRITICAL(Service_FS, "(unreachable) Invalid mount point {}", mount_point); LOG_CRITICAL(Service_FS, "(unreachable) Invalid mount point {}", mount_point);
return ERROR_FILE_NOT_FOUND; return ResultFileNotFound;
case PathParser::PathNotFound: case PathParser::PathNotFound:
LOG_ERROR(Service_FS, "Path not found {}", full_path); LOG_ERROR(Service_FS, "Path not found {}", full_path);
return ERROR_PATH_NOT_FOUND; return ResultPathNotFound;
case PathParser::FileInPath: case PathParser::FileInPath:
case PathParser::DirectoryFound: case PathParser::DirectoryFound:
case PathParser::NotFound: case PathParser::NotFound:
LOG_ERROR(Service_FS, "File not found {}", full_path); LOG_ERROR(Service_FS, "File not found {}", full_path);
return ERROR_FILE_NOT_FOUND; return ResultFileNotFound;
case PathParser::FileFound: case PathParser::FileFound:
break; // Expected 'success' case break; // Expected 'success' case
} }
if (FileUtil::Delete(full_path)) { if (FileUtil::Delete(full_path)) {
return RESULT_SUCCESS; return ResultSuccess;
} }
LOG_CRITICAL(Service_FS, "(unreachable) Unknown error deleting {}", full_path); LOG_CRITICAL(Service_FS, "(unreachable) Unknown error deleting {}", full_path);
return ERROR_FILE_NOT_FOUND; return ResultFileNotFound;
} }
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); const PathParser path_parser_src(src_path);
// TODO: Verify these return codes with HW // TODO: Verify these return codes with HW
if (!path_parser_src.IsValid()) { if (!path_parser_src.IsValid()) {
LOG_ERROR(Service_FS, "Invalid src path {}", src_path.DebugStr()); LOG_ERROR(Service_FS, "Invalid src path {}", src_path.DebugStr());
return ERROR_INVALID_PATH; return ResultInvalidPath;
} }
const PathParser path_parser_dest(dest_path); const PathParser path_parser_dest(dest_path);
if (!path_parser_dest.IsValid()) { if (!path_parser_dest.IsValid()) {
LOG_ERROR(Service_FS, "Invalid dest path {}", dest_path.DebugStr()); LOG_ERROR(Service_FS, "Invalid dest path {}", dest_path.DebugStr());
return ERROR_INVALID_PATH; return ResultInvalidPath;
} }
const auto src_path_full = path_parser_src.BuildHostPath(mount_point); const auto src_path_full = path_parser_src.BuildHostPath(mount_point);
const auto dest_path_full = path_parser_dest.BuildHostPath(mount_point); const auto dest_path_full = path_parser_dest.BuildHostPath(mount_point);
if (FileUtil::Rename(src_path_full, dest_path_full)) { if (FileUtil::Rename(src_path_full, dest_path_full)) {
return RESULT_SUCCESS; return ResultSuccess;
} }
// TODO(yuriks): This code probably isn't right, it'll return a Status even if the file didn't // TODO(yuriks): This code probably isn't right, it'll return a Status even if the file didn't
// exist or similar. Verify. // exist or similar. Verify.
return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description return Result(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description
ErrorSummary::NothingHappened, ErrorLevel::Status); ErrorSummary::NothingHappened, ErrorLevel::Status);
} }
template <typename T> template <typename T>
static ResultCode DeleteDirectoryHelper(const Path& path, const std::string& mount_point, static Result DeleteDirectoryHelper(const Path& path, const std::string& mount_point, T deleter) {
T deleter) {
const PathParser path_parser(path); const PathParser path_parser(path);
if (!path_parser.IsValid()) { if (!path_parser.IsValid()) {
LOG_ERROR(Service_FS, "Invalid path {}", path.DebugStr()); LOG_ERROR(Service_FS, "Invalid path {}", path.DebugStr());
return ERROR_INVALID_PATH; return ResultInvalidPath;
} }
if (path_parser.IsRootDirectory()) if (path_parser.IsRootDirectory())
return ERROR_DIRECTORY_NOT_EMPTY; return ResultDirectoryNotEmpty;
const auto full_path = path_parser.BuildHostPath(mount_point); const auto full_path = path_parser.BuildHostPath(mount_point);
switch (path_parser.GetHostStatus(mount_point)) { switch (path_parser.GetHostStatus(mount_point)) {
case PathParser::InvalidMountPoint: case PathParser::InvalidMountPoint:
LOG_CRITICAL(Service_FS, "(unreachable) Invalid mount point {}", mount_point); LOG_CRITICAL(Service_FS, "(unreachable) Invalid mount point {}", mount_point);
return ERROR_PATH_NOT_FOUND; return ResultPathNotFound;
case PathParser::PathNotFound: case PathParser::PathNotFound:
case PathParser::NotFound: case PathParser::NotFound:
LOG_ERROR(Service_FS, "Path not found {}", full_path); LOG_ERROR(Service_FS, "Path not found {}", full_path);
return ERROR_PATH_NOT_FOUND; return ResultPathNotFound;
case PathParser::FileInPath: case PathParser::FileInPath:
case PathParser::FileFound: case PathParser::FileFound:
LOG_ERROR(Service_FS, "Unexpected file or directory {}", full_path); LOG_ERROR(Service_FS, "Unexpected file or directory {}", full_path);
return ERROR_UNEXPECTED_FILE_OR_DIRECTORY; return ResultUnexpectedFileOrDirectory;
case PathParser::DirectoryFound: case PathParser::DirectoryFound:
break; // Expected 'success' case break; // Expected 'success' case
} }
if (deleter(full_path)) { if (deleter(full_path)) {
return RESULT_SUCCESS; return ResultSuccess;
} }
LOG_ERROR(Service_FS, "Directory not empty {}", full_path); LOG_ERROR(Service_FS, "Directory not empty {}", full_path);
return ERROR_DIRECTORY_NOT_EMPTY; return ResultDirectoryNotEmpty;
} }
ResultCode SaveDataArchive::DeleteDirectory(const Path& path) const { Result SaveDataArchive::DeleteDirectory(const Path& path) const {
return DeleteDirectoryHelper(path, mount_point, FileUtil::DeleteDir); return DeleteDirectoryHelper(path, mount_point, FileUtil::DeleteDir);
} }
ResultCode SaveDataArchive::DeleteDirectoryRecursively(const Path& path) const { Result SaveDataArchive::DeleteDirectoryRecursively(const Path& path) const {
return DeleteDirectoryHelper( return DeleteDirectoryHelper(
path, mount_point, [](const std::string& p) { return FileUtil::DeleteDirRecursively(p); }); 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); const PathParser path_parser(path);
if (!path_parser.IsValid()) { if (!path_parser.IsValid()) {
LOG_ERROR(Service_FS, "Invalid path {}", path.DebugStr()); LOG_ERROR(Service_FS, "Invalid path {}", path.DebugStr());
return ERROR_INVALID_PATH; return ResultInvalidPath;
} }
const auto full_path = path_parser.BuildHostPath(mount_point); const auto full_path = path_parser.BuildHostPath(mount_point);
@ -217,44 +216,44 @@ ResultCode SaveDataArchive::CreateFile(const FileSys::Path& path, u64 size) cons
switch (path_parser.GetHostStatus(mount_point)) { switch (path_parser.GetHostStatus(mount_point)) {
case PathParser::InvalidMountPoint: case PathParser::InvalidMountPoint:
LOG_CRITICAL(Service_FS, "(unreachable) Invalid mount point {}", mount_point); LOG_CRITICAL(Service_FS, "(unreachable) Invalid mount point {}", mount_point);
return ERROR_FILE_NOT_FOUND; return ResultFileNotFound;
case PathParser::PathNotFound: case PathParser::PathNotFound:
LOG_ERROR(Service_FS, "Path not found {}", full_path); LOG_ERROR(Service_FS, "Path not found {}", full_path);
return ERROR_PATH_NOT_FOUND; return ResultPathNotFound;
case PathParser::FileInPath: case PathParser::FileInPath:
LOG_ERROR(Service_FS, "Unexpected file in path {}", full_path); LOG_ERROR(Service_FS, "Unexpected file in path {}", full_path);
return ERROR_UNEXPECTED_FILE_OR_DIRECTORY; return ResultUnexpectedFileOrDirectory;
case PathParser::DirectoryFound: case PathParser::DirectoryFound:
case PathParser::FileFound: case PathParser::FileFound:
LOG_ERROR(Service_FS, "{} already exists", full_path); LOG_ERROR(Service_FS, "{} already exists", full_path);
return ERROR_FILE_ALREADY_EXISTS; return ResultFileAlreadyExists;
case PathParser::NotFound: case PathParser::NotFound:
break; // Expected 'success' case break; // Expected 'success' case
} }
if (size == 0) { if (size == 0) {
FileUtil::CreateEmptyFile(full_path); FileUtil::CreateEmptyFile(full_path);
return RESULT_SUCCESS; return ResultSuccess;
} }
FileUtil::IOFile file(full_path, "wb"); FileUtil::IOFile file(full_path, "wb");
// Creates a sparse file (or a normal file on filesystems without the concept of sparse files) // Creates a sparse file (or a normal file on filesystems without the concept of sparse files)
// We do this by seeking to the right size, then writing a single null byte. // We do this by seeking to the right size, then writing a single null byte.
if (file.Seek(size - 1, SEEK_SET) && file.WriteBytes("", 1) == 1) { if (file.Seek(size - 1, SEEK_SET) && file.WriteBytes("", 1) == 1) {
return RESULT_SUCCESS; return ResultSuccess;
} }
LOG_ERROR(Service_FS, "Too large file"); LOG_ERROR(Service_FS, "Too large file");
return ResultCode(ErrorDescription::TooLarge, ErrorModule::FS, ErrorSummary::OutOfResource, return Result(ErrorDescription::TooLarge, ErrorModule::FS, ErrorSummary::OutOfResource,
ErrorLevel::Info); ErrorLevel::Info);
} }
ResultCode SaveDataArchive::CreateDirectory(const Path& path) const { Result SaveDataArchive::CreateDirectory(const Path& path) const {
const PathParser path_parser(path); const PathParser path_parser(path);
if (!path_parser.IsValid()) { if (!path_parser.IsValid()) {
LOG_ERROR(Service_FS, "Invalid path {}", path.DebugStr()); LOG_ERROR(Service_FS, "Invalid path {}", path.DebugStr());
return ERROR_INVALID_PATH; return ResultInvalidPath;
} }
const auto full_path = path_parser.BuildHostPath(mount_point); const auto full_path = path_parser.BuildHostPath(mount_point);
@ -262,57 +261,57 @@ ResultCode SaveDataArchive::CreateDirectory(const Path& path) const {
switch (path_parser.GetHostStatus(mount_point)) { switch (path_parser.GetHostStatus(mount_point)) {
case PathParser::InvalidMountPoint: case PathParser::InvalidMountPoint:
LOG_CRITICAL(Service_FS, "(unreachable) Invalid mount point {}", mount_point); LOG_CRITICAL(Service_FS, "(unreachable) Invalid mount point {}", mount_point);
return ERROR_FILE_NOT_FOUND; return ResultFileNotFound;
case PathParser::PathNotFound: case PathParser::PathNotFound:
LOG_ERROR(Service_FS, "Path not found {}", full_path); LOG_ERROR(Service_FS, "Path not found {}", full_path);
return ERROR_PATH_NOT_FOUND; return ResultPathNotFound;
case PathParser::FileInPath: case PathParser::FileInPath:
LOG_ERROR(Service_FS, "Unexpected file in path {}", full_path); LOG_ERROR(Service_FS, "Unexpected file in path {}", full_path);
return ERROR_UNEXPECTED_FILE_OR_DIRECTORY; return ResultUnexpectedFileOrDirectory;
case PathParser::DirectoryFound: case PathParser::DirectoryFound:
case PathParser::FileFound: case PathParser::FileFound:
LOG_ERROR(Service_FS, "{} already exists", full_path); LOG_ERROR(Service_FS, "{} already exists", full_path);
return ERROR_DIRECTORY_ALREADY_EXISTS; return ResultDirectoryAlreadyExists;
case PathParser::NotFound: case PathParser::NotFound:
break; // Expected 'success' case break; // Expected 'success' case
} }
if (FileUtil::CreateDir(mount_point + path.AsString())) { if (FileUtil::CreateDir(mount_point + path.AsString())) {
return RESULT_SUCCESS; return ResultSuccess;
} }
LOG_CRITICAL(Service_FS, "(unreachable) Unknown error creating {}", mount_point); LOG_CRITICAL(Service_FS, "(unreachable) Unknown error creating {}", mount_point);
return ResultCode(ErrorDescription::NoData, ErrorModule::FS, ErrorSummary::Canceled, return Result(ErrorDescription::NoData, ErrorModule::FS, ErrorSummary::Canceled,
ErrorLevel::Status); 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); const PathParser path_parser_src(src_path);
// TODO: Verify these return codes with HW // TODO: Verify these return codes with HW
if (!path_parser_src.IsValid()) { if (!path_parser_src.IsValid()) {
LOG_ERROR(Service_FS, "Invalid src path {}", src_path.DebugStr()); LOG_ERROR(Service_FS, "Invalid src path {}", src_path.DebugStr());
return ERROR_INVALID_PATH; return ResultInvalidPath;
} }
const PathParser path_parser_dest(dest_path); const PathParser path_parser_dest(dest_path);
if (!path_parser_dest.IsValid()) { if (!path_parser_dest.IsValid()) {
LOG_ERROR(Service_FS, "Invalid dest path {}", dest_path.DebugStr()); LOG_ERROR(Service_FS, "Invalid dest path {}", dest_path.DebugStr());
return ERROR_INVALID_PATH; return ResultInvalidPath;
} }
const auto src_path_full = path_parser_src.BuildHostPath(mount_point); const auto src_path_full = path_parser_src.BuildHostPath(mount_point);
const auto dest_path_full = path_parser_dest.BuildHostPath(mount_point); const auto dest_path_full = path_parser_dest.BuildHostPath(mount_point);
if (FileUtil::Rename(src_path_full, dest_path_full)) { if (FileUtil::Rename(src_path_full, dest_path_full)) {
return RESULT_SUCCESS; return ResultSuccess;
} }
// TODO(yuriks): This code probably isn't right, it'll return a Status even if the file didn't // TODO(yuriks): This code probably isn't right, it'll return a Status even if the file didn't
// exist or similar. Verify. // exist or similar. Verify.
return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description return Result(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description
ErrorSummary::NothingHappened, ErrorLevel::Status); ErrorSummary::NothingHappened, ErrorLevel::Status);
} }
ResultVal<std::unique_ptr<DirectoryBackend>> SaveDataArchive::OpenDirectory( ResultVal<std::unique_ptr<DirectoryBackend>> SaveDataArchive::OpenDirectory(
@ -321,7 +320,7 @@ ResultVal<std::unique_ptr<DirectoryBackend>> SaveDataArchive::OpenDirectory(
if (!path_parser.IsValid()) { if (!path_parser.IsValid()) {
LOG_ERROR(Service_FS, "Invalid path {}", path.DebugStr()); LOG_ERROR(Service_FS, "Invalid path {}", path.DebugStr());
return ERROR_INVALID_PATH; return ResultInvalidPath;
} }
const auto full_path = path_parser.BuildHostPath(mount_point); const auto full_path = path_parser.BuildHostPath(mount_point);
@ -329,15 +328,15 @@ ResultVal<std::unique_ptr<DirectoryBackend>> SaveDataArchive::OpenDirectory(
switch (path_parser.GetHostStatus(mount_point)) { switch (path_parser.GetHostStatus(mount_point)) {
case PathParser::InvalidMountPoint: case PathParser::InvalidMountPoint:
LOG_CRITICAL(Service_FS, "(unreachable) Invalid mount point {}", mount_point); LOG_CRITICAL(Service_FS, "(unreachable) Invalid mount point {}", mount_point);
return ERROR_FILE_NOT_FOUND; return ResultFileNotFound;
case PathParser::PathNotFound: case PathParser::PathNotFound:
case PathParser::NotFound: case PathParser::NotFound:
LOG_ERROR(Service_FS, "Path not found {}", full_path); LOG_ERROR(Service_FS, "Path not found {}", full_path);
return ERROR_PATH_NOT_FOUND; return ResultPathNotFound;
case PathParser::FileInPath: case PathParser::FileInPath:
case PathParser::FileFound: case PathParser::FileFound:
LOG_ERROR(Service_FS, "Unexpected file in path {}", full_path); LOG_ERROR(Service_FS, "Unexpected file in path {}", full_path);
return ERROR_UNEXPECTED_FILE_OR_DIRECTORY; return ResultUnexpectedFileOrDirectory;
case PathParser::DirectoryFound: case PathParser::DirectoryFound:
break; // Expected 'success' case break; // Expected 'success' case
} }

View file

@ -23,13 +23,13 @@ public:
ResultVal<std::unique_ptr<FileBackend>> OpenFile(const Path& path, ResultVal<std::unique_ptr<FileBackend>> OpenFile(const Path& path,
const Mode& mode) const override; const Mode& mode) const override;
ResultCode DeleteFile(const Path& path) const override; Result DeleteFile(const Path& path) const override;
ResultCode RenameFile(const Path& src_path, const Path& dest_path) const override; Result RenameFile(const Path& src_path, const Path& dest_path) const override;
ResultCode DeleteDirectory(const Path& path) const override; Result DeleteDirectory(const Path& path) const override;
ResultCode DeleteDirectoryRecursively(const Path& path) const override; Result DeleteDirectoryRecursively(const Path& path) const override;
ResultCode CreateFile(const Path& path, u64 size) const override; Result CreateFile(const Path& path, u64 size) const override;
ResultCode CreateDirectory(const Path& path) const override; Result CreateDirectory(const Path& path) const override;
ResultCode RenameDirectory(const Path& src_path, const Path& dest_path) const override; Result RenameDirectory(const Path& src_path, const Path& dest_path) const override;
ResultVal<std::unique_ptr<DirectoryBackend>> OpenDirectory(const Path& path) const override; ResultVal<std::unique_ptr<DirectoryBackend>> OpenDirectory(const Path& path) const override;
u64 GetFreeBytes() const override; u64 GetFreeBytes() const override;

View file

@ -26,8 +26,8 @@ static Core::TimingEventType* applet_update_event = nullptr;
/// The interval at which the Applet update callback will be called, 16.6ms /// The interval at which the Applet update callback will be called, 16.6ms
static const u64 applet_update_interval_us = 16666; static const u64 applet_update_interval_us = 16666;
ResultCode Applet::Create(Service::APT::AppletId id, Service::APT::AppletId parent, bool preload, Result Applet::Create(Service::APT::AppletId id, Service::APT::AppletId parent, bool preload,
const std::shared_ptr<Service::APT::AppletManager>& manager) { const std::shared_ptr<Service::APT::AppletManager>& manager) {
switch (id) { switch (id) {
case Service::APT::AppletId::SoftwareKeyboard1: case Service::APT::AppletId::SoftwareKeyboard1:
case Service::APT::AppletId::SoftwareKeyboard2: case Service::APT::AppletId::SoftwareKeyboard2:
@ -48,8 +48,8 @@ ResultCode Applet::Create(Service::APT::AppletId id, Service::APT::AppletId pare
default: default:
LOG_ERROR(Service_APT, "Could not create applet {}", id); LOG_ERROR(Service_APT, "Could not create applet {}", id);
// TODO(Subv): Find the right error code // TODO(Subv): Find the right error code
return ResultCode(ErrorDescription::NotFound, ErrorModule::Applet, return Result(ErrorDescription::NotFound, ErrorModule::Applet, ErrorSummary::NotSupported,
ErrorSummary::NotSupported, ErrorLevel::Permanent); ErrorLevel::Permanent);
} }
Service::APT::AppletAttributes attributes; Service::APT::AppletAttributes attributes;
@ -66,7 +66,7 @@ ResultCode Applet::Create(Service::APT::AppletId id, Service::APT::AppletId pare
// Schedule the update event // Schedule the update event
Core::System::GetInstance().CoreTiming().ScheduleEvent( Core::System::GetInstance().CoreTiming().ScheduleEvent(
usToCycles(applet_update_interval_us), applet_update_event, static_cast<u64>(id)); usToCycles(applet_update_interval_us), applet_update_event, static_cast<u64>(id));
return RESULT_SUCCESS; return ResultSuccess;
} }
std::shared_ptr<Applet> Applet::Get(Service::APT::AppletId id) { std::shared_ptr<Applet> Applet::Get(Service::APT::AppletId id) {
@ -104,10 +104,10 @@ bool Applet::IsActive() const {
return is_active; return is_active;
} }
ResultCode Applet::ReceiveParameter(const Service::APT::MessageParameter& parameter) { Result Applet::ReceiveParameter(const Service::APT::MessageParameter& parameter) {
switch (parameter.signal) { switch (parameter.signal) {
case Service::APT::SignalType::Wakeup: { case Service::APT::SignalType::Wakeup: {
ResultCode result = Start(parameter); Result result = Start(parameter);
if (!result.IsError()) { if (!result.IsError()) {
is_active = true; is_active = true;
} }

View file

@ -20,10 +20,10 @@ public:
* @param id Id of the applet to create. * @param id Id of the applet to create.
* @param parent Id of the applet's parent. * @param parent Id of the applet's parent.
* @param preload Whether the applet is being preloaded. * @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, static Result Create(Service::APT::AppletId id, Service::APT::AppletId parent, bool preload,
const std::shared_ptr<Service::APT::AppletManager>& manager); const std::shared_ptr<Service::APT::AppletManager>& manager);
/** /**
* Retrieves the Applet instance identified by the specified id. * Retrieves the Applet instance identified by the specified id.
@ -35,9 +35,9 @@ public:
/** /**
* Handles a parameter from the application. * Handles a parameter from the application.
* @param parameter Parameter data to handle. * @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. * Whether the applet is currently running.
@ -62,22 +62,22 @@ protected:
/** /**
* Handles a parameter from the application. * Handles a parameter from the application.
* @param parameter Parameter data to handle. * @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. * Handles the Applet start event, triggered from the application.
* @param parameter Parameter data to handle. * @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, * Sends the LibAppletClosing signal to the application,
* along with the relevant data buffers. * 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 id; ///< Id of this Applet
Service::APT::AppletId parent; ///< Id of this Applet's parent Service::APT::AppletId parent; ///< Id of this Applet's parent

View file

@ -9,12 +9,12 @@
namespace HLE::Applets { 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) { if (parameter.signal != Service::APT::SignalType::Request) {
LOG_ERROR(Service_APT, "unsupported signal {}", parameter.signal); LOG_ERROR(Service_APT, "unsupported signal {}", parameter.signal);
UNIMPLEMENTED(); UNIMPLEMENTED();
// TODO(Subv): Find the right error code // TODO(Subv): Find the right error code
return ResultCode(-1); return ResultUnknown;
} }
// The LibAppJustStarted message contains a buffer with the size of the framebuffer shared // The LibAppJustStarted message contains a buffer with the size of the framebuffer shared
@ -40,10 +40,10 @@ ResultCode ErrEula::ReceiveParameterImpl(const Service::APT::MessageParameter& p
.object = framebuffer_memory, .object = framebuffer_memory,
}); });
return RESULT_SUCCESS; return ResultSuccess;
} }
ResultCode ErrEula::Start(const Service::APT::MessageParameter& parameter) { Result ErrEula::Start(const Service::APT::MessageParameter& parameter) {
startup_param = parameter.buffer; startup_param = parameter.buffer;
// TODO(Subv): Set the expected fields in the response buffer before resending it to the // TODO(Subv): Set the expected fields in the response buffer before resending it to the
@ -52,14 +52,14 @@ ResultCode ErrEula::Start(const Service::APT::MessageParameter& parameter) {
// Let the application know that we're closing. // Let the application know that we're closing.
Finalize(); Finalize();
return RESULT_SUCCESS; return ResultSuccess;
} }
ResultCode ErrEula::Finalize() { Result ErrEula::Finalize() {
std::vector<u8> buffer(startup_param.size()); std::vector<u8> buffer(startup_param.size());
std::fill(buffer.begin(), buffer.end(), 0); std::fill(buffer.begin(), buffer.end(), 0);
CloseApplet(nullptr, buffer); CloseApplet(nullptr, buffer);
return RESULT_SUCCESS; return ResultSuccess;
} }
void ErrEula::Update() {} void ErrEula::Update() {}

View file

@ -15,9 +15,9 @@ public:
std::weak_ptr<Service::APT::AppletManager> manager) std::weak_ptr<Service::APT::AppletManager> manager)
: Applet(id, parent, preload, std::move(manager)) {} : Applet(id, parent, preload, std::move(manager)) {}
ResultCode ReceiveParameterImpl(const Service::APT::MessageParameter& parameter) override; Result ReceiveParameterImpl(const Service::APT::MessageParameter& parameter) override;
ResultCode Start(const Service::APT::MessageParameter& parameter) override; Result Start(const Service::APT::MessageParameter& parameter) override;
ResultCode Finalize() override; Result Finalize() override;
void Update() override; void Update() override;
private: private:

View file

@ -17,12 +17,12 @@
namespace HLE::Applets { 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) { if (parameter.signal != Service::APT::SignalType::Request) {
LOG_ERROR(Service_APT, "unsupported signal {}", parameter.signal); LOG_ERROR(Service_APT, "unsupported signal {}", parameter.signal);
UNIMPLEMENTED(); UNIMPLEMENTED();
// TODO(Subv): Find the right error code // TODO(Subv): Find the right error code
return ResultCode(-1); return ResultUnknown;
} }
// The LibAppJustStarted message contains a buffer with the size of the framebuffer shared // The LibAppJustStarted message contains a buffer with the size of the framebuffer shared
@ -47,10 +47,10 @@ ResultCode MiiSelector::ReceiveParameterImpl(const Service::APT::MessageParamete
.object = framebuffer_memory, .object = framebuffer_memory,
}); });
return RESULT_SUCCESS; return ResultSuccess;
} }
ResultCode MiiSelector::Start(const Service::APT::MessageParameter& parameter) { Result MiiSelector::Start(const Service::APT::MessageParameter& parameter) {
ASSERT_MSG(parameter.buffer.size() == sizeof(config), ASSERT_MSG(parameter.buffer.size() == sizeof(config),
"The size of the parameter (MiiConfig) is wrong"); "The size of the parameter (MiiConfig) is wrong");
@ -63,7 +63,7 @@ ResultCode MiiSelector::Start(const Service::APT::MessageParameter& parameter) {
MiiSelectorConfig frontend_config = ToFrontendConfig(config); MiiSelectorConfig frontend_config = ToFrontendConfig(config);
frontend_applet->Setup(frontend_config); frontend_applet->Setup(frontend_config);
return RESULT_SUCCESS; return ResultSuccess;
} }
void MiiSelector::Update() { void MiiSelector::Update() {
@ -78,11 +78,11 @@ void MiiSelector::Update() {
Finalize(); Finalize();
} }
ResultCode MiiSelector::Finalize() { Result MiiSelector::Finalize() {
std::vector<u8> buffer(sizeof(MiiResult)); std::vector<u8> buffer(sizeof(MiiResult));
std::memcpy(buffer.data(), &result, buffer.size()); std::memcpy(buffer.data(), &result, buffer.size());
CloseApplet(nullptr, buffer); CloseApplet(nullptr, buffer);
return RESULT_SUCCESS; return ResultSuccess;
} }
MiiResult MiiSelector::GetStandardMiiResult() { MiiResult MiiSelector::GetStandardMiiResult() {

View file

@ -66,9 +66,9 @@ public:
std::weak_ptr<Service::APT::AppletManager> manager) std::weak_ptr<Service::APT::AppletManager> manager)
: Applet(id, parent, preload, std::move(manager)) {} : Applet(id, parent, preload, std::move(manager)) {}
ResultCode ReceiveParameterImpl(const Service::APT::MessageParameter& parameter) override; Result ReceiveParameterImpl(const Service::APT::MessageParameter& parameter) override;
ResultCode Start(const Service::APT::MessageParameter& parameter) override; Result Start(const Service::APT::MessageParameter& parameter) override;
ResultCode Finalize() override; Result Finalize() override;
void Update() override; void Update() override;
static MiiResult GetStandardMiiResult(); static MiiResult GetStandardMiiResult();

View file

@ -9,12 +9,12 @@
namespace HLE::Applets { 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) { if (parameter.signal != Service::APT::SignalType::Request) {
LOG_ERROR(Service_APT, "unsupported signal {}", parameter.signal); LOG_ERROR(Service_APT, "unsupported signal {}", parameter.signal);
UNIMPLEMENTED(); UNIMPLEMENTED();
// TODO(Subv): Find the right error code // TODO(Subv): Find the right error code
return ResultCode(-1); return ResultUnknown;
} }
// The Request message contains a buffer with the size of the framebuffer shared // The Request message contains a buffer with the size of the framebuffer shared
@ -40,10 +40,10 @@ ResultCode Mint::ReceiveParameterImpl(const Service::APT::MessageParameter& para
.object = framebuffer_memory, .object = framebuffer_memory,
}); });
return RESULT_SUCCESS; return ResultSuccess;
} }
ResultCode Mint::Start(const Service::APT::MessageParameter& parameter) { Result Mint::Start(const Service::APT::MessageParameter& parameter) {
startup_param = parameter.buffer; startup_param = parameter.buffer;
// TODO(Subv): Set the expected fields in the response buffer before resending it to the // TODO(Subv): Set the expected fields in the response buffer before resending it to the
@ -52,14 +52,14 @@ ResultCode Mint::Start(const Service::APT::MessageParameter& parameter) {
// Let the application know that we're closing // Let the application know that we're closing
Finalize(); Finalize();
return RESULT_SUCCESS; return ResultSuccess;
} }
ResultCode Mint::Finalize() { Result Mint::Finalize() {
std::vector<u8> buffer(startup_param.size()); std::vector<u8> buffer(startup_param.size());
std::fill(buffer.begin(), buffer.end(), 0); std::fill(buffer.begin(), buffer.end(), 0);
CloseApplet(nullptr, buffer); CloseApplet(nullptr, buffer);
return RESULT_SUCCESS; return ResultSuccess;
} }
void Mint::Update() {} void Mint::Update() {}

View file

@ -15,9 +15,9 @@ public:
std::weak_ptr<Service::APT::AppletManager> manager) std::weak_ptr<Service::APT::AppletManager> manager)
: Applet(id, parent, preload, std::move(manager)) {} : Applet(id, parent, preload, std::move(manager)) {}
ResultCode ReceiveParameterImpl(const Service::APT::MessageParameter& parameter) override; Result ReceiveParameterImpl(const Service::APT::MessageParameter& parameter) override;
ResultCode Start(const Service::APT::MessageParameter& parameter) override; Result Start(const Service::APT::MessageParameter& parameter) override;
ResultCode Finalize() override; Result Finalize() override;
void Update() override; void Update() override;
private: private:

View file

@ -19,7 +19,7 @@
namespace HLE::Applets { namespace HLE::Applets {
ResultCode SoftwareKeyboard::ReceiveParameterImpl(Service::APT::MessageParameter const& parameter) { Result SoftwareKeyboard::ReceiveParameterImpl(Service::APT::MessageParameter const& parameter) {
switch (parameter.signal) { switch (parameter.signal) {
case Service::APT::SignalType::Request: { case Service::APT::SignalType::Request: {
// The LibAppJustStarted message contains a buffer with the size of the framebuffer shared // The LibAppJustStarted message contains a buffer with the size of the framebuffer shared
@ -44,7 +44,7 @@ ResultCode SoftwareKeyboard::ReceiveParameterImpl(Service::APT::MessageParameter
.object = framebuffer_memory, .object = framebuffer_memory,
}); });
return RESULT_SUCCESS; return ResultSuccess;
} }
case Service::APT::SignalType::Message: { case Service::APT::SignalType::Message: {
@ -58,7 +58,7 @@ ResultCode SoftwareKeyboard::ReceiveParameterImpl(Service::APT::MessageParameter
case SoftwareKeyboardCallbackResult::OK: case SoftwareKeyboardCallbackResult::OK:
// Finish execution // Finish execution
Finalize(); Finalize();
return RESULT_SUCCESS; return ResultSuccess;
case SoftwareKeyboardCallbackResult::Close: case SoftwareKeyboardCallbackResult::Close:
// Let the frontend display error and quit // Let the frontend display error and quit
@ -66,14 +66,14 @@ ResultCode SoftwareKeyboard::ReceiveParameterImpl(Service::APT::MessageParameter
config.return_code = SoftwareKeyboardResult::BannedInput; config.return_code = SoftwareKeyboardResult::BannedInput;
config.text_offset = config.text_length = 0; config.text_offset = config.text_length = 0;
Finalize(); Finalize();
return RESULT_SUCCESS; return ResultSuccess;
case SoftwareKeyboardCallbackResult::Continue: case SoftwareKeyboardCallbackResult::Continue:
// Let the frontend display error and get input again // Let the frontend display error and get input again
// The input will be sent for validation again on next Update(). // The input will be sent for validation again on next Update().
frontend_applet->ShowError(Common::UTF16BufferToUTF8(config.callback_msg)); frontend_applet->ShowError(Common::UTF16BufferToUTF8(config.callback_msg));
frontend_applet->Execute(ToFrontendConfig(config)); frontend_applet->Execute(ToFrontendConfig(config));
return RESULT_SUCCESS; return ResultSuccess;
default: default:
UNREACHABLE(); UNREACHABLE();
@ -84,12 +84,12 @@ ResultCode SoftwareKeyboard::ReceiveParameterImpl(Service::APT::MessageParameter
LOG_ERROR(Service_APT, "unsupported signal {}", parameter.signal); LOG_ERROR(Service_APT, "unsupported signal {}", parameter.signal);
UNIMPLEMENTED(); UNIMPLEMENTED();
// TODO(Subv): Find the right error code // TODO(Subv): Find the right error code
return ResultCode(-1); return ResultUnknown;
} }
} }
} }
ResultCode SoftwareKeyboard::Start(Service::APT::MessageParameter const& parameter) { Result SoftwareKeyboard::Start(Service::APT::MessageParameter const& parameter) {
ASSERT_MSG(parameter.buffer.size() == sizeof(config), ASSERT_MSG(parameter.buffer.size() == sizeof(config),
"The size of the parameter (SoftwareKeyboardConfig) is wrong"); "The size of the parameter (SoftwareKeyboardConfig) is wrong");
@ -104,7 +104,7 @@ ResultCode SoftwareKeyboard::Start(Service::APT::MessageParameter const& paramet
frontend_applet->Execute(ToFrontendConfig(config)); frontend_applet->Execute(ToFrontendConfig(config));
return RESULT_SUCCESS; return ResultSuccess;
} }
void SoftwareKeyboard::Update() { void SoftwareKeyboard::Update() {
@ -166,12 +166,12 @@ void SoftwareKeyboard::DrawScreenKeyboard() {
// TODO(Subv): Draw the HLE keyboard, for now just do nothing // TODO(Subv): Draw the HLE keyboard, for now just do nothing
} }
ResultCode SoftwareKeyboard::Finalize() { Result SoftwareKeyboard::Finalize() {
std::vector<u8> buffer(sizeof(SoftwareKeyboardConfig)); std::vector<u8> buffer(sizeof(SoftwareKeyboardConfig));
std::memcpy(buffer.data(), &config, buffer.size()); std::memcpy(buffer.data(), &config, buffer.size());
CloseApplet(nullptr, buffer); CloseApplet(nullptr, buffer);
text_memory = nullptr; text_memory = nullptr;
return RESULT_SUCCESS; return ResultSuccess;
} }
Frontend::KeyboardConfig SoftwareKeyboard::ToFrontendConfig( Frontend::KeyboardConfig SoftwareKeyboard::ToFrontendConfig(

View file

@ -179,9 +179,9 @@ public:
std::weak_ptr<Service::APT::AppletManager> manager) std::weak_ptr<Service::APT::AppletManager> manager)
: Applet(id, parent, preload, std::move(manager)) {} : Applet(id, parent, preload, std::move(manager)) {}
ResultCode ReceiveParameterImpl(const Service::APT::MessageParameter& parameter) override; Result ReceiveParameterImpl(const Service::APT::MessageParameter& parameter) override;
ResultCode Start(const Service::APT::MessageParameter& parameter) override; Result Start(const Service::APT::MessageParameter& parameter) override;
ResultCode Finalize() override; Result Finalize() override;
void Update() override; void Update() override;
/** /**

View file

@ -20,8 +20,8 @@ constexpr std::size_t MAX_STATIC_BUFFERS = 16;
// These errors are commonly returned by invalid IPC translations, so alias them here for // These errors are commonly returned by invalid IPC translations, so alias them here for
// convenience. // convenience.
// TODO(yuriks): These will probably go away once translation is implemented inside the kernel. // TODO(yuriks): These will probably go away once translation is implemented inside the kernel.
using Kernel::ERR_INVALID_BUFFER_DESCRIPTOR; using Kernel::ResultInvalidBufferDescriptor;
constexpr auto ERR_INVALID_HANDLE = Kernel::ERR_INVALID_HANDLE_OS; constexpr auto ResultInvalidHandle = Kernel::ResultInvalidHandleOs;
enum DescriptorType : u32 { enum DescriptorType : u32 {
// Buffer related descriptors types (mask : 0x0F) // Buffer related descriptors types (mask : 0x0F)

View file

@ -161,7 +161,7 @@ inline void RequestBuilder::Push(bool value) {
} }
template <> template <>
inline void RequestBuilder::Push(ResultCode value) { inline void RequestBuilder::Push(Result value) {
Push(value.raw); Push(value.raw);
} }
@ -371,8 +371,8 @@ inline bool RequestParser::Pop() {
} }
template <> template <>
inline ResultCode RequestParser::Pop() { inline Result RequestParser::Pop() {
return ResultCode{Pop<u32>()}; return Result{Pop<u32>()};
} }
template <typename T> template <typename T>

View file

@ -108,8 +108,8 @@ void AddressArbiter::WakeUp(ThreadWakeupReason reason, std::shared_ptr<Thread> t
waiting_threads.end()); waiting_threads.end());
}; };
ResultCode AddressArbiter::ArbitrateAddress(std::shared_ptr<Thread> thread, ArbitrationType type, Result AddressArbiter::ArbitrateAddress(std::shared_ptr<Thread> thread, ArbitrationType type,
VAddr address, s32 value, u64 nanoseconds) { VAddr address, s32 value, u64 nanoseconds) {
switch (type) { switch (type) {
// Signal thread(s) waiting for arbitrate address... // Signal thread(s) waiting for arbitrate address...
@ -171,17 +171,16 @@ ResultCode AddressArbiter::ArbitrateAddress(std::shared_ptr<Thread> thread, Arbi
default: default:
LOG_ERROR(Kernel, "unknown type={}", type); LOG_ERROR(Kernel, "unknown type={}", type);
return ERR_INVALID_ENUM_VALUE_FND; return ResultInvalidEnumValueFnd;
} }
// The calls that use a timeout seem to always return a Timeout error even if they did not put // The calls that use a timeout seem to always return a Timeout error even if they did not put
// the thread to sleep // the thread to sleep
if (type == ArbitrationType::WaitIfLessThanWithTimeout || if (type == ArbitrationType::WaitIfLessThanWithTimeout ||
type == ArbitrationType::DecrementAndWaitIfLessThanWithTimeout) { type == ArbitrationType::DecrementAndWaitIfLessThanWithTimeout) {
return ResultTimeout;
return RESULT_TIMEOUT;
} }
return RESULT_SUCCESS; return ResultSuccess;
} }
} // namespace Kernel } // namespace Kernel

View file

@ -55,8 +55,8 @@ public:
std::shared_ptr<ResourceLimit> resource_limit; std::shared_ptr<ResourceLimit> resource_limit;
std::string name; ///< Name of address arbiter object (optional) std::string name; ///< Name of address arbiter object (optional)
ResultCode ArbitrateAddress(std::shared_ptr<Thread> thread, ArbitrationType type, VAddr address, Result ArbitrateAddress(std::shared_ptr<Thread> thread, ArbitrationType type, VAddr address,
s32 value, u64 nanoseconds); s32 value, u64 nanoseconds);
class Callback; class Callback;

View file

@ -20,32 +20,31 @@ namespace Kernel {
ClientPort::ClientPort(KernelSystem& kernel) : Object(kernel), kernel(kernel) {} ClientPort::ClientPort(KernelSystem& kernel) : Object(kernel), kernel(kernel) {}
ClientPort::~ClientPort() = default; ClientPort::~ClientPort() = default;
ResultVal<std::shared_ptr<ClientSession>> ClientPort::Connect() { Result ClientPort::Connect(std::shared_ptr<ClientSession>* out_client_session) {
// Note: Threads do not wait for the server endpoint to call // Note: Threads do not wait for the server endpoint to call
// AcceptSession before returning from this call. // AcceptSession before returning from this call.
if (active_sessions >= max_sessions) { R_UNLESS(active_sessions < max_sessions, ResultMaxConnectionsReached);
return ERR_MAX_CONNECTIONS_REACHED;
}
active_sessions++; active_sessions++;
// Create a new session pair, let the created sessions inherit the parent port's HLE handler. // Create a new session pair, let the created sessions inherit the parent port's HLE handler.
auto [server, client] = kernel.CreateSessionPair(server_port->GetName(), SharedFrom(this)); auto [server, client] = kernel.CreateSessionPair(server_port->GetName(), SharedFrom(this));
if (server_port->hle_handler) if (server_port->hle_handler) {
server_port->hle_handler->ClientConnected(server); server_port->hle_handler->ClientConnected(server);
else } else {
server_port->pending_sessions.push_back(server); server_port->pending_sessions.push_back(server);
}
// Wake the threads waiting on the ServerPort // Wake the threads waiting on the ServerPort
server_port->WakeupAllWaitingThreads(); server_port->WakeupAllWaitingThreads();
return client; *out_client_session = client;
return ResultSuccess;
} }
void ClientPort::ConnectionClosed() { void ClientPort::ConnectionClosed() {
ASSERT(active_sessions > 0); ASSERT(active_sessions > 0);
--active_sessions; --active_sessions;
} }

View file

@ -46,7 +46,7 @@ public:
* waiting on it to awake. * waiting on it to awake.
* @returns ClientSession The client endpoint of the created Session pair, or error code. * @returns ClientSession The client endpoint of the created Session pair, or error code.
*/ */
ResultVal<std::shared_ptr<ClientSession>> Connect(); Result Connect(std::shared_ptr<ClientSession>* out_client_session);
/** /**
* Signifies that a previously active connection has been closed, * Signifies that a previously active connection has been closed,

View file

@ -44,11 +44,10 @@ ClientSession::~ClientSession() {
} }
} }
ResultCode ClientSession::SendSyncRequest(std::shared_ptr<Thread> thread) { Result ClientSession::SendSyncRequest(std::shared_ptr<Thread> thread) {
// Keep ServerSession alive until we're done working with it. // Keep ServerSession alive until we're done working with it.
std::shared_ptr<ServerSession> server = SharedFrom(parent->server); std::shared_ptr<ServerSession> server = SharedFrom(parent->server);
if (server == nullptr) R_UNLESS(server, ResultSessionClosed);
return ERR_SESSION_CLOSED_BY_REMOTE;
// Signal the server session that new data is available // Signal the server session that new data is available
return server->HandleSyncRequest(std::move(thread)); return server->HandleSyncRequest(std::move(thread));

View file

@ -42,9 +42,9 @@ public:
/** /**
* Sends an SyncRequest from the current emulated thread. * Sends an SyncRequest from the current emulated thread.
* @param thread Thread that initiated the request. * @param thread Thread that initiated the request.
* @return ResultCode of the operation. * @return Result of the operation.
*/ */
ResultCode SendSyncRequest(std::shared_ptr<Thread> thread); Result SendSyncRequest(std::shared_ptr<Thread> thread);
std::string name; ///< Name of client port (optional) std::string name; ///< Name of client port (optional)

View file

@ -31,85 +31,83 @@ enum {
// WARNING: The kernel is quite inconsistent in it's usage of errors code. Make sure to always // 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. // double check that the code matches before re-using the constant.
constexpr ResultCode ERR_OUT_OF_HANDLES(ErrCodes::OutOfHandles, ErrorModule::Kernel, constexpr Result ResultOutOfHandles(ErrCodes::OutOfHandles, ErrorModule::Kernel,
ErrorSummary::OutOfResource, ErrorSummary::OutOfResource,
ErrorLevel::Permanent); // 0xD8600413 ErrorLevel::Permanent); // 0xD8600413
constexpr ResultCode ERR_SESSION_CLOSED_BY_REMOTE(ErrCodes::SessionClosedByRemote, ErrorModule::OS, constexpr Result ResultSessionClosed(ErrCodes::SessionClosedByRemote, ErrorModule::OS,
ErrorSummary::Canceled, ErrorSummary::Canceled,
ErrorLevel::Status); // 0xC920181A ErrorLevel::Status); // 0xC920181A
constexpr ResultCode ERR_PORT_NAME_TOO_LONG(ErrCodes::PortNameTooLong, ErrorModule::OS, constexpr Result ResultPortNameTooLong(ErrCodes::PortNameTooLong, ErrorModule::OS,
ErrorSummary::InvalidArgument, ErrorSummary::InvalidArgument,
ErrorLevel::Usage); // 0xE0E0181E ErrorLevel::Usage); // 0xE0E0181E
constexpr ResultCode ERR_WRONG_PERMISSION(ErrCodes::WrongPermission, ErrorModule::OS, constexpr Result ResultWrongPermission(ErrCodes::WrongPermission, ErrorModule::OS,
ErrorSummary::WrongArgument, ErrorLevel::Permanent); ErrorSummary::WrongArgument, ErrorLevel::Permanent);
constexpr ResultCode ERR_INVALID_BUFFER_DESCRIPTOR(ErrCodes::InvalidBufferDescriptor, constexpr Result ResultInvalidBufferDescriptor(ErrCodes::InvalidBufferDescriptor, ErrorModule::OS,
ErrorModule::OS, ErrorSummary::WrongArgument, ErrorSummary::WrongArgument, ErrorLevel::Permanent);
ErrorLevel::Permanent); constexpr Result ResultMaxConnectionsReached(ErrCodes::MaxConnectionsReached, ErrorModule::OS,
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,
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,
ErrorSummary::WouldBlock, ErrorSummary::WouldBlock,
ErrorLevel::Permanent); // 0xD8401823 ErrorLevel::Temporary); // 0xD0401834
constexpr Result ResultNotAuthorized(ErrorDescription::NotAuthorized, ErrorModule::OS,
ErrorSummary::WrongArgument,
ErrorLevel::Permanent); // 0xD9001BEA
constexpr Result ResultInvalidEnumValue(ErrorDescription::InvalidEnumValue, ErrorModule::Kernel,
ErrorSummary::InvalidArgument,
ErrorLevel::Permanent); // 0xD8E007ED
constexpr Result ResultInvalidEnumValueFnd(ErrorDescription::InvalidEnumValue, ErrorModule::FND,
ErrorSummary::InvalidArgument,
ErrorLevel::Permanent); // 0xD8E093ED
constexpr Result ResultInvalidCombination(ErrorDescription::InvalidCombination, ErrorModule::OS,
ErrorSummary::InvalidArgument,
ErrorLevel::Usage); // 0xE0E01BEE
constexpr Result ResultInvalidCombinationKernel(ErrorDescription::InvalidCombination,
ErrorModule::Kernel, ErrorSummary::WrongArgument,
ErrorLevel::Permanent); // 0xD90007EE
constexpr Result ResultMisalignedAddress(ErrorDescription::MisalignedAddress, ErrorModule::OS,
ErrorSummary::InvalidArgument,
ErrorLevel::Usage); // 0xE0E01BF1
constexpr Result ResultMisalignedSize(ErrorDescription::MisalignedSize, ErrorModule::OS,
ErrorSummary::InvalidArgument,
ErrorLevel::Usage); // 0xE0E01BF2
constexpr Result ResultOutOfMemory(ErrorDescription::OutOfMemory, ErrorModule::Kernel,
ErrorSummary::OutOfResource,
ErrorLevel::Permanent); // 0xD86007F3
/// Returned when out of heap or linear heap memory when allocating
constexpr Result ResultOutOfHeapMemory(ErrorDescription::OutOfMemory, ErrorModule::OS,
ErrorSummary::OutOfResource,
ErrorLevel::Status); // 0xC860180A
constexpr Result ResultNotImplemented(ErrorDescription::NotImplemented, ErrorModule::OS,
ErrorSummary::InvalidArgument,
ErrorLevel::Usage); // 0xE0E01BF4
constexpr Result ResultInvalidAddress(ErrorDescription::InvalidAddress, ErrorModule::OS,
ErrorSummary::InvalidArgument,
ErrorLevel::Usage); // 0xE0E01BF5
constexpr Result ResultInvalidAddressState(ErrorDescription::InvalidAddress, ErrorModule::OS,
ErrorSummary::InvalidState,
ErrorLevel::Usage); // 0xE0A01BF5
constexpr Result ResultInvalidPointer(ErrorDescription::InvalidPointer, ErrorModule::Kernel,
ErrorSummary::InvalidArgument,
ErrorLevel::Permanent); // 0xD8E007F6
constexpr Result ResultInvalidHandle(ErrorDescription::InvalidHandle, ErrorModule::Kernel,
ErrorSummary::InvalidArgument,
ErrorLevel::Permanent); // 0xD8E007F7
/// Alternate code returned instead of ResultInvalidHandle in some code paths.
constexpr Result ResultInvalidHandleOs(ErrorDescription::InvalidHandle, ErrorModule::OS,
ErrorSummary::WrongArgument,
ErrorLevel::Permanent); // 0xD9001BF7
constexpr Result ResultNotFound(ErrorDescription::NotFound, ErrorModule::Kernel,
ErrorSummary::NotFound, ErrorLevel::Permanent); // 0xD88007FA
constexpr Result ResultOutOfRange(ErrorDescription::OutOfRange, ErrorModule::OS,
ErrorSummary::InvalidArgument,
ErrorLevel::Usage); // 0xE0E01BFD
constexpr Result ResultOutOfRangeKernel(ErrorDescription::OutOfRange, ErrorModule::Kernel,
ErrorSummary::InvalidArgument,
ErrorLevel::Permanent); // 0xD8E007FD
constexpr Result ResultTimeout(ErrorDescription::Timeout, ErrorModule::OS,
ErrorSummary::StatusChanged, ErrorLevel::Info);
/// Returned when Accept() is called on a port with no sessions to be accepted.
constexpr Result ResultNoPendingSessions(ErrCodes::NoPendingSessions, ErrorModule::OS,
ErrorSummary::WouldBlock,
ErrorLevel::Permanent); // 0xD8401823
} // namespace Kernel } // namespace Kernel

View file

@ -36,8 +36,9 @@ bool Event::ShouldWait(const Thread* thread) const {
void Event::Acquire(Thread* thread) { void Event::Acquire(Thread* thread) {
ASSERT_MSG(!ShouldWait(thread), "object unavailable!"); ASSERT_MSG(!ShouldWait(thread), "object unavailable!");
if (reset_type == ResetType::OneShot) if (reset_type == ResetType::OneShot) {
signaled = false; signaled = false;
}
} }
void Event::Signal() { void Event::Signal() {
@ -52,8 +53,9 @@ void Event::Clear() {
void Event::WakeupAllWaitingThreads() { void Event::WakeupAllWaitingThreads() {
WaitObject::WakeupAllWaitingThreads(); WaitObject::WakeupAllWaitingThreads();
if (reset_type == ResetType::Pulse) if (reset_type == ResetType::Pulse) {
signaled = false; signaled = false;
}
} }
} // namespace Kernel } // namespace Kernel

View file

@ -28,56 +28,48 @@ HandleTable::HandleTable(KernelSystem& kernel) : kernel(kernel) {
HandleTable::~HandleTable() = default; HandleTable::~HandleTable() = default;
ResultVal<Handle> HandleTable::Create(std::shared_ptr<Object> obj) { Result HandleTable::Create(Handle* out_handle, std::shared_ptr<Object> obj) {
DEBUG_ASSERT(obj != nullptr); DEBUG_ASSERT(obj != nullptr);
u16 slot = next_free_slot; u16 slot = next_free_slot;
if (slot >= generations.size()) { R_UNLESS(slot < generations.size(), ResultOutOfHandles);
LOG_ERROR(Kernel, "Unable to allocate Handle, too many slots in use.");
return ERR_OUT_OF_HANDLES;
}
next_free_slot = generations[slot]; next_free_slot = generations[slot];
u16 generation = next_generation++; u16 generation = next_generation++;
// Overflow count so it fits in the 15 bits dedicated to the generation in the handle. // Overflow count so it fits in the 15 bits dedicated to the generation in the handle.
// CTR-OS doesn't use generation 0, so skip straight to 1. // CTR-OS doesn't use generation 0, so skip straight to 1.
if (next_generation >= (1 << 15)) if (next_generation >= (1 << 15)) {
next_generation = 1; next_generation = 1;
}
generations[slot] = generation; generations[slot] = generation;
objects[slot] = std::move(obj); objects[slot] = std::move(obj);
Handle handle = generation | (slot << 15); *out_handle = generation | (slot << 15);
return handle; return ResultSuccess;
} }
ResultVal<Handle> HandleTable::Duplicate(Handle handle) { Result HandleTable::Duplicate(Handle* out_handle, Handle handle) {
std::shared_ptr<Object> object = GetGeneric(handle); std::shared_ptr<Object> object = GetGeneric(handle);
if (object == nullptr) { R_UNLESS(object, ResultInvalidHandle);
LOG_ERROR(Kernel, "Tried to duplicate invalid handle: {:08X}", handle); return Create(out_handle, std::move(object));
return ERR_INVALID_HANDLE;
}
return Create(std::move(object));
} }
ResultCode HandleTable::Close(Handle handle) { Result HandleTable::Close(Handle handle) {
if (!IsValid(handle)) R_UNLESS(IsValid(handle), ResultInvalidHandle);
return ERR_INVALID_HANDLE;
u16 slot = GetSlot(handle);
const u16 slot = GetSlot(handle);
objects[slot] = nullptr; objects[slot] = nullptr;
generations[slot] = next_free_slot; generations[slot] = next_free_slot;
next_free_slot = slot; next_free_slot = slot;
return RESULT_SUCCESS; return ResultSuccess;
} }
bool HandleTable::IsValid(Handle handle) const { bool HandleTable::IsValid(Handle handle) const {
std::size_t slot = GetSlot(handle); const u16 slot = GetSlot(handle);
u16 generation = GetGeneration(handle); const u16 generation = GetGeneration(handle);
return slot < MAX_COUNT && objects[slot] != nullptr && generations[slot] == generation; return slot < MAX_COUNT && objects[slot] != nullptr && generations[slot] == generation;
} }

View file

@ -51,24 +51,24 @@ public:
/** /**
* Allocates a handle for the given object. * Allocates a handle for the given object.
* @return The created Handle or one of the following errors: * @return The created Handle or one of the following errors:
* - `ERR_OUT_OF_HANDLES`: the maximum number of handles has been exceeded. * - `ResultOutOfHandles`: the maximum number of handles has been exceeded.
*/ */
ResultVal<Handle> Create(std::shared_ptr<Object> obj); Result Create(Handle* out_handle, std::shared_ptr<Object> obj);
/** /**
* Returns a new handle that points to the same object as the passed in handle. * Returns a new handle that points to the same object as the passed in handle.
* @return The duplicated Handle or one of the following errors: * @return The duplicated Handle or one of the following errors:
* - `ERR_INVALID_HANDLE`: an invalid handle was passed in. * - `ResultInvalidHandle`: an invalid handle was passed in.
* - Any errors returned by `Create()`. * - Any errors returned by `Create()`.
*/ */
ResultVal<Handle> Duplicate(Handle handle); Result Duplicate(Handle* out_handle, Handle handle);
/** /**
* Closes a handle, removing it from the table and decreasing the object's ref-count. * Closes a handle, removing it from the table and decreasing the object's ref-count.
* @return `RESULT_SUCCESS` or one of the following errors: * @return `ResultSuccess` or one of the following errors:
* - `ERR_INVALID_HANDLE`: an invalid handle was passed in. * - `ResultInvalidHandle`: 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. /// Checks if a handle is valid and points to an existing object.
bool IsValid(Handle handle) const; bool IsValid(Handle handle) const;

View file

@ -126,8 +126,8 @@ void HLERequestContext::AddStaticBuffer(u8 buffer_id, std::vector<u8> data) {
static_buffers[buffer_id] = std::move(data); static_buffers[buffer_id] = std::move(data);
} }
ResultCode HLERequestContext::PopulateFromIncomingCommandBuffer( Result HLERequestContext::PopulateFromIncomingCommandBuffer(const u32_le* src_cmdbuf,
const u32_le* src_cmdbuf, std::shared_ptr<Process> src_process_) { std::shared_ptr<Process> src_process_) {
auto& src_process = *src_process_; auto& src_process = *src_process_;
IPC::Header header{src_cmdbuf[0]}; IPC::Header header{src_cmdbuf[0]};
@ -203,11 +203,11 @@ ResultCode HLERequestContext::PopulateFromIncomingCommandBuffer(
std::move(translated_cmdbuf)); std::move(translated_cmdbuf));
} }
return RESULT_SUCCESS; return ResultSuccess;
} }
ResultCode HLERequestContext::WriteToOutgoingCommandBuffer(u32_le* dst_cmdbuf, Result HLERequestContext::WriteToOutgoingCommandBuffer(u32_le* dst_cmdbuf,
Process& dst_process) const { Process& dst_process) const {
IPC::Header header{cmd_buf[0]}; IPC::Header header{cmd_buf[0]};
std::size_t untranslated_size = 1u + header.normal_params_size; std::size_t untranslated_size = 1u + header.normal_params_size;
@ -239,7 +239,7 @@ ResultCode HLERequestContext::WriteToOutgoingCommandBuffer(u32_le* dst_cmdbuf,
Handle handle = 0; Handle handle = 0;
if (object != nullptr) { if (object != nullptr) {
// TODO(yuriks): Figure out the proper error handling for if this fails // TODO(yuriks): Figure out the proper error handling for if this fails
handle = dst_process.handle_table.Create(object).Unwrap(); R_ASSERT(dst_process.handle_table.Create(std::addressof(handle), object));
} }
dst_cmdbuf[i++] = handle; dst_cmdbuf[i++] = handle;
} }
@ -281,7 +281,7 @@ ResultCode HLERequestContext::WriteToOutgoingCommandBuffer(u32_le* dst_cmdbuf,
std::move(translated_cmdbuf)); std::move(translated_cmdbuf));
} }
return RESULT_SUCCESS; return ResultSuccess;
} }
MappedBuffer& HLERequestContext::GetMappedBuffer(u32 id_from_cmdbuf) { MappedBuffer& HLERequestContext::GetMappedBuffer(u32 id_from_cmdbuf) {

View file

@ -363,10 +363,10 @@ public:
MappedBuffer& GetMappedBuffer(u32 id_from_cmdbuf); MappedBuffer& GetMappedBuffer(u32 id_from_cmdbuf);
/// Populates this context with data from the requesting process/thread. /// Populates this context with data from the requesting process/thread.
ResultCode PopulateFromIncomingCommandBuffer(const u32_le* src_cmdbuf, Result PopulateFromIncomingCommandBuffer(const u32_le* src_cmdbuf,
std::shared_ptr<Process> src_process); std::shared_ptr<Process> src_process);
/// Writes data from this context back to the requesting process/thread. /// 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. /// Reports an unimplemented function.
void ReportUnimplemented() const; void ReportUnimplemented() const;

View file

@ -18,12 +18,11 @@
namespace Kernel { namespace Kernel {
ResultCode TranslateCommandBuffer(Kernel::KernelSystem& kernel, Memory::MemorySystem& memory, Result TranslateCommandBuffer(Kernel::KernelSystem& kernel, Memory::MemorySystem& memory,
std::shared_ptr<Thread> src_thread, std::shared_ptr<Thread> src_thread,
std::shared_ptr<Thread> dst_thread, VAddr src_address, std::shared_ptr<Thread> dst_thread, VAddr src_address,
VAddr dst_address, VAddr dst_address,
std::vector<MappedBufferContext>& mapped_buffer_context, std::vector<MappedBufferContext>& mapped_buffer_context, bool reply) {
bool reply) {
auto src_process = src_thread->owner_process.lock(); auto src_process = src_thread->owner_process.lock();
auto dst_process = dst_thread->owner_process.lock(); auto dst_process = dst_thread->owner_process.lock();
ASSERT(src_process && dst_process); 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 // Note: The real kernel does not check that the number of handles fits into the command
// buffer before writing them, only after finishing. // buffer before writing them, only after finishing.
if (i + num_handles > command_size) { if (i + num_handles > command_size) {
return ResultCode(ErrCodes::CommandTooLarge, ErrorModule::OS, return Result(ErrCodes::CommandTooLarge, ErrorModule::OS,
ErrorSummary::InvalidState, ErrorLevel::Status); ErrorSummary::InvalidState, ErrorLevel::Status);
} }
for (u32 j = 0; j < num_handles; ++j) { for (u32 j = 0; j < num_handles; ++j) {
@ -88,8 +87,8 @@ ResultCode TranslateCommandBuffer(Kernel::KernelSystem& kernel, Memory::MemorySy
continue; continue;
} }
auto result = dst_process->handle_table.Create(std::move(object)); R_ASSERT(dst_process->handle_table.Create(std::addressof(cmd_buf[i++]),
cmd_buf[i++] = result.ValueOr(0); std::move(object)));
} }
break; break;
} }
@ -180,10 +179,10 @@ ResultCode TranslateCommandBuffer(Kernel::KernelSystem& kernel, Memory::MemorySy
next_vma.meminfo_state == MemoryState::Reserved); next_vma.meminfo_state == MemoryState::Reserved);
// Unmap the buffer and guard pages from the source process // 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, src_process->vm_manager.UnmapRange(page_start - Memory::CITRA_PAGE_SIZE,
(num_pages + 2) * Memory::CITRA_PAGE_SIZE); (num_pages + 2) * Memory::CITRA_PAGE_SIZE);
ASSERT(result == RESULT_SUCCESS); ASSERT(result == ResultSuccess);
mapped_buffer_context.erase(found); mapped_buffer_context.erase(found);
@ -216,11 +215,11 @@ ResultCode TranslateCommandBuffer(Kernel::KernelSystem& kernel, Memory::MemorySy
ASSERT(dst_process->vm_manager.ChangeMemoryState( ASSERT(dst_process->vm_manager.ChangeMemoryState(
low_guard_address, Memory::CITRA_PAGE_SIZE, Kernel::MemoryState::Shared, low_guard_address, Memory::CITRA_PAGE_SIZE, Kernel::MemoryState::Shared,
Kernel::VMAPermission::ReadWrite, Kernel::MemoryState::Reserved, Kernel::VMAPermission::ReadWrite, Kernel::MemoryState::Reserved,
Kernel::VMAPermission::None) == RESULT_SUCCESS); Kernel::VMAPermission::None) == ResultSuccess);
ASSERT(dst_process->vm_manager.ChangeMemoryState( ASSERT(dst_process->vm_manager.ChangeMemoryState(
high_guard_address, Memory::CITRA_PAGE_SIZE, Kernel::MemoryState::Shared, high_guard_address, Memory::CITRA_PAGE_SIZE, Kernel::MemoryState::Shared,
Kernel::VMAPermission::ReadWrite, Kernel::MemoryState::Reserved, Kernel::VMAPermission::ReadWrite, Kernel::MemoryState::Reserved,
Kernel::VMAPermission::None) == RESULT_SUCCESS); Kernel::VMAPermission::None) == ResultSuccess);
// Get proper mapped buffer address and store it in the cmd buffer. // Get proper mapped buffer address and store it in the cmd buffer.
target_address += Memory::CITRA_PAGE_SIZE; target_address += Memory::CITRA_PAGE_SIZE;
@ -249,6 +248,6 @@ ResultCode TranslateCommandBuffer(Kernel::KernelSystem& kernel, Memory::MemorySy
memory.WriteBlock(*dst_process, dst_address, cmd_buf.data(), command_size * sizeof(u32)); memory.WriteBlock(*dst_process, dst_address, cmd_buf.data(), command_size * sizeof(u32));
return RESULT_SUCCESS; return ResultSuccess;
} }
} // namespace Kernel } // namespace Kernel

View file

@ -40,10 +40,9 @@ private:
}; };
/// Performs IPC command buffer translation from one process to another. /// Performs IPC command buffer translation from one process to another.
ResultCode TranslateCommandBuffer(KernelSystem& system, Memory::MemorySystem& memory, Result TranslateCommandBuffer(KernelSystem& system, Memory::MemorySystem& memory,
std::shared_ptr<Thread> src_thread, std::shared_ptr<Thread> src_thread,
std::shared_ptr<Thread> dst_thread, VAddr src_address, std::shared_ptr<Thread> dst_thread, VAddr src_address,
VAddr dst_address, VAddr dst_address,
std::vector<MappedBufferContext>& mapped_buffer_context, std::vector<MappedBufferContext>& mapped_buffer_context, bool reply);
bool reply);
} // namespace Kernel } // namespace Kernel

View file

@ -66,7 +66,7 @@ void Mutex::Acquire(Thread* thread) {
lock_count++; 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. // We can only release the mutex if it's held by the calling thread.
if (thread != holding_thread.get()) { if (thread != holding_thread.get()) {
if (holding_thread) { 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 {}", "Tried to release a mutex (owned by thread id {}) from a different thread id {}",
holding_thread->thread_id, thread->thread_id); holding_thread->thread_id, thread->thread_id);
} }
return ResultCode(ErrCodes::WrongLockingThread, ErrorModule::Kernel, return Result(ErrCodes::WrongLockingThread, ErrorModule::Kernel,
ErrorSummary::InvalidArgument, ErrorLevel::Permanent); ErrorSummary::InvalidArgument, ErrorLevel::Permanent);
} }
// Note: It should not be possible for the situation where the mutex has a holding thread with a // 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. // zero lock count to occur. The real kernel still checks for this, so we do too.
if (lock_count <= 0) if (lock_count <= 0)
return ResultCode(ErrorDescription::InvalidResultValue, ErrorModule::Kernel, return Result(ErrorDescription::InvalidResultValue, ErrorModule::Kernel,
ErrorSummary::InvalidState, ErrorLevel::Permanent); ErrorSummary::InvalidState, ErrorLevel::Permanent);
lock_count--; lock_count--;
@ -96,7 +96,7 @@ ResultCode Mutex::Release(Thread* thread) {
kernel.PrepareReschedule(); kernel.PrepareReschedule();
} }
return RESULT_SUCCESS; return ResultSuccess;
} }
void Mutex::AddWaitingThread(std::shared_ptr<Thread> thread) { void Mutex::AddWaitingThread(std::shared_ptr<Thread> thread) {

View file

@ -60,7 +60,7 @@ public:
* @param thread Thread that wants to release the mutex. * @param thread Thread that wants to release the mutex.
* @returns The result code of the operation. * @returns The result code of the operation.
*/ */
ResultCode Release(Thread* thread); Result Release(Thread* thread);
private: private:
KernelSystem& kernel; KernelSystem& kernel;

View file

@ -192,9 +192,12 @@ void Process::Run(s32 main_thread_priority, u32 stack_size) {
return; return;
} }
VAddr out_addr{};
auto MapSegment = [&](CodeSet::Segment& segment, VMAPermission permissions, auto MapSegment = [&](CodeSet::Segment& segment, VMAPermission permissions,
MemoryState memory_state) { MemoryState memory_state) {
HeapAllocate(segment.addr, segment.size, permissions, memory_state, true); HeapAllocate(std::addressof(out_addr), segment.addr, segment.size, permissions,
memory_state, true);
kernel.memory.WriteBlock(*this, segment.addr, codeset->memory.data() + segment.offset, kernel.memory.WriteBlock(*this, segment.addr, codeset->memory.data() + segment.offset,
segment.size); segment.size);
}; };
@ -205,8 +208,8 @@ void Process::Run(s32 main_thread_priority, u32 stack_size) {
MapSegment(codeset->DataSegment(), VMAPermission::ReadWrite, MemoryState::Private); MapSegment(codeset->DataSegment(), VMAPermission::ReadWrite, MemoryState::Private);
// Allocate and map stack // Allocate and map stack
HeapAllocate(Memory::HEAP_VADDR_END - stack_size, stack_size, VMAPermission::ReadWrite, HeapAllocate(std::addressof(out_addr), Memory::HEAP_VADDR_END - stack_size, stack_size,
MemoryState::Locked, true); VMAPermission::ReadWrite, MemoryState::Locked, true);
// Map special address mappings // Map special address mappings
kernel.MapSharedPages(vm_manager); kernel.MapSharedPages(vm_manager);
@ -246,14 +249,14 @@ VAddr Process::GetLinearHeapLimit() const {
return GetLinearHeapBase() + memory_region->size; return GetLinearHeapBase() + memory_region->size;
} }
ResultVal<VAddr> Process::HeapAllocate(VAddr target, u32 size, VMAPermission perms, Result Process::HeapAllocate(VAddr* out_addr, VAddr target, u32 size, VMAPermission perms,
MemoryState memory_state, bool skip_range_check) { MemoryState memory_state, bool skip_range_check) {
LOG_DEBUG(Kernel, "Allocate heap target={:08X}, size={:08X}", target, size); LOG_DEBUG(Kernel, "Allocate heap target={:08X}, size={:08X}", target, size);
if (target < Memory::HEAP_VADDR || target + size > Memory::HEAP_VADDR_END || if (target < Memory::HEAP_VADDR || target + size > Memory::HEAP_VADDR_END ||
target + size < target) { target + size < target) {
if (!skip_range_check) { if (!skip_range_check) {
LOG_ERROR(Kernel, "Invalid heap address"); LOG_ERROR(Kernel, "Invalid heap address");
return ERR_INVALID_ADDRESS; return ResultInvalidAddress;
} }
} }
{ {
@ -261,13 +264,13 @@ ResultVal<VAddr> Process::HeapAllocate(VAddr target, u32 size, VMAPermission per
if (vma->second.type != VMAType::Free || if (vma->second.type != VMAType::Free ||
vma->second.base + vma->second.size < target + size) { vma->second.base + vma->second.size < target + size) {
LOG_ERROR(Kernel, "Trying to allocate already allocated memory"); LOG_ERROR(Kernel, "Trying to allocate already allocated memory");
return ERR_INVALID_ADDRESS_STATE; return ResultInvalidAddressState;
} }
} }
auto allocated_fcram = memory_region->HeapAllocate(size); auto allocated_fcram = memory_region->HeapAllocate(size);
if (allocated_fcram.empty()) { if (allocated_fcram.empty()) {
LOG_ERROR(Kernel, "Not enough space"); LOG_ERROR(Kernel, "Not enough space");
return ERR_OUT_OF_HEAP_MEMORY; return ResultOutOfHeapMemory;
} }
// Maps heap block by block // Maps heap block by block
@ -290,20 +293,19 @@ ResultVal<VAddr> Process::HeapAllocate(VAddr target, u32 size, VMAPermission per
memory_used += size; memory_used += size;
resource_limit->Reserve(ResourceLimitType::Commit, size); resource_limit->Reserve(ResourceLimitType::Commit, size);
return target; *out_addr = target;
return ResultSuccess;
} }
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); LOG_DEBUG(Kernel, "Free heap target={:08X}, size={:08X}", target, size);
if (target < Memory::HEAP_VADDR || target + size > Memory::HEAP_VADDR_END || if (target < Memory::HEAP_VADDR || target + size > Memory::HEAP_VADDR_END ||
target + size < target) { target + size < target) {
LOG_ERROR(Kernel, "Invalid heap address"); LOG_ERROR(Kernel, "Invalid heap address");
return ERR_INVALID_ADDRESS; return ResultInvalidAddress;
} }
if (size == 0) { R_SUCCEED_IF(size == 0);
return RESULT_SUCCESS;
}
// Free heaps block by block // Free heaps block by block
CASCADE_RESULT(auto backing_blocks, vm_manager.GetBackingBlocksForRange(target, size)); CASCADE_RESULT(auto backing_blocks, vm_manager.GetBackingBlocksForRange(target, size));
@ -313,23 +315,23 @@ ResultCode Process::HeapFree(VAddr target, u32 size) {
holding_memory -= MemoryRegionInfo::Interval(backing_offset, backing_offset + block_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()); ASSERT(result.IsSuccess());
memory_used -= size; memory_used -= size;
resource_limit->Release(ResourceLimitType::Commit, size); resource_limit->Release(ResourceLimitType::Commit, size);
return RESULT_SUCCESS; return ResultSuccess;
} }
ResultVal<VAddr> Process::LinearAllocate(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); LOG_DEBUG(Kernel, "Allocate linear heap target={:08X}, size={:08X}", target, size);
u32 physical_offset; u32 physical_offset;
if (target == 0) { if (target == 0) {
auto offset = memory_region->LinearAllocate(size); auto offset = memory_region->LinearAllocate(size);
if (!offset) { if (!offset) {
LOG_ERROR(Kernel, "Not enough space"); LOG_ERROR(Kernel, "Not enough space");
return ERR_OUT_OF_HEAP_MEMORY; return ResultOutOfHeapMemory;
} }
physical_offset = *offset; physical_offset = *offset;
target = physical_offset + GetLinearHeapAreaAddress(); target = physical_offset + GetLinearHeapAreaAddress();
@ -337,7 +339,7 @@ ResultVal<VAddr> Process::LinearAllocate(VAddr target, u32 size, VMAPermission p
if (target < GetLinearHeapBase() || target + size > GetLinearHeapLimit() || if (target < GetLinearHeapBase() || target + size > GetLinearHeapLimit() ||
target + size < target) { target + size < target) {
LOG_ERROR(Kernel, "Invalid linear heap address"); LOG_ERROR(Kernel, "Invalid linear heap address");
return ERR_INVALID_ADDRESS; return ResultInvalidAddress;
} }
// Kernel would crash/return error when target doesn't meet some requirement. // Kernel would crash/return error when target doesn't meet some requirement.
@ -350,7 +352,7 @@ ResultVal<VAddr> Process::LinearAllocate(VAddr target, u32 size, VMAPermission p
physical_offset = target - GetLinearHeapAreaAddress(); // relative to FCRAM physical_offset = target - GetLinearHeapAreaAddress(); // relative to FCRAM
if (!memory_region->LinearAllocate(physical_offset, size)) { if (!memory_region->LinearAllocate(physical_offset, size)) {
LOG_ERROR(Kernel, "Trying to allocate already allocated memory"); LOG_ERROR(Kernel, "Trying to allocate already allocated memory");
return ERR_INVALID_ADDRESS_STATE; return ResultInvalidAddressState;
} }
} }
@ -366,26 +368,20 @@ ResultVal<VAddr> Process::LinearAllocate(VAddr target, u32 size, VMAPermission p
resource_limit->Reserve(ResourceLimitType::Commit, size); resource_limit->Reserve(ResourceLimitType::Commit, size);
LOG_DEBUG(Kernel, "Allocated at target={:08X}", target); LOG_DEBUG(Kernel, "Allocated at target={:08X}", target);
return target; *out_addr = target;
return ResultSuccess;
} }
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); LOG_DEBUG(Kernel, "Free linear heap target={:08X}, size={:08X}", target, size);
if (target < GetLinearHeapBase() || target + size > GetLinearHeapLimit() || if (target < GetLinearHeapBase() || target + size > GetLinearHeapLimit() ||
target + size < target) { target + size < target) {
LOG_ERROR(Kernel, "Invalid linear heap address"); LOG_ERROR(Kernel, "Invalid linear heap address");
return ERR_INVALID_ADDRESS; return ResultInvalidAddress;
} }
if (size == 0) { R_SUCCEED_IF(size == 0);
return RESULT_SUCCESS; R_TRY(vm_manager.UnmapRange(target, size));
}
ResultCode result = vm_manager.UnmapRange(target, size);
if (result.IsError()) {
LOG_ERROR(Kernel, "Trying to free already freed memory");
return result;
}
u32 physical_offset = target - GetLinearHeapAreaAddress(); // relative to FCRAM u32 physical_offset = target - GetLinearHeapAreaAddress(); // relative to FCRAM
memory_region->Free(physical_offset, size); memory_region->Free(physical_offset, size);
@ -394,7 +390,7 @@ ResultCode Process::LinearFree(VAddr target, u32 size) {
memory_used -= size; memory_used -= size;
resource_limit->Release(ResourceLimitType::Commit, size); resource_limit->Release(ResourceLimitType::Commit, size);
return RESULT_SUCCESS; return ResultSuccess;
} }
ResultVal<VAddr> Process::AllocateThreadLocalStorage() { ResultVal<VAddr> Process::AllocateThreadLocalStorage() {
@ -435,7 +431,7 @@ ResultVal<VAddr> Process::AllocateThreadLocalStorage() {
if (!offset) { if (!offset) {
LOG_ERROR(Kernel_SVC, LOG_ERROR(Kernel_SVC,
"Not enough space in BASE linear region to allocate a new TLS page"); "Not enough space in BASE linear region to allocate a new TLS page");
return ERR_OUT_OF_MEMORY; return ResultOutOfMemory;
} }
holding_tls_memory += holding_tls_memory +=
@ -467,14 +463,13 @@ ResultVal<VAddr> Process::AllocateThreadLocalStorage() {
return tls_address; return tls_address;
} }
ResultCode Process::Map(VAddr target, VAddr source, u32 size, VMAPermission perms, Result Process::Map(VAddr target, VAddr source, u32 size, VMAPermission perms, bool privileged) {
bool privileged) {
LOG_DEBUG(Kernel, "Map memory target={:08X}, source={:08X}, size={:08X}, perms={:08X}", target, LOG_DEBUG(Kernel, "Map memory target={:08X}, source={:08X}, size={:08X}, perms={:08X}", target,
source, size, perms); source, size, perms);
if (!privileged && (source < Memory::HEAP_VADDR || source + size > Memory::HEAP_VADDR_END || if (!privileged && (source < Memory::HEAP_VADDR || source + size > Memory::HEAP_VADDR_END ||
source + size < source)) { source + size < source)) {
LOG_ERROR(Kernel, "Invalid source address"); LOG_ERROR(Kernel, "Invalid source address");
return ERR_INVALID_ADDRESS; return ResultInvalidAddress;
} }
// TODO(wwylele): check target address range. Is it also restricted to heap region? // TODO(wwylele): check target address range. Is it also restricted to heap region?
@ -489,17 +484,17 @@ ResultCode Process::Map(VAddr target, VAddr source, u32 size, VMAPermission perm
VMAPermission::ReadWrite, VMAPermission::ReadWrite,
MemoryState::AliasCode, perms); MemoryState::AliasCode, perms);
} else { } else {
return ERR_INVALID_ADDRESS; return ResultInvalidAddress;
} }
} else { } else {
return ERR_INVALID_ADDRESS_STATE; return ResultInvalidAddressState;
} }
} }
auto vma = vm_manager.FindVMA(target); auto vma = vm_manager.FindVMA(target);
if (vma->second.type != VMAType::Free || vma->second.base + vma->second.size < target + size) { if (vma->second.type != VMAType::Free || vma->second.base + vma->second.size < target + size) {
LOG_ERROR(Kernel, "Trying to map to already allocated memory"); LOG_ERROR(Kernel, "Trying to map to already allocated memory");
return ERR_INVALID_ADDRESS_STATE; return ResultInvalidAddressState;
} }
MemoryState source_state = privileged ? MemoryState::Locked : MemoryState::Aliased; MemoryState source_state = privileged ? MemoryState::Locked : MemoryState::Aliased;
@ -507,8 +502,8 @@ ResultCode Process::Map(VAddr target, VAddr source, u32 size, VMAPermission perm
VMAPermission source_perm = privileged ? VMAPermission::None : VMAPermission::ReadWrite; VMAPermission source_perm = privileged ? VMAPermission::None : VMAPermission::ReadWrite;
// Mark source region as Aliased // Mark source region as Aliased
CASCADE_CODE(vm_manager.ChangeMemoryState(source, size, MemoryState::Private, R_TRY(vm_manager.ChangeMemoryState(source, size, MemoryState::Private, VMAPermission::ReadWrite,
VMAPermission::ReadWrite, source_state, source_perm)); source_state, source_perm));
CASCADE_RESULT(auto backing_blocks, vm_manager.GetBackingBlocksForRange(source, size)); CASCADE_RESULT(auto backing_blocks, vm_manager.GetBackingBlocksForRange(source, size));
VAddr interval_target = target; VAddr interval_target = target;
@ -520,16 +515,15 @@ ResultCode Process::Map(VAddr target, VAddr source, u32 size, VMAPermission perm
interval_target += block_size; interval_target += block_size;
} }
return RESULT_SUCCESS; return ResultSuccess;
} }
ResultCode Process::Unmap(VAddr target, VAddr source, u32 size, VMAPermission perms, Result Process::Unmap(VAddr target, VAddr source, u32 size, VMAPermission perms, bool privileged) {
bool privileged) {
LOG_DEBUG(Kernel, "Unmap memory target={:08X}, source={:08X}, size={:08X}, perms={:08X}", LOG_DEBUG(Kernel, "Unmap memory target={:08X}, source={:08X}, size={:08X}, perms={:08X}",
target, source, size, perms); target, source, size, perms);
if (!privileged && (source < Memory::HEAP_VADDR || source + size > Memory::HEAP_VADDR_END || if (!privileged && (source < Memory::HEAP_VADDR || source + size > Memory::HEAP_VADDR_END ||
source + size < source)) { source + size < source)) {
LOG_ERROR(Kernel, "Invalid source address"); LOG_ERROR(Kernel, "Invalid source address");
return ERR_INVALID_ADDRESS; return ResultInvalidAddress;
} }
// TODO(wwylele): check target address range. Is it also restricted to heap region? // TODO(wwylele): check target address range. Is it also restricted to heap region?
@ -543,10 +537,10 @@ ResultCode Process::Unmap(VAddr target, VAddr source, u32 size, VMAPermission pe
VMAPermission::None, MemoryState::Private, VMAPermission::None, MemoryState::Private,
perms); perms);
} else { } else {
return ERR_INVALID_ADDRESS; return ResultInvalidAddress;
} }
} else { } else {
return ERR_INVALID_ADDRESS_STATE; return ResultInvalidAddressState;
} }
} }
@ -555,13 +549,13 @@ ResultCode Process::Unmap(VAddr target, VAddr source, u32 size, VMAPermission pe
MemoryState source_state = privileged ? MemoryState::Locked : MemoryState::Aliased; MemoryState source_state = privileged ? MemoryState::Locked : MemoryState::Aliased;
CASCADE_CODE(vm_manager.UnmapRange(target, size)); R_TRY(vm_manager.UnmapRange(target, size));
// Change back source region state. Note that the permission is reprotected according to param // Change back source region state. Note that the permission is reprotected according to param
CASCADE_CODE(vm_manager.ChangeMemoryState(source, size, source_state, VMAPermission::None, R_TRY(vm_manager.ChangeMemoryState(source, size, source_state, VMAPermission::None,
MemoryState::Private, perms)); MemoryState::Private, perms));
return RESULT_SUCCESS; return ResultSuccess;
} }
void Process::FreeAllMemory() { void Process::FreeAllMemory() {

View file

@ -231,20 +231,19 @@ public:
VAddr GetLinearHeapBase() const; VAddr GetLinearHeapBase() const;
VAddr GetLinearHeapLimit() const; VAddr GetLinearHeapLimit() const;
ResultVal<VAddr> HeapAllocate(VAddr target, u32 size, VMAPermission perms, Result HeapAllocate(VAddr* out_addr, VAddr target, u32 size, VMAPermission perms,
MemoryState memory_state = MemoryState::Private, MemoryState memory_state = MemoryState::Private,
bool skip_range_check = false); bool skip_range_check = false);
ResultCode HeapFree(VAddr target, u32 size); Result HeapFree(VAddr target, u32 size);
ResultVal<VAddr> LinearAllocate(VAddr target, u32 size, VMAPermission perms); Result LinearAllocate(VAddr* out_addr, VAddr target, u32 size, VMAPermission perms);
ResultCode LinearFree(VAddr target, u32 size); Result LinearFree(VAddr target, u32 size);
ResultVal<VAddr> AllocateThreadLocalStorage(); ResultVal<VAddr> AllocateThreadLocalStorage();
ResultCode Map(VAddr target, VAddr source, u32 size, VMAPermission perms, Result Map(VAddr target, VAddr source, u32 size, VMAPermission perms, bool privileged = false);
bool privileged = false); Result Unmap(VAddr target, VAddr source, u32 size, VMAPermission perms,
ResultCode Unmap(VAddr target, VAddr source, u32 size, VMAPermission perms, bool privileged = false);
bool privileged = false);
private: private:
void FreeAllMemory(); void FreeAllMemory();

View file

@ -26,9 +26,7 @@ ResultVal<std::shared_ptr<Semaphore>> KernelSystem::CreateSemaphore(s32 initial_
s32 max_count, s32 max_count,
std::string name) { std::string name) {
if (initial_count > max_count) { R_UNLESS(initial_count <= max_count, ResultInvalidCombinationKernel);
return ERR_INVALID_COMBINATION_KERNEL;
}
// When the semaphore is created, some slots are reserved for other threads, // When the semaphore is created, some slots are reserved for other threads,
// and the rest is reserved for the caller thread // and the rest is reserved for the caller thread
@ -44,21 +42,20 @@ bool Semaphore::ShouldWait(const Thread* thread) const {
} }
void Semaphore::Acquire(Thread* thread) { void Semaphore::Acquire(Thread* thread) {
if (available_count <= 0) if (available_count <= 0) {
return; return;
}
--available_count; --available_count;
} }
ResultVal<s32> Semaphore::Release(s32 release_count) { Result Semaphore::Release(s32* out_count, s32 release_count) {
if (max_count - available_count < release_count) R_UNLESS(max_count >= release_count + available_count, ResultOutOfRangeKernel);
return ERR_OUT_OF_RANGE_KERNEL;
s32 previous_count = available_count; *out_count = available_count;
available_count += release_count; available_count += release_count;
WakeupAllWaitingThreads(); WakeupAllWaitingThreads();
return previous_count; return ResultSuccess;
} }
} // namespace Kernel } // namespace Kernel

View file

@ -47,7 +47,7 @@ public:
* @param release_count The number of slots to release * @param release_count The number of slots to release
* @return The number of free slots the semaphore had before this call * @return The number of free slots the semaphore had before this call
*/ */
ResultVal<s32> Release(s32 release_count); Result Release(s32* out_count, s32 release_count);
private: private:
friend class boost::serialization::access; friend class boost::serialization::access;

View file

@ -24,14 +24,12 @@ namespace Kernel {
ServerPort::ServerPort(KernelSystem& kernel) : WaitObject(kernel) {} ServerPort::ServerPort(KernelSystem& kernel) : WaitObject(kernel) {}
ServerPort::~ServerPort() {} ServerPort::~ServerPort() {}
ResultVal<std::shared_ptr<ServerSession>> ServerPort::Accept() { Result ServerPort::Accept(std::shared_ptr<ServerSession>* out_server_session) {
if (pending_sessions.empty()) { R_UNLESS(!pending_sessions.empty(), ResultNoPendingSessions);
return ERR_NO_PENDING_SESSIONS;
}
auto session = std::move(pending_sessions.back()); *out_server_session = std::move(pending_sessions.back());
pending_sessions.pop_back(); pending_sessions.pop_back();
return session; return ResultSuccess;
} }
bool ServerPort::ShouldWait(const Thread* thread) const { bool ServerPort::ShouldWait(const Thread* thread) const {

View file

@ -39,9 +39,9 @@ public:
/** /**
* Accepts a pending incoming connection on this port. If there are no pending sessions, will * Accepts a pending incoming connection on this port. If there are no pending sessions, will
* return ERR_NO_PENDING_SESSIONS. * return ResultNoPendingSessions.
*/ */
ResultVal<std::shared_ptr<ServerSession>> Accept(); Result Accept(std::shared_ptr<ServerSession>* out_server_session);
/** /**
* Sets the HLE handler template for the port. ServerSessions crated by connecting to this port * Sets the HLE handler template for the port. ServerSessions crated by connecting to this port

View file

@ -77,7 +77,7 @@ void ServerSession::Acquire(Thread* thread) {
pending_requesting_threads.pop_back(); pending_requesting_threads.pop_back();
} }
ResultCode ServerSession::HandleSyncRequest(std::shared_ptr<Thread> thread) { Result ServerSession::HandleSyncRequest(std::shared_ptr<Thread> thread) {
// The ServerSession received a sync request, this means that there's new data available // 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 // from its ClientSession, so wake up any threads that may be waiting on a svcReplyAndReceive or
// similar. // similar.
@ -136,7 +136,7 @@ ResultCode ServerSession::HandleSyncRequest(std::shared_ptr<Thread> thread) {
// If this ServerSession does not have an HLE implementation, just wake up the threads waiting // If this ServerSession does not have an HLE implementation, just wake up the threads waiting
// on it. // on it.
WakeupAllWaitingThreads(); WakeupAllWaitingThreads();
return RESULT_SUCCESS; return ResultSuccess;
} }
KernelSystem::SessionPair KernelSystem::CreateSessionPair(const std::string& name, KernelSystem::SessionPair KernelSystem::CreateSessionPair(const std::string& name,

View file

@ -66,9 +66,9 @@ public:
/** /**
* Handle a sync request from the emulated application. * Handle a sync request from the emulated application.
* @param thread Thread that initiated the request. * @param thread Thread that initiated the request.
* @returns ResultCode from the operation. * @returns Result from the operation.
*/ */
ResultCode HandleSyncRequest(std::shared_ptr<Thread> thread); Result HandleSyncRequest(std::shared_ptr<Thread> thread);
bool ShouldWait(const Thread* thread) const override; bool ShouldWait(const Thread* thread) const override;

View file

@ -67,9 +67,9 @@ ResultVal<std::shared_ptr<SharedMemory>> KernelSystem::CreateSharedMemory(
auto& vm_manager = owner_process->vm_manager; auto& vm_manager = owner_process->vm_manager;
// The memory is already available and mapped in the owner process. // The memory is already available and mapped in the owner process.
CASCADE_CODE(vm_manager.ChangeMemoryState(address, size, MemoryState::Private, R_TRY(vm_manager.ChangeMemoryState(address, size, MemoryState::Private,
VMAPermission::ReadWrite, MemoryState::Locked, VMAPermission::ReadWrite, MemoryState::Locked,
SharedMemory::ConvertPermissions(permissions))); SharedMemory::ConvertPermissions(permissions)));
auto backing_blocks = vm_manager.GetBackingBlocksForRange(address, size); auto backing_blocks = vm_manager.GetBackingBlocksForRange(address, size);
ASSERT(backing_blocks.Succeeded()); // should success after verifying memory state above ASSERT(backing_blocks.Succeeded()); // should success after verifying memory state above
@ -107,29 +107,29 @@ std::shared_ptr<SharedMemory> KernelSystem::CreateSharedMemoryForApplet(
return shared_memory; return shared_memory;
} }
ResultCode SharedMemory::Map(Process& target_process, VAddr address, MemoryPermission permissions, Result SharedMemory::Map(Process& target_process, VAddr address, MemoryPermission permissions,
MemoryPermission other_permissions) { MemoryPermission other_permissions) {
MemoryPermission own_other_permissions = MemoryPermission own_other_permissions =
&target_process == owner_process.lock().get() ? this->permissions : this->other_permissions; &target_process == owner_process.lock().get() ? this->permissions : this->other_permissions;
// Automatically allocated memory blocks can only be mapped with other_permissions = DontCare // Automatically allocated memory blocks can only be mapped with other_permissions = DontCare
if (base_address == 0 && other_permissions != MemoryPermission::DontCare) { if (base_address == 0 && other_permissions != MemoryPermission::DontCare) {
return ERR_INVALID_COMBINATION; return ResultInvalidCombination;
} }
// Error out if the requested permissions don't match what the creator process allows. // Error out if the requested permissions don't match what the creator process allows.
if (static_cast<u32>(permissions) & ~static_cast<u32>(own_other_permissions)) { if (static_cast<u32>(permissions) & ~static_cast<u32>(own_other_permissions)) {
LOG_ERROR(Kernel, "cannot map id={}, address=0x{:08X} name={}, permissions don't match", LOG_ERROR(Kernel, "cannot map id={}, address=0x{:08X} name={}, permissions don't match",
GetObjectId(), address, name); GetObjectId(), address, name);
return ERR_INVALID_COMBINATION; return ResultInvalidCombination;
} }
// Heap-backed memory blocks can not be mapped with other_permissions = DontCare // Heap-backed memory blocks can not be mapped with other_permissions = DontCare
if (base_address != 0 && other_permissions == MemoryPermission::DontCare) { if (base_address != 0 && other_permissions == MemoryPermission::DontCare) {
LOG_ERROR(Kernel, "cannot map id={}, address=0x{08X} name={}, permissions don't match", LOG_ERROR(Kernel, "cannot map id={}, address=0x{08X} name={}, permissions don't match",
GetObjectId(), address, name); GetObjectId(), address, name);
return ERR_INVALID_COMBINATION; return ResultInvalidCombination;
} }
// Error out if the provided permissions are not compatible with what the creator process needs. // Error out if the provided permissions are not compatible with what the creator process needs.
@ -137,12 +137,12 @@ ResultCode SharedMemory::Map(Process& target_process, VAddr address, MemoryPermi
static_cast<u32>(this->permissions) & ~static_cast<u32>(other_permissions)) { static_cast<u32>(this->permissions) & ~static_cast<u32>(other_permissions)) {
LOG_ERROR(Kernel, "cannot map id={}, address=0x{:08X} name={}, permissions don't match", LOG_ERROR(Kernel, "cannot map id={}, address=0x{:08X} name={}, permissions don't match",
GetObjectId(), address, name); GetObjectId(), address, name);
return ERR_WRONG_PERMISSION; return ResultWrongPermission;
} }
// TODO(Subv): Check for the Shared Device Mem flag in the creator process. // TODO(Subv): Check for the Shared Device Mem flag in the creator process.
/*if (was_created_with_shared_device_mem && address != 0) { /*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); ErrorSummary::InvalidArgument, ErrorLevel::Usage);
}*/ }*/
@ -153,7 +153,7 @@ ResultCode SharedMemory::Map(Process& target_process, VAddr address, MemoryPermi
if (address < Memory::HEAP_VADDR || address + size >= Memory::SHARED_MEMORY_VADDR_END) { if (address < Memory::HEAP_VADDR || address + size >= Memory::SHARED_MEMORY_VADDR_END) {
LOG_ERROR(Kernel, "cannot map id={}, address=0x{:08X} name={}, invalid address", LOG_ERROR(Kernel, "cannot map id={}, address=0x{:08X} name={}, invalid address",
GetObjectId(), address, name); GetObjectId(), address, name);
return ERR_INVALID_ADDRESS; return ResultInvalidAddress;
} }
} }
@ -174,7 +174,7 @@ ResultCode SharedMemory::Map(Process& target_process, VAddr address, MemoryPermi
Kernel, Kernel,
"cannot map id={}, address=0x{:08X} name={}, mapping to already allocated memory", "cannot map id={}, address=0x{:08X} name={}, mapping to already allocated memory",
GetObjectId(), address, name); GetObjectId(), address, name);
return ERR_INVALID_ADDRESS_STATE; return ResultInvalidAddressState;
} }
} }
@ -188,10 +188,10 @@ ResultCode SharedMemory::Map(Process& target_process, VAddr address, MemoryPermi
interval_target += interval.second; interval_target += interval.second;
} }
return RESULT_SUCCESS; return ResultSuccess;
} }
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 // TODO(Subv): Verify what happens if the application tries to unmap an address that is not
// mapped to a SharedMemory. // mapped to a SharedMemory.
return target_process.vm_manager.UnmapRange(address, size); return target_process.vm_manager.UnmapRange(address, size);

View file

@ -61,8 +61,8 @@ public:
* @param permissions Memory block map permissions (specified by SVC field) * @param permissions Memory block map permissions (specified by SVC field)
* @param other_permissions Memory block map other 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, Result Map(Process& target_process, VAddr address, MemoryPermission permissions,
MemoryPermission other_permissions); MemoryPermission other_permissions);
/** /**
* Unmaps a shared memory block from the specified address in system memory * 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 * @param address Address in system memory where the shared memory block is mapped
* @return Result code of the unmap operation * @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 * Gets a pointer to the shared memory block

File diff suppressed because it is too large Load diff

View file

@ -281,21 +281,21 @@ private:
}; };
template <typename SVCT> template <typename SVCT>
struct WrapPass<SVCT, ResultCode /*empty for T, Ts...*/> { struct WrapPass<SVCT, Result /*empty for T, Ts...*/> {
// Call function R(Context::svc)(Us...) and transfer the return value to registers // Call function R(Context::svc)(Us...) and transfer the return value to registers
template <typename... Us> template <typename... Us>
static void Call(Context& context, SVCT svc, Us... u) { static void Call(Context& context, SVCT svc, Us... u) {
static_assert(std::is_same_v<SVCT, ResultCode (Context::*)(Us...)>); static_assert(std::is_same_v<SVCT, Result (Context::*)(Us...)>);
if constexpr (std::is_void_v<ResultCode>) { if constexpr (std::is_void_v<Result>) {
(context.*svc)(u...); (context.*svc)(u...);
} else { } else {
ResultCode r = (context.*svc)(u...); Result r = (context.*svc)(u...);
if (r.IsError()) { if (r.IsError()) {
LOG_ERROR(Kernel_SVC, "level={} summary={} module={} description={}", LOG_ERROR(Kernel_SVC, "level={} summary={} module={} description={}",
r.level.ExtractValue(r.raw), r.summary.ExtractValue(r.raw), r.level.ExtractValue(r.raw), r.summary.ExtractValue(r.raw),
r.module.ExtractValue(r.raw), r.description.ExtractValue(r.raw)); r.module.ExtractValue(r.raw), r.description.ExtractValue(r.raw));
} }
SetParam<INDEX_RETURN, ResultCode, ResultCode, Us...>(context, r); SetParam<INDEX_RETURN, Result, Result, Us...>(context, r);
} }
} }
}; };

View file

@ -332,20 +332,20 @@ ResultVal<std::shared_ptr<Thread>> KernelSystem::CreateThread(
// Check if priority is in ranged. Lowest priority -> highest priority id. // Check if priority is in ranged. Lowest priority -> highest priority id.
if (priority > ThreadPrioLowest) { if (priority > ThreadPrioLowest) {
LOG_ERROR(Kernel_SVC, "Invalid thread priority: {}", priority); LOG_ERROR(Kernel_SVC, "Invalid thread priority: {}", priority);
return ERR_OUT_OF_RANGE; return ResultOutOfRange;
} }
if (processor_id > ThreadProcessorIdMax) { if (processor_id > ThreadProcessorIdMax) {
LOG_ERROR(Kernel_SVC, "Invalid processor id: {}", processor_id); LOG_ERROR(Kernel_SVC, "Invalid processor id: {}", processor_id);
return ERR_OUT_OF_RANGE_KERNEL; return ResultOutOfRangeKernel;
} }
// TODO(yuriks): Other checks, returning 0xD9001BEA // TODO(yuriks): Other checks, returning 0xD9001BEA
if (!memory.IsValidVirtualAddress(*owner_process, entry_point)) { if (!memory.IsValidVirtualAddress(*owner_process, entry_point)) {
LOG_ERROR(Kernel_SVC, "(name={}): invalid entry {:08x}", name, entry_point); LOG_ERROR(Kernel_SVC, "(name={}): invalid entry {:08x}", name, entry_point);
// TODO: Verify error // TODO: Verify error
return ResultCode(ErrorDescription::InvalidAddress, ErrorModule::Kernel, return Result(ErrorDescription::InvalidAddress, ErrorModule::Kernel,
ErrorSummary::InvalidArgument, ErrorLevel::Permanent); ErrorSummary::InvalidArgument, ErrorLevel::Permanent);
} }
auto thread = std::make_shared<Thread>(*this, processor_id); auto thread = std::make_shared<Thread>(*this, processor_id);
@ -445,7 +445,7 @@ void ThreadManager::Reschedule() {
SwitchContext(next); SwitchContext(next);
} }
void Thread::SetWaitSynchronizationResult(ResultCode result) { void Thread::SetWaitSynchronizationResult(Result result) {
context.cpu_registers[0] = result.raw; context.cpu_registers[0] = result.raw;
} }

View file

@ -243,7 +243,7 @@ public:
* Sets the result after the thread awakens (from either WaitSynchronization SVC) * Sets the result after the thread awakens (from either WaitSynchronization SVC)
* @param result Value to set to the returned result * @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) * Sets the output parameter value after the thread awakens (from WaitSynchronizationN SVC only)

View file

@ -83,8 +83,8 @@ ResultVal<VAddr> VMManager::MapBackingMemoryToBase(VAddr base, u32 region_size,
// Do not try to allocate the block if there are no available addresses within the desired // Do not try to allocate the block if there are no available addresses within the desired
// region. // region.
if (vma_handle == vma_map.end() || target + size > base + region_size) { if (vma_handle == vma_map.end() || target + size > base + region_size) {
return ResultCode(ErrorDescription::OutOfMemory, ErrorModule::Kernel, return Result(ErrorDescription::OutOfMemory, ErrorModule::Kernel,
ErrorSummary::OutOfResource, ErrorLevel::Permanent); ErrorSummary::OutOfResource, ErrorLevel::Permanent);
} }
auto result = MapBackingMemory(target, memory, size, state); auto result = MapBackingMemory(target, memory, size, state);
@ -114,11 +114,11 @@ ResultVal<VMManager::VMAHandle> VMManager::MapBackingMemory(VAddr target, Memory
return MergeAdjacent(vma_handle); return MergeAdjacent(vma_handle);
} }
ResultCode VMManager::ChangeMemoryState(VAddr target, u32 size, MemoryState expected_state, Result VMManager::ChangeMemoryState(VAddr target, u32 size, MemoryState expected_state,
VMAPermission expected_perms, MemoryState new_state, VMAPermission expected_perms, MemoryState new_state,
VMAPermission new_perms) { VMAPermission new_perms) {
if (is_locked) { if (is_locked) {
return RESULT_SUCCESS; return ResultSuccess;
} }
VAddr target_end = target + size; VAddr target_end = target + size;
@ -126,16 +126,16 @@ ResultCode VMManager::ChangeMemoryState(VAddr target, u32 size, MemoryState expe
VMAIter i_end = vma_map.lower_bound(target_end); VMAIter i_end = vma_map.lower_bound(target_end);
if (begin_vma == vma_map.end()) if (begin_vma == vma_map.end())
return ERR_INVALID_ADDRESS; return ResultInvalidAddress;
for (auto i = begin_vma; i != i_end; ++i) { for (auto i = begin_vma; i != i_end; ++i) {
auto& vma = i->second; auto& vma = i->second;
if (vma.meminfo_state != expected_state) { if (vma.meminfo_state != expected_state) {
return ERR_INVALID_ADDRESS_STATE; return ResultInvalidAddressState;
} }
u32 perms = static_cast<u32>(expected_perms); u32 perms = static_cast<u32>(expected_perms);
if ((static_cast<u32>(vma.permissions) & perms) != perms) { if ((static_cast<u32>(vma.permissions) & perms) != perms) {
return ERR_INVALID_ADDRESS_STATE; return ResultInvalidAddressState;
} }
} }
@ -151,7 +151,7 @@ ResultCode VMManager::ChangeMemoryState(VAddr target, u32 size, MemoryState expe
vma = std::next(MergeAdjacent(vma)); vma = std::next(MergeAdjacent(vma));
} }
return RESULT_SUCCESS; return ResultSuccess;
} }
VMManager::VMAIter VMManager::Unmap(VMAIter vma_handle) { VMManager::VMAIter VMManager::Unmap(VMAIter vma_handle) {
@ -168,7 +168,7 @@ VMManager::VMAIter VMManager::Unmap(VMAIter vma_handle) {
return MergeAdjacent(vma_handle); return MergeAdjacent(vma_handle);
} }
ResultCode VMManager::UnmapRange(VAddr target, u32 size) { Result VMManager::UnmapRange(VAddr target, u32 size) {
ASSERT(!is_locked); ASSERT(!is_locked);
CASCADE_RESULT(VMAIter vma, CarveVMARange(target, size)); CASCADE_RESULT(VMAIter vma, CarveVMARange(target, size));
@ -182,7 +182,7 @@ ResultCode VMManager::UnmapRange(VAddr target, u32 size) {
} }
ASSERT(FindVMA(target)->second.size >= size); ASSERT(FindVMA(target)->second.size >= size);
return RESULT_SUCCESS; return ResultSuccess;
} }
VMManager::VMAHandle VMManager::Reprotect(VMAHandle vma_handle, VMAPermission new_perms) { VMManager::VMAHandle VMManager::Reprotect(VMAHandle vma_handle, VMAPermission new_perms) {
@ -197,7 +197,7 @@ VMManager::VMAHandle VMManager::Reprotect(VMAHandle vma_handle, VMAPermission ne
return MergeAdjacent(iter); 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); ASSERT(!is_locked);
CASCADE_RESULT(VMAIter vma, CarveVMARange(target, size)); CASCADE_RESULT(VMAIter vma, CarveVMARange(target, size));
@ -210,7 +210,7 @@ ResultCode VMManager::ReprotectRange(VAddr target, u32 size, VMAPermission new_p
vma = std::next(StripIterConstness(Reprotect(vma, new_perms))); vma = std::next(StripIterConstness(Reprotect(vma, new_perms)));
} }
return RESULT_SUCCESS; return ResultSuccess;
} }
void VMManager::LogLayout(Common::Log::Level log_level) const { void VMManager::LogLayout(Common::Log::Level log_level) const {
@ -242,13 +242,13 @@ ResultVal<VMManager::VMAIter> VMManager::CarveVMA(VAddr base, u32 size) {
VMAIter vma_handle = StripIterConstness(FindVMA(base)); VMAIter vma_handle = StripIterConstness(FindVMA(base));
if (vma_handle == vma_map.end()) { if (vma_handle == vma_map.end()) {
// Target address is outside the range managed by the kernel // Target address is outside the range managed by the kernel
return ERR_INVALID_ADDRESS; return ResultInvalidAddress;
} }
const VirtualMemoryArea& vma = vma_handle->second; const VirtualMemoryArea& vma = vma_handle->second;
if (vma.type != VMAType::Free) { if (vma.type != VMAType::Free) {
// Region is already allocated // Region is already allocated
return ERR_INVALID_ADDRESS_STATE; return ResultInvalidAddressState;
} }
const VAddr start_in_vma = base - vma.base; const VAddr start_in_vma = base - vma.base;
@ -256,7 +256,7 @@ ResultVal<VMManager::VMAIter> VMManager::CarveVMA(VAddr base, u32 size) {
if (end_in_vma > vma.size) { if (end_in_vma > vma.size) {
// Requested allocation doesn't fit inside VMA // Requested allocation doesn't fit inside VMA
return ERR_INVALID_ADDRESS_STATE; return ResultInvalidAddressState;
} }
if (end_in_vma != vma.size) { if (end_in_vma != vma.size) {
@ -284,7 +284,7 @@ ResultVal<VMManager::VMAIter> VMManager::CarveVMARange(VAddr target, u32 size) {
const VMAIter i_end = vma_map.lower_bound(target_end); const VMAIter i_end = vma_map.lower_bound(target_end);
if (std::any_of(begin_vma, i_end, if (std::any_of(begin_vma, i_end,
[](const auto& entry) { return entry.second.type == VMAType::Free; })) { [](const auto& entry) { return entry.second.type == VMAType::Free; })) {
return ERR_INVALID_ADDRESS_STATE; return ResultInvalidAddressState;
} }
if (target != begin_vma->second.base) { if (target != begin_vma->second.base) {
@ -367,7 +367,7 @@ ResultVal<std::vector<std::pair<MemoryRef, u32>>> VMManager::GetBackingBlocksFor
auto vma = FindVMA(interval_target); auto vma = FindVMA(interval_target);
if (vma->second.type != VMAType::BackingMemory) { if (vma->second.type != VMAType::BackingMemory) {
LOG_ERROR(Kernel, "Trying to use already freed memory"); LOG_ERROR(Kernel, "Trying to use already freed memory");
return ERR_INVALID_ADDRESS_STATE; return ResultInvalidAddressState;
} }
VAddr interval_end = std::min(address + size, vma->second.base + vma->second.size); VAddr interval_end = std::min(address + size, vma->second.base + vma->second.size);

View file

@ -165,18 +165,18 @@ public:
* @param new_state New MemoryState for the range. * @param new_state New MemoryState for the range.
* @param new_perms New VMAPermission for the range. * @param new_perms New VMAPermission for the range.
*/ */
ResultCode ChangeMemoryState(VAddr target, u32 size, MemoryState expected_state, Result ChangeMemoryState(VAddr target, u32 size, MemoryState expected_state,
VMAPermission expected_perms, MemoryState new_state, VMAPermission expected_perms, MemoryState new_state,
VMAPermission new_perms); VMAPermission new_perms);
/// Unmaps a range of addresses, splitting VMAs as necessary. /// 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. /// Changes the permissions of the given VMA.
VMAHandle Reprotect(VMAHandle vma, VMAPermission new_perms); VMAHandle Reprotect(VMAHandle vma, VMAPermission new_perms);
/// Changes the permissions of a range of addresses, splitting VMAs as necessary. /// 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 /// Dumps the address space layout to the log, for debugging
void LogLayout(Common::Log::Level log_level) const; void LogLayout(Common::Log::Level log_level) const;

View file

@ -192,7 +192,7 @@ enum class ErrorLevel : u32 {
}; };
/// Encapsulates a CTR-OS error code, allowing it to be separated into its constituent fields. /// Encapsulates a CTR-OS error code, allowing it to be separated into its constituent fields.
union ResultCode { union Result {
u32 raw; u32 raw;
BitField<0, 10, u32> description; BitField<0, 10, u32> description;
@ -205,18 +205,18 @@ union ResultCode {
// error // error
BitField<31, 1, u32> is_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, constexpr Result(ErrorDescription description, ErrorModule module, ErrorSummary summary,
ErrorLevel level) ErrorLevel level)
: ResultCode(static_cast<u32>(description), module, summary, level) {} : Result(static_cast<u32>(description), module, summary, level) {}
constexpr ResultCode(u32 description_, ErrorModule module_, ErrorSummary summary_, constexpr Result(u32 description_, ErrorModule module_, ErrorSummary summary_,
ErrorLevel level_) ErrorLevel level_)
: raw(description.FormatValue(description_) | module.FormatValue(module_) | : raw(description.FormatValue(description_) | module.FormatValue(module_) |
summary.FormatValue(summary_) | level.FormatValue(level_)) {} summary.FormatValue(summary_) | level.FormatValue(level_)) {}
constexpr ResultCode& operator=(const ResultCode& o) = default; constexpr Result& operator=(const Result& o) = default;
constexpr bool IsSuccess() const { constexpr bool IsSuccess() const {
return is_error.ExtractValue(raw) == 0; return is_error.ExtractValue(raw) == 0;
@ -234,23 +234,23 @@ private:
friend class boost::serialization::access; 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; 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; return a.raw != b.raw;
} }
// Convenience functions for creating some common kinds of errors: // Convenience functions for creating some common kinds of errors:
/// The default success `ResultCode`. /// The default success `Result`.
constexpr ResultCode RESULT_SUCCESS(0); constexpr Result ResultSuccess(0);
/// Might be returned instead of a dummy success for unimplemented APIs. /// Might be returned instead of a dummy success for unimplemented APIs.
constexpr ResultCode UnimplementedFunction(ErrorModule module) { constexpr Result UnimplementedFunction(ErrorModule module) {
return ResultCode(ErrorDescription::NotImplemented, module, ErrorSummary::NotSupported, return Result(ErrorDescription::NotImplemented, module, ErrorSummary::NotSupported,
ErrorLevel::Permanent); ErrorLevel::Permanent);
} }
/** /**
@ -259,10 +259,10 @@ constexpr ResultCode UnimplementedFunction(ErrorModule module) {
* @note This should only be used when a particular error code * @note This should only be used when a particular error code
* is not known yet. * is not known yet.
*/ */
constexpr ResultCode RESULT_UNKNOWN(UINT32_MAX); constexpr Result ResultUnknown(std::numeric_limits<u32>::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 * 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(). * 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(), * 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<int> Frobnicate(float strength) { * ResultVal<int> Frobnicate(float strength) {
* if (strength < 0.f || strength > 1.0f) { * if (strength < 0.f || strength > 1.0f) {
* // Can't frobnicate too weakly or too strongly * // Can't frobnicate too weakly or too strongly
* return ResultCode(ErrorDescription::OutOfRange, ErrorModule::Common, * return Result(ErrorDescription::OutOfRange, ErrorModule::Common,
* ErrorSummary::InvalidArgument, ErrorLevel::Permanent); * ErrorSummary::InvalidArgument, ErrorLevel::Permanent);
* } else { * } else {
* // Frobnicated! Give caller a cookie * // Frobnicated! Give caller a cookie
@ -297,7 +297,7 @@ class ResultVal {
public: public:
constexpr ResultVal() : expected{} {} constexpr ResultVal() : expected{} {}
constexpr ResultVal(ResultCode code) : expected{Common::Unexpected(code)} {} constexpr ResultVal(Result code) : expected{Common::Unexpected(code)} {}
template <typename U> template <typename U>
constexpr ResultVal(U&& val) : expected{std::forward<U>(val)} {} constexpr ResultVal(U&& val) : expected{std::forward<U>(val)} {}
@ -317,8 +317,8 @@ public:
return expected.has_value(); return expected.has_value();
} }
[[nodiscard]] constexpr ResultCode Code() const { [[nodiscard]] constexpr Result Code() const {
return expected.has_value() ? RESULT_SUCCESS : expected.error(); return expected.has_value() ? ResultSuccess : expected.error();
} }
[[nodiscard]] constexpr bool Succeeded() const { [[nodiscard]] constexpr bool Succeeded() const {
@ -385,7 +385,7 @@ public:
private: private:
// TODO: Replace this with std::expected once it is standardized in the STL. // TODO: Replace this with std::expected once it is standardized in the STL.
Common::Expected<T, ResultCode> expected; Common::Expected<T, Result> expected;
}; };
/** /**
@ -400,11 +400,28 @@ private:
return CONCAT2(check_result_L, __LINE__).Code(); \ return CONCAT2(check_result_L, __LINE__).Code(); \
target = std::move(*CONCAT2(check_result_L, __LINE__)) target = std::move(*CONCAT2(check_result_L, __LINE__))
/** #define R_SUCCEEDED(res) (static_cast<Result>(res).IsSuccess())
* Analogous to CASCADE_RESULT, but for a bare ResultCode. The code will be propagated if #define R_FAILED(res) (static_cast<Result>(res).IsError())
* non-success, or discarded otherwise.
*/ /// Evaluates a boolean expression, and returns a result unless that expression is true.
#define CASCADE_CODE(source) \ #define R_UNLESS(expr, res) \
auto CONCAT2(check_result_L, __LINE__) = source; \ { \
if (CONCAT2(check_result_L, __LINE__).IsError()) \ if (!(expr)) { \
return CONCAT2(check_result_L, __LINE__); return (res); \
} \
}
/// Evaluates an expression that returns a result, and returns the result if it would fail.
#define R_TRY(res_expr) \
{ \
const auto _tmp_r_try_rc = (res_expr); \
if (R_FAILED(_tmp_r_try_rc)) { \
return (_tmp_r_try_rc); \
} \
}
/// Evaluates a boolean expression, and succeeds if that expression is true.
#define R_SUCCEED_IF(expr) R_UNLESS(!(expr), ResultSuccess)
/// Evaluates a boolean expression, and asserts if that expression is false.
#define R_ASSERT(expr) ASSERT(R_SUCCEEDED(expr))

View file

@ -28,7 +28,7 @@ void Module::Interface::CreateDefaultConfig(Kernel::HLERequestContext& ctx) {
std::memcpy(buffer.data(), &ac->default_config, buffer.size()); std::memcpy(buffer.data(), &ac->default_config, buffer.size());
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushStaticBuffer(std::move(buffer), 0); rb.PushStaticBuffer(std::move(buffer), 0);
LOG_WARNING(Service_AC, "(STUBBED) called"); LOG_WARNING(Service_AC, "(STUBBED) called");
@ -48,7 +48,7 @@ void Module::Interface::ConnectAsync(Kernel::HLERequestContext& ctx) {
} }
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_WARNING(Service_AC, "(STUBBED) called"); LOG_WARNING(Service_AC, "(STUBBED) called");
} }
@ -58,7 +58,7 @@ void Module::Interface::GetConnectResult(Kernel::HLERequestContext& ctx) {
rp.Skip(2, false); // ProcessId descriptor rp.Skip(2, false); // ProcessId descriptor
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
} }
void Module::Interface::CloseAsync(Kernel::HLERequestContext& ctx) { void Module::Interface::CloseAsync(Kernel::HLERequestContext& ctx) {
@ -79,7 +79,7 @@ void Module::Interface::CloseAsync(Kernel::HLERequestContext& ctx) {
ac->ac_connected = false; ac->ac_connected = false;
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
} }
void Module::Interface::GetCloseResult(Kernel::HLERequestContext& ctx) { void Module::Interface::GetCloseResult(Kernel::HLERequestContext& ctx) {
@ -87,7 +87,7 @@ void Module::Interface::GetCloseResult(Kernel::HLERequestContext& ctx) {
rp.Skip(2, false); // ProcessId descriptor rp.Skip(2, false); // ProcessId descriptor
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_WARNING(Service_AC, "(STUBBED) called"); LOG_WARNING(Service_AC, "(STUBBED) called");
} }
@ -102,7 +102,7 @@ void Module::Interface::GetWifiStatus(Kernel::HLERequestContext& ctx) {
} }
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push<u32>(static_cast<u32>(can_reach_internet ? (Settings::values.is_new_3ds rb.Push<u32>(static_cast<u32>(can_reach_internet ? (Settings::values.is_new_3ds
? WifiStatus::STATUS_CONNECTED_N3DS ? WifiStatus::STATUS_CONNECTED_N3DS
: WifiStatus::STATUS_CONNECTED_O3DS) : WifiStatus::STATUS_CONNECTED_O3DS)
@ -114,7 +114,7 @@ void Module::Interface::GetInfraPriority(Kernel::HLERequestContext& ctx) {
[[maybe_unused]] const std::vector<u8>& ac_config = rp.PopStaticBuffer(); [[maybe_unused]] const std::vector<u8>& ac_config = rp.PopStaticBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push<u32>(0); // Infra Priority, default 0 rb.Push<u32>(0); // Infra Priority, default 0
LOG_WARNING(Service_AC, "(STUBBED) called"); LOG_WARNING(Service_AC, "(STUBBED) called");
@ -131,7 +131,7 @@ void Module::Interface::SetRequestEulaVersion(Kernel::HLERequestContext& ctx) {
// TODO(Subv): Copy over the input ACConfig to the stored ACConfig. // TODO(Subv): Copy over the input ACConfig to the stored ACConfig.
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushStaticBuffer(std::move(ac_config), 0); rb.PushStaticBuffer(std::move(ac_config), 0);
LOG_WARNING(Service_AC, "(STUBBED) called, major={}, minor={}", major, minor); LOG_WARNING(Service_AC, "(STUBBED) called, major={}, minor={}", major, minor);
@ -147,7 +147,7 @@ void Module::Interface::RegisterDisconnectEvent(Kernel::HLERequestContext& ctx)
} }
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_WARNING(Service_AC, "(STUBBED) called"); LOG_WARNING(Service_AC, "(STUBBED) called");
} }
@ -157,7 +157,7 @@ void Module::Interface::GetConnectingProxyEnable(Kernel::HLERequestContext& ctx)
constexpr bool proxy_enabled = false; constexpr bool proxy_enabled = false;
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push(proxy_enabled); rb.Push(proxy_enabled);
LOG_WARNING(Service_AC, "(STUBBED) called"); LOG_WARNING(Service_AC, "(STUBBED) called");
@ -170,7 +170,7 @@ void Module::Interface::IsConnected(Kernel::HLERequestContext& ctx) {
u32 unk_param = rp.Pop<u32>(); u32 unk_param = rp.Pop<u32>();
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push(ac->ac_connected); rb.Push(ac->ac_connected);
LOG_WARNING(Service_AC, "(STUBBED) called unk=0x{:08X} descriptor=0x{:08X} param=0x{:08X}", unk, LOG_WARNING(Service_AC, "(STUBBED) called unk=0x{:08X} descriptor=0x{:08X} param=0x{:08X}", unk,
@ -186,7 +186,7 @@ void Module::Interface::SetClientVersion(Kernel::HLERequestContext& ctx) {
LOG_WARNING(Service_AC, "(STUBBED) called, version: 0x{:08X}", version); LOG_WARNING(Service_AC, "(STUBBED) called, version: 0x{:08X}", version);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
} }
Module::Interface::Interface(std::shared_ptr<Module> ac, const char* name, u32 max_session) Module::Interface::Interface(std::shared_ptr<Module> ac, const char* name, u32 max_session)

View file

@ -28,7 +28,7 @@ void Module::Interface::Initialize(Kernel::HLERequestContext& ctx) {
sdk_version, shared_memory_size, caller_pid); sdk_version, shared_memory_size, caller_pid);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
} }
void Module::Interface::GetAccountDataBlock(Kernel::HLERequestContext& ctx) { void Module::Interface::GetAccountDataBlock(Kernel::HLERequestContext& ctx) {
@ -42,7 +42,7 @@ void Module::Interface::GetAccountDataBlock(Kernel::HLERequestContext& ctx) {
size, block_id); size, block_id);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
} }
void InstallInterfaces(Core::System& system) { void InstallInterfaces(Core::System& system) {

View file

@ -93,7 +93,7 @@ ResultVal<std::size_t> CIAFile::Read(u64 offset, std::size_t length, u8* buffer)
return length; return length;
} }
ResultCode CIAFile::WriteTicket() { Result CIAFile::WriteTicket() {
auto load_result = container.LoadTicket(data, container.GetTicketOffset()); auto load_result = container.LoadTicket(data, container.GetTicketOffset());
if (load_result != Loader::ResultStatus::Success) { if (load_result != Loader::ResultStatus::Success) {
LOG_ERROR(Service_AM, "Could not read ticket from CIA."); LOG_ERROR(Service_AM, "Could not read ticket from CIA.");
@ -105,10 +105,10 @@ ResultCode CIAFile::WriteTicket() {
// TODO: Write out .tik files to nand? // TODO: Write out .tik files to nand?
install_state = CIAInstallState::TicketLoaded; install_state = CIAInstallState::TicketLoaded;
return RESULT_SUCCESS; return ResultSuccess;
} }
ResultCode CIAFile::WriteTitleMetadata() { Result CIAFile::WriteTitleMetadata() {
auto load_result = container.LoadTitleMetadata(data, container.GetTitleMetadataOffset()); auto load_result = container.LoadTitleMetadata(data, container.GetTitleMetadataOffset());
if (load_result != Loader::ResultStatus::Success) { if (load_result != Loader::ResultStatus::Success) {
LOG_ERROR(Service_AM, "Could not read title metadata from CIA."); LOG_ERROR(Service_AM, "Could not read title metadata from CIA.");
@ -138,7 +138,7 @@ ResultCode CIAFile::WriteTitleMetadata() {
if (tmd.Save(tmd_path) != Loader::ResultStatus::Success) { if (tmd.Save(tmd_path) != Loader::ResultStatus::Success) {
LOG_ERROR(Service_AM, "Failed to install title metadata file from CIA."); LOG_ERROR(Service_AM, "Failed to install title metadata file from CIA.");
// TODO: Correct result code. // TODO: Correct result code.
return FileSys::ERROR_FILE_NOT_FOUND; return FileSys::ResultFileNotFound;
} }
// Create any other .app folders which may not exist yet // Create any other .app folders which may not exist yet
@ -158,7 +158,7 @@ ResultCode CIAFile::WriteTitleMetadata() {
if (!file.IsOpen()) { if (!file.IsOpen()) {
LOG_ERROR(Service_AM, "Could not open output file '{}' for content {}.", path, i); LOG_ERROR(Service_AM, "Could not open output file '{}' for content {}.", path, i);
// TODO: Correct error code. // TODO: Correct error code.
return FileSys::ERROR_FILE_NOT_FOUND; return FileSys::ResultFileNotFound;
} }
} }
@ -173,7 +173,7 @@ ResultCode CIAFile::WriteTitleMetadata() {
} else { } else {
LOG_ERROR(Service_AM, "Could not read title key from ticket for encrypted CIA."); LOG_ERROR(Service_AM, "Could not read title key from ticket for encrypted CIA.");
// TODO: Correct error code. // TODO: Correct error code.
return FileSys::ERROR_FILE_NOT_FOUND; return FileSys::ResultFileNotFound;
} }
} else { } else {
LOG_INFO(Service_AM, LOG_INFO(Service_AM,
@ -182,7 +182,7 @@ ResultCode CIAFile::WriteTitleMetadata() {
install_state = CIAInstallState::TMDLoaded; install_state = CIAInstallState::TMDLoaded;
return RESULT_SUCCESS; return ResultSuccess;
} }
ResultVal<std::size_t> CIAFile::WriteContentData(u64 offset, std::size_t length, const u8* buffer) { ResultVal<std::size_t> CIAFile::WriteContentData(u64 offset, std::size_t length, const u8* buffer) {
@ -772,7 +772,7 @@ void Module::Interface::GetNumPrograms(Kernel::HLERequestContext& ctx) {
u32 media_type = rp.Pop<u8>(); u32 media_type = rp.Pop<u8>();
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push<u32>(static_cast<u32>(am->am_title_list[media_type].size())); rb.Push<u32>(static_cast<u32>(am->am_title_list[media_type].size()));
} }
@ -789,8 +789,8 @@ void Module::Interface::FindDLCContentInfos(Kernel::HLERequestContext& ctx) {
u32 tid_high = static_cast<u32>(title_id >> 32); u32 tid_high = static_cast<u32>(title_id >> 32);
if (tid_high != TID_HIGH_DLC) { if (tid_high != TID_HIGH_DLC) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 4); IPC::RequestBuilder rb = rp.MakeBuilder(1, 4);
rb.Push(ResultCode(ErrCodes::InvalidTIDInList, ErrorModule::AM, rb.Push(Result(ErrCodes::InvalidTIDInList, ErrorModule::AM, ErrorSummary::InvalidArgument,
ErrorSummary::InvalidArgument, ErrorLevel::Usage)); ErrorLevel::Usage));
rb.PushMappedBuffer(content_requested_in); rb.PushMappedBuffer(content_requested_in);
rb.PushMappedBuffer(content_info_out); rb.PushMappedBuffer(content_info_out);
return; return;
@ -836,7 +836,7 @@ void Module::Interface::FindDLCContentInfos(Kernel::HLERequestContext& ctx) {
} }
IPC::RequestBuilder rb = rp.MakeBuilder(1, 4); IPC::RequestBuilder rb = rp.MakeBuilder(1, 4);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushMappedBuffer(content_requested_in); rb.PushMappedBuffer(content_requested_in);
rb.PushMappedBuffer(content_info_out); rb.PushMappedBuffer(content_info_out);
} }
@ -854,8 +854,8 @@ void Module::Interface::ListDLCContentInfos(Kernel::HLERequestContext& ctx) {
u32 tid_high = static_cast<u32>(title_id >> 32); u32 tid_high = static_cast<u32>(title_id >> 32);
if (tid_high != TID_HIGH_DLC) { if (tid_high != TID_HIGH_DLC) {
IPC::RequestBuilder rb = rp.MakeBuilder(2, 2); IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
rb.Push(ResultCode(ErrCodes::InvalidTIDInList, ErrorModule::AM, rb.Push(Result(ErrCodes::InvalidTIDInList, ErrorModule::AM, ErrorSummary::InvalidArgument,
ErrorSummary::InvalidArgument, ErrorLevel::Usage)); ErrorLevel::Usage));
rb.Push<u32>(0); rb.Push<u32>(0);
rb.PushMappedBuffer(content_info_out); rb.PushMappedBuffer(content_info_out);
return; return;
@ -889,7 +889,7 @@ void Module::Interface::ListDLCContentInfos(Kernel::HLERequestContext& ctx) {
} }
IPC::RequestBuilder rb = rp.MakeBuilder(2, 2); IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push(copied); rb.Push(copied);
rb.PushMappedBuffer(content_info_out); rb.PushMappedBuffer(content_info_out);
} }
@ -902,7 +902,7 @@ void Module::Interface::DeleteContents(Kernel::HLERequestContext& ctx) {
auto& content_ids_in = rp.PopMappedBuffer(); auto& content_ids_in = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushMappedBuffer(content_ids_in); rb.PushMappedBuffer(content_ids_in);
LOG_WARNING(Service_AM, "(STUBBED) media_type={}, title_id=0x{:016x}, content_count={}", LOG_WARNING(Service_AM, "(STUBBED) media_type={}, title_id=0x{:016x}, content_count={}",
media_type, title_id, content_count); media_type, title_id, content_count);
@ -929,14 +929,13 @@ void Module::Interface::GetProgramList(Kernel::HLERequestContext& ctx) {
title_ids_output.Write(am->am_title_list[media_type].data(), 0, copied * sizeof(u64)); title_ids_output.Write(am->am_title_list[media_type].data(), 0, copied * sizeof(u64));
IPC::RequestBuilder rb = rp.MakeBuilder(2, 2); IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push(copied); rb.Push(copied);
rb.PushMappedBuffer(title_ids_output); rb.PushMappedBuffer(title_ids_output);
} }
ResultCode GetTitleInfoFromList(std::span<const u64> title_id_list, Result GetTitleInfoFromList(std::span<const u64> title_id_list, Service::FS::MediaType media_type,
Service::FS::MediaType media_type, Kernel::MappedBuffer& title_info_out) {
Kernel::MappedBuffer& title_info_out) {
std::size_t write_offset = 0; std::size_t write_offset = 0;
for (u32 i = 0; i < title_id_list.size(); i++) { for (u32 i = 0; i < title_id_list.size(); i++) {
std::string tmd_path = GetTitleMetadataPath(media_type, title_id_list[i]); std::string tmd_path = GetTitleMetadataPath(media_type, title_id_list[i]);
@ -952,14 +951,14 @@ ResultCode GetTitleInfoFromList(std::span<const u64> title_id_list,
title_info.version = tmd.GetTitleVersion(); title_info.version = tmd.GetTitleVersion();
title_info.type = tmd.GetTitleType(); title_info.type = tmd.GetTitleType();
} else { } else {
return ResultCode(ErrorDescription::NotFound, ErrorModule::AM, return Result(ErrorDescription::NotFound, ErrorModule::AM, ErrorSummary::InvalidState,
ErrorSummary::InvalidState, ErrorLevel::Permanent); ErrorLevel::Permanent);
} }
title_info_out.Write(&title_info, write_offset, sizeof(TitleInfo)); title_info_out.Write(&title_info, write_offset, sizeof(TitleInfo));
write_offset += sizeof(TitleInfo); write_offset += sizeof(TitleInfo);
} }
return RESULT_SUCCESS; return ResultSuccess;
} }
void Module::Interface::GetProgramInfos(Kernel::HLERequestContext& ctx) { void Module::Interface::GetProgramInfos(Kernel::HLERequestContext& ctx) {
@ -973,7 +972,7 @@ void Module::Interface::GetProgramInfos(Kernel::HLERequestContext& ctx) {
std::vector<u64> title_id_list(title_count); std::vector<u64> title_id_list(title_count);
title_id_list_buffer.Read(title_id_list.data(), 0, title_count * sizeof(u64)); 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); IPC::RequestBuilder rb = rp.MakeBuilder(1, 4);
rb.Push(result); rb.Push(result);
@ -994,21 +993,21 @@ void Module::Interface::DeleteUserProgram(Kernel::HLERequestContext& ctx) {
u8 variation = static_cast<u8>(title_id & 0xFF); u8 variation = static_cast<u8>(title_id & 0xFF);
if (category & CATEGORY_SYSTEM || category & CATEGORY_DLP || variation & VARIATION_SYSTEM) { if (category & CATEGORY_SYSTEM || category & CATEGORY_DLP || variation & VARIATION_SYSTEM) {
LOG_ERROR(Service_AM, "Trying to uninstall system app"); LOG_ERROR(Service_AM, "Trying to uninstall system app");
rb.Push(ResultCode(ErrCodes::TryingToUninstallSystemApp, ErrorModule::AM, rb.Push(Result(ErrCodes::TryingToUninstallSystemApp, ErrorModule::AM,
ErrorSummary::InvalidArgument, ErrorLevel::Usage)); ErrorSummary::InvalidArgument, ErrorLevel::Usage));
return; return;
} }
LOG_INFO(Service_AM, "Deleting title 0x{:016x}", title_id); LOG_INFO(Service_AM, "Deleting title 0x{:016x}", title_id);
std::string path = GetTitlePath(media_type, title_id); std::string path = GetTitlePath(media_type, title_id);
if (!FileUtil::Exists(path)) { if (!FileUtil::Exists(path)) {
rb.Push(ResultCode(ErrorDescription::NotFound, ErrorModule::AM, ErrorSummary::InvalidState, rb.Push(Result(ErrorDescription::NotFound, ErrorModule::AM, ErrorSummary::InvalidState,
ErrorLevel::Permanent)); ErrorLevel::Permanent));
LOG_ERROR(Service_AM, "Title not found"); LOG_ERROR(Service_AM, "Title not found");
return; return;
} }
bool success = FileUtil::DeleteDirRecursively(path); bool success = FileUtil::DeleteDirRecursively(path);
am->ScanForAllTitles(); am->ScanForAllTitles();
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
if (!success) if (!success)
LOG_ERROR(Service_AM, "FileUtil::DeleteDirRecursively unexpectedly failed"); LOG_ERROR(Service_AM, "FileUtil::DeleteDirRecursively unexpectedly failed");
} }
@ -1021,8 +1020,8 @@ void Module::Interface::GetProductCode(Kernel::HLERequestContext& ctx) {
if (!FileUtil::Exists(path)) { if (!FileUtil::Exists(path)) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ResultCode(ErrorDescription::NotFound, ErrorModule::AM, ErrorSummary::InvalidState, rb.Push(Result(ErrorDescription::NotFound, ErrorModule::AM, ErrorSummary::InvalidState,
ErrorLevel::Permanent)); ErrorLevel::Permanent));
} else { } else {
struct ProductCode { struct ProductCode {
u8 code[0x10]; u8 code[0x10];
@ -1034,7 +1033,7 @@ void Module::Interface::GetProductCode(Kernel::HLERequestContext& ctx) {
FileSys::NCCHContainer ncch(path); FileSys::NCCHContainer ncch(path);
ncch.Load(); ncch.Load();
std::memcpy(&product_code.code, &ncch.ncch_header.product_code, 0x10); std::memcpy(&product_code.code, &ncch.ncch_header.product_code, 0x10);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushRaw(product_code); rb.PushRaw(product_code);
} }
} }
@ -1050,14 +1049,14 @@ void Module::Interface::GetDLCTitleInfos(Kernel::HLERequestContext& ctx) {
std::vector<u64> title_id_list(title_count); std::vector<u64> title_id_list(title_count);
title_id_list_buffer.Read(title_id_list.data(), 0, title_count * sizeof(u64)); title_id_list_buffer.Read(title_id_list.data(), 0, title_count * sizeof(u64));
ResultCode result = RESULT_SUCCESS; Result result = ResultSuccess;
// Validate that DLC TIDs were passed in // Validate that DLC TIDs were passed in
for (u32 i = 0; i < title_count; i++) { for (u32 i = 0; i < title_count; i++) {
u32 tid_high = static_cast<u32>(title_id_list[i] >> 32); u32 tid_high = static_cast<u32>(title_id_list[i] >> 32);
if (tid_high != TID_HIGH_DLC) { if (tid_high != TID_HIGH_DLC) {
result = ResultCode(ErrCodes::InvalidTIDInList, ErrorModule::AM, result = Result(ErrCodes::InvalidTIDInList, ErrorModule::AM,
ErrorSummary::InvalidArgument, ErrorLevel::Usage); ErrorSummary::InvalidArgument, ErrorLevel::Usage);
break; break;
} }
} }
@ -1083,14 +1082,14 @@ void Module::Interface::GetPatchTitleInfos(Kernel::HLERequestContext& ctx) {
std::vector<u64> title_id_list(title_count); std::vector<u64> title_id_list(title_count);
title_id_list_buffer.Read(title_id_list.data(), 0, title_count * sizeof(u64)); title_id_list_buffer.Read(title_id_list.data(), 0, title_count * sizeof(u64));
ResultCode result = RESULT_SUCCESS; Result result = ResultSuccess;
// Validate that update TIDs were passed in // Validate that update TIDs were passed in
for (u32 i = 0; i < title_count; i++) { for (u32 i = 0; i < title_count; i++) {
u32 tid_high = static_cast<u32>(title_id_list[i] >> 32); u32 tid_high = static_cast<u32>(title_id_list[i] >> 32);
if (tid_high != TID_HIGH_UPDATE) { if (tid_high != TID_HIGH_UPDATE) {
result = ResultCode(ErrCodes::InvalidTIDInList, ErrorModule::AM, result = Result(ErrCodes::InvalidTIDInList, ErrorModule::AM,
ErrorSummary::InvalidArgument, ErrorLevel::Usage); ErrorSummary::InvalidArgument, ErrorLevel::Usage);
break; break;
} }
} }
@ -1124,7 +1123,7 @@ void Module::Interface::ListDataTitleTicketInfos(Kernel::HLERequestContext& ctx)
} }
IPC::RequestBuilder rb = rp.MakeBuilder(2, 2); IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push(ticket_count); rb.Push(ticket_count);
rb.PushMappedBuffer(ticket_info_out); rb.PushMappedBuffer(ticket_info_out);
@ -1142,14 +1141,14 @@ void Module::Interface::GetDLCContentInfoCount(Kernel::HLERequestContext& ctx) {
u32 tid_high = static_cast<u32>(title_id >> 32); u32 tid_high = static_cast<u32>(title_id >> 32);
if (tid_high != TID_HIGH_DLC) { if (tid_high != TID_HIGH_DLC) {
IPC::RequestBuilder rb = rp.MakeBuilder(2, 2); IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
rb.Push(ResultCode(ErrCodes::InvalidTID, ErrorModule::AM, ErrorSummary::InvalidArgument, rb.Push(Result(ErrCodes::InvalidTID, ErrorModule::AM, ErrorSummary::InvalidArgument,
ErrorLevel::Usage)); ErrorLevel::Usage));
rb.Push<u32>(0); rb.Push<u32>(0);
return; return;
} }
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); // No error rb.Push(ResultSuccess); // No error
std::string tmd_path = GetTitleMetadataPath(media_type, title_id); std::string tmd_path = GetTitleMetadataPath(media_type, title_id);
@ -1168,7 +1167,7 @@ void Module::Interface::DeleteTicket(Kernel::HLERequestContext& ctx) {
u64 title_id = rp.Pop<u64>(); u64 title_id = rp.Pop<u64>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_WARNING(Service_AM, "(STUBBED) called title_id=0x{:016x}", title_id); LOG_WARNING(Service_AM, "(STUBBED) called title_id=0x{:016x}", title_id);
} }
@ -1181,7 +1180,7 @@ void Module::Interface::GetNumTickets(Kernel::HLERequestContext& ctx) {
} }
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push(ticket_count); rb.Push(ticket_count);
LOG_WARNING(Service_AM, "(STUBBED) called ticket_count=0x{:08x}", ticket_count); LOG_WARNING(Service_AM, "(STUBBED) called ticket_count=0x{:08x}", ticket_count);
} }
@ -1202,7 +1201,7 @@ void Module::Interface::GetTicketList(Kernel::HLERequestContext& ctx) {
} }
IPC::RequestBuilder rb = rp.MakeBuilder(2, 2); IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push(tickets_written); rb.Push(tickets_written);
rb.PushMappedBuffer(ticket_tids_out); rb.PushMappedBuffer(ticket_tids_out);
LOG_WARNING(Service_AM, "(STUBBED) ticket_list_count=0x{:08x}, ticket_index=0x{:08x}", LOG_WARNING(Service_AM, "(STUBBED) ticket_list_count=0x{:08x}, ticket_index=0x{:08x}",
@ -1216,7 +1215,7 @@ void Module::Interface::NeedsCleanup(Kernel::HLERequestContext& ctx) {
LOG_DEBUG(Service_AM, "(STUBBED) media_type=0x{:02x}", media_type); LOG_DEBUG(Service_AM, "(STUBBED) media_type=0x{:02x}", media_type);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push<bool>(false); rb.Push<bool>(false);
} }
@ -1227,7 +1226,7 @@ void Module::Interface::DoCleanup(Kernel::HLERequestContext& ctx) {
LOG_DEBUG(Service_AM, "(STUBBED) called, media_type={:#02x}", media_type); LOG_DEBUG(Service_AM, "(STUBBED) called, media_type={:#02x}", media_type);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
} }
void Module::Interface::QueryAvailableTitleDatabase(Kernel::HLERequestContext& ctx) { void Module::Interface::QueryAvailableTitleDatabase(Kernel::HLERequestContext& ctx) {
@ -1235,7 +1234,7 @@ void Module::Interface::QueryAvailableTitleDatabase(Kernel::HLERequestContext& c
u8 media_type = rp.Pop<u8>(); u8 media_type = rp.Pop<u8>();
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); // No error rb.Push(ResultSuccess); // No error
rb.Push(true); rb.Push(true);
LOG_WARNING(Service_AM, "(STUBBED) media_type={}", media_type); LOG_WARNING(Service_AM, "(STUBBED) media_type={}", media_type);
@ -1247,7 +1246,7 @@ void Module::Interface::GetPersonalizedTicketInfoList(Kernel::HLERequestContext&
[[maybe_unused]] auto& buffer = rp.PopMappedBuffer(); [[maybe_unused]] auto& buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); // No error rb.Push(ResultSuccess); // No error
rb.Push(0); rb.Push(0);
LOG_WARNING(Service_AM, "(STUBBED) called, ticket_count={}", ticket_count); LOG_WARNING(Service_AM, "(STUBBED) called, ticket_count={}", ticket_count);
@ -1259,7 +1258,7 @@ void Module::Interface::GetNumImportTitleContextsFiltered(Kernel::HLERequestCont
u8 filter = rp.Pop<u8>(); u8 filter = rp.Pop<u8>();
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); // No error rb.Push(ResultSuccess); // No error
rb.Push(0); rb.Push(0);
LOG_WARNING(Service_AM, "(STUBBED) called, media_type={}, filter={}", media_type, filter); LOG_WARNING(Service_AM, "(STUBBED) called, media_type={}, filter={}", media_type, filter);
@ -1273,7 +1272,7 @@ void Module::Interface::GetImportTitleContextListFiltered(Kernel::HLERequestCont
auto& buffer = rp.PopMappedBuffer(); auto& buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(2, 2); IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
rb.Push(RESULT_SUCCESS); // No error rb.Push(ResultSuccess); // No error
rb.Push(0); rb.Push(0);
rb.PushMappedBuffer(buffer); rb.PushMappedBuffer(buffer);
@ -1291,7 +1290,7 @@ void Module::Interface::CheckContentRights(Kernel::HLERequestContext& ctx) {
FileUtil::Exists(GetTitleContentPath(Service::FS::MediaType::SDMC, tid, content_index)); FileUtil::Exists(GetTitleContentPath(Service::FS::MediaType::SDMC, tid, content_index));
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); // No error rb.Push(ResultSuccess); // No error
rb.Push(has_rights); rb.Push(has_rights);
LOG_WARNING(Service_AM, "(STUBBED) tid={:016x}, content_index={}", tid, content_index); LOG_WARNING(Service_AM, "(STUBBED) tid={:016x}, content_index={}", tid, content_index);
@ -1307,7 +1306,7 @@ void Module::Interface::CheckContentRightsIgnorePlatform(Kernel::HLERequestConte
FileUtil::Exists(GetTitleContentPath(Service::FS::MediaType::SDMC, tid, content_index)); FileUtil::Exists(GetTitleContentPath(Service::FS::MediaType::SDMC, tid, content_index));
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); // No error rb.Push(ResultSuccess); // No error
rb.Push(has_rights); rb.Push(has_rights);
LOG_WARNING(Service_AM, "(STUBBED) tid={:016x}, content_index={}", tid, content_index); LOG_WARNING(Service_AM, "(STUBBED) tid={:016x}, content_index={}", tid, content_index);
@ -1319,8 +1318,8 @@ void Module::Interface::BeginImportProgram(Kernel::HLERequestContext& ctx) {
if (am->cia_installing) { if (am->cia_installing) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ResultCode(ErrCodes::CIACurrentlyInstalling, ErrorModule::AM, rb.Push(Result(ErrCodes::CIACurrentlyInstalling, ErrorModule::AM,
ErrorSummary::InvalidState, ErrorLevel::Permanent)); ErrorSummary::InvalidState, ErrorLevel::Permanent));
return; return;
} }
@ -1333,7 +1332,7 @@ void Module::Interface::BeginImportProgram(Kernel::HLERequestContext& ctx) {
am->cia_installing = true; am->cia_installing = true;
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS); // No error rb.Push(ResultSuccess); // No error
rb.PushCopyObjects(file->Connect()); rb.PushCopyObjects(file->Connect());
LOG_WARNING(Service_AM, "(STUBBED) media_type={}", media_type); LOG_WARNING(Service_AM, "(STUBBED) media_type={}", media_type);
@ -1344,8 +1343,8 @@ void Module::Interface::BeginImportProgramTemporarily(Kernel::HLERequestContext&
if (am->cia_installing) { if (am->cia_installing) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ResultCode(ErrCodes::CIACurrentlyInstalling, ErrorModule::AM, rb.Push(Result(ErrCodes::CIACurrentlyInstalling, ErrorModule::AM,
ErrorSummary::InvalidState, ErrorLevel::Permanent)); ErrorSummary::InvalidState, ErrorLevel::Permanent));
return; return;
} }
@ -1360,7 +1359,7 @@ void Module::Interface::BeginImportProgramTemporarily(Kernel::HLERequestContext&
am->cia_installing = true; am->cia_installing = true;
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS); // No error rb.Push(ResultSuccess); // No error
rb.PushCopyObjects(file->Connect()); rb.PushCopyObjects(file->Connect());
LOG_WARNING(Service_AM, "(STUBBED)"); LOG_WARNING(Service_AM, "(STUBBED)");
@ -1374,7 +1373,7 @@ void Module::Interface::EndImportProgram(Kernel::HLERequestContext& ctx) {
am->cia_installing = false; am->cia_installing = false;
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
} }
void Module::Interface::EndImportProgramWithoutCommit(Kernel::HLERequestContext& ctx) { void Module::Interface::EndImportProgramWithoutCommit(Kernel::HLERequestContext& ctx) {
@ -1387,7 +1386,7 @@ void Module::Interface::EndImportProgramWithoutCommit(Kernel::HLERequestContext&
am->cia_installing = false; am->cia_installing = false;
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
} }
void Module::Interface::CommitImportPrograms(Kernel::HLERequestContext& ctx) { void Module::Interface::CommitImportPrograms(Kernel::HLERequestContext& ctx) {
@ -1402,7 +1401,7 @@ void Module::Interface::CommitImportPrograms(Kernel::HLERequestContext& ctx) {
am->ScanForAllTitles(); am->ScanForAllTitles();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushMappedBuffer(buffer); rb.PushMappedBuffer(buffer);
} }
@ -1445,14 +1444,14 @@ ResultVal<std::unique_ptr<AMFileWrapper>> GetFileFromSession(
if (file_session->parent == nullptr) { if (file_session->parent == nullptr) {
LOG_WARNING(Service_AM, "Invalid file handle!"); LOG_WARNING(Service_AM, "Invalid file handle!");
return Kernel::ERR_INVALID_HANDLE; return Kernel::ResultInvalidHandle;
} }
std::shared_ptr<Kernel::ServerSession> server = std::shared_ptr<Kernel::ServerSession> server =
Kernel::SharedFrom(file_session->parent->server); Kernel::SharedFrom(file_session->parent->server);
if (server == nullptr) { if (server == nullptr) {
LOG_WARNING(Service_AM, "File handle ServerSession disconnected!"); LOG_WARNING(Service_AM, "File handle ServerSession disconnected!");
return Kernel::ERR_SESSION_CLOSED_BY_REMOTE; return Kernel::ResultSessionClosed;
} }
if (server->hle_handler != nullptr) { if (server->hle_handler != nullptr) {
@ -1468,13 +1467,13 @@ ResultVal<std::unique_ptr<AMFileWrapper>> GetFileFromSession(
} }
LOG_ERROR(Service_AM, "Failed to cast handle to FSFile!"); LOG_ERROR(Service_AM, "Failed to cast handle to FSFile!");
return Kernel::ERR_INVALID_HANDLE; return Kernel::ResultInvalidHandle;
} }
// Probably the best bet if someone is LLEing the fs service is to just have them LLE AM // Probably the best bet if someone is LLEing the fs service is to just have them LLE AM
// while they're at it, so not implemented. // while they're at it, so not implemented.
LOG_ERROR(Service_AM, "Given file handle does not have an HLE handler!"); LOG_ERROR(Service_AM, "Given file handle does not have an HLE handler!");
return Kernel::ERR_NOT_IMPLEMENTED; return Kernel::ResultNotImplemented;
} }
void Module::Interface::GetProgramInfoFromCia(Kernel::HLERequestContext& ctx) { void Module::Interface::GetProgramInfoFromCia(Kernel::HLERequestContext& ctx) {
@ -1492,8 +1491,8 @@ void Module::Interface::GetProgramInfoFromCia(Kernel::HLERequestContext& ctx) {
FileSys::CIAContainer container; FileSys::CIAContainer container;
if (container.Load(*file_res.Unwrap()) != Loader::ResultStatus::Success) { if (container.Load(*file_res.Unwrap()) != Loader::ResultStatus::Success) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ResultCode(ErrCodes::InvalidCIAHeader, ErrorModule::AM, rb.Push(Result(ErrCodes::InvalidCIAHeader, ErrorModule::AM, ErrorSummary::InvalidArgument,
ErrorSummary::InvalidArgument, ErrorLevel::Permanent)); ErrorLevel::Permanent));
return; return;
} }
@ -1510,7 +1509,7 @@ void Module::Interface::GetProgramInfoFromCia(Kernel::HLERequestContext& ctx) {
title_info.type = tmd.GetTitleType(); title_info.type = tmd.GetTitleType();
IPC::RequestBuilder rb = rp.MakeBuilder(8, 0); IPC::RequestBuilder rb = rp.MakeBuilder(8, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushRaw<TitleInfo>(title_info); rb.PushRaw<TitleInfo>(title_info);
} }
@ -1533,8 +1532,8 @@ void Module::Interface::GetSystemMenuDataFromCia(Kernel::HLERequestContext& ctx)
FileSys::CIAContainer container; FileSys::CIAContainer container;
if (container.Load(*file) != Loader::ResultStatus::Success) { if (container.Load(*file) != Loader::ResultStatus::Success) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(ResultCode(ErrCodes::InvalidCIAHeader, ErrorModule::AM, rb.Push(Result(ErrCodes::InvalidCIAHeader, ErrorModule::AM, ErrorSummary::InvalidArgument,
ErrorSummary::InvalidArgument, ErrorLevel::Permanent)); ErrorLevel::Permanent));
rb.PushMappedBuffer(output_buffer); rb.PushMappedBuffer(output_buffer);
return; return;
} }
@ -1545,8 +1544,8 @@ void Module::Interface::GetSystemMenuDataFromCia(Kernel::HLERequestContext& ctx)
temp.size(), temp.data()); temp.size(), temp.data());
if (read_result.Failed() || *read_result != temp.size()) { if (read_result.Failed() || *read_result != temp.size()) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(ResultCode(ErrCodes::InvalidCIAHeader, ErrorModule::AM, rb.Push(Result(ErrCodes::InvalidCIAHeader, ErrorModule::AM, ErrorSummary::InvalidArgument,
ErrorSummary::InvalidArgument, ErrorLevel::Permanent)); ErrorLevel::Permanent));
rb.PushMappedBuffer(output_buffer); rb.PushMappedBuffer(output_buffer);
return; return;
} }
@ -1554,7 +1553,7 @@ void Module::Interface::GetSystemMenuDataFromCia(Kernel::HLERequestContext& ctx)
output_buffer.Write(temp.data(), 0, temp.size()); output_buffer.Write(temp.data(), 0, temp.size());
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushMappedBuffer(output_buffer); rb.PushMappedBuffer(output_buffer);
} }
@ -1572,8 +1571,8 @@ void Module::Interface::GetDependencyListFromCia(Kernel::HLERequestContext& ctx)
FileSys::CIAContainer container; FileSys::CIAContainer container;
if (container.Load(*file_res.Unwrap()) != Loader::ResultStatus::Success) { if (container.Load(*file_res.Unwrap()) != Loader::ResultStatus::Success) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ResultCode(ErrCodes::InvalidCIAHeader, ErrorModule::AM, rb.Push(Result(ErrCodes::InvalidCIAHeader, ErrorModule::AM, ErrorSummary::InvalidArgument,
ErrorSummary::InvalidArgument, ErrorLevel::Permanent)); ErrorLevel::Permanent));
return; return;
} }
@ -1581,7 +1580,7 @@ void Module::Interface::GetDependencyListFromCia(Kernel::HLERequestContext& ctx)
std::memcpy(buffer.data(), container.GetDependencies().data(), buffer.size()); std::memcpy(buffer.data(), container.GetDependencies().data(), buffer.size());
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushStaticBuffer(std::move(buffer), 0); rb.PushStaticBuffer(std::move(buffer), 0);
} }
@ -1599,13 +1598,13 @@ void Module::Interface::GetTransferSizeFromCia(Kernel::HLERequestContext& ctx) {
FileSys::CIAContainer container; FileSys::CIAContainer container;
if (container.Load(*file_res.Unwrap()) != Loader::ResultStatus::Success) { if (container.Load(*file_res.Unwrap()) != Loader::ResultStatus::Success) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ResultCode(ErrCodes::InvalidCIAHeader, ErrorModule::AM, rb.Push(Result(ErrCodes::InvalidCIAHeader, ErrorModule::AM, ErrorSummary::InvalidArgument,
ErrorSummary::InvalidArgument, ErrorLevel::Permanent)); ErrorLevel::Permanent));
return; return;
} }
IPC::RequestBuilder rb = rp.MakeBuilder(3, 0); IPC::RequestBuilder rb = rp.MakeBuilder(3, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push(container.GetMetadataOffset()); rb.Push(container.GetMetadataOffset());
} }
@ -1623,13 +1622,13 @@ void Module::Interface::GetCoreVersionFromCia(Kernel::HLERequestContext& ctx) {
FileSys::CIAContainer container; FileSys::CIAContainer container;
if (container.Load(*file_res.Unwrap()) != Loader::ResultStatus::Success) { if (container.Load(*file_res.Unwrap()) != Loader::ResultStatus::Success) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ResultCode(ErrCodes::InvalidCIAHeader, ErrorModule::AM, rb.Push(Result(ErrCodes::InvalidCIAHeader, ErrorModule::AM, ErrorSummary::InvalidArgument,
ErrorSummary::InvalidArgument, ErrorLevel::Permanent)); ErrorLevel::Permanent));
return; return;
} }
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push(container.GetCoreVersion()); rb.Push(container.GetCoreVersion());
} }
@ -1648,8 +1647,8 @@ void Module::Interface::GetRequiredSizeFromCia(Kernel::HLERequestContext& ctx) {
FileSys::CIAContainer container; FileSys::CIAContainer container;
if (container.Load(*file_res.Unwrap()) != Loader::ResultStatus::Success) { if (container.Load(*file_res.Unwrap()) != Loader::ResultStatus::Success) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ResultCode(ErrCodes::InvalidCIAHeader, ErrorModule::AM, rb.Push(Result(ErrCodes::InvalidCIAHeader, ErrorModule::AM, ErrorSummary::InvalidArgument,
ErrorSummary::InvalidArgument, ErrorLevel::Permanent)); ErrorLevel::Permanent));
return; return;
} }
@ -1657,11 +1656,11 @@ void Module::Interface::GetRequiredSizeFromCia(Kernel::HLERequestContext& ctx) {
// on some mediatypes. Since this is more of a required install size we'll report // on some mediatypes. Since this is more of a required install size we'll report
// what Citra needs, but it would be good to be more accurate here. // what Citra needs, but it would be good to be more accurate here.
IPC::RequestBuilder rb = rp.MakeBuilder(3, 0); IPC::RequestBuilder rb = rp.MakeBuilder(3, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push(container.GetTitleMetadata().GetContentSizeByIndex(FileSys::TMDContentIndex::Main)); 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. // Use the content folder so we don't delete the user's save data.
const auto path = GetTitlePath(media_type, title_id) + "content/"; const auto path = GetTitlePath(media_type, title_id) + "content/";
if (!FileUtil::Exists(path)) { if (!FileUtil::Exists(path)) {
@ -1673,7 +1672,7 @@ ResultCode UninstallProgram(const FS::MediaType media_type, const u64 title_id)
return {ErrorDescription::NotFound, ErrorModule::AM, ErrorSummary::InvalidState, return {ErrorDescription::NotFound, ErrorModule::AM, ErrorSummary::InvalidState,
ErrorLevel::Permanent}; ErrorLevel::Permanent};
} }
return RESULT_SUCCESS; return ResultSuccess;
} }
void Module::Interface::DeleteProgram(Kernel::HLERequestContext& ctx) { void Module::Interface::DeleteProgram(Kernel::HLERequestContext& ctx) {
@ -1694,7 +1693,7 @@ void Module::Interface::GetSystemUpdaterMutex(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx); IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushCopyObjects(am->system_updater_mutex); rb.PushCopyObjects(am->system_updater_mutex);
} }
@ -1713,13 +1712,13 @@ void Module::Interface::GetMetaSizeFromCia(Kernel::HLERequestContext& ctx) {
if (container.Load(*file_res.Unwrap()) != Loader::ResultStatus::Success) { if (container.Load(*file_res.Unwrap()) != Loader::ResultStatus::Success) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ResultCode(ErrCodes::InvalidCIAHeader, ErrorModule::AM, rb.Push(Result(ErrCodes::InvalidCIAHeader, ErrorModule::AM, ErrorSummary::InvalidArgument,
ErrorSummary::InvalidArgument, ErrorLevel::Permanent)); ErrorLevel::Permanent));
return; return;
} }
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push(container.GetMetadataSize()); rb.Push(container.GetMetadataSize());
} }
@ -1744,8 +1743,8 @@ void Module::Interface::GetMetaDataFromCia(Kernel::HLERequestContext& ctx) {
FileSys::CIAContainer container; FileSys::CIAContainer container;
if (container.Load(*file) != Loader::ResultStatus::Success) { if (container.Load(*file) != Loader::ResultStatus::Success) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(ResultCode(ErrCodes::InvalidCIAHeader, ErrorModule::AM, rb.Push(Result(ErrCodes::InvalidCIAHeader, ErrorModule::AM, ErrorSummary::InvalidArgument,
ErrorSummary::InvalidArgument, ErrorLevel::Permanent)); ErrorLevel::Permanent));
rb.PushMappedBuffer(output_buffer); rb.PushMappedBuffer(output_buffer);
return; return;
} }
@ -1755,14 +1754,14 @@ void Module::Interface::GetMetaDataFromCia(Kernel::HLERequestContext& ctx) {
auto read_result = file->Read(container.GetMetadataOffset(), output_size, temp.data()); auto read_result = file->Read(container.GetMetadataOffset(), output_size, temp.data());
if (read_result.Failed() || *read_result != output_size) { if (read_result.Failed() || *read_result != output_size) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ResultCode(ErrCodes::InvalidCIAHeader, ErrorModule::AM, rb.Push(Result(ErrCodes::InvalidCIAHeader, ErrorModule::AM, ErrorSummary::InvalidArgument,
ErrorSummary::InvalidArgument, ErrorLevel::Permanent)); ErrorLevel::Permanent));
return; return;
} }
output_buffer.Write(temp.data(), 0, output_size); output_buffer.Write(temp.data(), 0, output_size);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushMappedBuffer(output_buffer); rb.PushMappedBuffer(output_buffer);
} }
@ -1774,7 +1773,7 @@ void Module::Interface::BeginImportTicket(Kernel::HLERequestContext& ctx) {
FileSys::Path{}); FileSys::Path{});
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS); // No error rb.Push(ResultSuccess); // No error
rb.PushCopyObjects(file->Connect()); rb.PushCopyObjects(file->Connect());
LOG_WARNING(Service_AM, "(STUBBED) called"); LOG_WARNING(Service_AM, "(STUBBED) called");
@ -1785,7 +1784,7 @@ void Module::Interface::EndImportTicket(Kernel::HLERequestContext& ctx) {
[[maybe_unused]] const auto ticket = rp.PopObject<Kernel::ClientSession>(); [[maybe_unused]] const auto ticket = rp.PopObject<Kernel::ClientSession>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_WARNING(Service_AM, "(STUBBED) called"); LOG_WARNING(Service_AM, "(STUBBED) called");
} }

View file

@ -84,8 +84,8 @@ public:
~CIAFile(); ~CIAFile();
ResultVal<std::size_t> Read(u64 offset, std::size_t length, u8* buffer) const override; ResultVal<std::size_t> Read(u64 offset, std::size_t length, u8* buffer) const override;
ResultCode WriteTicket(); Result WriteTicket();
ResultCode WriteTitleMetadata(); Result WriteTitleMetadata();
ResultVal<std::size_t> WriteContentData(u64 offset, std::size_t length, const u8* buffer); ResultVal<std::size_t> WriteContentData(u64 offset, std::size_t length, const u8* buffer);
ResultVal<std::size_t> Write(u64 offset, std::size_t length, bool flush, ResultVal<std::size_t> Write(u64 offset, std::size_t length, bool flush,
const u8* buffer) override; const u8* buffer) override;
@ -203,7 +203,7 @@ std::string GetMediaTitlePath(Service::FS::MediaType media_type);
* @param title_id the title ID to uninstall * @param title_id the title ID to uninstall
* @return result of the uninstall operation * @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 { class Module final {
public: public:

View file

@ -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 // A new parameter can not be sent if the previous one hasn't been consumed yet
if (next_parameter) { if (next_parameter) {
LOG_WARNING(Service_APT, "Parameter from {:03X} to {:03X} blocked by pending parameter.", LOG_WARNING(Service_APT, "Parameter from {:03X} to {:03X} blocked by pending parameter.",
@ -271,18 +271,18 @@ ResultCode AppletManager::SendParameter(const MessageParameter& parameter) {
} }
CancelAndSendParameter(parameter); CancelAndSendParameter(parameter);
return RESULT_SUCCESS; return ResultSuccess;
} }
ResultVal<MessageParameter> AppletManager::GlanceParameter(AppletId app_id) { ResultVal<MessageParameter> AppletManager::GlanceParameter(AppletId app_id) {
if (!next_parameter) { if (!next_parameter) {
return ResultCode(ErrorDescription::NoData, ErrorModule::Applet, ErrorSummary::InvalidState, return Result(ErrorDescription::NoData, ErrorModule::Applet, ErrorSummary::InvalidState,
ErrorLevel::Status); ErrorLevel::Status);
} }
if (next_parameter->destination_id != app_id) { if (next_parameter->destination_id != app_id) {
return ResultCode(ErrorDescription::NotFound, ErrorModule::Applet, ErrorSummary::NotFound, return Result(ErrorDescription::NotFound, ErrorModule::Applet, ErrorSummary::NotFound,
ErrorLevel::Status); ErrorLevel::Status);
} }
auto parameter = *next_parameter; auto parameter = *next_parameter;
@ -348,8 +348,8 @@ ResultVal<AppletManager::InitializeResult> AppletManager::Initialize(AppletId ap
auto slot_data = GetAppletSlot(slot); auto slot_data = GetAppletSlot(slot);
if (slot_data->registered) { if (slot_data->registered) {
LOG_WARNING(Service_APT, "Applet attempted to register in occupied slot {:02X}", slot); LOG_WARNING(Service_APT, "Applet attempted to register in occupied slot {:02X}", slot);
return ResultCode(ErrorDescription::AlreadyExists, ErrorModule::Applet, return Result(ErrorDescription::AlreadyExists, ErrorModule::Applet,
ErrorSummary::InvalidState, ErrorLevel::Status); ErrorSummary::InvalidState, ErrorLevel::Status);
} }
LOG_DEBUG(Service_APT, "Initializing applet with ID {:03X} and attributes {:08X}.", app_id, LOG_DEBUG(Service_APT, "Initializing applet with ID {:03X} and attributes {:08X}.", app_id,
@ -377,7 +377,7 @@ ResultVal<AppletManager::InitializeResult> AppletManager::Initialize(AppletId ap
return InitializeResult{slot_data->notification_event, slot_data->parameter_event}; return InitializeResult{slot_data->notification_event, slot_data->parameter_event};
} }
ResultCode AppletManager::Enable(AppletAttributes attributes) { Result AppletManager::Enable(AppletAttributes attributes) {
auto slot = GetAppletSlotFromAttributes(attributes); auto slot = GetAppletSlotFromAttributes(attributes);
if (slot == AppletSlot::Error) { if (slot == AppletSlot::Error) {
LOG_WARNING(Service_APT, LOG_WARNING(Service_APT,
@ -406,10 +406,10 @@ ResultCode AppletManager::Enable(AppletAttributes attributes) {
delayed_parameter.reset(); delayed_parameter.reset();
} }
return RESULT_SUCCESS; return ResultSuccess;
} }
ResultCode AppletManager::Finalize(AppletId app_id) { Result AppletManager::Finalize(AppletId app_id) {
auto slot = GetAppletSlotFromId(app_id); auto slot = GetAppletSlotFromId(app_id);
if (slot == AppletSlot::Error) { if (slot == AppletSlot::Error) {
return {ErrorDescription::NotFound, ErrorModule::Applet, ErrorSummary::NotFound, return {ErrorDescription::NotFound, ErrorModule::Applet, ErrorSummary::NotFound,
@ -430,7 +430,7 @@ ResultCode AppletManager::Finalize(AppletId app_id) {
active_slot = GetAppletSlotFromPos(AppletPos::System); active_slot = GetAppletSlotFromPos(AppletPos::System);
} }
return RESULT_SUCCESS; return ResultSuccess;
} }
u32 AppletManager::CountRegisteredApplet() { u32 AppletManager::CountRegisteredApplet() {
@ -446,14 +446,14 @@ bool AppletManager::IsRegistered(AppletId app_id) {
ResultVal<AppletAttributes> AppletManager::GetAttribute(AppletId app_id) { ResultVal<AppletAttributes> AppletManager::GetAttribute(AppletId app_id) {
auto slot = GetAppletSlotFromId(app_id); auto slot = GetAppletSlotFromId(app_id);
if (slot == AppletSlot::Error) { if (slot == AppletSlot::Error) {
return ResultCode(ErrorDescription::NotFound, ErrorModule::Applet, ErrorSummary::NotFound, return Result(ErrorDescription::NotFound, ErrorModule::Applet, ErrorSummary::NotFound,
ErrorLevel::Status); ErrorLevel::Status);
} }
auto slot_data = GetAppletSlot(slot); auto slot_data = GetAppletSlot(slot);
if (!slot_data->registered) { if (!slot_data->registered) {
return ResultCode(ErrorDescription::NotFound, ErrorModule::Applet, ErrorSummary::NotFound, return Result(ErrorDescription::NotFound, ErrorModule::Applet, ErrorSummary::NotFound,
ErrorLevel::Status); ErrorLevel::Status);
} }
return slot_data->attributes; return slot_data->attributes;
@ -470,17 +470,17 @@ ResultVal<Notification> AppletManager::InquireNotification(AppletId app_id) {
} }
} }
return ResultCode(ErrorDescription::NotFound, ErrorModule::Applet, ErrorSummary::NotFound, return Result(ErrorDescription::NotFound, ErrorModule::Applet, ErrorSummary::NotFound,
ErrorLevel::Status); ErrorLevel::Status);
} }
ResultCode AppletManager::SendNotification(Notification notification) { Result AppletManager::SendNotification(Notification notification) {
if (active_slot != AppletSlot::Error) { if (active_slot != AppletSlot::Error) {
const auto slot_data = GetAppletSlot(active_slot); const auto slot_data = GetAppletSlot(active_slot);
if (slot_data->registered) { if (slot_data->registered) {
slot_data->notification = notification; slot_data->notification = notification;
slot_data->notification_event->Signal(); slot_data->notification_event->Signal();
return RESULT_SUCCESS; return ResultSuccess;
} }
} }
@ -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 // The real APT service returns an error if there's a pending APT parameter when this function
// is called. // is called.
if (next_parameter) { if (next_parameter) {
@ -519,14 +519,14 @@ ResultCode AppletManager::PrepareToStartLibraryApplet(AppletId applet_id) {
auto process = auto process =
NS::LaunchTitle(FS::MediaType::NAND, GetTitleIdForApplet(applet_id, cfg->GetRegionValue())); NS::LaunchTitle(FS::MediaType::NAND, GetTitleIdForApplet(applet_id, cfg->GetRegionValue()));
if (process) { if (process) {
return RESULT_SUCCESS; return ResultSuccess;
} }
// If we weren't able to load the native applet title, try to fallback to an HLE implementation. // If we weren't able to load the native applet title, try to fallback to an HLE implementation.
auto applet = HLE::Applets::Applet::Get(applet_id); auto applet = HLE::Applets::Applet::Get(applet_id);
if (applet) { if (applet) {
LOG_WARNING(Service_APT, "applet has already been started id={:03X}", applet_id); LOG_WARNING(Service_APT, "applet has already been started id={:03X}", applet_id);
return RESULT_SUCCESS; return ResultSuccess;
} else { } else {
auto parent = GetAppletSlotId(last_library_launcher_slot); auto parent = GetAppletSlotId(last_library_launcher_slot);
LOG_DEBUG(Service_APT, "Creating HLE applet {:03X} with parent {:03X}", applet_id, parent); LOG_DEBUG(Service_APT, "Creating HLE applet {:03X} with parent {:03X}", applet_id, parent);
@ -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) { if (GetAppletSlot(AppletSlot::LibraryApplet)->registered) {
return {ErrorDescription::AlreadyExists, ErrorModule::Applet, ErrorSummary::InvalidState, return {ErrorDescription::AlreadyExists, ErrorModule::Applet, ErrorSummary::InvalidState,
ErrorLevel::Status}; ErrorLevel::Status};
@ -547,14 +547,14 @@ ResultCode AppletManager::PreloadLibraryApplet(AppletId applet_id) {
auto process = auto process =
NS::LaunchTitle(FS::MediaType::NAND, GetTitleIdForApplet(applet_id, cfg->GetRegionValue())); NS::LaunchTitle(FS::MediaType::NAND, GetTitleIdForApplet(applet_id, cfg->GetRegionValue()));
if (process) { if (process) {
return RESULT_SUCCESS; return ResultSuccess;
} }
// If we weren't able to load the native applet title, try to fallback to an HLE implementation. // If we weren't able to load the native applet title, try to fallback to an HLE implementation.
auto applet = HLE::Applets::Applet::Get(applet_id); auto applet = HLE::Applets::Applet::Get(applet_id);
if (applet) { if (applet) {
LOG_WARNING(Service_APT, "applet has already been started id={:08X}", applet_id); LOG_WARNING(Service_APT, "applet has already been started id={:08X}", applet_id);
return RESULT_SUCCESS; return ResultSuccess;
} else { } else {
auto parent = GetAppletSlotId(last_library_launcher_slot); auto parent = GetAppletSlotId(last_library_launcher_slot);
LOG_DEBUG(Service_APT, "Creating HLE applet {:03X} with parent {:03X}", applet_id, parent); LOG_DEBUG(Service_APT, "Creating HLE applet {:03X} with parent {:03X}", applet_id, parent);
@ -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. // TODO(Subv): This function should fail depending on the applet preparation state.
GetAppletSlot(AppletSlot::LibraryApplet)->loaded = true; GetAppletSlot(AppletSlot::LibraryApplet)->loaded = true;
return RESULT_SUCCESS; return ResultSuccess;
} }
ResultCode AppletManager::StartLibraryApplet(AppletId applet_id, Result AppletManager::StartLibraryApplet(AppletId applet_id, std::shared_ptr<Kernel::Object> object,
std::shared_ptr<Kernel::Object> object, const std::vector<u8>& buffer) {
const std::vector<u8>& buffer) {
active_slot = AppletSlot::LibraryApplet; active_slot = AppletSlot::LibraryApplet;
auto send_res = SendParameter({ auto send_res = SendParameter({
@ -585,11 +584,10 @@ ResultCode AppletManager::StartLibraryApplet(AppletId applet_id,
return send_res; return send_res;
} }
return RESULT_SUCCESS; return ResultSuccess;
} }
ResultCode AppletManager::PrepareToCloseLibraryApplet(bool not_pause, bool exiting, Result AppletManager::PrepareToCloseLibraryApplet(bool not_pause, bool exiting, bool jump_home) {
bool jump_home) {
if (next_parameter) { if (next_parameter) {
return {ErrCodes::ParameterPresent, ErrorModule::Applet, ErrorSummary::InvalidState, return {ErrCodes::ParameterPresent, ErrorModule::Applet, ErrorSummary::InvalidState,
ErrorLevel::Status}; ErrorLevel::Status};
@ -604,11 +602,11 @@ ResultCode AppletManager::PrepareToCloseLibraryApplet(bool not_pause, bool exiti
else else
library_applet_closing_command = SignalType::WakeupByExit; library_applet_closing_command = SignalType::WakeupByExit;
return RESULT_SUCCESS; return ResultSuccess;
} }
ResultCode AppletManager::CloseLibraryApplet(std::shared_ptr<Kernel::Object> object, Result AppletManager::CloseLibraryApplet(std::shared_ptr<Kernel::Object> object,
const std::vector<u8>& buffer) { const std::vector<u8>& buffer) {
auto slot = GetAppletSlot(AppletSlot::LibraryApplet); auto slot = GetAppletSlot(AppletSlot::LibraryApplet);
auto destination_id = GetAppletSlotId(last_library_launcher_slot); auto destination_id = GetAppletSlotId(last_library_launcher_slot);
@ -630,10 +628,10 @@ ResultCode AppletManager::CloseLibraryApplet(std::shared_ptr<Kernel::Object> obj
SendParameter(param); SendParameter(param);
} }
return RESULT_SUCCESS; return ResultSuccess;
} }
ResultCode AppletManager::CancelLibraryApplet(bool app_exiting) { Result AppletManager::CancelLibraryApplet(bool app_exiting) {
if (next_parameter) { if (next_parameter) {
return {ErrCodes::ParameterPresent, ErrorModule::Applet, ErrorSummary::InvalidState, return {ErrCodes::ParameterPresent, ErrorModule::Applet, ErrorSummary::InvalidState,
ErrorLevel::Status}; ErrorLevel::Status};
@ -652,8 +650,8 @@ ResultCode AppletManager::CancelLibraryApplet(bool app_exiting) {
}); });
} }
ResultCode AppletManager::SendDspSleep(AppletId from_applet_id, Result AppletManager::SendDspSleep(AppletId from_applet_id,
std::shared_ptr<Kernel::Object> object) { std::shared_ptr<Kernel::Object> object) {
auto lib_slot = GetAppletSlotFromPos(AppletPos::Library); auto lib_slot = GetAppletSlotFromPos(AppletPos::Library);
auto lib_app_id = auto lib_app_id =
lib_slot != AppletSlot::Error ? GetAppletSlot(lib_slot)->applet_id : AppletId::None; lib_slot != AppletSlot::Error ? GetAppletSlot(lib_slot)->applet_id : AppletId::None;
@ -681,11 +679,11 @@ ResultCode AppletManager::SendDspSleep(AppletId from_applet_id,
}); });
} }
return RESULT_SUCCESS; return ResultSuccess;
} }
ResultCode AppletManager::SendDspWakeUp(AppletId from_applet_id, Result AppletManager::SendDspWakeUp(AppletId from_applet_id,
std::shared_ptr<Kernel::Object> object) { std::shared_ptr<Kernel::Object> object) {
auto lib_slot = GetAppletSlotFromPos(AppletPos::Library); auto lib_slot = GetAppletSlotFromPos(AppletPos::Library);
auto lib_app_id = auto lib_app_id =
lib_slot != AppletSlot::Error ? GetAppletSlot(lib_slot)->applet_id : AppletId::None; lib_slot != AppletSlot::Error ? GetAppletSlot(lib_slot)->applet_id : AppletId::None;
@ -714,10 +712,10 @@ ResultCode AppletManager::SendDspWakeUp(AppletId from_applet_id,
} }
} }
return RESULT_SUCCESS; return ResultSuccess;
} }
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 // The real APT service returns an error if there's a pending APT parameter when this function
// is called. // is called.
if (next_parameter) { if (next_parameter) {
@ -726,12 +724,11 @@ ResultCode AppletManager::PrepareToStartSystemApplet(AppletId applet_id) {
} }
last_system_launcher_slot = active_slot; last_system_launcher_slot = active_slot;
return RESULT_SUCCESS; return ResultSuccess;
} }
ResultCode AppletManager::StartSystemApplet(AppletId applet_id, Result AppletManager::StartSystemApplet(AppletId applet_id, std::shared_ptr<Kernel::Object> object,
std::shared_ptr<Kernel::Object> object, const std::vector<u8>& buffer) {
const std::vector<u8>& buffer) {
auto source_applet_id = AppletId::None; auto source_applet_id = AppletId::None;
if (last_system_launcher_slot != AppletSlot::Error) { if (last_system_launcher_slot != AppletSlot::Error) {
const auto slot_data = GetAppletSlot(last_system_launcher_slot); const auto slot_data = GetAppletSlot(last_system_launcher_slot);
@ -769,20 +766,20 @@ ResultCode AppletManager::StartSystemApplet(AppletId applet_id,
.buffer = buffer, .buffer = buffer,
}); });
return RESULT_SUCCESS; return ResultSuccess;
} }
ResultCode AppletManager::PrepareToCloseSystemApplet() { Result AppletManager::PrepareToCloseSystemApplet() {
if (next_parameter) { if (next_parameter) {
return {ErrCodes::ParameterPresent, ErrorModule::Applet, ErrorSummary::InvalidState, return {ErrCodes::ParameterPresent, ErrorModule::Applet, ErrorSummary::InvalidState,
ErrorLevel::Status}; ErrorLevel::Status};
} }
return RESULT_SUCCESS; return ResultSuccess;
} }
ResultCode AppletManager::CloseSystemApplet(std::shared_ptr<Kernel::Object> object, Result AppletManager::CloseSystemApplet(std::shared_ptr<Kernel::Object> object,
const std::vector<u8>& buffer) { const std::vector<u8>& buffer) {
ASSERT_MSG(active_slot == AppletSlot::HomeMenu || active_slot == AppletSlot::SystemApplet, ASSERT_MSG(active_slot == AppletSlot::HomeMenu || active_slot == AppletSlot::SystemApplet,
"Attempting to close a system applet from a non-system applet."); "Attempting to close a system applet from a non-system applet.");
@ -806,10 +803,10 @@ ResultCode AppletManager::CloseSystemApplet(std::shared_ptr<Kernel::Object> obje
} }
// TODO: Terminate the running applet title // TODO: Terminate the running applet title
return RESULT_SUCCESS; return ResultSuccess;
} }
ResultCode AppletManager::OrderToCloseSystemApplet() { Result AppletManager::OrderToCloseSystemApplet() {
if (active_slot == AppletSlot::Error) { if (active_slot == AppletSlot::Error) {
return {ErrCodes::InvalidAppletSlot, ErrorModule::Applet, ErrorSummary::InvalidState, return {ErrCodes::InvalidAppletSlot, ErrorModule::Applet, ErrorSummary::InvalidState,
ErrorLevel::Status}; ErrorLevel::Status};
@ -843,10 +840,10 @@ ResultCode AppletManager::OrderToCloseSystemApplet() {
.signal = SignalType::WakeupByCancel, .signal = SignalType::WakeupByCancel,
}); });
return RESULT_SUCCESS; return ResultSuccess;
} }
ResultCode AppletManager::PrepareToJumpToHomeMenu() { Result AppletManager::PrepareToJumpToHomeMenu() {
if (next_parameter) { if (next_parameter) {
return {ErrCodes::ParameterPresent, ErrorModule::Applet, ErrorSummary::InvalidState, return {ErrCodes::ParameterPresent, ErrorModule::Applet, ErrorSummary::InvalidState,
ErrorLevel::Status}; ErrorLevel::Status};
@ -860,11 +857,11 @@ ResultCode AppletManager::PrepareToJumpToHomeMenu() {
EnsureHomeMenuLoaded(); EnsureHomeMenuLoaded();
} }
return RESULT_SUCCESS; return ResultSuccess;
} }
ResultCode AppletManager::JumpToHomeMenu(std::shared_ptr<Kernel::Object> object, Result AppletManager::JumpToHomeMenu(std::shared_ptr<Kernel::Object> object,
const std::vector<u8>& buffer) { const std::vector<u8>& buffer) {
if (last_jump_to_home_slot != AppletSlot::Error) { if (last_jump_to_home_slot != AppletSlot::Error) {
auto slot_data = GetAppletSlot(last_jump_to_home_slot); auto slot_data = GetAppletSlot(last_jump_to_home_slot);
if (slot_data->applet_id != AppletId::None) { if (slot_data->applet_id != AppletId::None) {
@ -910,10 +907,10 @@ ResultCode AppletManager::JumpToHomeMenu(std::shared_ptr<Kernel::Object> object,
} }
} }
return RESULT_SUCCESS; return ResultSuccess;
} }
ResultCode AppletManager::PrepareToLeaveHomeMenu() { Result AppletManager::PrepareToLeaveHomeMenu() {
if (!GetAppletSlot(AppletSlot::Application)->registered) { if (!GetAppletSlot(AppletSlot::Application)->registered) {
return {ErrCodes::InvalidAppletSlot, ErrorModule::Applet, ErrorSummary::InvalidState, return {ErrCodes::InvalidAppletSlot, ErrorModule::Applet, ErrorSummary::InvalidState,
ErrorLevel::Status}; ErrorLevel::Status};
@ -924,11 +921,11 @@ ResultCode AppletManager::PrepareToLeaveHomeMenu() {
ErrorLevel::Status}; ErrorLevel::Status};
} }
return RESULT_SUCCESS; return ResultSuccess;
} }
ResultCode AppletManager::LeaveHomeMenu(std::shared_ptr<Kernel::Object> object, Result AppletManager::LeaveHomeMenu(std::shared_ptr<Kernel::Object> object,
const std::vector<u8>& buffer) { const std::vector<u8>& buffer) {
active_slot = AppletSlot::Application; active_slot = AppletSlot::Application;
SendParameter({ SendParameter({
@ -939,10 +936,10 @@ ResultCode AppletManager::LeaveHomeMenu(std::shared_ptr<Kernel::Object> object,
.buffer = buffer, .buffer = buffer,
}); });
return RESULT_SUCCESS; return ResultSuccess;
} }
ResultCode AppletManager::OrderToCloseApplication() { Result AppletManager::OrderToCloseApplication() {
if (active_slot == AppletSlot::Error) { if (active_slot == AppletSlot::Error) {
return {ErrCodes::InvalidAppletSlot, ErrorModule::Applet, ErrorSummary::InvalidState, return {ErrCodes::InvalidAppletSlot, ErrorModule::Applet, ErrorSummary::InvalidState,
ErrorLevel::Status}; ErrorLevel::Status};
@ -964,10 +961,10 @@ ResultCode AppletManager::OrderToCloseApplication() {
.signal = SignalType::WakeupByCancel, .signal = SignalType::WakeupByCancel,
}); });
return RESULT_SUCCESS; return ResultSuccess;
} }
ResultCode AppletManager::PrepareToCloseApplication(bool return_to_sys) { Result AppletManager::PrepareToCloseApplication(bool return_to_sys) {
if (active_slot == AppletSlot::Error) { if (active_slot == AppletSlot::Error) {
return {ErrCodes::InvalidAppletSlot, ErrorModule::Applet, ErrorSummary::InvalidState, return {ErrCodes::InvalidAppletSlot, ErrorModule::Applet, ErrorSummary::InvalidState,
ErrorLevel::Status}; ErrorLevel::Status};
@ -1015,11 +1012,11 @@ ResultCode AppletManager::PrepareToCloseApplication(bool return_to_sys) {
// EnsureHomeMenuLoaded(); // EnsureHomeMenuLoaded();
} }
return RESULT_SUCCESS; return ResultSuccess;
} }
ResultCode AppletManager::CloseApplication(std::shared_ptr<Kernel::Object> object, Result AppletManager::CloseApplication(std::shared_ptr<Kernel::Object> object,
const std::vector<u8>& buffer) { const std::vector<u8>& buffer) {
ordered_to_close_application = false; ordered_to_close_application = false;
application_cancelled = false; application_cancelled = false;
@ -1044,7 +1041,7 @@ ResultCode AppletManager::CloseApplication(std::shared_ptr<Kernel::Object> objec
} }
// TODO: Terminate the application process. // TODO: Terminate the application process.
return RESULT_SUCCESS; return ResultSuccess;
} }
ResultVal<AppletManager::AppletManInfo> AppletManager::GetAppletManInfo( ResultVal<AppletManager::AppletManInfo> AppletManager::GetAppletManInfo(
@ -1079,14 +1076,14 @@ ResultVal<AppletManager::AppletManInfo> AppletManager::GetAppletManInfo(
ResultVal<AppletManager::AppletInfo> AppletManager::GetAppletInfo(AppletId app_id) { ResultVal<AppletManager::AppletInfo> AppletManager::GetAppletInfo(AppletId app_id) {
auto slot = GetAppletSlotFromId(app_id); auto slot = GetAppletSlotFromId(app_id);
if (slot == AppletSlot::Error) { if (slot == AppletSlot::Error) {
return ResultCode(ErrorDescription::NotFound, ErrorModule::Applet, ErrorSummary::NotFound, return Result(ErrorDescription::NotFound, ErrorModule::Applet, ErrorSummary::NotFound,
ErrorLevel::Status); ErrorLevel::Status);
} }
auto slot_data = GetAppletSlot(slot); auto slot_data = GetAppletSlot(slot);
if (!slot_data->registered) { if (!slot_data->registered) {
return ResultCode(ErrorDescription::NotFound, ErrorModule::Applet, ErrorSummary::NotFound, return Result(ErrorDescription::NotFound, ErrorModule::Applet, ErrorSummary::NotFound,
ErrorLevel::Status); ErrorLevel::Status);
} }
auto media_type = Service::AM::GetTitleMediaType(slot_data->title_id); auto media_type = Service::AM::GetTitleMediaType(slot_data->title_id);
@ -1102,14 +1099,13 @@ ResultVal<AppletManager::AppletInfo> AppletManager::GetAppletInfo(AppletId app_i
ResultVal<Service::FS::MediaType> AppletManager::Unknown54(u32 in_param) { ResultVal<Service::FS::MediaType> AppletManager::Unknown54(u32 in_param) {
auto slot_data = GetAppletSlot(AppletSlot::Application); auto slot_data = GetAppletSlot(AppletSlot::Application);
if (slot_data->applet_id == AppletId::None) { if (slot_data->applet_id == AppletId::None) {
return ResultCode{ErrCodes::AppNotRunning, ErrorModule::Applet, ErrorSummary::InvalidState, return Result{ErrCodes::AppNotRunning, ErrorModule::Applet, ErrorSummary::InvalidState,
ErrorLevel::Permanent}; ErrorLevel::Permanent};
} }
if (in_param >= 0x80) { if (in_param >= 0x80) {
// TODO: Add error description name when the parameter is known. // TODO: Add error description name when the parameter is known.
return ResultCode{10, ErrorModule::Applet, ErrorSummary::InvalidArgument, return Result{10, ErrorModule::Applet, ErrorSummary::InvalidArgument, ErrorLevel::Usage};
ErrorLevel::Usage};
} }
// TODO: Figure out what this logic is actually for. // 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, Result AppletManager::PrepareToDoApplicationJump(u64 title_id, FS::MediaType media_type,
ApplicationJumpFlags flags) { ApplicationJumpFlags flags) {
// A running application can not launch another application directly because the applet state // 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 // 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. // launch the Home Menu and tell it to launch our desired application.
@ -1180,10 +1176,10 @@ ResultCode AppletManager::PrepareToDoApplicationJump(u64 title_id, FS::MediaType
// Note: The real console uses the Home Menu to perform the application jump, therefore the menu // Note: The real console uses the Home Menu to perform the application jump, therefore the menu
// needs to be running. The real APT module starts the Home Menu here if it's not already // needs to be running. The real APT module starts the Home Menu here if it's not already
// running, we don't have to do this. See `EnsureHomeMenuLoaded` for launching the Home Menu. // running, we don't have to do this. See `EnsureHomeMenuLoaded` for launching the Home Menu.
return RESULT_SUCCESS; return ResultSuccess;
} }
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 // 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 // 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 // we launch the new application directly. In the real APT service, the Home Menu must be
@ -1212,7 +1208,7 @@ ResultCode AppletManager::DoApplicationJump(const DeliverArg& arg) {
}); });
// TODO: APT terminates the application here, usually it will exit itself properly though. // TODO: APT terminates the application here, usually it will exit itself properly though.
return RESULT_SUCCESS; return ResultSuccess;
} else { } else {
// Otherwise, work around the missing home menu by launching the title directly. // Otherwise, work around the missing home menu by launching the title directly.
@ -1227,16 +1223,16 @@ ResultCode AppletManager::DoApplicationJump(const DeliverArg& arg) {
LOG_CRITICAL(Service_APT, "Failed to launch title during application jump, exiting."); LOG_CRITICAL(Service_APT, "Failed to launch title during application jump, exiting.");
system.RequestShutdown(); system.RequestShutdown();
} }
return RESULT_SUCCESS; return ResultSuccess;
*/ */
NS::RebootToTitle(system, app_jump_parameters.next_media_type, NS::RebootToTitle(system, app_jump_parameters.next_media_type,
app_jump_parameters.next_title_id); app_jump_parameters.next_title_id);
return RESULT_SUCCESS; return ResultSuccess;
} }
} }
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 || if (active_slot == AppletSlot::Error ||
GetAppletSlot(active_slot)->attributes.applet_pos != AppletPos::System) { GetAppletSlot(active_slot)->attributes.applet_pos != AppletPos::System) {
return {ErrCodes::InvalidAppletSlot, ErrorModule::Applet, ErrorSummary::InvalidState, return {ErrCodes::InvalidAppletSlot, ErrorModule::Applet, ErrorSummary::InvalidState,
@ -1259,11 +1255,11 @@ ResultCode AppletManager::PrepareToStartApplication(u64 title_id, FS::MediaType
capture_buffer_info.reset(); capture_buffer_info.reset();
return RESULT_SUCCESS; return ResultSuccess;
} }
ResultCode AppletManager::StartApplication(const std::vector<u8>& parameter, Result AppletManager::StartApplication(const std::vector<u8>& parameter,
const std::vector<u8>& hmac, bool paused) { const std::vector<u8>& hmac, bool paused) {
// The delivery argument is always unconditionally set. // The delivery argument is always unconditionally set.
deliver_arg.emplace(DeliverArg{parameter, hmac}); deliver_arg.emplace(DeliverArg{parameter, hmac});
@ -1295,11 +1291,11 @@ ResultCode AppletManager::StartApplication(const std::vector<u8>& parameter,
return WakeupApplication(nullptr, {}); return WakeupApplication(nullptr, {});
} }
return RESULT_SUCCESS; return ResultSuccess;
} }
ResultCode AppletManager::WakeupApplication(std::shared_ptr<Kernel::Object> object, Result AppletManager::WakeupApplication(std::shared_ptr<Kernel::Object> object,
const std::vector<u8>& buffer) { const std::vector<u8>& buffer) {
// Send a Wakeup signal via the apt parameter to the application once it registers itself. // 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 // The real APT service does this by spin waiting on another thread until the application is
// registered. // registered.
@ -1311,10 +1307,10 @@ ResultCode AppletManager::WakeupApplication(std::shared_ptr<Kernel::Object> obje
.buffer = buffer, .buffer = buffer,
}); });
return RESULT_SUCCESS; return ResultSuccess;
} }
ResultCode AppletManager::CancelApplication() { Result AppletManager::CancelApplication() {
auto application_slot_data = GetAppletSlot(AppletSlot::Application); auto application_slot_data = GetAppletSlot(AppletSlot::Application);
if (application_slot_data->applet_id == AppletId::None) { if (application_slot_data->applet_id == AppletId::None) {
return {ErrCodes::InvalidAppletSlot, ErrorModule::Applet, ErrorSummary::InvalidState, return {ErrCodes::InvalidAppletSlot, ErrorModule::Applet, ErrorSummary::InvalidState,
@ -1330,7 +1326,7 @@ ResultCode AppletManager::CancelApplication() {
.signal = SignalType::WakeupByCancel, .signal = SignalType::WakeupByCancel,
}); });
return RESULT_SUCCESS; return ResultSuccess;
} }
void AppletManager::SendApplicationParameterAfterRegistration(const MessageParameter& parameter) { void AppletManager::SendApplicationParameterAfterRegistration(const MessageParameter& parameter) {

View file

@ -264,7 +264,7 @@ public:
*/ */
void CancelAndSendParameter(const MessageParameter& parameter); void CancelAndSendParameter(const MessageParameter& parameter);
ResultCode SendParameter(const MessageParameter& parameter); Result SendParameter(const MessageParameter& parameter);
ResultVal<MessageParameter> GlanceParameter(AppletId app_id); ResultVal<MessageParameter> GlanceParameter(AppletId app_id);
ResultVal<MessageParameter> ReceiveParameter(AppletId app_id); ResultVal<MessageParameter> ReceiveParameter(AppletId app_id);
bool CancelParameter(bool check_sender, AppletId sender_appid, bool check_receiver, bool CancelParameter(bool check_sender, AppletId sender_appid, bool check_receiver,
@ -283,51 +283,48 @@ public:
}; };
ResultVal<InitializeResult> Initialize(AppletId app_id, AppletAttributes attributes); ResultVal<InitializeResult> Initialize(AppletId app_id, AppletAttributes attributes);
ResultCode Enable(AppletAttributes attributes); Result Enable(AppletAttributes attributes);
ResultCode Finalize(AppletId app_id); Result Finalize(AppletId app_id);
u32 CountRegisteredApplet(); u32 CountRegisteredApplet();
bool IsRegistered(AppletId app_id); bool IsRegistered(AppletId app_id);
ResultVal<AppletAttributes> GetAttribute(AppletId app_id); ResultVal<AppletAttributes> GetAttribute(AppletId app_id);
ResultVal<Notification> InquireNotification(AppletId app_id); ResultVal<Notification> InquireNotification(AppletId app_id);
ResultCode SendNotification(Notification notification); Result SendNotification(Notification notification);
void SendNotificationToAll(Notification notification); void SendNotificationToAll(Notification notification);
ResultCode PrepareToStartLibraryApplet(AppletId applet_id); Result PrepareToStartLibraryApplet(AppletId applet_id);
ResultCode PreloadLibraryApplet(AppletId applet_id); Result PreloadLibraryApplet(AppletId applet_id);
ResultCode FinishPreloadingLibraryApplet(AppletId applet_id); Result FinishPreloadingLibraryApplet(AppletId applet_id);
ResultCode StartLibraryApplet(AppletId applet_id, std::shared_ptr<Kernel::Object> object, Result StartLibraryApplet(AppletId applet_id, std::shared_ptr<Kernel::Object> object,
const std::vector<u8>& buffer);
ResultCode PrepareToCloseLibraryApplet(bool not_pause, bool exiting, bool jump_home);
ResultCode CloseLibraryApplet(std::shared_ptr<Kernel::Object> object,
const std::vector<u8>& buffer);
ResultCode CancelLibraryApplet(bool app_exiting);
ResultCode SendDspSleep(AppletId from_applet_id, std::shared_ptr<Kernel::Object> object);
ResultCode SendDspWakeUp(AppletId from_applet_id, std::shared_ptr<Kernel::Object> object);
ResultCode PrepareToStartSystemApplet(AppletId applet_id);
ResultCode StartSystemApplet(AppletId applet_id, std::shared_ptr<Kernel::Object> object,
const std::vector<u8>& buffer);
ResultCode PrepareToCloseSystemApplet();
ResultCode CloseSystemApplet(std::shared_ptr<Kernel::Object> object,
const std::vector<u8>& buffer);
ResultCode OrderToCloseSystemApplet();
ResultCode PrepareToJumpToHomeMenu();
ResultCode JumpToHomeMenu(std::shared_ptr<Kernel::Object> object,
const std::vector<u8>& buffer); const std::vector<u8>& buffer);
ResultCode PrepareToLeaveHomeMenu(); Result PrepareToCloseLibraryApplet(bool not_pause, bool exiting, bool jump_home);
ResultCode LeaveHomeMenu(std::shared_ptr<Kernel::Object> object, const std::vector<u8>& buffer); Result CloseLibraryApplet(std::shared_ptr<Kernel::Object> object,
const std::vector<u8>& buffer);
Result CancelLibraryApplet(bool app_exiting);
ResultCode OrderToCloseApplication(); Result SendDspSleep(AppletId from_applet_id, std::shared_ptr<Kernel::Object> object);
ResultCode PrepareToCloseApplication(bool return_to_sys); Result SendDspWakeUp(AppletId from_applet_id, std::shared_ptr<Kernel::Object> object);
ResultCode CloseApplication(std::shared_ptr<Kernel::Object> object,
const std::vector<u8>& buffer);
ResultCode PrepareToDoApplicationJump(u64 title_id, FS::MediaType media_type, Result PrepareToStartSystemApplet(AppletId applet_id);
ApplicationJumpFlags flags); Result StartSystemApplet(AppletId applet_id, std::shared_ptr<Kernel::Object> object,
ResultCode DoApplicationJump(const DeliverArg& arg); const std::vector<u8>& buffer);
Result PrepareToCloseSystemApplet();
Result CloseSystemApplet(std::shared_ptr<Kernel::Object> object, const std::vector<u8>& buffer);
Result OrderToCloseSystemApplet();
Result PrepareToJumpToHomeMenu();
Result JumpToHomeMenu(std::shared_ptr<Kernel::Object> object, const std::vector<u8>& buffer);
Result PrepareToLeaveHomeMenu();
Result LeaveHomeMenu(std::shared_ptr<Kernel::Object> object, const std::vector<u8>& buffer);
Result OrderToCloseApplication();
Result PrepareToCloseApplication(bool return_to_sys);
Result CloseApplication(std::shared_ptr<Kernel::Object> object, const std::vector<u8>& buffer);
Result PrepareToDoApplicationJump(u64 title_id, FS::MediaType media_type,
ApplicationJumpFlags flags);
Result DoApplicationJump(const DeliverArg& arg);
boost::optional<DeliverArg> ReceiveDeliverArg() { boost::optional<DeliverArg> ReceiveDeliverArg() {
auto arg = deliver_arg; auto arg = deliver_arg;
@ -369,12 +366,11 @@ public:
std::memcpy(&capture_buffer_info.get(), buffer.data(), sizeof(CaptureBufferInfo)); std::memcpy(&capture_buffer_info.get(), buffer.data(), sizeof(CaptureBufferInfo));
} }
ResultCode PrepareToStartApplication(u64 title_id, FS::MediaType media_type); Result PrepareToStartApplication(u64 title_id, FS::MediaType media_type);
ResultCode StartApplication(const std::vector<u8>& parameter, const std::vector<u8>& hmac, Result StartApplication(const std::vector<u8>& parameter, const std::vector<u8>& hmac,
bool paused); bool paused);
ResultCode WakeupApplication(std::shared_ptr<Kernel::Object> object, Result WakeupApplication(std::shared_ptr<Kernel::Object> object, const std::vector<u8>& buffer);
const std::vector<u8>& buffer); Result CancelApplication();
ResultCode CancelApplication();
struct AppletManInfo { struct AppletManInfo {
AppletPos active_applet_pos; AppletPos active_applet_pos;

View file

@ -70,7 +70,7 @@ void Module::NSInterface::SetWirelessRebootInfo(Kernel::HLERequestContext& ctx)
apt->wireless_reboot_info = std::move(buffer); apt->wireless_reboot_info = std::move(buffer);
auto rb = rp.MakeBuilder(1, 0); auto rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_WARNING(Service_APT, "called size={}", size); LOG_WARNING(Service_APT, "called size={}", size);
} }
@ -83,7 +83,7 @@ void Module::NSInterface::ShutdownAsync(Kernel::HLERequestContext& ctx) {
apt->system.RequestShutdown(); apt->system.RequestShutdown();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
} }
void Module::NSInterface::RebootSystem(Kernel::HLERequestContext& ctx) { void Module::NSInterface::RebootSystem(Kernel::HLERequestContext& ctx) {
@ -107,7 +107,7 @@ void Module::NSInterface::RebootSystem(Kernel::HLERequestContext& ctx) {
} }
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
} }
void Module::NSInterface::RebootSystemClean(Kernel::HLERequestContext& ctx) { void Module::NSInterface::RebootSystemClean(Kernel::HLERequestContext& ctx) {
@ -118,7 +118,7 @@ void Module::NSInterface::RebootSystemClean(Kernel::HLERequestContext& ctx) {
apt->system.RequestReset(); apt->system.RequestReset();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
} }
void Module::APTInterface::Initialize(Kernel::HLERequestContext& ctx) { void Module::APTInterface::Initialize(Kernel::HLERequestContext& ctx) {
@ -134,7 +134,7 @@ void Module::APTInterface::Initialize(Kernel::HLERequestContext& ctx) {
rb.Push(result.Code()); rb.Push(result.Code());
} else { } else {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 3); IPC::RequestBuilder rb = rp.MakeBuilder(1, 3);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushCopyObjects(result->notification_event, result->parameter_event); rb.PushCopyObjects(result->notification_event, result->parameter_event);
} }
} }
@ -314,7 +314,7 @@ void Module::APTInterface::GetSharedFont(Kernel::HLERequestContext& ctx) {
apt->shared_font_relocated = true; apt->shared_font_relocated = true;
} }
rb.Push(RESULT_SUCCESS); // No error rb.Push(ResultSuccess); // No error
// Since the SharedMemory interface doesn't provide the address at which the memory was // Since the SharedMemory interface doesn't provide the address at which the memory was
// allocated, the real APT service calculates this address by scanning the entire address space // allocated, the real APT service calculates this address by scanning the entire address space
// (using svcQueryMemory) and searches for an allocation of the same size as the Shared Font. // (using svcQueryMemory) and searches for an allocation of the same size as the Shared Font.
@ -329,7 +329,7 @@ void Module::APTInterface::GetWirelessRebootInfo(Kernel::HLERequestContext& ctx)
LOG_WARNING(Service_APT, "called size={:08X}", size); LOG_WARNING(Service_APT, "called size={:08X}", size);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushStaticBuffer(apt->wireless_reboot_info, 0); rb.PushStaticBuffer(apt->wireless_reboot_info, 0);
} }
@ -338,7 +338,7 @@ void Module::APTInterface::NotifyToWait(Kernel::HLERequestContext& ctx) {
const auto app_id = rp.Pop<u32>(); const auto app_id = rp.Pop<u32>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); // No error rb.Push(ResultSuccess); // No error
LOG_WARNING(Service_APT, "(STUBBED) app_id={}", app_id); LOG_WARNING(Service_APT, "(STUBBED) app_id={}", app_id);
} }
@ -359,7 +359,7 @@ void Module::APTInterface::GetLockHandle(Kernel::HLERequestContext& ctx) {
rb.Push(result.Code()); rb.Push(result.Code());
} else { } else {
IPC::RequestBuilder rb = rp.MakeBuilder(3, 2); IPC::RequestBuilder rb = rp.MakeBuilder(3, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushRaw(result->corrected_attributes); rb.PushRaw(result->corrected_attributes);
rb.Push<u32>(result->state); rb.Push<u32>(result->state);
rb.PushCopyObjects(result->lock); rb.PushCopyObjects(result->lock);
@ -398,7 +398,7 @@ void Module::APTInterface::GetAppletManInfo(Kernel::HLERequestContext& ctx) {
rb.Push(info.Code()); rb.Push(info.Code());
} else { } else {
IPC::RequestBuilder rb = rp.MakeBuilder(5, 0); IPC::RequestBuilder rb = rp.MakeBuilder(5, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushEnum(info->active_applet_pos); rb.PushEnum(info->active_applet_pos);
rb.PushEnum(info->requested_applet_id); rb.PushEnum(info->requested_applet_id);
rb.PushEnum(info->home_menu_applet_id); rb.PushEnum(info->home_menu_applet_id);
@ -412,7 +412,7 @@ void Module::APTInterface::CountRegisteredApplet(Kernel::HLERequestContext& ctx)
LOG_DEBUG(Service_APT, "called"); LOG_DEBUG(Service_APT, "called");
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push(apt->applet_manager->CountRegisteredApplet()); rb.Push(apt->applet_manager->CountRegisteredApplet());
} }
@ -421,7 +421,7 @@ void Module::APTInterface::IsRegistered(Kernel::HLERequestContext& ctx) {
const auto app_id = rp.PopEnum<AppletId>(); const auto app_id = rp.PopEnum<AppletId>();
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); // No error rb.Push(ResultSuccess); // No error
rb.Push(apt->applet_manager->IsRegistered(app_id)); rb.Push(apt->applet_manager->IsRegistered(app_id));
LOG_DEBUG(Service_APT, "called app_id={:#010X}", app_id); LOG_DEBUG(Service_APT, "called app_id={:#010X}", app_id);
@ -439,7 +439,7 @@ void Module::APTInterface::GetAttribute(Kernel::HLERequestContext& ctx) {
rb.Push(applet_attr.Code()); rb.Push(applet_attr.Code());
} else { } else {
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push(applet_attr.Unwrap().raw); rb.Push(applet_attr.Unwrap().raw);
} }
} }
@ -456,7 +456,7 @@ void Module::APTInterface::InquireNotification(Kernel::HLERequestContext& ctx) {
rb.Push(notification.Code()); rb.Push(notification.Code());
} else { } else {
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push(static_cast<u32>(notification.Unwrap())); rb.Push(static_cast<u32>(notification.Unwrap()));
} }
} }
@ -502,7 +502,7 @@ void Module::APTInterface::ReceiveParameter(Kernel::HLERequestContext& ctx) {
buffer_size); // APT always push a buffer with the maximum size buffer_size); // APT always push a buffer with the maximum size
IPC::RequestBuilder rb = rp.MakeBuilder(4, 4); IPC::RequestBuilder rb = rp.MakeBuilder(4, 4);
rb.Push(RESULT_SUCCESS); // No error rb.Push(ResultSuccess); // No error
rb.PushEnum(next_parameter->sender_id); rb.PushEnum(next_parameter->sender_id);
rb.PushEnum(next_parameter->signal); // Signal type rb.PushEnum(next_parameter->signal); // Signal type
rb.Push(size); // Parameter buffer size rb.Push(size); // Parameter buffer size
@ -528,7 +528,7 @@ void Module::APTInterface::GlanceParameter(Kernel::HLERequestContext& ctx) {
buffer_size); // APT always push a buffer with the maximum size buffer_size); // APT always push a buffer with the maximum size
IPC::RequestBuilder rb = rp.MakeBuilder(4, 4); IPC::RequestBuilder rb = rp.MakeBuilder(4, 4);
rb.Push(RESULT_SUCCESS); // No error rb.Push(ResultSuccess); // No error
rb.PushEnum(next_parameter->sender_id); rb.PushEnum(next_parameter->sender_id);
rb.PushEnum(next_parameter->signal); // Signal type rb.PushEnum(next_parameter->signal); // Signal type
rb.Push(size); // Parameter buffer size rb.Push(size); // Parameter buffer size
@ -550,7 +550,7 @@ void Module::APTInterface::CancelParameter(Kernel::HLERequestContext& ctx) {
check_sender, sender_appid, check_receiver, receiver_appid); check_sender, sender_appid, check_receiver, receiver_appid);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); // No error rb.Push(ResultSuccess); // No error
rb.Push(apt->applet_manager->CancelParameter(check_sender, sender_appid, check_receiver, rb.Push(apt->applet_manager->CancelParameter(check_sender, sender_appid, check_receiver,
receiver_appid)); receiver_appid));
} }
@ -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, LOG_INFO(Service_APT, "called title_id={:016X}, media_type={:#01X}, flags={:#08X}", title_id,
media_type, flags); media_type, flags);
ResultCode result = apt->applet_manager->PrepareToDoApplicationJump( Result result = apt->applet_manager->PrepareToDoApplicationJump(
title_id, static_cast<FS::MediaType>(media_type), flags); title_id, static_cast<FS::MediaType>(media_type), flags);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
@ -592,7 +592,7 @@ void Module::APTInterface::GetProgramIdOnApplicationJump(Kernel::HLERequestConte
const auto parameters = apt->applet_manager->GetApplicationJumpParameters(); const auto parameters = apt->applet_manager->GetApplicationJumpParameters();
IPC::RequestBuilder rb = rp.MakeBuilder(7, 0); IPC::RequestBuilder rb = rp.MakeBuilder(7, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push<u64>(parameters.current_title_id); rb.Push<u64>(parameters.current_title_id);
rb.Push(static_cast<u8>(parameters.current_media_type)); rb.Push(static_cast<u8>(parameters.current_media_type));
rb.Push<u64>(parameters.next_title_id); rb.Push<u64>(parameters.next_title_id);
@ -611,7 +611,7 @@ void Module::APTInterface::SendDeliverArg(Kernel::HLERequestContext& ctx) {
apt->applet_manager->SetDeliverArg(DeliverArg{param, hmac}); apt->applet_manager->SetDeliverArg(DeliverArg{param, hmac});
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
} }
void Module::APTInterface::ReceiveDeliverArg(Kernel::HLERequestContext& ctx) { void Module::APTInterface::ReceiveDeliverArg(Kernel::HLERequestContext& ctx) {
@ -626,7 +626,7 @@ void Module::APTInterface::ReceiveDeliverArg(Kernel::HLERequestContext& ctx) {
arg.hmac.resize(std::min<std::size_t>(hmac_size, 0x20)); arg.hmac.resize(std::min<std::size_t>(hmac_size, 0x20));
IPC::RequestBuilder rb = rp.MakeBuilder(4, 4); IPC::RequestBuilder rb = rp.MakeBuilder(4, 4);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push(arg.source_program_id); rb.Push(arg.source_program_id);
rb.Push<u8>(1); rb.Push<u8>(1);
rb.PushStaticBuffer(std::move(arg.param), 0); rb.PushStaticBuffer(std::move(arg.param), 0);
@ -702,8 +702,8 @@ void Module::APTInterface::AppletUtility(Kernel::HLERequestContext& ctx) {
} }
IPC::RequestBuilder rb = rp.MakeBuilder(2, 2); IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
rb.Push(RESULT_SUCCESS); // No error rb.Push(ResultSuccess); // No error
rb.Push(RESULT_SUCCESS); // Utility function result rb.Push(ResultSuccess); // Utility function result
rb.PushStaticBuffer(out, 0); rb.PushStaticBuffer(out, 0);
} }
@ -720,7 +720,7 @@ void Module::APTInterface::SetAppCpuTimeLimit(Kernel::HLERequestContext& ctx) {
apt->cpu_percent = value; apt->cpu_percent = value;
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); // No error rb.Push(ResultSuccess); // No error
} }
void Module::APTInterface::GetAppCpuTimeLimit(Kernel::HLERequestContext& ctx) { void Module::APTInterface::GetAppCpuTimeLimit(Kernel::HLERequestContext& ctx) {
@ -733,7 +733,7 @@ void Module::APTInterface::GetAppCpuTimeLimit(Kernel::HLERequestContext& ctx) {
} }
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); // No error rb.Push(ResultSuccess); // No error
rb.Push(apt->cpu_percent); rb.Push(apt->cpu_percent);
} }
@ -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 // This command must return an error when called, otherwise the Home Menu will try to reboot the
// system. // system.
rb.Push(ResultCode(ErrorDescription::AlreadyExists, ErrorModule::Applet, rb.Push(Result(ErrorDescription::AlreadyExists, ErrorModule::Applet, ErrorSummary::InvalidState,
ErrorSummary::InvalidState, ErrorLevel::Status)); ErrorLevel::Status));
} }
void Module::APTInterface::PreloadLibraryApplet(Kernel::HLERequestContext& ctx) { void Module::APTInterface::PreloadLibraryApplet(Kernel::HLERequestContext& ctx) {
@ -944,7 +944,7 @@ void Module::APTInterface::ReplySleepQuery(Kernel::HLERequestContext& ctx) {
from_app_id, reply_value); from_app_id, reply_value);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
} }
void Module::APTInterface::ReplySleepNotificationComplete(Kernel::HLERequestContext& ctx) { void Module::APTInterface::ReplySleepNotificationComplete(Kernel::HLERequestContext& ctx) {
@ -954,7 +954,7 @@ void Module::APTInterface::ReplySleepNotificationComplete(Kernel::HLERequestCont
LOG_WARNING(Service_APT, "(STUBBED) called, from_app_id={:08X}", from_app_id); LOG_WARNING(Service_APT, "(STUBBED) called, from_app_id={:08X}", from_app_id);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
} }
void Module::APTInterface::PrepareToJumpToHomeMenu(Kernel::HLERequestContext& ctx) { void Module::APTInterface::PrepareToJumpToHomeMenu(Kernel::HLERequestContext& ctx) {
@ -1010,7 +1010,7 @@ void Module::APTInterface::LoadSysMenuArg(Kernel::HLERequestContext& ctx) {
std::copy_n(apt->sys_menu_arg_buffer.cbegin(), size, buffer.begin()); std::copy_n(apt->sys_menu_arg_buffer.cbegin(), size, buffer.begin());
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushStaticBuffer(std::move(buffer), 0); rb.PushStaticBuffer(std::move(buffer), 0);
} }
@ -1025,7 +1025,7 @@ void Module::APTInterface::StoreSysMenuArg(Kernel::HLERequestContext& ctx) {
std::copy_n(buffer.cbegin(), size, apt->sys_menu_arg_buffer.begin()); std::copy_n(buffer.cbegin(), size, apt->sys_menu_arg_buffer.begin());
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
} }
void Module::APTInterface::SendCaptureBufferInfo(Kernel::HLERequestContext& ctx) { void Module::APTInterface::SendCaptureBufferInfo(Kernel::HLERequestContext& ctx) {
@ -1038,7 +1038,7 @@ void Module::APTInterface::SendCaptureBufferInfo(Kernel::HLERequestContext& ctx)
apt->applet_manager->SendCaptureBufferInfo(buffer); apt->applet_manager->SendCaptureBufferInfo(buffer);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
} }
void Module::APTInterface::ReceiveCaptureBufferInfo(Kernel::HLERequestContext& ctx) { void Module::APTInterface::ReceiveCaptureBufferInfo(Kernel::HLERequestContext& ctx) {
@ -1052,7 +1052,7 @@ void Module::APTInterface::ReceiveCaptureBufferInfo(Kernel::HLERequestContext& c
screen_capture_buffer.resize(size); screen_capture_buffer.resize(size);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 2); IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push(real_size); rb.Push(real_size);
rb.PushStaticBuffer(std::move(screen_capture_buffer), 0); rb.PushStaticBuffer(std::move(screen_capture_buffer), 0);
} }
@ -1068,7 +1068,7 @@ void Module::APTInterface::GetCaptureInfo(Kernel::HLERequestContext& ctx) {
screen_capture_buffer.resize(size); screen_capture_buffer.resize(size);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 2); IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push(real_size); rb.Push(real_size);
rb.PushStaticBuffer(std::move(screen_capture_buffer), 0); rb.PushStaticBuffer(std::move(screen_capture_buffer), 0);
} }
@ -1085,7 +1085,7 @@ void Module::APTInterface::Unknown54(Kernel::HLERequestContext& ctx) {
rb.Push(media_type.Code()); rb.Push(media_type.Code());
} else { } else {
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushEnum(media_type.Unwrap()); rb.PushEnum(media_type.Unwrap());
} }
} }
@ -1099,7 +1099,7 @@ void Module::APTInterface::SetScreenCapturePostPermission(Kernel::HLERequestCont
apt->screen_capture_post_permission = static_cast<ScreencapPostPermission>(permission & 0xF); apt->screen_capture_post_permission = static_cast<ScreencapPostPermission>(permission & 0xF);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); // No error rb.Push(ResultSuccess); // No error
} }
void Module::APTInterface::GetScreenCapturePostPermission(Kernel::HLERequestContext& ctx) { void Module::APTInterface::GetScreenCapturePostPermission(Kernel::HLERequestContext& ctx) {
@ -1108,7 +1108,7 @@ void Module::APTInterface::GetScreenCapturePostPermission(Kernel::HLERequestCont
LOG_DEBUG(Service_APT, "called"); LOG_DEBUG(Service_APT, "called");
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); // No error rb.Push(ResultSuccess); // No error
rb.Push(static_cast<u32>(apt->screen_capture_post_permission)); rb.Push(static_cast<u32>(apt->screen_capture_post_permission));
} }
@ -1131,7 +1131,7 @@ void Module::APTInterface::GetProgramId(Kernel::HLERequestContext& ctx) {
LOG_DEBUG(Service_APT, "called process_id={}", process_id); LOG_DEBUG(Service_APT, "called process_id={}", process_id);
IPC::RequestBuilder rb = rp.MakeBuilder(3, 0); IPC::RequestBuilder rb = rp.MakeBuilder(3, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
auto fs_user = auto fs_user =
Core::System::GetInstance().ServiceManager().GetService<Service::FS::FS_USER>("fs:USER"); Core::System::GetInstance().ServiceManager().GetService<Service::FS::FS_USER>("fs:USER");
@ -1161,7 +1161,7 @@ void Module::APTInterface::GetProgramInfo(Kernel::HLERequestContext& ctx) {
// TODO: Proper error code // TODO: Proper error code
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_UNKNOWN); rb.Push(ResultUnknown);
return; return;
} }
@ -1171,7 +1171,7 @@ void Module::APTInterface::GetProgramInfo(Kernel::HLERequestContext& ctx) {
// TODO: Proper error code // TODO: Proper error code
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_UNKNOWN); rb.Push(ResultUnknown);
return; return;
} }
@ -1181,12 +1181,12 @@ void Module::APTInterface::GetProgramInfo(Kernel::HLERequestContext& ctx) {
// TODO: Proper error code // TODO: Proper error code
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_UNKNOWN); rb.Push(ResultUnknown);
return; return;
} }
IPC::RequestBuilder rb = rp.MakeBuilder(3, 0); IPC::RequestBuilder rb = rp.MakeBuilder(3, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push(static_cast<u8>(memory_mode.first.value())); rb.Push(static_cast<u8>(memory_mode.first.value()));
rb.Push(core_version.first.value()); rb.Push(core_version.first.value());
} }
@ -1203,7 +1203,7 @@ void Module::APTInterface::GetAppletInfo(Kernel::HLERequestContext& ctx) {
rb.Push(info.Code()); rb.Push(info.Code());
} else { } else {
IPC::RequestBuilder rb = rp.MakeBuilder(7, 0); IPC::RequestBuilder rb = rp.MakeBuilder(7, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push(info->title_id); rb.Push(info->title_id);
rb.Push(static_cast<u8>(info->media_type)); rb.Push(static_cast<u8>(info->media_type));
rb.Push(info->registered); rb.Push(info->registered);
@ -1248,7 +1248,7 @@ void Module::APTInterface::GetStartupArgument(Kernel::HLERequestContext& ctx) {
param.resize(std::min(parameter_size, max_parameter_size)); param.resize(std::min(parameter_size, max_parameter_size));
IPC::RequestBuilder rb = rp.MakeBuilder(2, 2); IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push(exists); rb.Push(exists);
rb.PushStaticBuffer(std::move(param), 0); rb.PushStaticBuffer(std::move(param), 0);
} }
@ -1292,7 +1292,7 @@ void Module::APTInterface::Wrap(Kernel::HLERequestContext& ctx) {
output.Write(cipher.data(), nonce_size, cipher.size()); output.Write(cipher.data(), nonce_size, cipher.size());
IPC::RequestBuilder rb = rp.MakeBuilder(1, 4); IPC::RequestBuilder rb = rp.MakeBuilder(1, 4);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
// Unmap buffer // Unmap buffer
rb.PushMappedBuffer(input); rb.PushMappedBuffer(input);
rb.PushMappedBuffer(output); rb.PushMappedBuffer(output);
@ -1338,11 +1338,11 @@ void Module::APTInterface::Unwrap(Kernel::HLERequestContext& ctx) {
output.Write(nonce.data(), nonce_offset, nonce_size); output.Write(nonce.data(), nonce_offset, nonce_size);
output.Write(pdata.data() + nonce_offset, nonce_offset + nonce_size, output.Write(pdata.data() + nonce_offset, nonce_offset + nonce_size,
pdata.size() - nonce_offset); pdata.size() - nonce_offset);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
} else { } else {
LOG_ERROR(Service_APT, "Failed to decrypt data"); LOG_ERROR(Service_APT, "Failed to decrypt data");
rb.Push(ResultCode(static_cast<ErrorDescription>(1), ErrorModule::PS, rb.Push(Result(static_cast<ErrorDescription>(1), ErrorModule::PS,
ErrorSummary::WrongArgument, ErrorLevel::Status)); ErrorSummary::WrongArgument, ErrorLevel::Status));
} }
// Unmap buffer // Unmap buffer
@ -1366,7 +1366,7 @@ void Module::APTInterface::Reboot(Kernel::HLERequestContext& ctx) {
NS::RebootToTitle(apt->system, media_type, title_id); NS::RebootToTitle(apt->system, media_type, title_id);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
} }
void Module::APTInterface::HardwareResetAsync(Kernel::HLERequestContext& ctx) { void Module::APTInterface::HardwareResetAsync(Kernel::HLERequestContext& ctx) {
@ -1377,7 +1377,7 @@ void Module::APTInterface::HardwareResetAsync(Kernel::HLERequestContext& ctx) {
apt->system.RequestReset(); apt->system.RequestReset();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
} }
void Module::APTInterface::GetTargetPlatform(Kernel::HLERequestContext& ctx) { void Module::APTInterface::GetTargetPlatform(Kernel::HLERequestContext& ctx) {
@ -1386,7 +1386,7 @@ void Module::APTInterface::GetTargetPlatform(Kernel::HLERequestContext& ctx) {
LOG_DEBUG(Service_APT, "called"); LOG_DEBUG(Service_APT, "called");
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushEnum(apt->applet_manager->GetTargetPlatform()); rb.PushEnum(apt->applet_manager->GetTargetPlatform());
} }
@ -1405,7 +1405,7 @@ void Module::APTInterface::GetApplicationRunningMode(Kernel::HLERequestContext&
LOG_DEBUG(Service_APT, "called"); LOG_DEBUG(Service_APT, "called");
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushEnum(apt->applet_manager->GetApplicationRunningMode()); rb.PushEnum(apt->applet_manager->GetApplicationRunningMode());
} }
@ -1425,7 +1425,7 @@ void Module::APTInterface::IsStandardMemoryLayout(Kernel::HLERequestContext& ctx
} }
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push(is_standard); rb.Push(is_standard);
} }
@ -1439,7 +1439,7 @@ void Module::APTInterface::IsTitleAllowed(Kernel::HLERequestContext& ctx) {
// We allow all titles to be launched, so this function is a no-op // We allow all titles to be launched, so this function is a no-op
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push(true); rb.Push(true);
} }

View file

@ -43,7 +43,7 @@ std::shared_ptr<OnlineService> Module::Interface::GetSessionService(
// TODO: Error code for uninitialized session. // TODO: Error code for uninitialized session.
IPC::RequestParser rp(ctx); IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_UNKNOWN); rb.Push(ResultUnknown);
return nullptr; return nullptr;
} }
return session_data->online_service; return session_data->online_service;
@ -80,7 +80,7 @@ void Module::Interface::SetStorageInfo(Kernel::HLERequestContext& ctx) {
const u8 extdata_type = rp.Pop<u8>(); /// 0 = NAND, 1 = SD const u8 extdata_type = rp.Pop<u8>(); /// 0 = NAND, 1 = SD
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_WARNING(Service_BOSS, LOG_WARNING(Service_BOSS,
"(STUBBED) extdata_id={:#018x}, boss_size={:#010x}, extdata_type={:#04x}", "(STUBBED) extdata_id={:#018x}, boss_size={:#010x}, extdata_type={:#04x}",
@ -91,7 +91,7 @@ void Module::Interface::UnregisterStorage(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx); IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_WARNING(Service_BOSS, "(STUBBED) called"); LOG_WARNING(Service_BOSS, "(STUBBED) called");
} }
@ -100,7 +100,7 @@ void Module::Interface::GetStorageInfo(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx); IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push<u32>(0); rb.Push<u32>(0);
LOG_WARNING(Service_BOSS, "(STUBBED) called"); LOG_WARNING(Service_BOSS, "(STUBBED) called");
@ -112,7 +112,7 @@ void Module::Interface::RegisterPrivateRootCa(Kernel::HLERequestContext& ctx) {
auto& buffer = rp.PopMappedBuffer(); auto& buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushMappedBuffer(buffer); rb.PushMappedBuffer(buffer);
LOG_WARNING(Service_BOSS, "(STUBBED)"); LOG_WARNING(Service_BOSS, "(STUBBED)");
@ -126,7 +126,7 @@ void Module::Interface::RegisterPrivateClientCert(Kernel::HLERequestContext& ctx
auto& buffer2 = rp.PopMappedBuffer(); auto& buffer2 = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 4); IPC::RequestBuilder rb = rp.MakeBuilder(1, 4);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushMappedBuffer(buffer1); rb.PushMappedBuffer(buffer1);
rb.PushMappedBuffer(buffer2); rb.PushMappedBuffer(buffer2);
@ -138,7 +138,7 @@ void Module::Interface::GetNewArrivalFlag(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx); IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push<u8>(boss->new_arrival_flag); rb.Push<u8>(boss->new_arrival_flag);
LOG_WARNING(Service_BOSS, "(STUBBED) new_arrival_flag={}", boss->new_arrival_flag); LOG_WARNING(Service_BOSS, "(STUBBED) new_arrival_flag={}", boss->new_arrival_flag);
@ -149,7 +149,7 @@ void Module::Interface::RegisterNewArrivalEvent(Kernel::HLERequestContext& ctx)
[[maybe_unused]] const auto event = rp.PopObject<Kernel::Event>(); [[maybe_unused]] const auto event = rp.PopObject<Kernel::Event>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_WARNING(Service_BOSS, "(STUBBED)"); LOG_WARNING(Service_BOSS, "(STUBBED)");
} }
@ -159,7 +159,7 @@ void Module::Interface::SetOptoutFlag(Kernel::HLERequestContext& ctx) {
boss->output_flag = rp.Pop<u8>(); boss->output_flag = rp.Pop<u8>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_WARNING(Service_BOSS, "output_flag={}", boss->output_flag); LOG_WARNING(Service_BOSS, "output_flag={}", boss->output_flag);
} }
@ -168,7 +168,7 @@ void Module::Interface::GetOptoutFlag(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx); IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push<u8>(boss->output_flag); rb.Push<u8>(boss->output_flag);
LOG_WARNING(Service_BOSS, "output_flag={}", boss->output_flag); LOG_WARNING(Service_BOSS, "output_flag={}", boss->output_flag);
@ -188,7 +188,7 @@ void Module::Interface::RegisterTask(Kernel::HLERequestContext& ctx) {
online_service->RegisterTask(size, buffer); online_service->RegisterTask(size, buffer);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushMappedBuffer(buffer); rb.PushMappedBuffer(buffer);
LOG_DEBUG(Service_BOSS, "called, size={:#010x}, unk_param2={:#04x}, unk_param3={:#04x}", size, LOG_DEBUG(Service_BOSS, "called, size={:#010x}, unk_param2={:#04x}, unk_param3={:#04x}", size,
@ -221,7 +221,7 @@ void Module::Interface::ReconfigureTask(Kernel::HLERequestContext& ctx) {
auto& buffer = rp.PopMappedBuffer(); auto& buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushMappedBuffer(buffer); rb.PushMappedBuffer(buffer);
LOG_WARNING(Service_BOSS, "(STUBBED) size={:#010x}, unk_param2={:#04x}", size, unk_param2); LOG_WARNING(Service_BOSS, "(STUBBED) size={:#010x}, unk_param2={:#04x}", size, unk_param2);
@ -237,7 +237,7 @@ void Module::Interface::GetTaskIdList(Kernel::HLERequestContext& ctx) {
online_service->GetTaskIdList(); online_service->GetTaskIdList();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_DEBUG(Service_BOSS, "called"); LOG_DEBUG(Service_BOSS, "called");
} }
@ -248,7 +248,7 @@ void Module::Interface::GetStepIdList(Kernel::HLERequestContext& ctx) {
auto& buffer = rp.PopMappedBuffer(); auto& buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushMappedBuffer(buffer); rb.PushMappedBuffer(buffer);
LOG_WARNING(Service_BOSS, "(STUBBED) size={:#010x}", size); LOG_WARNING(Service_BOSS, "(STUBBED) size={:#010x}", size);
@ -269,7 +269,7 @@ void Module::Interface::GetNsDataIdList(Kernel::HLERequestContext& ctx) {
const u16 entries_count = online_service->GetNsDataIdList(filter, max_entries, buffer); const u16 entries_count = online_service->GetNsDataIdList(filter, max_entries, buffer);
IPC::RequestBuilder rb = rp.MakeBuilder(3, 2); IPC::RequestBuilder rb = rp.MakeBuilder(3, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push<u16>(entries_count); /// Actual number of output entries rb.Push<u16>(entries_count); /// Actual number of output entries
rb.Push<u16>(0); /// Last word-index copied to output in the internal NsDataId list. rb.Push<u16>(0); /// Last word-index copied to output in the internal NsDataId list.
rb.PushMappedBuffer(buffer); rb.PushMappedBuffer(buffer);
@ -295,7 +295,7 @@ void Module::Interface::GetNsDataIdList1(Kernel::HLERequestContext& ctx) {
const u16 entries_count = online_service->GetNsDataIdList(filter, max_entries, buffer); const u16 entries_count = online_service->GetNsDataIdList(filter, max_entries, buffer);
IPC::RequestBuilder rb = rp.MakeBuilder(3, 2); IPC::RequestBuilder rb = rp.MakeBuilder(3, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push<u16>(entries_count); /// Actual number of output entries rb.Push<u16>(entries_count); /// Actual number of output entries
rb.Push<u16>(0); /// Last word-index copied to output in the internal NsDataId list. rb.Push<u16>(0); /// Last word-index copied to output in the internal NsDataId list.
rb.PushMappedBuffer(buffer); rb.PushMappedBuffer(buffer);
@ -321,7 +321,7 @@ void Module::Interface::GetNsDataIdList2(Kernel::HLERequestContext& ctx) {
const u16 entries_count = online_service->GetNsDataIdList(filter, max_entries, buffer); const u16 entries_count = online_service->GetNsDataIdList(filter, max_entries, buffer);
IPC::RequestBuilder rb = rp.MakeBuilder(3, 2); IPC::RequestBuilder rb = rp.MakeBuilder(3, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push<u16>(entries_count); /// Actual number of output entries rb.Push<u16>(entries_count); /// Actual number of output entries
rb.Push<u16>(0); /// Last word-index copied to output in the internal NsDataId list. rb.Push<u16>(0); /// Last word-index copied to output in the internal NsDataId list.
rb.PushMappedBuffer(buffer); rb.PushMappedBuffer(buffer);
@ -347,7 +347,7 @@ void Module::Interface::GetNsDataIdList3(Kernel::HLERequestContext& ctx) {
const u16 entries_count = online_service->GetNsDataIdList(filter, max_entries, buffer); const u16 entries_count = online_service->GetNsDataIdList(filter, max_entries, buffer);
IPC::RequestBuilder rb = rp.MakeBuilder(3, 2); IPC::RequestBuilder rb = rp.MakeBuilder(3, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push<u16>(entries_count); /// Actual number of output entries rb.Push<u16>(entries_count); /// Actual number of output entries
rb.Push<u16>(0); /// Last word-index copied to output in the internal NsDataId list. rb.Push<u16>(0); /// Last word-index copied to output in the internal NsDataId list.
rb.PushMappedBuffer(buffer); rb.PushMappedBuffer(buffer);
@ -383,7 +383,7 @@ void Module::Interface::SendPropertyHandle(Kernel::HLERequestContext& ctx) {
[[maybe_unused]] const std::shared_ptr<Kernel::Object> object = rp.PopGenericObject(); [[maybe_unused]] const std::shared_ptr<Kernel::Object> object = rp.PopGenericObject();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_WARNING(Service_BOSS, "(STUBBED) property_id={:#06x}", property_id); LOG_WARNING(Service_BOSS, "(STUBBED) property_id={:#06x}", property_id);
} }
@ -415,7 +415,7 @@ void Module::Interface::UpdateTaskInterval(Kernel::HLERequestContext& ctx) {
auto& buffer = rp.PopMappedBuffer(); auto& buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushMappedBuffer(buffer); rb.PushMappedBuffer(buffer);
LOG_WARNING(Service_BOSS, "(STUBBED) size={:#010x}, unk_param2={:#06x}", size, unk_param2); LOG_WARNING(Service_BOSS, "(STUBBED) size={:#010x}, unk_param2={:#06x}", size, unk_param2);
@ -431,7 +431,7 @@ void Module::Interface::UpdateTaskCount(Kernel::HLERequestContext& ctx) {
buffer.Read(task_id.data(), 0, size); buffer.Read(task_id.data(), 0, size);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushMappedBuffer(buffer); rb.PushMappedBuffer(buffer);
LOG_WARNING(Service_BOSS, "(STUBBED) size={:#010x}, unk_param2={:#010x}, task_id={}", size, LOG_WARNING(Service_BOSS, "(STUBBED) size={:#010x}, unk_param2={:#010x}, task_id={}", size,
@ -444,7 +444,7 @@ void Module::Interface::GetTaskInterval(Kernel::HLERequestContext& ctx) {
auto& buffer = rp.PopMappedBuffer(); auto& buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(2, 2); IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push<u32>(0); // stub 0 ( 32bit value) rb.Push<u32>(0); // stub 0 ( 32bit value)
rb.PushMappedBuffer(buffer); rb.PushMappedBuffer(buffer);
@ -460,7 +460,7 @@ void Module::Interface::GetTaskCount(Kernel::HLERequestContext& ctx) {
buffer.Read(task_id.data(), 0, size); buffer.Read(task_id.data(), 0, size);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 2); IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push<u32>(0); // stub 0 ( 32bit value) rb.Push<u32>(0); // stub 0 ( 32bit value)
rb.PushMappedBuffer(buffer); rb.PushMappedBuffer(buffer);
@ -477,7 +477,7 @@ void Module::Interface::GetTaskServiceStatus(Kernel::HLERequestContext& ctx) {
constexpr u8 task_service_status = 1; constexpr u8 task_service_status = 1;
IPC::RequestBuilder rb = rp.MakeBuilder(2, 2); IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push<u8>(task_service_status); rb.Push<u8>(task_service_status);
rb.PushMappedBuffer(buffer); rb.PushMappedBuffer(buffer);
@ -490,7 +490,7 @@ void Module::Interface::StartTask(Kernel::HLERequestContext& ctx) {
auto& buffer = rp.PopMappedBuffer(); auto& buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushMappedBuffer(buffer); rb.PushMappedBuffer(buffer);
LOG_WARNING(Service_BOSS, "(STUBBED) size={:#010x}", size); LOG_WARNING(Service_BOSS, "(STUBBED) size={:#010x}", size);
@ -502,7 +502,7 @@ void Module::Interface::StartTaskImmediate(Kernel::HLERequestContext& ctx) {
auto& buffer = rp.PopMappedBuffer(); auto& buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushMappedBuffer(buffer); rb.PushMappedBuffer(buffer);
LOG_WARNING(Service_BOSS, "(STUBBED) size={:#010x}", size); LOG_WARNING(Service_BOSS, "(STUBBED) size={:#010x}", size);
@ -514,7 +514,7 @@ void Module::Interface::CancelTask(Kernel::HLERequestContext& ctx) {
auto& buffer = rp.PopMappedBuffer(); auto& buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushMappedBuffer(buffer); rb.PushMappedBuffer(buffer);
LOG_WARNING(Service_BOSS, "(STUBBED) size={:#010x}", size); LOG_WARNING(Service_BOSS, "(STUBBED) size={:#010x}", size);
@ -524,7 +524,7 @@ void Module::Interface::GetTaskFinishHandle(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx); IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushCopyObjects<Kernel::Event>(boss->task_finish_event); rb.PushCopyObjects<Kernel::Event>(boss->task_finish_event);
LOG_WARNING(Service_BOSS, "(STUBBED) called"); LOG_WARNING(Service_BOSS, "(STUBBED) called");
@ -537,7 +537,7 @@ void Module::Interface::GetTaskState(Kernel::HLERequestContext& ctx) {
auto& buffer = rp.PopMappedBuffer(); auto& buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(4, 2); IPC::RequestBuilder rb = rp.MakeBuilder(4, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push<u8>(0); /// TaskStatus rb.Push<u8>(0); /// TaskStatus
rb.Push<u32>(0); /// Current state value for task PropertyID 0x4 rb.Push<u32>(0); /// Current state value for task PropertyID 0x4
rb.Push<u8>(0); /// unknown, usually 0 rb.Push<u8>(0); /// unknown, usually 0
@ -552,7 +552,7 @@ void Module::Interface::GetTaskResult(Kernel::HLERequestContext& ctx) {
auto& buffer = rp.PopMappedBuffer(); auto& buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(4, 2); IPC::RequestBuilder rb = rp.MakeBuilder(4, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push<u8>(0); // stub 0 (8 bit value) rb.Push<u8>(0); // stub 0 (8 bit value)
rb.Push<u32>(0); // stub 0 (32 bit value) rb.Push<u32>(0); // stub 0 (32 bit value)
rb.Push<u8>(0); // stub 0 (8 bit value) rb.Push<u8>(0); // stub 0 (8 bit value)
@ -567,7 +567,7 @@ void Module::Interface::GetTaskCommErrorCode(Kernel::HLERequestContext& ctx) {
auto& buffer = rp.PopMappedBuffer(); auto& buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(4, 2); IPC::RequestBuilder rb = rp.MakeBuilder(4, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push<u32>(0); // stub 0 (32 bit value) rb.Push<u32>(0); // stub 0 (32 bit value)
rb.Push<u32>(0); // stub 0 (32 bit value) rb.Push<u32>(0); // stub 0 (32 bit value)
rb.Push<u8>(0); // stub 0 (8 bit value) rb.Push<u8>(0); // stub 0 (8 bit value)
@ -584,7 +584,7 @@ void Module::Interface::GetTaskStatus(Kernel::HLERequestContext& ctx) {
auto& buffer = rp.PopMappedBuffer(); auto& buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(2, 2); IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push<u8>(0); // stub 0 (8 bit value) rb.Push<u8>(0); // stub 0 (8 bit value)
rb.PushMappedBuffer(buffer); rb.PushMappedBuffer(buffer);
@ -599,7 +599,7 @@ void Module::Interface::GetTaskError(Kernel::HLERequestContext& ctx) {
auto& buffer = rp.PopMappedBuffer(); auto& buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(2, 2); IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push<u8>(0); // stub 0 (8 bit value) rb.Push<u8>(0); // stub 0 (8 bit value)
rb.PushMappedBuffer(buffer); rb.PushMappedBuffer(buffer);
@ -613,7 +613,7 @@ void Module::Interface::GetTaskInfo(Kernel::HLERequestContext& ctx) {
auto& buffer = rp.PopMappedBuffer(); auto& buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushMappedBuffer(buffer); rb.PushMappedBuffer(buffer);
LOG_WARNING(Service_BOSS, "(STUBBED) size={:#010x}, unk_param2={:#04x}", size, unk_param2); LOG_WARNING(Service_BOSS, "(STUBBED) size={:#010x}, unk_param2={:#04x}", size, unk_param2);
@ -624,7 +624,7 @@ void Module::Interface::DeleteNsData(Kernel::HLERequestContext& ctx) {
const u32 ns_data_id = rp.Pop<u32>(); const u32 ns_data_id = rp.Pop<u32>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_WARNING(Service_BOSS, "(STUBBED) ns_data_id={:#010x}", ns_data_id); LOG_WARNING(Service_BOSS, "(STUBBED) ns_data_id={:#010x}", ns_data_id);
} }
@ -684,7 +684,7 @@ void Module::Interface::SetNsDataAdditionalInfo(Kernel::HLERequestContext& ctx)
const u32 unk_param2 = rp.Pop<u32>(); const u32 unk_param2 = rp.Pop<u32>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_WARNING(Service_BOSS, "(STUBBED) unk_param1={:#010x}, unk_param2={:#010x}", unk_param1, LOG_WARNING(Service_BOSS, "(STUBBED) unk_param1={:#010x}, unk_param2={:#010x}", unk_param1,
unk_param2); unk_param2);
@ -695,7 +695,7 @@ void Module::Interface::GetNsDataAdditionalInfo(Kernel::HLERequestContext& ctx)
const u32 unk_param1 = rp.Pop<u32>(); const u32 unk_param1 = rp.Pop<u32>();
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push<u32>(0); // stub 0 (32bit value) rb.Push<u32>(0); // stub 0 (32bit value)
LOG_WARNING(Service_BOSS, "(STUBBED) unk_param1={:#010x}", unk_param1); LOG_WARNING(Service_BOSS, "(STUBBED) unk_param1={:#010x}", unk_param1);
@ -707,7 +707,7 @@ void Module::Interface::SetNsDataNewFlag(Kernel::HLERequestContext& ctx) {
boss->ns_data_new_flag = rp.Pop<u8>(); boss->ns_data_new_flag = rp.Pop<u8>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_WARNING(Service_BOSS, "(STUBBED) unk_param1={:#010x}, ns_data_new_flag={:#04x}", unk_param1, LOG_WARNING(Service_BOSS, "(STUBBED) unk_param1={:#010x}, ns_data_new_flag={:#04x}", unk_param1,
boss->ns_data_new_flag); boss->ns_data_new_flag);
@ -718,7 +718,7 @@ void Module::Interface::GetNsDataNewFlag(Kernel::HLERequestContext& ctx) {
const u32 unk_param1 = rp.Pop<u32>(); const u32 unk_param1 = rp.Pop<u32>();
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push<u8>(boss->ns_data_new_flag); rb.Push<u8>(boss->ns_data_new_flag);
LOG_WARNING(Service_BOSS, "(STUBBED) unk_param1={:#010x}, ns_data_new_flag={:#04x}", unk_param1, LOG_WARNING(Service_BOSS, "(STUBBED) unk_param1={:#010x}, ns_data_new_flag={:#04x}", unk_param1,
@ -738,12 +738,12 @@ void Module::Interface::GetNsDataLastUpdate(Kernel::HLERequestContext& ctx) {
if (!entry.has_value()) { if (!entry.has_value()) {
// TODO: Proper error code. // TODO: Proper error code.
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_UNKNOWN); rb.Push(ResultUnknown);
return; return;
} }
IPC::RequestBuilder rb = rp.MakeBuilder(3, 0); IPC::RequestBuilder rb = rp.MakeBuilder(3, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push<u32>(0); rb.Push<u32>(0);
rb.Push<u32>(entry->header.download_date); // return the download date from the ns data rb.Push<u32>(entry->header.download_date); // return the download date from the ns data
@ -755,7 +755,7 @@ void Module::Interface::GetErrorCode(Kernel::HLERequestContext& ctx) {
const u8 input = rp.Pop<u8>(); const u8 input = rp.Pop<u8>();
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push<u32>(0); /// output value rb.Push<u32>(0); /// output value
LOG_WARNING(Service_BOSS, "(STUBBED) input={:#010x}", input); LOG_WARNING(Service_BOSS, "(STUBBED) input={:#010x}", input);
@ -770,7 +770,7 @@ void Module::Interface::RegisterStorageEntry(Kernel::HLERequestContext& ctx) {
const u8 unk_param5 = rp.Pop<u8>(); const u8 unk_param5 = rp.Pop<u8>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_WARNING(Service_BOSS, LOG_WARNING(Service_BOSS,
"(STUBBED) unk_param1={:#010x}, unk_param2={:#010x}, unk_param3={:#010x}, " "(STUBBED) unk_param1={:#010x}, unk_param2={:#010x}, unk_param3={:#010x}, "
@ -782,7 +782,7 @@ void Module::Interface::GetStorageEntryInfo(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx); IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(3, 0); IPC::RequestBuilder rb = rp.MakeBuilder(3, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push<u32>(0); // stub 0 (32bit value) rb.Push<u32>(0); // stub 0 (32bit value)
rb.Push<u16>(0); // stub 0 (16bit value) rb.Push<u16>(0); // stub 0 (16bit value)
@ -797,7 +797,7 @@ void Module::Interface::SetStorageOption(Kernel::HLERequestContext& ctx) {
const u16 unk_param4 = rp.Pop<u16>(); const u16 unk_param4 = rp.Pop<u16>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_WARNING(Service_BOSS, LOG_WARNING(Service_BOSS,
"(STUBBED) unk_param1={:#04x}, unk_param2={:#010x}, " "(STUBBED) unk_param1={:#04x}, unk_param2={:#010x}, "
@ -809,7 +809,7 @@ void Module::Interface::GetStorageOption(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx); IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(5, 0); IPC::RequestBuilder rb = rp.MakeBuilder(5, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push<u32>(0); // stub 0 (32bit value) rb.Push<u32>(0); // stub 0 (32bit value)
rb.Push<u8>(0); // stub 0 (8bit value) rb.Push<u8>(0); // stub 0 (8bit value)
rb.Push<u16>(0); // stub 0 (16bit value) rb.Push<u16>(0); // stub 0 (16bit value)
@ -824,7 +824,7 @@ void Module::Interface::StartBgImmediate(Kernel::HLERequestContext& ctx) {
auto& buffer = rp.PopMappedBuffer(); auto& buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushMappedBuffer(buffer); rb.PushMappedBuffer(buffer);
LOG_WARNING(Service_BOSS, "(STUBBED) size={:#010x}", size); LOG_WARNING(Service_BOSS, "(STUBBED) size={:#010x}", size);
@ -836,7 +836,7 @@ void Module::Interface::GetTaskProperty0(Kernel::HLERequestContext& ctx) {
auto& buffer = rp.PopMappedBuffer(); auto& buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(2, 2); IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push<u8>(0); /// current state of PropertyID 0x0 stub 0 (8bit value) rb.Push<u8>(0); /// current state of PropertyID 0x0 stub 0 (8bit value)
rb.PushMappedBuffer(buffer); rb.PushMappedBuffer(buffer);
@ -851,7 +851,7 @@ void Module::Interface::RegisterImmediateTask(Kernel::HLERequestContext& ctx) {
auto& buffer = rp.PopMappedBuffer(); auto& buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushMappedBuffer(buffer); rb.PushMappedBuffer(buffer);
LOG_WARNING(Service_BOSS, "(STUBBED) size={:#010x}, unk_param2={:#04x}, unk_param3={:#04x}", LOG_WARNING(Service_BOSS, "(STUBBED) size={:#010x}, unk_param2={:#04x}, unk_param3={:#04x}",
@ -866,7 +866,7 @@ void Module::Interface::SetTaskQuery(Kernel::HLERequestContext& ctx) {
auto& buffer2 = rp.PopMappedBuffer(); auto& buffer2 = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 4); IPC::RequestBuilder rb = rp.MakeBuilder(1, 4);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushMappedBuffer(buffer1); rb.PushMappedBuffer(buffer1);
rb.PushMappedBuffer(buffer2); rb.PushMappedBuffer(buffer2);
@ -882,7 +882,7 @@ void Module::Interface::GetTaskQuery(Kernel::HLERequestContext& ctx) {
auto& buffer2 = rp.PopMappedBuffer(); auto& buffer2 = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 4); IPC::RequestBuilder rb = rp.MakeBuilder(1, 4);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushMappedBuffer(buffer1); rb.PushMappedBuffer(buffer1);
rb.PushMappedBuffer(buffer2); rb.PushMappedBuffer(buffer2);
@ -896,7 +896,7 @@ void Module::Interface::InitializeSessionPrivileged(Kernel::HLERequestContext& c
rp.PopPID(); rp.PopPID();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_WARNING(Service_BOSS, "(STUBBED) programID={:#018x}", programID); LOG_WARNING(Service_BOSS, "(STUBBED) programID={:#018x}", programID);
} }
@ -906,7 +906,7 @@ void Module::Interface::GetAppNewFlag(Kernel::HLERequestContext& ctx) {
const u64 programID = rp.Pop<u64>(); const u64 programID = rp.Pop<u64>();
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push<u8>(0); // 0 = nothing new, 1 = new content rb.Push<u8>(0); // 0 = nothing new, 1 = new content
LOG_WARNING(Service_BOSS, "(STUBBED) programID={:#018x}", programID); LOG_WARNING(Service_BOSS, "(STUBBED) programID={:#018x}", programID);
@ -922,7 +922,7 @@ void Module::Interface::GetNsDataIdListPrivileged(Kernel::HLERequestContext& ctx
auto& buffer = rp.PopMappedBuffer(); auto& buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(3, 2); IPC::RequestBuilder rb = rp.MakeBuilder(3, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push<u16>(0); /// Actual number of output entries rb.Push<u16>(0); /// Actual number of output entries
rb.Push<u16>(0); /// Last word-index copied to output in the internal NsDataId list. rb.Push<u16>(0); /// Last word-index copied to output in the internal NsDataId list.
rb.PushMappedBuffer(buffer); rb.PushMappedBuffer(buffer);
@ -943,7 +943,7 @@ void Module::Interface::GetNsDataIdListPrivileged1(Kernel::HLERequestContext& ct
auto& buffer = rp.PopMappedBuffer(); auto& buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(3, 2); IPC::RequestBuilder rb = rp.MakeBuilder(3, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push<u16>(0); /// Actual number of output entries rb.Push<u16>(0); /// Actual number of output entries
rb.Push<u16>(0); /// Last word-index copied to output in the internal NsDataId list. rb.Push<u16>(0); /// Last word-index copied to output in the internal NsDataId list.
rb.PushMappedBuffer(buffer); rb.PushMappedBuffer(buffer);
@ -961,7 +961,7 @@ void Module::Interface::SendPropertyPrivileged(Kernel::HLERequestContext& ctx) {
auto& buffer = rp.PopMappedBuffer(); auto& buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushMappedBuffer(buffer); rb.PushMappedBuffer(buffer);
LOG_WARNING(Service_BOSS, "(STUBBED) property_id={:#06x}, size={:#010x}", property_id, size); LOG_WARNING(Service_BOSS, "(STUBBED) property_id={:#06x}, size={:#010x}", property_id, size);
@ -973,7 +973,7 @@ void Module::Interface::DeleteNsDataPrivileged(Kernel::HLERequestContext& ctx) {
const u32 ns_data_id = rp.Pop<u32>(); const u32 ns_data_id = rp.Pop<u32>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_WARNING(Service_BOSS, "(STUBBED) programID={:#018x}, ns_data_id={:#010x}", programID, LOG_WARNING(Service_BOSS, "(STUBBED) programID={:#018x}, ns_data_id={:#010x}", programID,
ns_data_id); ns_data_id);
@ -988,7 +988,7 @@ void Module::Interface::GetNsDataHeaderInfoPrivileged(Kernel::HLERequestContext&
auto& buffer = rp.PopMappedBuffer(); auto& buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushMappedBuffer(buffer); rb.PushMappedBuffer(buffer);
LOG_WARNING(Service_BOSS, LOG_WARNING(Service_BOSS,
@ -1005,7 +1005,7 @@ void Module::Interface::ReadNsDataPrivileged(Kernel::HLERequestContext& ctx) {
auto& buffer = rp.PopMappedBuffer(); auto& buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(3, 2); IPC::RequestBuilder rb = rp.MakeBuilder(3, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push<u32>(size); /// Should be actual read size rb.Push<u32>(size); /// Should be actual read size
rb.Push<u32>(0); /// unknown rb.Push<u32>(0); /// unknown
rb.PushMappedBuffer(buffer); rb.PushMappedBuffer(buffer);
@ -1022,7 +1022,7 @@ void Module::Interface::SetNsDataNewFlagPrivileged(Kernel::HLERequestContext& ct
boss->ns_data_new_flag_privileged = rp.Pop<u8>(); boss->ns_data_new_flag_privileged = rp.Pop<u8>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_WARNING( LOG_WARNING(
Service_BOSS, Service_BOSS,
@ -1036,7 +1036,7 @@ void Module::Interface::GetNsDataNewFlagPrivileged(Kernel::HLERequestContext& ct
const u32 unk_param1 = rp.Pop<u32>(); const u32 unk_param1 = rp.Pop<u32>();
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push<u8>(boss->ns_data_new_flag_privileged); rb.Push<u8>(boss->ns_data_new_flag_privileged);
LOG_WARNING( LOG_WARNING(

View file

@ -38,7 +38,7 @@ void BossTaskProperties::serialize(Archive& ar, const unsigned int) {
} }
SERIALIZE_IMPL(BossTaskProperties) SERIALIZE_IMPL(BossTaskProperties)
ResultCode OnlineService::InitializeSession(u64 init_program_id) { Result OnlineService::InitializeSession(u64 init_program_id) {
// The BOSS service uses three databases: // The BOSS service uses three databases:
// BOSS_A: Archive? A list of program ids and some properties that are keyed on program // 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 // BOSS_SS: Saved Strings? Includes the url and the other string properties, and also some other
@ -65,7 +65,7 @@ ResultCode OnlineService::InitializeSession(u64 init_program_id) {
std::unique_ptr<FileSys::ArchiveBackend> boss_system_save_data_archive; std::unique_ptr<FileSys::ArchiveBackend> boss_system_save_data_archive;
if (archive_result.Succeeded()) { if (archive_result.Succeeded()) {
boss_system_save_data_archive = std::move(archive_result).Unwrap(); boss_system_save_data_archive = std::move(archive_result).Unwrap();
} else if (archive_result.Code() == FileSys::ERROR_NOT_FOUND) { } else if (archive_result.Code() == FileSys::ResultNotFound) {
// If the archive didn't exist, create the files inside // If the archive didn't exist, create the files inside
systemsavedata_factory.Format(archive_path, FileSys::ArchiveFormatInfo(), 0); systemsavedata_factory.Format(archive_path, FileSys::ArchiveFormatInfo(), 0);
@ -74,13 +74,13 @@ ResultCode OnlineService::InitializeSession(u64 init_program_id) {
if (!create_archive_result.Succeeded()) { if (!create_archive_result.Succeeded()) {
LOG_ERROR(Service_BOSS, "Could not open BOSS savedata"); LOG_ERROR(Service_BOSS, "Could not open BOSS savedata");
// TODO: Proper error code. // TODO: Proper error code.
return RESULT_UNKNOWN; return ResultUnknown;
} }
boss_system_save_data_archive = std::move(create_archive_result).Unwrap(); boss_system_save_data_archive = std::move(create_archive_result).Unwrap();
} else { } else {
LOG_ERROR(Service_BOSS, "Could not open BOSS savedata"); LOG_ERROR(Service_BOSS, "Could not open BOSS savedata");
// TODO: Proper error code. // TODO: Proper error code.
return RESULT_UNKNOWN; return ResultUnknown;
} }
FileSys::Mode open_mode = {}; FileSys::Mode open_mode = {};
@ -94,7 +94,7 @@ ResultCode OnlineService::InitializeSession(u64 init_program_id) {
boss_system_save_data_archive->OpenFile(FileSys::Path("/BOSS_SS.db"), open_mode); boss_system_save_data_archive->OpenFile(FileSys::Path("/BOSS_SS.db"), open_mode);
if (!boss_sv_result.Succeeded() || !boss_ss_result.Succeeded()) { if (!boss_sv_result.Succeeded() || !boss_ss_result.Succeeded()) {
LOG_ERROR(Service_BOSS, "Could not open BOSS database."); LOG_ERROR(Service_BOSS, "Could not open BOSS database.");
return RESULT_SUCCESS; return ResultSuccess;
} }
auto boss_sv = std::move(boss_sv_result).Unwrap(); auto boss_sv = std::move(boss_sv_result).Unwrap();
@ -103,7 +103,7 @@ ResultCode OnlineService::InitializeSession(u64 init_program_id) {
((boss_sv->GetSize() - BOSS_SAVE_HEADER_SIZE) % BOSS_S_ENTRY_SIZE) == 0 && ((boss_sv->GetSize() - BOSS_SAVE_HEADER_SIZE) % BOSS_S_ENTRY_SIZE) == 0 &&
boss_sv->GetSize() == boss_ss->GetSize())) { boss_sv->GetSize() == boss_ss->GetSize())) {
LOG_ERROR(Service_BOSS, "BOSS database has incorrect size."); LOG_ERROR(Service_BOSS, "BOSS database has incorrect size.");
return RESULT_SUCCESS; return ResultSuccess;
} }
// Read the files if they already exist // Read the files if they already exist
@ -135,7 +135,7 @@ ResultCode OnlineService::InitializeSession(u64 init_program_id) {
current_props = BossTaskProperties(); current_props = BossTaskProperties();
} }
return RESULT_SUCCESS; return ResultSuccess;
} }
void OnlineService::RegisterTask(const u32 size, Kernel::MappedBuffer& buffer) { void OnlineService::RegisterTask(const u32 size, Kernel::MappedBuffer& buffer) {
@ -150,11 +150,11 @@ void OnlineService::RegisterTask(const u32 size, Kernel::MappedBuffer& buffer) {
current_props = BossTaskProperties(); 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) { if (size > TASK_ID_SIZE) {
LOG_WARNING(Service_BOSS, "TaskId cannot be longer than 8"); LOG_WARNING(Service_BOSS, "TaskId cannot be longer than 8");
// TODO: Proper error code. // TODO: Proper error code.
return RESULT_UNKNOWN; return ResultUnknown;
} }
std::string task_id(size, 0); std::string task_id(size, 0);
@ -162,10 +162,10 @@ ResultCode OnlineService::UnregisterTask(const u32 size, Kernel::MappedBuffer& b
if (task_id_list.erase(task_id) == 0) { if (task_id_list.erase(task_id) == 0) {
LOG_WARNING(Service_BOSS, "TaskId not in list"); LOG_WARNING(Service_BOSS, "TaskId not in list");
// TODO: Proper error code. // TODO: Proper error code.
return RESULT_UNKNOWN; return ResultUnknown;
} }
return RESULT_SUCCESS; return ResultSuccess;
} }
void OnlineService::GetTaskIdList() { void OnlineService::GetTaskIdList() {
@ -334,13 +334,13 @@ std::optional<NsDataEntry> OnlineService::GetNsDataEntryFromId(const u32 ns_data
return *entry_iter; 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 u32 size, Kernel::MappedBuffer& buffer) {
const auto entry = GetNsDataEntryFromId(ns_data_id); const auto entry = GetNsDataEntryFromId(ns_data_id);
if (!entry.has_value()) { if (!entry.has_value()) {
LOG_WARNING(Service_BOSS, "Failed to find NsData entry for ID {:#010X}", ns_data_id); LOG_WARNING(Service_BOSS, "Failed to find NsData entry for ID {:#010X}", ns_data_id);
// TODO: Proper error code. // TODO: Proper error code.
return RESULT_UNKNOWN; return ResultUnknown;
} }
static constexpr std::array EXPECTED_NS_DATA_HEADER_INFO_SIZES = { static constexpr std::array EXPECTED_NS_DATA_HEADER_INFO_SIZES = {
@ -355,31 +355,31 @@ ResultCode OnlineService::GetNsDataHeaderInfo(const u32 ns_data_id, const NsData
if (size != EXPECTED_NS_DATA_HEADER_INFO_SIZES[static_cast<u8>(type)]) { if (size != EXPECTED_NS_DATA_HEADER_INFO_SIZES[static_cast<u8>(type)]) {
LOG_WARNING(Service_BOSS, "Invalid size {} for type {}", size, type); LOG_WARNING(Service_BOSS, "Invalid size {} for type {}", size, type);
// TODO: Proper error code. // TODO: Proper error code.
return RESULT_UNKNOWN; return ResultUnknown;
} }
switch (type) { switch (type) {
case NsDataHeaderInfoType::ProgramId: case NsDataHeaderInfoType::ProgramId:
buffer.Write(&entry->header.program_id, 0, size); buffer.Write(&entry->header.program_id, 0, size);
return RESULT_SUCCESS; return ResultSuccess;
case NsDataHeaderInfoType::Unknown: { case NsDataHeaderInfoType::Unknown: {
// TODO: Figure out what this is. Stubbed to zero for now. // TODO: Figure out what this is. Stubbed to zero for now.
const u32 zero = 0; const u32 zero = 0;
buffer.Write(&zero, 0, size); buffer.Write(&zero, 0, size);
return RESULT_SUCCESS; return ResultSuccess;
} }
case NsDataHeaderInfoType::Datatype: case NsDataHeaderInfoType::Datatype:
buffer.Write(&entry->header.datatype, 0, size); buffer.Write(&entry->header.datatype, 0, size);
return RESULT_SUCCESS; return ResultSuccess;
case NsDataHeaderInfoType::PayloadSize: case NsDataHeaderInfoType::PayloadSize:
buffer.Write(&entry->header.payload_size, 0, size); buffer.Write(&entry->header.payload_size, 0, size);
return RESULT_SUCCESS; return ResultSuccess;
case NsDataHeaderInfoType::NsDataId: case NsDataHeaderInfoType::NsDataId:
buffer.Write(&entry->header.ns_data_id, 0, size); buffer.Write(&entry->header.ns_data_id, 0, size);
return RESULT_SUCCESS; return ResultSuccess;
case NsDataHeaderInfoType::Version: case NsDataHeaderInfoType::Version:
buffer.Write(&entry->header.version, 0, size); buffer.Write(&entry->header.version, 0, size);
return RESULT_SUCCESS; return ResultSuccess;
case NsDataHeaderInfoType::Everything: { case NsDataHeaderInfoType::Everything: {
const NsDataHeaderInfo info = { const NsDataHeaderInfo info = {
.program_id = entry->header.program_id, .program_id = entry->header.program_id,
@ -389,12 +389,12 @@ ResultCode OnlineService::GetNsDataHeaderInfo(const u32 ns_data_id, const NsData
.version = entry->header.version, .version = entry->header.version,
}; };
buffer.Write(&info, 0, size); buffer.Write(&info, 0, size);
return RESULT_SUCCESS; return ResultSuccess;
} }
default: default:
LOG_WARNING(Service_BOSS, "Unknown header info type {}", type); LOG_WARNING(Service_BOSS, "Unknown header info type {}", type);
// TODO: Proper error code. // TODO: Proper error code.
return RESULT_UNKNOWN; return ResultUnknown;
} }
} }
@ -404,7 +404,7 @@ ResultVal<size_t> OnlineService::ReadNsData(const u32 ns_data_id, const u64 offs
if (!entry.has_value()) { if (!entry.has_value()) {
LOG_WARNING(Service_BOSS, "Failed to find NsData entry for ID {:#010X}", ns_data_id); LOG_WARNING(Service_BOSS, "Failed to find NsData entry for ID {:#010X}", ns_data_id);
// TODO: Proper error code. // TODO: Proper error code.
return RESULT_UNKNOWN; return ResultUnknown;
} }
if (entry->header.payload_size < size + offset) { if (entry->header.payload_size < size + offset) {
@ -413,13 +413,13 @@ ResultVal<size_t> OnlineService::ReadNsData(const u32 ns_data_id, const u64 offs
"length is {:#010X}", "length is {:#010X}",
size, offset, static_cast<u32>(entry->header.payload_size)); size, offset, static_cast<u32>(entry->header.payload_size));
// TODO: Proper error code. // TODO: Proper error code.
return RESULT_UNKNOWN; return ResultUnknown;
} }
auto boss_archive = OpenBossExtData(); auto boss_archive = OpenBossExtData();
if (!boss_archive) { if (!boss_archive) {
// TODO: Proper error code. // TODO: Proper error code.
return RESULT_UNKNOWN; return ResultUnknown;
} }
FileSys::Path file_path = fmt::format("/{}", entry->filename); FileSys::Path file_path = fmt::format("/{}", entry->filename);
@ -429,7 +429,7 @@ ResultVal<size_t> OnlineService::ReadNsData(const u32 ns_data_id, const u64 offs
if (!file_result.Succeeded()) { if (!file_result.Succeeded()) {
LOG_WARNING(Service_BOSS, "Failed to open SpotPass extdata file '{}'.", entry->filename); LOG_WARNING(Service_BOSS, "Failed to open SpotPass extdata file '{}'.", entry->filename);
// TODO: Proper error code. // TODO: Proper error code.
return RESULT_UNKNOWN; return ResultUnknown;
} }
auto file = std::move(file_result).Unwrap(); auto file = std::move(file_result).Unwrap();
@ -438,7 +438,7 @@ ResultVal<size_t> OnlineService::ReadNsData(const u32 ns_data_id, const u64 offs
if (!read_result.Succeeded()) { if (!read_result.Succeeded()) {
LOG_WARNING(Service_BOSS, "Failed to read SpotPass extdata file '{}'.", entry->filename); LOG_WARNING(Service_BOSS, "Failed to read SpotPass extdata file '{}'.", entry->filename);
// TODO: Proper error code. // TODO: Proper error code.
return RESULT_UNKNOWN; return ResultUnknown;
} }
buffer.Write(ns_data_array.data(), 0, size); buffer.Write(ns_data_array.data(), 0, size);
@ -452,12 +452,12 @@ struct overload : Ts... {
template <class... Ts> template <class... Ts>
overload(Ts...) -> overload<Ts...>; overload(Ts...) -> overload<Ts...>;
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<PropertyID>(id); const auto property_id = static_cast<PropertyID>(id);
if (!current_props.properties.contains(property_id)) { if (!current_props.properties.contains(property_id)) {
LOG_ERROR(Service_BOSS, "Unknown property with ID {:#06x} and size {}", property_id, size); LOG_ERROR(Service_BOSS, "Unknown property with ID {:#06x} and size {}", property_id, size);
// TODO: Proper error code. // TODO: Proper error code.
return RESULT_UNKNOWN; return ResultUnknown;
} }
auto& prop = current_props.properties[property_id]; auto& prop = current_props.properties[property_id];
@ -489,16 +489,15 @@ ResultCode OnlineService::SendProperty(const u16 id, const u32 size, Kernel::Map
[&](std::vector<u32>& cur_prop) { read_vector(cur_prop); }}, [&](std::vector<u32>& cur_prop) { read_vector(cur_prop); }},
prop); prop);
return RESULT_SUCCESS; return ResultSuccess;
} }
ResultCode OnlineService::ReceiveProperty(const u16 id, const u32 size, Result OnlineService::ReceiveProperty(const u16 id, const u32 size, Kernel::MappedBuffer& buffer) {
Kernel::MappedBuffer& buffer) {
const auto property_id = static_cast<PropertyID>(id); const auto property_id = static_cast<PropertyID>(id);
if (!current_props.properties.contains(property_id)) { if (!current_props.properties.contains(property_id)) {
LOG_ERROR(Service_BOSS, "Unknown property with ID {:#06x} and size {}", property_id, size); LOG_ERROR(Service_BOSS, "Unknown property with ID {:#06x} and size {}", property_id, size);
// TODO: Proper error code. // TODO: Proper error code.
return RESULT_UNKNOWN; return ResultUnknown;
} }
auto write_pod = [&]<typename T>(T& cur_prop) { auto write_pod = [&]<typename T>(T& cur_prop) {
@ -526,7 +525,7 @@ ResultCode OnlineService::ReceiveProperty(const u16 id, const u32 size,
[&](std::vector<u32>& cur_prop) { write_vector(cur_prop); }}, [&](std::vector<u32>& cur_prop) { write_vector(cur_prop); }},
prop); prop);
return RESULT_SUCCESS; return ResultSuccess;
} }
} // namespace Service::BOSS } // namespace Service::BOSS

View file

@ -161,18 +161,18 @@ class OnlineService final {
public: public:
explicit OnlineService(u64 program_id_, u64 extdata_id_); 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); 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(); void GetTaskIdList();
u16 GetNsDataIdList(const u32 filter, const u32 max_entries, Kernel::MappedBuffer& buffer); u16 GetNsDataIdList(const u32 filter, const u32 max_entries, Kernel::MappedBuffer& buffer);
std::optional<NsDataEntry> GetNsDataEntryFromId(const u32 ns_data_id); std::optional<NsDataEntry> 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); const u32 size, Kernel::MappedBuffer& buffer);
ResultVal<size_t> ReadNsData(const u32 ns_data_id, const u64 offset, const u32 size, ResultVal<size_t> ReadNsData(const u32 ns_data_id, const u64 offset, const u32 size,
Kernel::MappedBuffer& buffer); Kernel::MappedBuffer& buffer);
ResultCode SendProperty(const u16 id, const u32 size, Kernel::MappedBuffer& buffer); Result SendProperty(const u16 id, const u32 size, Kernel::MappedBuffer& buffer);
ResultCode ReceiveProperty(const u16 id, const u32 size, Kernel::MappedBuffer& buffer); Result ReceiveProperty(const u16 id, const u32 size, Kernel::MappedBuffer& buffer);
private: private:
std::unique_ptr<FileSys::ArchiveBackend> OpenBossExtData(); std::unique_ptr<FileSys::ArchiveBackend> OpenBossExtData();

View file

@ -77,10 +77,10 @@ constexpr std::array<int, 13> LATENCY_BY_FRAME_RATE{{
33, // Rate_30_To_10 33, // Rate_30_To_10
}}; }};
const ResultCode ERROR_INVALID_ENUM_VALUE(ErrorDescription::InvalidEnumValue, ErrorModule::CAM, const Result ERROR_INVALID_ENUM_VALUE(ErrorDescription::InvalidEnumValue, ErrorModule::CAM,
ErrorSummary::InvalidArgument, ErrorLevel::Usage); ErrorSummary::InvalidArgument, ErrorLevel::Usage);
const ResultCode ERROR_OUT_OF_RANGE(ErrorDescription::OutOfRange, ErrorModule::CAM, const Result ERROR_OUT_OF_RANGE(ErrorDescription::OutOfRange, ErrorModule::CAM,
ErrorSummary::InvalidArgument, ErrorLevel::Usage); ErrorSummary::InvalidArgument, ErrorLevel::Usage);
void Module::PortConfig::Clear() { void Module::PortConfig::Clear() {
completion_event->Clear(); completion_event->Clear();
@ -278,7 +278,7 @@ void Module::Interface::StartCapture(Kernel::HLERequestContext& ctx) {
LOG_WARNING(Service_CAM, "port {} already started", i); LOG_WARNING(Service_CAM, "port {} already started", i);
} }
} }
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
} else { } else {
LOG_ERROR(Service_CAM, "invalid port_select={}", port_select.m_val); LOG_ERROR(Service_CAM, "invalid port_select={}", port_select.m_val);
rb.Push(ERROR_INVALID_ENUM_VALUE); rb.Push(ERROR_INVALID_ENUM_VALUE);
@ -303,7 +303,7 @@ void Module::Interface::StopCapture(Kernel::HLERequestContext& ctx) {
LOG_WARNING(Service_CAM, "port {} already stopped", i); LOG_WARNING(Service_CAM, "port {} already stopped", i);
} }
} }
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
} else { } else {
LOG_ERROR(Service_CAM, "invalid port_select={}", port_select.m_val); LOG_ERROR(Service_CAM, "invalid port_select={}", port_select.m_val);
rb.Push(ERROR_INVALID_ENUM_VALUE); rb.Push(ERROR_INVALID_ENUM_VALUE);
@ -324,7 +324,7 @@ void Module::Interface::IsBusy(Kernel::HLERequestContext& ctx) {
for (int i : port_select) { for (int i : port_select) {
is_busy &= cam->ports[i].is_busy; is_busy &= cam->ports[i].is_busy;
} }
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push(is_busy); rb.Push(is_busy);
} else { } else {
LOG_ERROR(Service_CAM, "invalid port_select={}", port_select.m_val); LOG_ERROR(Service_CAM, "invalid port_select={}", port_select.m_val);
@ -340,7 +340,7 @@ void Module::Interface::ClearBuffer(Kernel::HLERequestContext& ctx) {
const PortSet port_select(rp.Pop<u8>()); const PortSet port_select(rp.Pop<u8>());
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_WARNING(Service_CAM, "(STUBBED) called, port_select={}", port_select.m_val); LOG_WARNING(Service_CAM, "(STUBBED) called, port_select={}", port_select.m_val);
} }
@ -352,7 +352,7 @@ void Module::Interface::GetVsyncInterruptEvent(Kernel::HLERequestContext& ctx) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
if (port_select.IsSingle()) { if (port_select.IsSingle()) {
int port = *port_select.begin(); int port = *port_select.begin();
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushCopyObjects(cam->ports[port].vsync_interrupt_event); rb.PushCopyObjects(cam->ports[port].vsync_interrupt_event);
} else { } else {
LOG_ERROR(Service_CAM, "invalid port_select={}", port_select.m_val); LOG_ERROR(Service_CAM, "invalid port_select={}", port_select.m_val);
@ -370,7 +370,7 @@ void Module::Interface::GetBufferErrorInterruptEvent(Kernel::HLERequestContext&
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
if (port_select.IsSingle()) { if (port_select.IsSingle()) {
int port = *port_select.begin(); int port = *port_select.begin();
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushCopyObjects(cam->ports[port].buffer_error_interrupt_event); rb.PushCopyObjects(cam->ports[port].buffer_error_interrupt_event);
} else { } else {
LOG_ERROR(Service_CAM, "invalid port_select={}", port_select.m_val); LOG_ERROR(Service_CAM, "invalid port_select={}", port_select.m_val);
@ -405,7 +405,7 @@ void Module::Interface::SetReceiving(Kernel::HLERequestContext& ctx) {
port.is_pending_receiving = true; port.is_pending_receiving = true;
} }
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushCopyObjects(port.completion_event); rb.PushCopyObjects(port.completion_event);
} else { } else {
LOG_ERROR(Service_CAM, "invalid port_select={}", port_select.m_val); LOG_ERROR(Service_CAM, "invalid port_select={}", port_select.m_val);
@ -425,7 +425,7 @@ void Module::Interface::IsFinishedReceiving(Kernel::HLERequestContext& ctx) {
if (port_select.IsSingle()) { if (port_select.IsSingle()) {
int port = *port_select.begin(); int port = *port_select.begin();
bool is_busy = cam->ports[port].is_receiving || cam->ports[port].is_pending_receiving; bool is_busy = cam->ports[port].is_receiving || cam->ports[port].is_pending_receiving;
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push(!is_busy); rb.Push(!is_busy);
} else { } else {
LOG_ERROR(Service_CAM, "invalid port_select={}", port_select.m_val); LOG_ERROR(Service_CAM, "invalid port_select={}", port_select.m_val);
@ -448,7 +448,7 @@ void Module::Interface::SetTransferLines(Kernel::HLERequestContext& ctx) {
for (int i : port_select) { for (int i : port_select) {
cam->ports[i].transfer_bytes = transfer_lines * width * 2; cam->ports[i].transfer_bytes = transfer_lines * width * 2;
} }
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
} else { } else {
LOG_ERROR(Service_CAM, "invalid port_select={}", port_select.m_val); LOG_ERROR(Service_CAM, "invalid port_select={}", port_select.m_val);
rb.Push(ERROR_INVALID_ENUM_VALUE); rb.Push(ERROR_INVALID_ENUM_VALUE);
@ -476,7 +476,7 @@ void Module::Interface::GetMaxLines(Kernel::HLERequestContext& ctx) {
if (lines > height) { if (lines > height) {
lines = height; lines = height;
} }
ResultCode result = RESULT_SUCCESS; Result result = ResultSuccess;
while (height % lines != 0 || (lines * width * 2 % MIN_TRANSFER_UNIT != 0)) { while (height % lines != 0 || (lines * width * 2 % MIN_TRANSFER_UNIT != 0)) {
--lines; --lines;
if (lines == 0) { if (lines == 0) {
@ -503,7 +503,7 @@ void Module::Interface::SetTransferBytes(Kernel::HLERequestContext& ctx) {
for (int i : port_select) { for (int i : port_select) {
cam->ports[i].transfer_bytes = transfer_bytes; cam->ports[i].transfer_bytes = transfer_bytes;
} }
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
} else { } else {
LOG_ERROR(Service_CAM, "invalid port_select={}", port_select.m_val); LOG_ERROR(Service_CAM, "invalid port_select={}", port_select.m_val);
rb.Push(ERROR_INVALID_ENUM_VALUE); rb.Push(ERROR_INVALID_ENUM_VALUE);
@ -520,7 +520,7 @@ void Module::Interface::GetTransferBytes(Kernel::HLERequestContext& ctx) {
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
if (port_select.IsSingle()) { if (port_select.IsSingle()) {
int port = *port_select.begin(); int port = *port_select.begin();
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push(cam->ports[port].transfer_bytes); rb.Push(cam->ports[port].transfer_bytes);
} else { } else {
LOG_ERROR(Service_CAM, "invalid port_select={}", port_select.m_val); LOG_ERROR(Service_CAM, "invalid port_select={}", port_select.m_val);
@ -551,7 +551,7 @@ void Module::Interface::GetMaxBytes(Kernel::HLERequestContext& ctx) {
bytes -= MIN_TRANSFER_UNIT; bytes -= MIN_TRANSFER_UNIT;
} }
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push(bytes); rb.Push(bytes);
} }
@ -568,7 +568,7 @@ void Module::Interface::SetTrimming(Kernel::HLERequestContext& ctx) {
for (int i : port_select) { for (int i : port_select) {
cam->ports[i].is_trimming = trim; cam->ports[i].is_trimming = trim;
} }
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
} else { } else {
LOG_ERROR(Service_CAM, "invalid port_select={}", port_select.m_val); LOG_ERROR(Service_CAM, "invalid port_select={}", port_select.m_val);
rb.Push(ERROR_INVALID_ENUM_VALUE); rb.Push(ERROR_INVALID_ENUM_VALUE);
@ -584,7 +584,7 @@ void Module::Interface::IsTrimming(Kernel::HLERequestContext& ctx) {
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
if (port_select.IsSingle()) { if (port_select.IsSingle()) {
int port = *port_select.begin(); int port = *port_select.begin();
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push(cam->ports[port].is_trimming); rb.Push(cam->ports[port].is_trimming);
} else { } else {
LOG_ERROR(Service_CAM, "invalid port_select={}", port_select.m_val); LOG_ERROR(Service_CAM, "invalid port_select={}", port_select.m_val);
@ -611,7 +611,7 @@ void Module::Interface::SetTrimmingParams(Kernel::HLERequestContext& ctx) {
cam->ports[i].x1 = x1; cam->ports[i].x1 = x1;
cam->ports[i].y1 = y1; cam->ports[i].y1 = y1;
} }
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
} else { } else {
LOG_ERROR(Service_CAM, "invalid port_select={}", port_select.m_val); LOG_ERROR(Service_CAM, "invalid port_select={}", port_select.m_val);
rb.Push(ERROR_INVALID_ENUM_VALUE); rb.Push(ERROR_INVALID_ENUM_VALUE);
@ -628,7 +628,7 @@ void Module::Interface::GetTrimmingParams(Kernel::HLERequestContext& ctx) {
IPC::RequestBuilder rb = rp.MakeBuilder(5, 0); IPC::RequestBuilder rb = rp.MakeBuilder(5, 0);
if (port_select.IsSingle()) { if (port_select.IsSingle()) {
int port = *port_select.begin(); int port = *port_select.begin();
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push(cam->ports[port].x0); rb.Push(cam->ports[port].x0);
rb.Push(cam->ports[port].y0); rb.Push(cam->ports[port].y0);
rb.Push(cam->ports[port].x1); rb.Push(cam->ports[port].x1);
@ -658,7 +658,7 @@ void Module::Interface::SetTrimmingParamsCenter(Kernel::HLERequestContext& ctx)
cam->ports[i].x1 = cam->ports[i].x0 + trim_w; cam->ports[i].x1 = cam->ports[i].x0 + trim_w;
cam->ports[i].y1 = cam->ports[i].y0 + trim_h; cam->ports[i].y1 = cam->ports[i].y0 + trim_h;
} }
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
} else { } else {
LOG_ERROR(Service_CAM, "invalid port_select={}", port_select.m_val); LOG_ERROR(Service_CAM, "invalid port_select={}", port_select.m_val);
rb.Push(ERROR_INVALID_ENUM_VALUE); rb.Push(ERROR_INVALID_ENUM_VALUE);
@ -684,7 +684,7 @@ void Module::Interface::Activate(Kernel::HLERequestContext& ctx) {
cam->ports[i].is_active = false; cam->ports[i].is_active = false;
cam->system.CoreTiming().UnscheduleEvent(cam->vsync_interrupt_event_callback, i); cam->system.CoreTiming().UnscheduleEvent(cam->vsync_interrupt_event_callback, i);
} }
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
} else if (camera_select[0] && camera_select[1]) { } else if (camera_select[0] && camera_select[1]) {
LOG_ERROR(Service_CAM, "camera 0 and 1 can't be both activated"); LOG_ERROR(Service_CAM, "camera 0 and 1 can't be both activated");
rb.Push(ERROR_INVALID_ENUM_VALUE); rb.Push(ERROR_INVALID_ENUM_VALUE);
@ -698,7 +698,7 @@ void Module::Interface::Activate(Kernel::HLERequestContext& ctx) {
if (camera_select[2]) { if (camera_select[2]) {
cam->ActivatePort(1, 2); cam->ActivatePort(1, 2);
} }
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
} }
} else { } else {
LOG_ERROR(Service_CAM, "invalid camera_select={}", camera_select.m_val); LOG_ERROR(Service_CAM, "invalid camera_select={}", camera_select.m_val);
@ -724,7 +724,7 @@ void Module::Interface::SwitchContext(Kernel::HLERequestContext& ctx) {
cam->cameras[camera].impl->SetFormat(context_config.format); cam->cameras[camera].impl->SetFormat(context_config.format);
cam->cameras[camera].impl->SetResolution(context_config.resolution); cam->cameras[camera].impl->SetResolution(context_config.resolution);
} }
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
} else { } else {
LOG_ERROR(Service_CAM, "invalid camera_select={}, context_select={}", camera_select.m_val, LOG_ERROR(Service_CAM, "invalid camera_select={}, context_select={}", camera_select.m_val,
context_select.m_val); context_select.m_val);
@ -751,7 +751,7 @@ void Module::Interface::FlipImage(Kernel::HLERequestContext& ctx) {
} }
} }
} }
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
} else { } else {
LOG_ERROR(Service_CAM, "invalid camera_select={}, context_select={}", camera_select.m_val, LOG_ERROR(Service_CAM, "invalid camera_select={}, context_select={}", camera_select.m_val,
context_select.m_val); context_select.m_val);
@ -784,7 +784,7 @@ void Module::Interface::SetDetailSize(Kernel::HLERequestContext& ctx) {
} }
} }
} }
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
} else { } else {
LOG_ERROR(Service_CAM, "invalid camera_select={}, context_select={}", camera_select.m_val, LOG_ERROR(Service_CAM, "invalid camera_select={}, context_select={}", camera_select.m_val,
context_select.m_val); context_select.m_val);
@ -814,7 +814,7 @@ void Module::Interface::SetSize(Kernel::HLERequestContext& ctx) {
} }
} }
} }
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
} else { } else {
LOG_ERROR(Service_CAM, "invalid camera_select={}, context_select={}", camera_select.m_val, LOG_ERROR(Service_CAM, "invalid camera_select={}, context_select={}", camera_select.m_val,
context_select.m_val); context_select.m_val);
@ -836,7 +836,7 @@ void Module::Interface::SetFrameRate(Kernel::HLERequestContext& ctx) {
cam->cameras[camera].frame_rate = frame_rate; cam->cameras[camera].frame_rate = frame_rate;
cam->cameras[camera].impl->SetFrameRate(frame_rate); cam->cameras[camera].impl->SetFrameRate(frame_rate);
} }
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
} else { } else {
LOG_ERROR(Service_CAM, "invalid camera_select={}", camera_select.m_val); LOG_ERROR(Service_CAM, "invalid camera_select={}", camera_select.m_val);
rb.Push(ERROR_INVALID_ENUM_VALUE); rb.Push(ERROR_INVALID_ENUM_VALUE);
@ -862,7 +862,7 @@ void Module::Interface::SetEffect(Kernel::HLERequestContext& ctx) {
} }
} }
} }
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
} else { } else {
LOG_ERROR(Service_CAM, "invalid camera_select={}, context_select={}", camera_select.m_val, LOG_ERROR(Service_CAM, "invalid camera_select={}, context_select={}", camera_select.m_val,
context_select.m_val); context_select.m_val);
@ -889,7 +889,7 @@ void Module::Interface::SetOutputFormat(Kernel::HLERequestContext& ctx) {
} }
} }
} }
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
} else { } else {
LOG_ERROR(Service_CAM, "invalid camera_select={}, context_select={}", camera_select.m_val, LOG_ERROR(Service_CAM, "invalid camera_select={}, context_select={}", camera_select.m_val,
context_select.m_val); context_select.m_val);
@ -906,7 +906,7 @@ void Module::Interface::SynchronizeVsyncTiming(Kernel::HLERequestContext& ctx) {
const u8 camera_select2 = rp.Pop<u8>(); const u8 camera_select2 = rp.Pop<u8>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_WARNING(Service_CAM, "(STUBBED) called, camera_select1={}, camera_select2={}", LOG_WARNING(Service_CAM, "(STUBBED) called, camera_select1={}, camera_select2={}",
camera_select1, camera_select2); camera_select1, camera_select2);
@ -925,7 +925,7 @@ void Module::Interface::GetLatestVsyncTiming(Kernel::HLERequestContext& ctx) {
} }
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
const std::size_t port_id = port_select.m_val == 1 ? 0 : 1; const std::size_t port_id = port_select.m_val == 1 ? 0 : 1;
std::vector<u8> out(count * sizeof(s64_le)); std::vector<u8> out(count * sizeof(s64_le));
@ -961,7 +961,7 @@ void Module::Interface::GetStereoCameraCalibrationData(Kernel::HLERequestContext
data.imageWidth = 640; data.imageWidth = 640;
data.imageHeight = 480; data.imageHeight = 480;
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushRaw(data); rb.PushRaw(data);
LOG_TRACE(Service_CAM, "called"); LOG_TRACE(Service_CAM, "called");
@ -974,13 +974,13 @@ void Module::Interface::SetPackageParameterWithoutContext(Kernel::HLERequestCont
rp.PopRaw(package); rp.PopRaw(package);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_WARNING(Service_CAM, "(STUBBED) called"); LOG_WARNING(Service_CAM, "(STUBBED) called");
} }
template <typename PackageParameterType> template <typename PackageParameterType>
ResultCode Module::SetPackageParameter(const PackageParameterType& package) { Result Module::SetPackageParameter(const PackageParameterType& package) {
const CameraSet camera_select(package.camera_select); const CameraSet camera_select(package.camera_select);
const ContextSet context_select(package.context_select); const ContextSet context_select(package.context_select);
@ -999,7 +999,7 @@ ResultCode Module::SetPackageParameter(const PackageParameterType& package) {
} }
} }
} }
return RESULT_SUCCESS; return ResultSuccess;
} else { } else {
LOG_ERROR(Service_CAM, "invalid camera_select={}, context_select={}", package.camera_select, LOG_ERROR(Service_CAM, "invalid camera_select={}, context_select={}", package.camera_select,
package.context_select); package.context_select);
@ -1018,7 +1018,7 @@ void Module::Interface::SetPackageParameterWithContext(Kernel::HLERequestContext
rp.PopRaw(package); rp.PopRaw(package);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
ResultCode result = cam->SetPackageParameter(package); Result result = cam->SetPackageParameter(package);
rb.Push(result); rb.Push(result);
LOG_DEBUG(Service_CAM, "called"); LOG_DEBUG(Service_CAM, "called");
@ -1031,7 +1031,7 @@ void Module::Interface::SetPackageParameterWithContextDetail(Kernel::HLERequestC
rp.PopRaw(package); rp.PopRaw(package);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
ResultCode result = cam->SetPackageParameter(package); Result result = cam->SetPackageParameter(package);
rb.Push(result); rb.Push(result);
LOG_DEBUG(Service_CAM, "called"); LOG_DEBUG(Service_CAM, "called");
@ -1040,7 +1040,7 @@ void Module::Interface::SetPackageParameterWithContextDetail(Kernel::HLERequestC
void Module::Interface::GetSuitableY2rStandardCoefficient(Kernel::HLERequestContext& ctx) { void Module::Interface::GetSuitableY2rStandardCoefficient(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx); IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push<u32>(0); rb.Push<u32>(0);
LOG_WARNING(Service_CAM, "(STUBBED) called"); LOG_WARNING(Service_CAM, "(STUBBED) called");
@ -1051,7 +1051,7 @@ void Module::Interface::PlayShutterSound(Kernel::HLERequestContext& ctx) {
u8 sound_id = rp.Pop<u8>(); u8 sound_id = rp.Pop<u8>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_WARNING(Service_CAM, "(STUBBED) called, sound_id={}", sound_id); LOG_WARNING(Service_CAM, "(STUBBED) called, sound_id={}", sound_id);
} }
@ -1081,7 +1081,7 @@ void Module::Interface::DriverInitialize(Kernel::HLERequestContext& ctx) {
cam->initialized = true; cam->initialized = true;
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_DEBUG(Service_CAM, "called"); LOG_DEBUG(Service_CAM, "called");
} }
@ -1099,7 +1099,7 @@ void Module::Interface::DriverFinalize(Kernel::HLERequestContext& ctx) {
cam->initialized = false; cam->initialized = false;
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_DEBUG(Service_CAM, "called"); LOG_DEBUG(Service_CAM, "called");
} }

View file

@ -166,7 +166,7 @@ public:
* 1: u8 selected port * 1: u8 selected port
* Outputs: * Outputs:
* 0: 0x00010040 * 0: 0x00010040
* 1: ResultCode * 1: Result
*/ */
void StartCapture(Kernel::HLERequestContext& ctx); void StartCapture(Kernel::HLERequestContext& ctx);
@ -177,7 +177,7 @@ public:
* 1: u8 selected port * 1: u8 selected port
* Outputs: * Outputs:
* 0: 0x00020040 * 0: 0x00020040
* 1: ResultCode * 1: Result
*/ */
void StopCapture(Kernel::HLERequestContext& ctx); void StopCapture(Kernel::HLERequestContext& ctx);
@ -188,7 +188,7 @@ public:
* 1: u8 selected port * 1: u8 selected port
* Outputs: * Outputs:
* 0: 0x00030080 * 0: 0x00030080
* 1: ResultCode * 1: Result
* 2: 0 if not capturing, 1 if capturing * 2: 0 if not capturing, 1 if capturing
*/ */
void IsBusy(Kernel::HLERequestContext& ctx); void IsBusy(Kernel::HLERequestContext& ctx);
@ -200,7 +200,7 @@ public:
* 1: u8 selected port * 1: u8 selected port
* Outputs: * Outputs:
* 0: 0x00040040 * 0: 0x00040040
* 2: ResultCode * 2: Result
*/ */
void ClearBuffer(Kernel::HLERequestContext& ctx); void ClearBuffer(Kernel::HLERequestContext& ctx);
@ -211,7 +211,7 @@ public:
* 1: u8 selected port * 1: u8 selected port
* Outputs: * Outputs:
* 0: 0x00050042 * 0: 0x00050042
* 1: ResultCode * 1: Result
* 2: Descriptor: Handle * 2: Descriptor: Handle
* 3: Event handle * 3: Event handle
*/ */
@ -224,7 +224,7 @@ public:
* 1: u8 selected port * 1: u8 selected port
* Outputs: * Outputs:
* 0: 0x00060042 * 0: 0x00060042
* 1: ResultCode * 1: Result
* 2: Descriptor: Handle * 2: Descriptor: Handle
* 3: Event handle * 3: Event handle
*/ */
@ -244,7 +244,7 @@ public:
* 6: Handle to destination process * 6: Handle to destination process
* Outputs: * Outputs:
* 0: 0x00070042 * 0: 0x00070042
* 1: ResultCode * 1: Result
* 2: Descriptor: Handle * 2: Descriptor: Handle
* 3: Handle to event signalled when transfer finishes * 3: Handle to event signalled when transfer finishes
*/ */
@ -257,7 +257,7 @@ public:
* 1: u8 selected port * 1: u8 selected port
* Outputs: * Outputs:
* 0: 0x00080080 * 0: 0x00080080
* 1: ResultCode * 1: Result
* 2: 0 if not finished, 1 if finished * 2: 0 if not finished, 1 if finished
*/ */
void IsFinishedReceiving(Kernel::HLERequestContext& ctx); void IsFinishedReceiving(Kernel::HLERequestContext& ctx);
@ -272,7 +272,7 @@ public:
* 4: u16 Height * 4: u16 Height
* Outputs: * Outputs:
* 0: 0x00090040 * 0: 0x00090040
* 1: ResultCode * 1: Result
* @todo figure out how the "buffer" actually works. * @todo figure out how the "buffer" actually works.
*/ */
void SetTransferLines(Kernel::HLERequestContext& ctx); void SetTransferLines(Kernel::HLERequestContext& ctx);
@ -285,7 +285,7 @@ public:
* 2: u16 Height * 2: u16 Height
* Outputs: * Outputs:
* 0: 0x000A0080 * 0: 0x000A0080
* 1: ResultCode * 1: Result
* 2: Maximum number of lines that fit in the buffer * 2: Maximum number of lines that fit in the buffer
* @todo figure out how the "buffer" actually works. * @todo figure out how the "buffer" actually works.
*/ */
@ -301,7 +301,7 @@ public:
* 4: u16 Height * 4: u16 Height
* Outputs: * Outputs:
* 0: 0x000B0040 * 0: 0x000B0040
* 1: ResultCode * 1: Result
* @todo figure out how the "buffer" actually works. * @todo figure out how the "buffer" actually works.
*/ */
void SetTransferBytes(Kernel::HLERequestContext& ctx); void SetTransferBytes(Kernel::HLERequestContext& ctx);
@ -313,7 +313,7 @@ public:
* 1: u8 selected port * 1: u8 selected port
* Outputs: * Outputs:
* 0: 0x000C0080 * 0: 0x000C0080
* 1: ResultCode * 1: Result
* 2: The number of bytes the buffer contains * 2: The number of bytes the buffer contains
* @todo figure out how the "buffer" actually works. * @todo figure out how the "buffer" actually works.
*/ */
@ -327,7 +327,7 @@ public:
* 2: u16 Height * 2: u16 Height
* Outputs: * Outputs:
* 0: 0x000D0080 * 0: 0x000D0080
* 1: ResultCode * 1: Result
* 2: Maximum number of bytes that fit in the buffer * 2: Maximum number of bytes that fit in the buffer
* @todo figure out how the "buffer" actually works. * @todo figure out how the "buffer" actually works.
*/ */
@ -341,7 +341,7 @@ public:
* 2: u8 bool Enable trimming if true * 2: u8 bool Enable trimming if true
* Outputs: * Outputs:
* 0: 0x000E0040 * 0: 0x000E0040
* 1: ResultCode * 1: Result
*/ */
void SetTrimming(Kernel::HLERequestContext& ctx); void SetTrimming(Kernel::HLERequestContext& ctx);
@ -352,7 +352,7 @@ public:
* 1: u8 selected port * 1: u8 selected port
* Outputs: * Outputs:
* 0: 0x000F0080 * 0: 0x000F0080
* 1: ResultCode * 1: Result
* 2: u8 bool Enable trimming if true * 2: u8 bool Enable trimming if true
*/ */
void IsTrimming(Kernel::HLERequestContext& ctx); void IsTrimming(Kernel::HLERequestContext& ctx);
@ -368,7 +368,7 @@ public:
* 5: y end (exclusive) * 5: y end (exclusive)
* Outputs: * Outputs:
* 0: 0x00100040 * 0: 0x00100040
* 1: ResultCode * 1: Result
*/ */
void SetTrimmingParams(Kernel::HLERequestContext& ctx); void SetTrimmingParams(Kernel::HLERequestContext& ctx);
@ -380,7 +380,7 @@ public:
* *
* Outputs: * Outputs:
* 0: 0x00110140 * 0: 0x00110140
* 1: ResultCode * 1: Result
* 2: x start * 2: x start
* 3: y start * 3: y start
* 4: x end (exclusive) * 4: x end (exclusive)
@ -400,7 +400,7 @@ public:
* 5: s16 Camera height * 5: s16 Camera height
* Outputs: * Outputs:
* 0: 0x00120040 * 0: 0x00120040
* 1: ResultCode * 1: Result
*/ */
void SetTrimmingParamsCenter(Kernel::HLERequestContext& ctx); void SetTrimmingParamsCenter(Kernel::HLERequestContext& ctx);
@ -411,7 +411,7 @@ public:
* 1: u8 selected camera * 1: u8 selected camera
* Outputs: * Outputs:
* 0: 0x00130040 * 0: 0x00130040
* 1: ResultCode * 1: Result
*/ */
void Activate(Kernel::HLERequestContext& ctx); void Activate(Kernel::HLERequestContext& ctx);
@ -423,7 +423,7 @@ public:
* 2: u8 selected context * 2: u8 selected context
* Outputs: * Outputs:
* 0: 0x00140040 * 0: 0x00140040
* 1: ResultCode * 1: Result
*/ */
void SwitchContext(Kernel::HLERequestContext& ctx); void SwitchContext(Kernel::HLERequestContext& ctx);
@ -436,7 +436,7 @@ public:
* 3: u8 selected context * 3: u8 selected context
* Outputs: * Outputs:
* 0: 0x001D0040 * 0: 0x001D0040
* 1: ResultCode * 1: Result
*/ */
void FlipImage(Kernel::HLERequestContext& ctx); void FlipImage(Kernel::HLERequestContext& ctx);
@ -455,7 +455,7 @@ public:
* 8: u8 selected context * 8: u8 selected context
* Outputs: * Outputs:
* 0: 0x001E0040 * 0: 0x001E0040
* 1: ResultCode * 1: Result
*/ */
void SetDetailSize(Kernel::HLERequestContext& ctx); void SetDetailSize(Kernel::HLERequestContext& ctx);
@ -468,7 +468,7 @@ public:
* 3: u8 selected context * 3: u8 selected context
* Outputs: * Outputs:
* 0: 0x001F0040 * 0: 0x001F0040
* 1: ResultCode * 1: Result
*/ */
void SetSize(Kernel::HLERequestContext& ctx); void SetSize(Kernel::HLERequestContext& ctx);
@ -480,7 +480,7 @@ public:
* 2: u8 Camera framerate (`FrameRate` enum) * 2: u8 Camera framerate (`FrameRate` enum)
* Outputs: * Outputs:
* 0: 0x00200040 * 0: 0x00200040
* 1: ResultCode * 1: Result
*/ */
void SetFrameRate(Kernel::HLERequestContext& ctx); void SetFrameRate(Kernel::HLERequestContext& ctx);
@ -493,7 +493,7 @@ public:
* 3: u8 selected context * 3: u8 selected context
* Outputs: * Outputs:
* 0: 0x00220040 * 0: 0x00220040
* 1: ResultCode * 1: Result
*/ */
void SetEffect(Kernel::HLERequestContext& ctx); void SetEffect(Kernel::HLERequestContext& ctx);
@ -506,7 +506,7 @@ public:
* 3: u8 selected context * 3: u8 selected context
* Outputs: * Outputs:
* 0: 0x00250040 * 0: 0x00250040
* 1: ResultCode * 1: Result
*/ */
void SetOutputFormat(Kernel::HLERequestContext& ctx); void SetOutputFormat(Kernel::HLERequestContext& ctx);
@ -518,7 +518,7 @@ public:
* 2: u8 selected camera 2 * 2: u8 selected camera 2
* Outputs: * Outputs:
* 0: 0x00280040 * 0: 0x00280040
* 1: ResultCode * 1: Result
*/ */
void SynchronizeVsyncTiming(Kernel::HLERequestContext& ctx); void SynchronizeVsyncTiming(Kernel::HLERequestContext& ctx);
@ -532,7 +532,7 @@ public:
* 65: s64* TimingsOutput * 65: s64* TimingsOutput
* Outputs: * Outputs:
* 0: 0x002A0042 * 0: 0x002A0042
* 1: ResultCode * 1: Result
* 2-3: Output static buffer * 2-3: Output static buffer
*/ */
void GetLatestVsyncTiming(Kernel::HLERequestContext& ctx); void GetLatestVsyncTiming(Kernel::HLERequestContext& ctx);
@ -545,7 +545,7 @@ public:
* 0: 0x002B0000 * 0: 0x002B0000
* Outputs: * Outputs:
* 0: 0x002B0440 * 0: 0x002B0440
* 1: ResultCode * 1: Result
* 2-17: `StereoCameraCalibrationData` structure with calibration values * 2-17: `StereoCameraCalibrationData` structure with calibration values
*/ */
void GetStereoCameraCalibrationData(Kernel::HLERequestContext& ctx); void GetStereoCameraCalibrationData(Kernel::HLERequestContext& ctx);
@ -559,7 +559,7 @@ public:
* 8-11: unused * 8-11: unused
* Outputs: * Outputs:
* 0: 0x00330040 * 0: 0x00330040
* 1: ResultCode * 1: Result
*/ */
void SetPackageParameterWithoutContext(Kernel::HLERequestContext& ctx); void SetPackageParameterWithoutContext(Kernel::HLERequestContext& ctx);
@ -572,7 +572,7 @@ public:
* 3-5: unused * 3-5: unused
* Outputs: * Outputs:
* 0: 0x00340040 * 0: 0x00340040
* 1: ResultCode * 1: Result
*/ */
void SetPackageParameterWithContext(Kernel::HLERequestContext& ctx); void SetPackageParameterWithContext(Kernel::HLERequestContext& ctx);
@ -585,7 +585,7 @@ public:
* 5-7: unused * 5-7: unused
* Outputs: * Outputs:
* 0: 0x00350040 * 0: 0x00350040
* 1: ResultCode * 1: Result
*/ */
void SetPackageParameterWithContextDetail(Kernel::HLERequestContext& ctx); void SetPackageParameterWithContextDetail(Kernel::HLERequestContext& ctx);
@ -595,7 +595,7 @@ public:
* 0: 0x00360000 * 0: 0x00360000
* Outputs: * Outputs:
* 0: 0x00360080 * 0: 0x00360080
* 1: ResultCode * 1: Result
* 2: ? * 2: ?
*/ */
void GetSuitableY2rStandardCoefficient(Kernel::HLERequestContext& ctx); void GetSuitableY2rStandardCoefficient(Kernel::HLERequestContext& ctx);
@ -607,7 +607,7 @@ public:
* 1: u8 Sound ID * 1: u8 Sound ID
* Outputs: * Outputs:
* 0: 0x00380040 * 0: 0x00380040
* 1: ResultCode * 1: Result
*/ */
void PlayShutterSound(Kernel::HLERequestContext& ctx); void PlayShutterSound(Kernel::HLERequestContext& ctx);
@ -617,7 +617,7 @@ public:
* 0: 0x00390000 * 0: 0x00390000
* Outputs: * Outputs:
* 0: 0x00390040 * 0: 0x00390040
* 1: ResultCode * 1: Result
*/ */
void DriverInitialize(Kernel::HLERequestContext& ctx); void DriverInitialize(Kernel::HLERequestContext& ctx);
@ -627,7 +627,7 @@ public:
* 0: 0x003A0000 * 0: 0x003A0000
* Outputs: * Outputs:
* 0: 0x003A0040 * 0: 0x003A0040
* 1: ResultCode * 1: Result
*/ */
void DriverFinalize(Kernel::HLERequestContext& ctx); void DriverFinalize(Kernel::HLERequestContext& ctx);
@ -653,7 +653,7 @@ private:
void ActivatePort(int port_id, int camera_id); void ActivatePort(int port_id, int camera_id);
template <typename PackageParameterType> template <typename PackageParameterType>
ResultCode SetPackageParameter(const PackageParameterType& package); Result SetPackageParameter(const PackageParameterType& package);
struct ContextConfig { struct ContextConfig {
Flip flip{Flip::None}; Flip flip{Flip::None};

View file

@ -37,23 +37,23 @@ constexpr std::array<CoefficientSet, 4> standard_coefficients{{
{{0x12A, 0x1CA, 0x88, 0x36, 0x21C, -0x1F04, 0x99C, -0x2421}}, // ITU_Rec709_Scaling {{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) { if (width == 0 || width > 1024 || width % 8 != 0) {
return ResultCode(ErrorDescription::OutOfRange, ErrorModule::CAM, return Result(ErrorDescription::OutOfRange, ErrorModule::CAM, ErrorSummary::InvalidArgument,
ErrorSummary::InvalidArgument, ErrorLevel::Usage); // 0xE0E053FD ErrorLevel::Usage); // 0xE0E053FD
} }
// Note: The hardware uses the register value 0 to represent a width of 1024, so for a width of // Note: The hardware uses the register value 0 to represent a width of 1024, so for a width of
// 1024 the `camera` module would set the value 0 here, but we don't need to emulate this // 1024 the `camera` module would set the value 0 here, but we don't need to emulate this
// internal detail. // internal detail.
this->input_line_width = width; this->input_line_width = width;
return RESULT_SUCCESS; return ResultSuccess;
} }
ResultCode ConversionConfiguration::SetInputLines(u16 lines) { Result ConversionConfiguration::SetInputLines(u16 lines) {
if (lines == 0 || lines > 1024) { if (lines == 0 || lines > 1024) {
return ResultCode(ErrorDescription::OutOfRange, ErrorModule::CAM, return Result(ErrorDescription::OutOfRange, ErrorModule::CAM, ErrorSummary::InvalidArgument,
ErrorSummary::InvalidArgument, ErrorLevel::Usage); // 0xE0E053FD ErrorLevel::Usage); // 0xE0E053FD
} }
// Note: In what appears to be a bug, the `camera` module does not set the hardware register at // Note: In what appears to be a bug, the `camera` module does not set the hardware register at
@ -62,19 +62,18 @@ ResultCode ConversionConfiguration::SetInputLines(u16 lines) {
if (lines != 1024) { if (lines != 1024) {
this->input_lines = lines; this->input_lines = lines;
} }
return RESULT_SUCCESS; return ResultSuccess;
} }
ResultCode ConversionConfiguration::SetStandardCoefficient( Result ConversionConfiguration::SetStandardCoefficient(StandardCoefficient standard_coefficient) {
StandardCoefficient standard_coefficient) {
const auto index = static_cast<std::size_t>(standard_coefficient); const auto index = static_cast<std::size_t>(standard_coefficient);
if (index >= standard_coefficients.size()) { if (index >= standard_coefficients.size()) {
return ResultCode(ErrorDescription::InvalidEnumValue, ErrorModule::CAM, return Result(ErrorDescription::InvalidEnumValue, ErrorModule::CAM,
ErrorSummary::InvalidArgument, ErrorLevel::Usage); // 0xE0E053ED ErrorSummary::InvalidArgument, ErrorLevel::Usage); // 0xE0E053ED
} }
std::memcpy(coefficients.data(), standard_coefficients[index].data(), sizeof(coefficients)); std::memcpy(coefficients.data(), standard_coefficients[index].data(), sizeof(coefficients));
return RESULT_SUCCESS; return ResultSuccess;
} }
void Y2R_U::SetInputFormat(Kernel::HLERequestContext& ctx) { void Y2R_U::SetInputFormat(Kernel::HLERequestContext& ctx) {
@ -83,7 +82,7 @@ void Y2R_U::SetInputFormat(Kernel::HLERequestContext& ctx) {
conversion.input_format = rp.PopEnum<InputFormat>(); conversion.input_format = rp.PopEnum<InputFormat>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_DEBUG(Service_Y2R, "called input_format={}", conversion.input_format); LOG_DEBUG(Service_Y2R, "called input_format={}", conversion.input_format);
} }
@ -92,7 +91,7 @@ void Y2R_U::GetInputFormat(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx); IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushEnum(conversion.input_format); rb.PushEnum(conversion.input_format);
LOG_DEBUG(Service_Y2R, "called input_format={}", conversion.input_format); LOG_DEBUG(Service_Y2R, "called input_format={}", conversion.input_format);
@ -104,7 +103,7 @@ void Y2R_U::SetOutputFormat(Kernel::HLERequestContext& ctx) {
conversion.output_format = rp.PopEnum<OutputFormat>(); conversion.output_format = rp.PopEnum<OutputFormat>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_DEBUG(Service_Y2R, "called output_format={}", conversion.output_format); LOG_DEBUG(Service_Y2R, "called output_format={}", conversion.output_format);
} }
@ -113,7 +112,7 @@ void Y2R_U::GetOutputFormat(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx); IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushEnum(conversion.output_format); rb.PushEnum(conversion.output_format);
LOG_DEBUG(Service_Y2R, "called output_format={}", conversion.output_format); LOG_DEBUG(Service_Y2R, "called output_format={}", conversion.output_format);
@ -125,7 +124,7 @@ void Y2R_U::SetRotation(Kernel::HLERequestContext& ctx) {
conversion.rotation = rp.PopEnum<Rotation>(); conversion.rotation = rp.PopEnum<Rotation>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_DEBUG(Service_Y2R, "called rotation={}", conversion.rotation); LOG_DEBUG(Service_Y2R, "called rotation={}", conversion.rotation);
} }
@ -134,7 +133,7 @@ void Y2R_U::GetRotation(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx); IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushEnum(conversion.rotation); rb.PushEnum(conversion.rotation);
LOG_DEBUG(Service_Y2R, "called rotation={}", conversion.rotation); LOG_DEBUG(Service_Y2R, "called rotation={}", conversion.rotation);
@ -146,7 +145,7 @@ void Y2R_U::SetBlockAlignment(Kernel::HLERequestContext& ctx) {
conversion.block_alignment = rp.PopEnum<BlockAlignment>(); conversion.block_alignment = rp.PopEnum<BlockAlignment>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_DEBUG(Service_Y2R, "called block_alignment={}", conversion.block_alignment); LOG_DEBUG(Service_Y2R, "called block_alignment={}", conversion.block_alignment);
} }
@ -155,7 +154,7 @@ void Y2R_U::GetBlockAlignment(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx); IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushEnum(conversion.block_alignment); rb.PushEnum(conversion.block_alignment);
LOG_DEBUG(Service_Y2R, "called block_alignment={}", conversion.block_alignment); LOG_DEBUG(Service_Y2R, "called block_alignment={}", conversion.block_alignment);
@ -167,7 +166,7 @@ void Y2R_U::SetSpacialDithering(Kernel::HLERequestContext& ctx) {
spacial_dithering_enabled = rp.Pop<bool>(); spacial_dithering_enabled = rp.Pop<bool>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_DEBUG(Service_Y2R, "(STUBBED) called"); LOG_DEBUG(Service_Y2R, "(STUBBED) called");
} }
@ -176,7 +175,7 @@ void Y2R_U::GetSpacialDithering(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx); IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push(spacial_dithering_enabled); rb.Push(spacial_dithering_enabled);
LOG_DEBUG(Service_Y2R, "(STUBBED) called"); LOG_DEBUG(Service_Y2R, "(STUBBED) called");
@ -187,7 +186,7 @@ void Y2R_U::SetTemporalDithering(Kernel::HLERequestContext& ctx) {
temporal_dithering_enabled = rp.Pop<bool>(); temporal_dithering_enabled = rp.Pop<bool>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_DEBUG(Service_Y2R, "(STUBBED) called"); LOG_DEBUG(Service_Y2R, "(STUBBED) called");
} }
@ -196,7 +195,7 @@ void Y2R_U::GetTemporalDithering(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx); IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push(temporal_dithering_enabled); rb.Push(temporal_dithering_enabled);
LOG_DEBUG(Service_Y2R, "(STUBBED) called"); LOG_DEBUG(Service_Y2R, "(STUBBED) called");
@ -207,7 +206,7 @@ void Y2R_U::SetTransferEndInterrupt(Kernel::HLERequestContext& ctx) {
transfer_end_interrupt_enabled = rp.Pop<bool>(); transfer_end_interrupt_enabled = rp.Pop<bool>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_DEBUG(Service_Y2R, "(STUBBED) called"); LOG_DEBUG(Service_Y2R, "(STUBBED) called");
} }
@ -216,7 +215,7 @@ void Y2R_U::GetTransferEndInterrupt(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx); IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push(transfer_end_interrupt_enabled); rb.Push(transfer_end_interrupt_enabled);
LOG_DEBUG(Service_Y2R, "(STUBBED) called"); LOG_DEBUG(Service_Y2R, "(STUBBED) called");
@ -226,7 +225,7 @@ void Y2R_U::GetTransferEndEvent(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx); IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushCopyObjects(completion_event); rb.PushCopyObjects(completion_event);
LOG_DEBUG(Service_Y2R, "called"); LOG_DEBUG(Service_Y2R, "called");
@ -242,7 +241,7 @@ void Y2R_U::SetSendingY(Kernel::HLERequestContext& ctx) {
// TODO (wwylele): pass process handle to y2r engine or convert VAddr to PAddr // TODO (wwylele): pass process handle to y2r engine or convert VAddr to PAddr
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_DEBUG(Service_Y2R, LOG_DEBUG(Service_Y2R,
"called image_size=0x{:08X}, transfer_unit={}, transfer_stride={}, " "called image_size=0x{:08X}, transfer_unit={}, transfer_stride={}, "
@ -261,7 +260,7 @@ void Y2R_U::SetSendingU(Kernel::HLERequestContext& ctx) {
// TODO (wwylele): pass the process handle to y2r engine or convert VAddr to PAddr // TODO (wwylele): pass the process handle to y2r engine or convert VAddr to PAddr
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_DEBUG(Service_Y2R, LOG_DEBUG(Service_Y2R,
"called image_size=0x{:08X}, transfer_unit={}, transfer_stride={}, " "called image_size=0x{:08X}, transfer_unit={}, transfer_stride={}, "
@ -281,7 +280,7 @@ void Y2R_U::SetSendingV(Kernel::HLERequestContext& ctx) {
// TODO (wwylele): pass the process handle to y2r engine or convert VAddr to PAddr // TODO (wwylele): pass the process handle to y2r engine or convert VAddr to PAddr
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_DEBUG(Service_Y2R, LOG_DEBUG(Service_Y2R,
"called image_size=0x{:08X}, transfer_unit={}, transfer_stride={}, " "called image_size=0x{:08X}, transfer_unit={}, transfer_stride={}, "
@ -301,7 +300,7 @@ void Y2R_U::SetSendingYUYV(Kernel::HLERequestContext& ctx) {
// TODO (wwylele): pass the process handle to y2r engine or convert VAddr to PAddr // TODO (wwylele): pass the process handle to y2r engine or convert VAddr to PAddr
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_DEBUG(Service_Y2R, LOG_DEBUG(Service_Y2R,
"called image_size=0x{:08X}, transfer_unit={}, transfer_stride={}, " "called image_size=0x{:08X}, transfer_unit={}, transfer_stride={}, "
@ -314,7 +313,7 @@ void Y2R_U::IsFinishedSendingYuv(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx); IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push<u8>(1); rb.Push<u8>(1);
LOG_DEBUG(Service_Y2R, "(STUBBED) called"); LOG_DEBUG(Service_Y2R, "(STUBBED) called");
@ -324,7 +323,7 @@ void Y2R_U::IsFinishedSendingY(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx); IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push<u8>(1); rb.Push<u8>(1);
LOG_DEBUG(Service_Y2R, "(STUBBED) called"); LOG_DEBUG(Service_Y2R, "(STUBBED) called");
@ -334,7 +333,7 @@ void Y2R_U::IsFinishedSendingU(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx); IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push<u8>(1); rb.Push<u8>(1);
LOG_DEBUG(Service_Y2R, "(STUBBED) called"); LOG_DEBUG(Service_Y2R, "(STUBBED) called");
@ -344,7 +343,7 @@ void Y2R_U::IsFinishedSendingV(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx); IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push<u8>(1); rb.Push<u8>(1);
LOG_DEBUG(Service_Y2R, "(STUBBED) called"); LOG_DEBUG(Service_Y2R, "(STUBBED) called");
@ -361,7 +360,7 @@ void Y2R_U::SetReceiving(Kernel::HLERequestContext& ctx) {
// TODO (wwylele): pass the process handle to y2r engine or convert VAddr to PAddr // TODO (wwylele): pass the process handle to y2r engine or convert VAddr to PAddr
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_DEBUG(Service_Y2R, LOG_DEBUG(Service_Y2R,
"called image_size=0x{:08X}, transfer_unit={}, transfer_stride={}, " "called image_size=0x{:08X}, transfer_unit={}, transfer_stride={}, "
@ -374,7 +373,7 @@ void Y2R_U::IsFinishedReceiving(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx); IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push<u8>(1); rb.Push<u8>(1);
LOG_DEBUG(Service_Y2R, "(STUBBED) called"); LOG_DEBUG(Service_Y2R, "(STUBBED) called");
@ -394,7 +393,7 @@ void Y2R_U::GetInputLineWidth(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx); IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push(conversion.input_line_width); rb.Push(conversion.input_line_width);
LOG_DEBUG(Service_Y2R, "called input_line_width={}", conversion.input_line_width); LOG_DEBUG(Service_Y2R, "called input_line_width={}", conversion.input_line_width);
@ -414,7 +413,7 @@ void Y2R_U::GetInputLines(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx); IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push(static_cast<u32>(conversion.input_lines)); rb.Push(static_cast<u32>(conversion.input_lines));
LOG_DEBUG(Service_Y2R, "called input_lines={}", conversion.input_lines); LOG_DEBUG(Service_Y2R, "called input_lines={}", conversion.input_lines);
@ -426,7 +425,7 @@ void Y2R_U::SetCoefficient(Kernel::HLERequestContext& ctx) {
rp.PopRaw<CoefficientSet>(conversion.coefficients); rp.PopRaw<CoefficientSet>(conversion.coefficients);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_DEBUG(Service_Y2R, "called coefficients=[{:X}, {:X}, {:X}, {:X}, {:X}, {:X}, {:X}, {:X}]", LOG_DEBUG(Service_Y2R, "called coefficients=[{:X}, {:X}, {:X}, {:X}, {:X}, {:X}, {:X}, {:X}]",
conversion.coefficients[0], conversion.coefficients[1], conversion.coefficients[2], conversion.coefficients[0], conversion.coefficients[1], conversion.coefficients[2],
@ -438,7 +437,7 @@ void Y2R_U::GetCoefficient(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx); IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(5, 0); IPC::RequestBuilder rb = rp.MakeBuilder(5, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushRaw(conversion.coefficients); rb.PushRaw(conversion.coefficients);
LOG_DEBUG(Service_Y2R, "called"); LOG_DEBUG(Service_Y2R, "called");
@ -460,14 +459,14 @@ void Y2R_U::GetStandardCoefficient(Kernel::HLERequestContext& ctx) {
if (index < standard_coefficients.size()) { if (index < standard_coefficients.size()) {
IPC::RequestBuilder rb = rp.MakeBuilder(5, 0); IPC::RequestBuilder rb = rp.MakeBuilder(5, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushRaw(standard_coefficients[index]); rb.PushRaw(standard_coefficients[index]);
LOG_DEBUG(Service_Y2R, "called standard_coefficient={} ", index); LOG_DEBUG(Service_Y2R, "called standard_coefficient={} ", index);
} else { } else {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ResultCode(ErrorDescription::InvalidEnumValue, ErrorModule::CAM, rb.Push(Result(ErrorDescription::InvalidEnumValue, ErrorModule::CAM,
ErrorSummary::InvalidArgument, ErrorLevel::Usage)); ErrorSummary::InvalidArgument, ErrorLevel::Usage));
LOG_ERROR(Service_Y2R, "called standard_coefficient={} The argument is invalid!", index); LOG_ERROR(Service_Y2R, "called standard_coefficient={} The argument is invalid!", index);
} }
@ -478,7 +477,7 @@ void Y2R_U::SetAlpha(Kernel::HLERequestContext& ctx) {
conversion.alpha = rp.Pop<u32>(); conversion.alpha = rp.Pop<u32>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_DEBUG(Service_Y2R, "called alpha={}", conversion.alpha); LOG_DEBUG(Service_Y2R, "called alpha={}", conversion.alpha);
} }
@ -487,7 +486,7 @@ void Y2R_U::GetAlpha(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx); IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push(conversion.alpha); rb.Push(conversion.alpha);
LOG_DEBUG(Service_Y2R, "called alpha={}", conversion.alpha); LOG_DEBUG(Service_Y2R, "called alpha={}", conversion.alpha);
@ -497,7 +496,7 @@ void Y2R_U::SetDitheringWeightParams(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx); IPC::RequestParser rp(ctx);
rp.PopRaw(dithering_weight_params); rp.PopRaw(dithering_weight_params);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_DEBUG(Service_Y2R, "called"); LOG_DEBUG(Service_Y2R, "called");
} }
@ -506,7 +505,7 @@ void Y2R_U::GetDitheringWeightParams(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx); IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(9, 0); IPC::RequestBuilder rb = rp.MakeBuilder(9, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushRaw(dithering_weight_params); rb.PushRaw(dithering_weight_params);
LOG_DEBUG(Service_Y2R, "called"); LOG_DEBUG(Service_Y2R, "called");
@ -526,7 +525,7 @@ void Y2R_U::StartConversion(Kernel::HLERequestContext& ctx) {
completion_event->Signal(); completion_event->Signal();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_DEBUG(Service_Y2R, "called"); LOG_DEBUG(Service_Y2R, "called");
} }
@ -535,7 +534,7 @@ void Y2R_U::StopConversion(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx); IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_DEBUG(Service_Y2R, "called"); LOG_DEBUG(Service_Y2R, "called");
} }
@ -544,7 +543,7 @@ void Y2R_U::IsBusyConversion(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx); IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push<u8>(0); // StartConversion always finishes immediately rb.Push<u8>(0); // StartConversion always finishes immediately
LOG_DEBUG(Service_Y2R, "called"); LOG_DEBUG(Service_Y2R, "called");
@ -559,7 +558,7 @@ void Y2R_U::SetPackageParameter(Kernel::HLERequestContext& ctx) {
conversion.rotation = params.rotation; conversion.rotation = params.rotation;
conversion.block_alignment = params.block_alignment; 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()) if (result.IsError())
goto cleanup; goto cleanup;
@ -593,7 +592,7 @@ void Y2R_U::PingProcess(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx); IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push<u8>(0); rb.Push<u8>(0);
LOG_DEBUG(Service_Y2R, "(STUBBED) called"); LOG_DEBUG(Service_Y2R, "(STUBBED) called");
@ -621,7 +620,7 @@ void Y2R_U::DriverInitialize(Kernel::HLERequestContext& ctx) {
completion_event->Clear(); completion_event->Clear();
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_DEBUG(Service_Y2R, "called"); LOG_DEBUG(Service_Y2R, "called");
} }
@ -630,7 +629,7 @@ void Y2R_U::DriverFinalize(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx); IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_DEBUG(Service_Y2R, "called"); LOG_DEBUG(Service_Y2R, "called");
} }
@ -639,7 +638,7 @@ void Y2R_U::GetPackageParameter(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx); IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(4, 0); IPC::RequestBuilder rb = rp.MakeBuilder(4, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushRaw(conversion); rb.PushRaw(conversion);
LOG_DEBUG(Service_Y2R, "called"); LOG_DEBUG(Service_Y2R, "called");

View file

@ -120,9 +120,9 @@ struct ConversionConfiguration {
/// Output parameters for the conversion results /// Output parameters for the conversion results
ConversionBuffer dst; ConversionBuffer dst;
ResultCode SetInputLineWidth(u16 width); Result SetInputLineWidth(u16 width);
ResultCode SetInputLines(u16 lines); Result SetInputLines(u16 lines);
ResultCode SetStandardCoefficient(StandardCoefficient standard_coefficient); Result SetStandardCoefficient(StandardCoefficient standard_coefficient);
private: private:
template <class Archive> template <class Archive>

View file

@ -76,11 +76,11 @@ void Module::Interface::Open(Kernel::HLERequestContext& ctx) {
if (dir_result.Failed()) { if (dir_result.Failed()) {
if (open_mode.create) { if (open_mode.create) {
cecd->cecd_system_save_data_archive->CreateDirectory(path); cecd->cecd_system_save_data_archive->CreateDirectory(path);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
} else { } else {
LOG_DEBUG(Service_CECD, "Failed to open directory: {}", path.AsString()); LOG_DEBUG(Service_CECD, "Failed to open directory: {}", path.AsString());
rb.Push(ResultCode(ErrorDescription::NoData, ErrorModule::CEC, rb.Push(Result(ErrorDescription::NoData, ErrorModule::CEC, ErrorSummary::NotFound,
ErrorSummary::NotFound, ErrorLevel::Status)); ErrorLevel::Status));
} }
rb.Push<u32>(0); // Zero entries rb.Push<u32>(0); // Zero entries
} else { } else {
@ -93,7 +93,7 @@ void Module::Interface::Open(Kernel::HLERequestContext& ctx) {
LOG_DEBUG(Service_CECD, "Number of entries found: {}", entry_count); LOG_DEBUG(Service_CECD, "Number of entries found: {}", entry_count);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push<u32>(entry_count); // Entry count rb.Push<u32>(entry_count); // Entry count
directory->Close(); directory->Close();
} }
@ -103,12 +103,12 @@ void Module::Interface::Open(Kernel::HLERequestContext& ctx) {
auto file_result = cecd->cecd_system_save_data_archive->OpenFile(path, mode); auto file_result = cecd->cecd_system_save_data_archive->OpenFile(path, mode);
if (file_result.Failed()) { if (file_result.Failed()) {
LOG_DEBUG(Service_CECD, "Failed to open file: {}", path.AsString()); LOG_DEBUG(Service_CECD, "Failed to open file: {}", path.AsString());
rb.Push(ResultCode(ErrorDescription::NoData, ErrorModule::CEC, ErrorSummary::NotFound, rb.Push(Result(ErrorDescription::NoData, ErrorModule::CEC, ErrorSummary::NotFound,
ErrorLevel::Status)); ErrorLevel::Status));
rb.Push<u32>(0); // No file size rb.Push<u32>(0); // No file size
} else { } else {
session_data->file = std::move(file_result).Unwrap(); session_data->file = std::move(file_result).Unwrap();
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push<u32>(static_cast<u32>(session_data->file->GetSize())); // Return file size rb.Push<u32>(static_cast<u32>(session_data->file->GetSize())); // Return file size
} }
@ -151,8 +151,8 @@ void Module::Interface::Read(Kernel::HLERequestContext& ctx) {
case CecDataPathType::MboxDir: case CecDataPathType::MboxDir:
case CecDataPathType::InboxDir: case CecDataPathType::InboxDir:
case CecDataPathType::OutboxDir: case CecDataPathType::OutboxDir:
rb.Push(ResultCode(ErrorDescription::NotAuthorized, ErrorModule::CEC, rb.Push(Result(ErrorDescription::NotAuthorized, ErrorModule::CEC, ErrorSummary::NotFound,
ErrorSummary::NotFound, ErrorLevel::Status)); ErrorLevel::Status));
rb.Push<u32>(0); // No bytes read rb.Push<u32>(0); // No bytes read
break; break;
default: // If not directory, then it is a file default: // If not directory, then it is a file
@ -163,7 +163,7 @@ void Module::Interface::Read(Kernel::HLERequestContext& ctx) {
write_buffer.Write(buffer.data(), 0, write_buffer_size); write_buffer.Write(buffer.data(), 0, write_buffer_size);
session_data->file->Close(); session_data->file->Close();
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push<u32>(bytes_read); rb.Push<u32>(bytes_read);
} }
rb.PushMappedBuffer(write_buffer); rb.PushMappedBuffer(write_buffer);
@ -225,11 +225,11 @@ void Module::Interface::ReadMessage(Kernel::HLERequestContext& ctx) {
msg_header.sender_id, msg_header.sender_id2, msg_header.send_count, msg_header.sender_id, msg_header.sender_id2, msg_header.send_count,
msg_header.forward_count, msg_header.user_data); msg_header.forward_count, msg_header.user_data);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push<u32>(bytes_read); rb.Push<u32>(bytes_read);
} else { } else {
rb.Push(ResultCode(ErrorDescription::NoData, ErrorModule::CEC, ErrorSummary::NotFound, rb.Push(Result(ErrorDescription::NoData, ErrorModule::CEC, ErrorSummary::NotFound,
ErrorLevel::Status)); ErrorLevel::Status));
rb.Push<u32>(0); // zero bytes read rb.Push<u32>(0); // zero bytes read
} }
rb.PushMappedBuffer(message_id_buffer); rb.PushMappedBuffer(message_id_buffer);
@ -317,11 +317,11 @@ void Module::Interface::ReadMessageWithHMAC(Kernel::HLERequestContext& ctx) {
else else
LOG_DEBUG(Service_CECD, "Verification failed"); LOG_DEBUG(Service_CECD, "Verification failed");
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push<u32>(bytes_read); rb.Push<u32>(bytes_read);
} else { } else {
rb.Push(ResultCode(ErrorDescription::NoData, ErrorModule::CEC, ErrorSummary::NotFound, rb.Push(Result(ErrorDescription::NoData, ErrorModule::CEC, ErrorSummary::NotFound,
ErrorLevel::Status)); ErrorLevel::Status));
rb.Push<u32>(0); // zero bytes read rb.Push<u32>(0); // zero bytes read
} }
@ -356,8 +356,8 @@ void Module::Interface::Write(Kernel::HLERequestContext& ctx) {
case CecDataPathType::MboxDir: case CecDataPathType::MboxDir:
case CecDataPathType::InboxDir: case CecDataPathType::InboxDir:
case CecDataPathType::OutboxDir: case CecDataPathType::OutboxDir:
rb.Push(ResultCode(ErrorDescription::NotAuthorized, ErrorModule::CEC, rb.Push(Result(ErrorDescription::NotAuthorized, ErrorModule::CEC, ErrorSummary::NotFound,
ErrorSummary::NotFound, ErrorLevel::Status)); ErrorLevel::Status));
break; break;
default: // If not directory, then it is a file default: // If not directory, then it is a file
std::vector<u8> buffer(read_buffer_size); std::vector<u8> buffer(read_buffer_size);
@ -376,7 +376,7 @@ void Module::Interface::Write(Kernel::HLERequestContext& ctx) {
session_data->file->Write(0, buffer.size(), true, buffer.data()).Unwrap()); session_data->file->Write(0, buffer.size(), true, buffer.data()).Unwrap());
session_data->file->Close(); session_data->file->Close();
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
} }
rb.PushMappedBuffer(read_buffer); rb.PushMappedBuffer(read_buffer);
@ -438,10 +438,10 @@ void Module::Interface::WriteMessage(Kernel::HLERequestContext& ctx) {
static_cast<u32>(message->Write(0, buffer_size, true, buffer.data()).Unwrap()); static_cast<u32>(message->Write(0, buffer_size, true, buffer.data()).Unwrap());
message->Close(); message->Close();
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
} else { } else {
rb.Push(ResultCode(ErrorDescription::NoData, ErrorModule::CEC, ErrorSummary::NotFound, rb.Push(Result(ErrorDescription::NoData, ErrorModule::CEC, ErrorSummary::NotFound,
ErrorLevel::Status)); ErrorLevel::Status));
} }
rb.PushMappedBuffer(read_buffer); rb.PushMappedBuffer(read_buffer);
@ -525,10 +525,10 @@ void Module::Interface::WriteMessageWithHMAC(Kernel::HLERequestContext& ctx) {
static_cast<u32>(message->Write(0, buffer_size, true, buffer.data()).Unwrap()); static_cast<u32>(message->Write(0, buffer_size, true, buffer.data()).Unwrap());
message->Close(); message->Close();
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
} else { } else {
rb.Push(ResultCode(ErrorDescription::NoData, ErrorModule::CEC, ErrorSummary::NotFound, rb.Push(Result(ErrorDescription::NoData, ErrorModule::CEC, ErrorSummary::NotFound,
ErrorLevel::Status)); ErrorLevel::Status));
} }
rb.PushMappedBuffer(read_buffer); rb.PushMappedBuffer(read_buffer);
@ -613,7 +613,7 @@ void Module::Interface::SetData(Kernel::HLERequestContext& ctx) {
} }
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushMappedBuffer(read_buffer); rb.PushMappedBuffer(read_buffer);
LOG_DEBUG(Service_CECD, "called, ncch_program_id={:#010x}, buffer_size={:#x}, option={:#x}", LOG_DEBUG(Service_CECD, "called, ncch_program_id={:#010x}, buffer_size={:#x}, option={:#x}",
@ -651,7 +651,7 @@ void Module::Interface::ReadData(Kernel::HLERequestContext& ctx) {
dest_buffer.Write(buffer.data(), 0, dest_buffer.Write(buffer.data(), 0,
std::min(static_cast<size_t>(dest_buffer_size), buffer.size())); std::min(static_cast<size_t>(dest_buffer_size), buffer.size()));
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushMappedBuffer(param_buffer); rb.PushMappedBuffer(param_buffer);
rb.PushMappedBuffer(dest_buffer); rb.PushMappedBuffer(dest_buffer);
@ -665,7 +665,7 @@ void Module::Interface::Start(Kernel::HLERequestContext& ctx) {
const CecCommand command = rp.PopEnum<CecCommand>(); const CecCommand command = rp.PopEnum<CecCommand>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_WARNING(Service_CECD, "(STUBBED) called, command={}", cecd->GetCecCommandAsString(command)); LOG_WARNING(Service_CECD, "(STUBBED) called, command={}", cecd->GetCecCommandAsString(command));
} }
@ -675,7 +675,7 @@ void Module::Interface::Stop(Kernel::HLERequestContext& ctx) {
const CecCommand command = rp.PopEnum<CecCommand>(); const CecCommand command = rp.PopEnum<CecCommand>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_WARNING(Service_CECD, "(STUBBED) called, command={}", cecd->GetCecCommandAsString(command)); LOG_WARNING(Service_CECD, "(STUBBED) called, command={}", cecd->GetCecCommandAsString(command));
} }
@ -687,7 +687,7 @@ void Module::Interface::GetCecInfoBuffer(Kernel::HLERequestContext& ctx) {
auto& buffer = rp.PopMappedBuffer(); auto& buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushMappedBuffer(buffer); rb.PushMappedBuffer(buffer);
LOG_DEBUG(Service_CECD, "called, buffer_size={}, possible_info_type={}", buffer_size, LOG_DEBUG(Service_CECD, "called, buffer_size={}, possible_info_type={}", buffer_size,
@ -698,7 +698,7 @@ void Module::Interface::GetCecdState(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx); IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushEnum(CecdState::NdmStatusIdle); rb.PushEnum(CecdState::NdmStatusIdle);
LOG_WARNING(Service_CECD, "(STUBBED) called"); LOG_WARNING(Service_CECD, "(STUBBED) called");
@ -708,7 +708,7 @@ void Module::Interface::GetCecInfoEventHandle(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx); IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushCopyObjects(cecd->cecinfo_event); rb.PushCopyObjects(cecd->cecinfo_event);
LOG_WARNING(Service_CECD, "(STUBBED) called"); LOG_WARNING(Service_CECD, "(STUBBED) called");
@ -718,7 +718,7 @@ void Module::Interface::GetChangeStateEventHandle(Kernel::HLERequestContext& ctx
IPC::RequestParser rp(ctx); IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushCopyObjects(cecd->change_state_event); rb.PushCopyObjects(cecd->change_state_event);
LOG_WARNING(Service_CECD, "(STUBBED) called"); LOG_WARNING(Service_CECD, "(STUBBED) called");
@ -745,8 +745,8 @@ void Module::Interface::OpenAndWrite(Kernel::HLERequestContext& ctx) {
case CecDataPathType::MboxDir: case CecDataPathType::MboxDir:
case CecDataPathType::InboxDir: case CecDataPathType::InboxDir:
case CecDataPathType::OutboxDir: case CecDataPathType::OutboxDir:
rb.Push(ResultCode(ErrorDescription::NotAuthorized, ErrorModule::CEC, rb.Push(Result(ErrorDescription::NotAuthorized, ErrorModule::CEC, ErrorSummary::NotFound,
ErrorSummary::NotFound, ErrorLevel::Status)); ErrorLevel::Status));
break; break;
default: // If not directory, then it is a file default: // If not directory, then it is a file
auto file_result = cecd->cecd_system_save_data_archive->OpenFile(path, mode); auto file_result = cecd->cecd_system_save_data_archive->OpenFile(path, mode);
@ -768,10 +768,10 @@ void Module::Interface::OpenAndWrite(Kernel::HLERequestContext& ctx) {
static_cast<u32>(file->Write(0, buffer.size(), true, buffer.data()).Unwrap()); static_cast<u32>(file->Write(0, buffer.size(), true, buffer.data()).Unwrap());
file->Close(); file->Close();
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
} else { } else {
rb.Push(ResultCode(ErrorDescription::NoData, ErrorModule::CEC, ErrorSummary::NotFound, rb.Push(Result(ErrorDescription::NoData, ErrorModule::CEC, ErrorSummary::NotFound,
ErrorLevel::Status)); ErrorLevel::Status));
} }
} }
rb.PushMappedBuffer(read_buffer); rb.PushMappedBuffer(read_buffer);
@ -804,8 +804,8 @@ void Module::Interface::OpenAndRead(Kernel::HLERequestContext& ctx) {
case CecDataPathType::MboxDir: case CecDataPathType::MboxDir:
case CecDataPathType::InboxDir: case CecDataPathType::InboxDir:
case CecDataPathType::OutboxDir: case CecDataPathType::OutboxDir:
rb.Push(ResultCode(ErrorDescription::NotAuthorized, ErrorModule::CEC, rb.Push(Result(ErrorDescription::NotAuthorized, ErrorModule::CEC, ErrorSummary::NotFound,
ErrorSummary::NotFound, ErrorLevel::Status)); ErrorLevel::Status));
rb.Push<u32>(0); // No entries read rb.Push<u32>(0); // No entries read
break; break;
default: // If not directory, then it is a file default: // If not directory, then it is a file
@ -819,11 +819,11 @@ void Module::Interface::OpenAndRead(Kernel::HLERequestContext& ctx) {
write_buffer.Write(buffer.data(), 0, buffer_size); write_buffer.Write(buffer.data(), 0, buffer_size);
file->Close(); file->Close();
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push<u32>(bytes_read); rb.Push<u32>(bytes_read);
} else { } else {
rb.Push(ResultCode(ErrorDescription::NoData, ErrorModule::CEC, ErrorSummary::NotFound, rb.Push(Result(ErrorDescription::NoData, ErrorModule::CEC, ErrorSummary::NotFound,
ErrorLevel::Status)); ErrorLevel::Status));
rb.Push<u32>(0); // No bytes read rb.Push<u32>(0); // No bytes read
} }
} }
@ -842,7 +842,7 @@ void Module::Interface::GetCecInfoEventHandleSys(Kernel::HLERequestContext& ctx)
rp.PopPID(); rp.PopPID();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushCopyObjects(cecd->cecinfosys_event); rb.PushCopyObjects(cecd->cecinfosys_event);
LOG_WARNING(Service_CECD, "(STUBBED) called"); LOG_WARNING(Service_CECD, "(STUBBED) called");
@ -1404,7 +1404,7 @@ Module::Module(Core::System& system) : system(system) {
auto archive_result = systemsavedata_factory.Open(archive_path, 0); auto archive_result = systemsavedata_factory.Open(archive_path, 0);
// If the archive didn't exist, create the files inside // If the archive didn't exist, create the files inside
if (archive_result.Code() != FileSys::ERROR_NOT_FOUND) { if (archive_result.Code() != FileSys::ResultNotFound) {
ASSERT_MSG(archive_result.Succeeded(), "Could not open the CECD SystemSaveData archive!"); ASSERT_MSG(archive_result.Succeeded(), "Could not open the CECD SystemSaveData archive!");
cecd_system_save_data_archive = std::move(archive_result).Unwrap(); cecd_system_save_data_archive = std::move(archive_result).Unwrap();
} else { } else {

View file

@ -500,7 +500,7 @@ public:
* Inputs: * Inputs:
* 0: Header Code[0x000E0000] * 0: Header Code[0x000E0000]
* Outputs: * Outputs:
* 1: ResultCode * 1: Result
* 2: CecdState * 2: CecdState
*/ */
void GetCecdState(Kernel::HLERequestContext& ctx); void GetCecdState(Kernel::HLERequestContext& ctx);
@ -510,7 +510,7 @@ public:
* Inputs: * Inputs:
* 0: Header Code[0x000F0000] * 0: Header Code[0x000F0000]
* Outputs: * Outputs:
* 1: ResultCode * 1: Result
* 3: Event Handle * 3: Event Handle
*/ */
void GetCecInfoEventHandle(Kernel::HLERequestContext& ctx); void GetCecInfoEventHandle(Kernel::HLERequestContext& ctx);
@ -520,7 +520,7 @@ public:
* Inputs: * Inputs:
* 0: Header Code[0x00100000] * 0: Header Code[0x00100000]
* Outputs: * Outputs:
* 1: ResultCode * 1: Result
* 3: Event Handle * 3: Event Handle
*/ */
void GetChangeStateEventHandle(Kernel::HLERequestContext& ctx); void GetChangeStateEventHandle(Kernel::HLERequestContext& ctx);
@ -593,7 +593,7 @@ public:
* Inputs: * Inputs:
* 0: Header Code[0x40020002] * 0: Header Code[0x40020002]
* Outputs: * Outputs:
* 1: ResultCode * 1: Result
* 3: Event Handle * 3: Event Handle
*/ */
void GetCecInfoEventHandleSys(Kernel::HLERequestContext& ctx); void GetCecInfoEventHandleSys(Kernel::HLERequestContext& ctx);

View file

@ -153,13 +153,13 @@ void Module::Interface::GetCountryCodeString(Kernel::HLERequestContext& ctx) {
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
if (country_code_id >= country_codes.size() || 0 == country_codes[country_code_id]) { 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); LOG_ERROR(Service_CFG, "requested country code id={} is invalid", country_code_id);
rb.Push(ResultCode(ErrorDescription::NotFound, ErrorModule::Config, rb.Push(Result(ErrorDescription::NotFound, ErrorModule::Config, ErrorSummary::WrongArgument,
ErrorSummary::WrongArgument, ErrorLevel::Permanent)); ErrorLevel::Permanent));
rb.Skip(1, false); rb.Skip(1, false);
return; return;
} }
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
// the real CFG service copies only three bytes (including the null-terminator) here // the real CFG service copies only three bytes (including the null-terminator) here
rb.Push<u32>(country_codes[country_code_id]); rb.Push<u32>(country_codes[country_code_id]);
} }
@ -187,13 +187,13 @@ void Module::Interface::GetCountryCodeID(Kernel::HLERequestContext& ctx) {
if (0 == country_code_id) { if (0 == country_code_id) {
LOG_ERROR(Service_CFG, "requested country code name={}{} is invalid", LOG_ERROR(Service_CFG, "requested country code name={}{} is invalid",
static_cast<char>(country_code & 0xff), static_cast<char>(country_code >> 8)); static_cast<char>(country_code & 0xff), static_cast<char>(country_code >> 8));
rb.Push(ResultCode(ErrorDescription::NotFound, ErrorModule::Config, rb.Push(Result(ErrorDescription::NotFound, ErrorModule::Config, ErrorSummary::WrongArgument,
ErrorSummary::WrongArgument, ErrorLevel::Permanent)); ErrorLevel::Permanent));
rb.Push<u16>(0x00FF); rb.Push<u16>(0x00FF);
return; return;
} }
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push<u16>(country_code_id); rb.Push<u16>(country_code_id);
} }
@ -210,7 +210,7 @@ void Module::Interface::GetRegion(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx); IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push<u8>(static_cast<u8>(cfg->GetRegionValue())); rb.Push<u8>(static_cast<u8>(cfg->GetRegionValue()));
} }
@ -220,7 +220,7 @@ void Module::Interface::SecureInfoGetByte101(Kernel::HLERequestContext& ctx) {
LOG_DEBUG(Service_CFG, "(STUBBED) called"); LOG_DEBUG(Service_CFG, "(STUBBED) called");
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
// According to 3dbrew this is normally 0. // According to 3dbrew this is normally 0.
rb.Push<u8>(0); rb.Push<u8>(0);
} }
@ -232,14 +232,14 @@ void Module::Interface::SetUUIDClockSequence(Kernel::HLERequestContext& ctx) {
cfg->SaveMCUConfig(); cfg->SaveMCUConfig();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
} }
void Module::Interface::GetUUIDClockSequence(Kernel::HLERequestContext& ctx) { void Module::Interface::GetUUIDClockSequence(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx); IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push<u16>(static_cast<u16>(cfg->mcu_data.clock_sequence)); rb.Push<u16>(static_cast<u16>(cfg->mcu_data.clock_sequence));
} }
@ -250,7 +250,7 @@ void Module::Interface::GetTransferableId(Kernel::HLERequestContext& ctx) {
IPC::RequestBuilder rb = rp.MakeBuilder(3, 0); IPC::RequestBuilder rb = rp.MakeBuilder(3, 0);
std::array<u8, 12> buffer; std::array<u8, 12> buffer;
const ResultCode result = const Result result =
cfg->GetConfigBlock(ConsoleUniqueID2BlockID, 8, AccessFlag::SystemRead, buffer.data()); cfg->GetConfigBlock(ConsoleUniqueID2BlockID, 8, AccessFlag::SystemRead, buffer.data());
rb.Push(result); rb.Push(result);
if (result.IsSuccess()) { if (result.IsSuccess()) {
@ -274,7 +274,7 @@ void Module::Interface::IsCoppacsSupported(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx); IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
u8 canada_or_usa = 1; u8 canada_or_usa = 1;
if (canada_or_usa == cfg->GetRegionValue()) { if (canada_or_usa == cfg->GetRegionValue()) {
@ -407,23 +407,23 @@ ResultVal<void*> Module::GetConfigBlockPointer(u32 block_id, u32 size, AccessFla
"Config block 0x{:X} with flags {} and size {} was not found, and no default " "Config block 0x{:X} with flags {} and size {} was not found, and no default "
"exists.", "exists.",
block_id, accesss_flag, size); block_id, accesss_flag, size);
return ResultCode(ErrorDescription::NotFound, ErrorModule::Config, return Result(ErrorDescription::NotFound, ErrorModule::Config,
ErrorSummary::WrongArgument, ErrorLevel::Permanent); ErrorSummary::WrongArgument, ErrorLevel::Permanent);
} }
} }
if (False(itr->access_flags & accesss_flag)) { if (False(itr->access_flags & accesss_flag)) {
LOG_ERROR(Service_CFG, "Invalid access flag {:X} for config block 0x{:X} with size {}", LOG_ERROR(Service_CFG, "Invalid access flag {:X} for config block 0x{:X} with size {}",
accesss_flag, block_id, size); accesss_flag, block_id, size);
return ResultCode(ErrorDescription::NotAuthorized, ErrorModule::Config, return Result(ErrorDescription::NotAuthorized, ErrorModule::Config,
ErrorSummary::WrongArgument, ErrorLevel::Permanent); ErrorSummary::WrongArgument, ErrorLevel::Permanent);
} }
if (itr->size != size) { if (itr->size != size) {
LOG_ERROR(Service_CFG, "Invalid size {} for config block 0x{:X} with flags {}", size, LOG_ERROR(Service_CFG, "Invalid size {} for config block 0x{:X} with flags {}", size,
block_id, accesss_flag); block_id, accesss_flag);
return ResultCode(ErrorDescription::InvalidSize, ErrorModule::Config, return Result(ErrorDescription::InvalidSize, ErrorModule::Config,
ErrorSummary::WrongArgument, ErrorLevel::Permanent); ErrorSummary::WrongArgument, ErrorLevel::Permanent);
} }
void* pointer; void* pointer;
@ -437,27 +437,26 @@ ResultVal<void*> Module::GetConfigBlockPointer(u32 block_id, u32 size, AccessFla
return pointer; 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; void* pointer = nullptr;
CASCADE_RESULT(pointer, GetConfigBlockPointer(block_id, size, accesss_flag)); CASCADE_RESULT(pointer, GetConfigBlockPointer(block_id, size, accesss_flag));
std::memcpy(output, pointer, size); std::memcpy(output, pointer, size);
return RESULT_SUCCESS; return ResultSuccess;
} }
ResultCode Module::SetConfigBlock(u32 block_id, u32 size, AccessFlag accesss_flag, Result Module::SetConfigBlock(u32 block_id, u32 size, AccessFlag accesss_flag, const void* input) {
const void* input) {
void* pointer = nullptr; void* pointer = nullptr;
CASCADE_RESULT(pointer, GetConfigBlockPointer(block_id, size, accesss_flag)); CASCADE_RESULT(pointer, GetConfigBlockPointer(block_id, size, accesss_flag));
std::memcpy(pointer, input, size); std::memcpy(pointer, input, size);
return RESULT_SUCCESS; return ResultSuccess;
} }
ResultCode Module::CreateConfigBlock(u32 block_id, u16 size, AccessFlag access_flags, Result Module::CreateConfigBlock(u32 block_id, u16 size, AccessFlag access_flags,
const void* data) { const void* data) {
SaveFileConfig* config = reinterpret_cast<SaveFileConfig*>(cfg_config_file_buffer.data()); SaveFileConfig* config = reinterpret_cast<SaveFileConfig*>(cfg_config_file_buffer.data());
if (config->total_entries >= CONFIG_FILE_MAX_BLOCK_ENTRIES) if (config->total_entries >= CONFIG_FILE_MAX_BLOCK_ENTRIES)
return ResultCode(-1); // TODO(Subv): Find the right error code return ResultUnknown; // TODO(Subv): Find the right error code
// Insert the block header with offset 0 for now // Insert the block header with offset 0 for now
config->block_entries[config->total_entries] = {block_id, 0, size, access_flags}; config->block_entries[config->total_entries] = {block_id, 0, size, access_flags};
@ -483,15 +482,15 @@ ResultCode Module::CreateConfigBlock(u32 block_id, u16 size, AccessFlag access_f
} }
++config->total_entries; ++config->total_entries;
return RESULT_SUCCESS; return ResultSuccess;
} }
ResultCode Module::DeleteConfigNANDSaveFile() { Result Module::DeleteConfigNANDSaveFile() {
FileSys::Path path("/config"); FileSys::Path path("/config");
return cfg_system_save_data_archive->DeleteFile(path); return cfg_system_save_data_archive->DeleteFile(path);
} }
ResultCode Module::UpdateConfigNANDSavegame() { Result Module::UpdateConfigNANDSavegame() {
FileSys::Mode mode = {}; FileSys::Mode mode = {};
mode.write_flag.Assign(1); mode.write_flag.Assign(1);
mode.create_flag.Assign(1); mode.create_flag.Assign(1);
@ -504,13 +503,13 @@ ResultCode Module::UpdateConfigNANDSavegame() {
auto config = std::move(config_result).Unwrap(); auto config = std::move(config_result).Unwrap();
config->Write(0, CONFIG_SAVEFILE_SIZE, 1, cfg_config_file_buffer.data()); config->Write(0, CONFIG_SAVEFILE_SIZE, 1, cfg_config_file_buffer.data());
return RESULT_SUCCESS; return ResultSuccess;
} }
ResultCode Module::FormatConfig() { Result Module::FormatConfig() {
ResultCode res = DeleteConfigNANDSaveFile(); Result res = DeleteConfigNANDSaveFile();
// The delete command fails if the file doesn't exist, so we have to check that too // 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) { if (!res.IsSuccess() && res != FileSys::ResultFileNotFound) {
return res; return res;
} }
// Delete the old data // Delete the old data
@ -540,10 +539,10 @@ ResultCode Module::FormatConfig() {
return res; return res;
} }
return RESULT_SUCCESS; return ResultSuccess;
} }
ResultCode Module::LoadConfigNANDSaveFile() { Result Module::LoadConfigNANDSaveFile() {
const std::string& nand_directory = FileUtil::GetUserPath(FileUtil::UserPath::NANDDir); const std::string& nand_directory = FileUtil::GetUserPath(FileUtil::UserPath::NANDDir);
FileSys::ArchiveFactory_SystemSaveData systemsavedata_factory(nand_directory); FileSys::ArchiveFactory_SystemSaveData systemsavedata_factory(nand_directory);
@ -552,7 +551,7 @@ ResultCode Module::LoadConfigNANDSaveFile() {
auto archive_result = systemsavedata_factory.Open(archive_path, 0); auto archive_result = systemsavedata_factory.Open(archive_path, 0);
// If the archive didn't exist, create the files inside // If the archive didn't exist, create the files inside
if (archive_result.Code() == FileSys::ERROR_NOT_FOUND) { if (archive_result.Code() == FileSys::ResultNotFound) {
// Format the archive to create the directories // Format the archive to create the directories
systemsavedata_factory.Format(archive_path, FileSys::ArchiveFormatInfo(), 0); systemsavedata_factory.Format(archive_path, FileSys::ArchiveFormatInfo(), 0);
@ -574,7 +573,7 @@ ResultCode Module::LoadConfigNANDSaveFile() {
if (config_result.Succeeded()) { if (config_result.Succeeded()) {
auto config = std::move(config_result).Unwrap(); auto config = std::move(config_result).Unwrap();
config->Read(0, CONFIG_SAVEFILE_SIZE, cfg_config_file_buffer.data()); config->Read(0, CONFIG_SAVEFILE_SIZE, cfg_config_file_buffer.data());
return RESULT_SUCCESS; return ResultSuccess;
} }
return FormatConfig(); return FormatConfig();
@ -777,10 +776,10 @@ std::pair<u32, u64> Module::GenerateConsoleUniqueId() const {
return std::make_pair(random_number, console_id); 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; u64_le console_id_le = console_id;
ResultCode res = SetConfigBlock(ConsoleUniqueID1BlockID, sizeof(console_id_le), Result res = SetConfigBlock(ConsoleUniqueID1BlockID, sizeof(console_id_le), AccessFlag::Global,
AccessFlag::Global, &console_id_le); &console_id_le);
if (!res.IsSuccess()) if (!res.IsSuccess())
return res; return res;
@ -795,7 +794,7 @@ ResultCode Module::SetConsoleUniqueId(u32 random_number, u64 console_id) {
if (!res.IsSuccess()) if (!res.IsSuccess())
return res; return res;
return RESULT_SUCCESS; return ResultSuccess;
} }
u64 Module::GetConsoleUniqueId() { u64 Module::GetConsoleUniqueId() {

View file

@ -389,9 +389,9 @@ private:
* @param size The size of the block we want to read * @param size The size of the block we want to read
* @param accesss_flag The requested block must have this access flag set * @param accesss_flag The requested block must have this access flag set
* @param output A pointer where we will write the read data * @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 * 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 size The size of the block we want to write
* @param accesss_flag The target block must have this access flag set * @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 * @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 * 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 size The size of the block we want to create
* @param accesss_flags The access flags of the new block * @param accesss_flags The access flags of the new block
* @param data A pointer containing the data we will write to 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, Result CreateConfigBlock(u32 block_id, u16 size, AccessFlag accesss_flags, const void* data);
const void* data);
/** /**
* Deletes the config savegame file from the filesystem, the buffer in memory is not affected * 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 * 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 * 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 * Loads MCU specific data
@ -538,7 +537,7 @@ public:
* @param random_number the random_number to set * @param random_number the random_number to set
* @param console_id the console id 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. * 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 * 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 * Saves MCU specific data

View file

@ -208,7 +208,7 @@ void CSND_SND::Initialize(Kernel::HLERequestContext& ctx) {
.Unwrap(); .Unwrap();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 3); IPC::RequestBuilder rb = rp.MakeBuilder(1, 3);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushCopyObjects(mutex, shared_memory); rb.PushCopyObjects(mutex, shared_memory);
LOG_WARNING(Service_CSND, LOG_WARNING(Service_CSND,
@ -228,7 +228,7 @@ void CSND_SND::Shutdown(Kernel::HLERequestContext& ctx) {
shared_memory = nullptr; shared_memory = nullptr;
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_WARNING(Service_CSND, "(STUBBED) called"); LOG_WARNING(Service_CSND, "(STUBBED) called");
} }
@ -240,8 +240,8 @@ void CSND_SND::ExecuteCommands(Kernel::HLERequestContext& ctx) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
if (!shared_memory) { if (!shared_memory) {
rb.Push(ResultCode(ErrorDescription::InvalidResultValue, ErrorModule::CSND, rb.Push(Result(ErrorDescription::InvalidResultValue, ErrorModule::CSND,
ErrorSummary::InvalidState, ErrorLevel::Status)); ErrorSummary::InvalidState, ErrorLevel::Status));
LOG_ERROR(Service_CSND, "called, shared memory not allocated"); LOG_ERROR(Service_CSND, "called, shared memory not allocated");
return; return;
} }
@ -394,7 +394,7 @@ void CSND_SND::ExecuteCommands(Kernel::HLERequestContext& ctx) {
*shared_memory->GetPointer(addr + offsetof(Type0Command, finished)) = 1; *shared_memory->GetPointer(addr + offsetof(Type0Command, finished)) = 1;
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
} }
void CSND_SND::AcquireSoundChannels(Kernel::HLERequestContext& ctx) { void CSND_SND::AcquireSoundChannels(Kernel::HLERequestContext& ctx) {
@ -405,7 +405,7 @@ void CSND_SND::AcquireSoundChannels(Kernel::HLERequestContext& ctx) {
acquired_channel_mask = 0xFFFFFF00; acquired_channel_mask = 0xFFFFFF00;
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push(acquired_channel_mask); rb.Push(acquired_channel_mask);
LOG_WARNING(Service_CSND, "(STUBBED) called"); LOG_WARNING(Service_CSND, "(STUBBED) called");
@ -417,7 +417,7 @@ void CSND_SND::ReleaseSoundChannels(Kernel::HLERequestContext& ctx) {
acquired_channel_mask = 0; acquired_channel_mask = 0;
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_WARNING(Service_CSND, "(STUBBED) called"); LOG_WARNING(Service_CSND, "(STUBBED) called");
} }
@ -428,12 +428,12 @@ void CSND_SND::AcquireCapUnit(Kernel::HLERequestContext& ctx) {
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
if (capture_units[0] && capture_units[1]) { if (capture_units[0] && capture_units[1]) {
LOG_WARNING(Service_CSND, "No more capture units available"); LOG_WARNING(Service_CSND, "No more capture units available");
rb.Push(ResultCode(ErrorDescription::InvalidResultValue, ErrorModule::CSND, rb.Push(Result(ErrorDescription::InvalidResultValue, ErrorModule::CSND,
ErrorSummary::OutOfResource, ErrorLevel::Status)); ErrorSummary::OutOfResource, ErrorLevel::Status));
rb.Skip(1, false); rb.Skip(1, false);
return; return;
} }
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
if (capture_units[0]) { if (capture_units[0]) {
capture_units[1] = true; capture_units[1] = true;
@ -453,7 +453,7 @@ void CSND_SND::ReleaseCapUnit(Kernel::HLERequestContext& ctx) {
capture_units[index] = false; capture_units[index] = false;
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_WARNING(Service_CSND, "(STUBBED) called, capture_unit_index={}", index); LOG_WARNING(Service_CSND, "(STUBBED) called, capture_unit_index={}", index);
} }
@ -465,7 +465,7 @@ void CSND_SND::FlushDataCache(Kernel::HLERequestContext& ctx) {
const auto process = rp.PopObject<Kernel::Process>(); const auto process = rp.PopObject<Kernel::Process>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_TRACE(Service_CSND, "(STUBBED) called address=0x{:08X}, size=0x{:08X}, process={}", address, LOG_TRACE(Service_CSND, "(STUBBED) called address=0x{:08X}, size=0x{:08X}, process={}", address,
size, process->process_id); size, process->process_id);
@ -478,7 +478,7 @@ void CSND_SND::StoreDataCache(Kernel::HLERequestContext& ctx) {
const auto process = rp.PopObject<Kernel::Process>(); const auto process = rp.PopObject<Kernel::Process>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_TRACE(Service_CSND, "(STUBBED) called address=0x{:08X}, size=0x{:08X}, process={}", address, LOG_TRACE(Service_CSND, "(STUBBED) called address=0x{:08X}, size=0x{:08X}, process={}", address,
size, process->process_id); size, process->process_id);
@ -491,7 +491,7 @@ void CSND_SND::InvalidateDataCache(Kernel::HLERequestContext& ctx) {
const auto process = rp.PopObject<Kernel::Process>(); const auto process = rp.PopObject<Kernel::Process>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_TRACE(Service_CSND, "(STUBBED) called address=0x{:08X}, size=0x{:08X}, process={}", address, LOG_TRACE(Service_CSND, "(STUBBED) called address=0x{:08X}, size=0x{:08X}, process={}", address,
size, process->process_id); size, process->process_id);
@ -501,7 +501,7 @@ void CSND_SND::Reset(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx); IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_WARNING(Service_CSND, "(STUBBED) called"); LOG_WARNING(Service_CSND, "(STUBBED) called");
} }

View file

@ -18,7 +18,7 @@ void DLP_SRVR::IsChild(Kernel::HLERequestContext& ctx) {
rp.Skip(1, false); rp.Skip(1, false);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push(false); rb.Push(false);
LOG_WARNING(Service_DLP, "(STUBBED) called"); LOG_WARNING(Service_DLP, "(STUBBED) called");

View file

@ -28,7 +28,7 @@ void DSP_DSP::RecvData(Kernel::HLERequestContext& ctx) {
const u32 register_number = rp.Pop<u32>(); const u32 register_number = rp.Pop<u32>();
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push(system.DSP().RecvData(register_number)); rb.Push(system.DSP().RecvData(register_number));
LOG_DEBUG(Service_DSP, "register_number={}", register_number); LOG_DEBUG(Service_DSP, "register_number={}", register_number);
@ -39,7 +39,7 @@ void DSP_DSP::RecvDataIsReady(Kernel::HLERequestContext& ctx) {
const u32 register_number = rp.Pop<u32>(); const u32 register_number = rp.Pop<u32>();
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push(system.DSP().RecvDataIsReady(register_number)); rb.Push(system.DSP().RecvDataIsReady(register_number));
LOG_DEBUG(Service_DSP, "register_number={}", register_number); LOG_DEBUG(Service_DSP, "register_number={}", register_number);
@ -52,7 +52,7 @@ void DSP_DSP::SetSemaphore(Kernel::HLERequestContext& ctx) {
system.DSP().SetSemaphore(semaphore_value); system.DSP().SetSemaphore(semaphore_value);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_INFO(Service_DSP, "called, semaphore_value={:04X}", semaphore_value); LOG_INFO(Service_DSP, "called, semaphore_value={:04X}", semaphore_value);
} }
@ -62,7 +62,7 @@ void DSP_DSP::ConvertProcessAddressFromDspDram(Kernel::HLERequestContext& ctx) {
const u32 address = rp.Pop<u32>(); const u32 address = rp.Pop<u32>();
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
// TODO(merry): There is a per-region offset missing in this calculation (that seems to be // TODO(merry): There is a per-region offset missing in this calculation (that seems to be
// always zero). // always zero).
@ -103,7 +103,7 @@ void DSP_DSP::WriteProcessPipe(Kernel::HLERequestContext& ctx) {
system.DSP().PipeWrite(pipe, buffer); system.DSP().PipeWrite(pipe, buffer);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_DEBUG(Service_DSP, "channel={}, size=0x{:X}, buffer_size={:X}", channel, size, LOG_DEBUG(Service_DSP, "channel={}, size=0x{:X}, buffer_size={:X}", channel, size,
buffer.size()); buffer.size());
@ -125,7 +125,7 @@ void DSP_DSP::ReadPipe(Kernel::HLERequestContext& ctx) {
UNREACHABLE(); // No more data is in pipe. Hardware hangs in this case; Should never happen. UNREACHABLE(); // No more data is in pipe. Hardware hangs in this case; Should never happen.
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushStaticBuffer(std::move(pipe_buffer), 0); rb.PushStaticBuffer(std::move(pipe_buffer), 0);
LOG_DEBUG(Service_DSP, "channel={}, peer={}, size=0x{:04X}, pipe_readable_size=0x{:04X}", LOG_DEBUG(Service_DSP, "channel={}, peer={}, size=0x{:04X}, pipe_readable_size=0x{:04X}",
@ -141,7 +141,7 @@ void DSP_DSP::GetPipeReadableSize(Kernel::HLERequestContext& ctx) {
const u16 pipe_readable_size = static_cast<u16>(system.DSP().GetPipeReadableSize(pipe)); const u16 pipe_readable_size = static_cast<u16>(system.DSP().GetPipeReadableSize(pipe));
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push<u16>(pipe_readable_size); rb.Push<u16>(pipe_readable_size);
LOG_DEBUG(Service_DSP, "channel={}, peer={}, return pipe_readable_size=0x{:04X}", channel, peer, LOG_DEBUG(Service_DSP, "channel={}, peer={}, return pipe_readable_size=0x{:04X}", channel, peer,
@ -163,7 +163,7 @@ void DSP_DSP::ReadPipeIfPossible(Kernel::HLERequestContext& ctx) {
} }
IPC::RequestBuilder rb = rp.MakeBuilder(2, 2); IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push<u16>(static_cast<u16>(pipe_buffer.size())); rb.Push<u16>(static_cast<u16>(pipe_buffer.size()));
rb.PushStaticBuffer(std::move(pipe_buffer), 0); rb.PushStaticBuffer(std::move(pipe_buffer), 0);
@ -179,7 +179,7 @@ void DSP_DSP::LoadComponent(Kernel::HLERequestContext& ctx) {
auto& buffer = rp.PopMappedBuffer(); auto& buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(2, 2); IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push(true); rb.Push(true);
rb.PushMappedBuffer(buffer); rb.PushMappedBuffer(buffer);
@ -198,7 +198,7 @@ void DSP_DSP::UnloadComponent(Kernel::HLERequestContext& ctx) {
system.DSP().UnloadComponent(); system.DSP().UnloadComponent();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_INFO(Service_DSP, "(STUBBED)"); LOG_INFO(Service_DSP, "(STUBBED)");
} }
@ -210,7 +210,7 @@ void DSP_DSP::FlushDataCache(Kernel::HLERequestContext& ctx) {
const auto process = rp.PopObject<Kernel::Process>(); const auto process = rp.PopObject<Kernel::Process>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_TRACE(Service_DSP, "called address=0x{:08X}, size=0x{:X}, process={}", address, size, LOG_TRACE(Service_DSP, "called address=0x{:08X}, size=0x{:X}, process={}", address, size,
process->process_id); process->process_id);
@ -223,7 +223,7 @@ void DSP_DSP::InvalidateDataCache(Kernel::HLERequestContext& ctx) {
const auto process = rp.PopObject<Kernel::Process>(); const auto process = rp.PopObject<Kernel::Process>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_TRACE(Service_DSP, "called address=0x{:08X}, size=0x{:X}, process={}", address, size, LOG_TRACE(Service_DSP, "called address=0x{:08X}, size=0x{:X}, process={}", address, size,
process->process_id); process->process_id);
@ -250,8 +250,8 @@ void DSP_DSP::RegisterInterruptEvents(Kernel::HLERequestContext& ctx) {
"Ran out of space to register interrupts (Attempted to register " "Ran out of space to register interrupts (Attempted to register "
"interrupt={}, channel={}, event={})", "interrupt={}, channel={}, event={})",
interrupt, channel, event->GetName()); interrupt, channel, event->GetName());
rb.Push(ResultCode(ErrorDescription::InvalidResultValue, ErrorModule::DSP, rb.Push(Result(ErrorDescription::InvalidResultValue, ErrorModule::DSP,
ErrorSummary::OutOfResource, ErrorLevel::Status)); ErrorSummary::OutOfResource, ErrorLevel::Status));
return; return;
} else { } else {
GetInterruptEvent(type, pipe) = event; GetInterruptEvent(type, pipe) = event;
@ -262,14 +262,14 @@ void DSP_DSP::RegisterInterruptEvents(Kernel::HLERequestContext& ctx) {
GetInterruptEvent(type, pipe) = nullptr; GetInterruptEvent(type, pipe) = nullptr;
LOG_INFO(Service_DSP, "Unregistered interrupt={}, channel={}", interrupt, channel); LOG_INFO(Service_DSP, "Unregistered interrupt={}, channel={}", interrupt, channel);
} }
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
} }
void DSP_DSP::GetSemaphoreEventHandle(Kernel::HLERequestContext& ctx) { void DSP_DSP::GetSemaphoreEventHandle(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx); IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushCopyObjects(semaphore_event); rb.PushCopyObjects(semaphore_event);
LOG_WARNING(Service_DSP, "(STUBBED) called"); LOG_WARNING(Service_DSP, "(STUBBED) called");
@ -280,7 +280,7 @@ void DSP_DSP::SetSemaphoreMask(Kernel::HLERequestContext& ctx) {
preset_semaphore = rp.Pop<u16>(); preset_semaphore = rp.Pop<u16>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_WARNING(Service_DSP, "(STUBBED) called mask=0x{:04X}", preset_semaphore); LOG_WARNING(Service_DSP, "(STUBBED) called mask=0x{:04X}", preset_semaphore);
} }
@ -289,7 +289,7 @@ void DSP_DSP::GetHeadphoneStatus(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx); IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push(false); /// u8, 0 = not inserted, 1 = inserted rb.Push(false); /// u8, 0 = not inserted, 1 = inserted
LOG_DEBUG(Service_DSP, "called"); LOG_DEBUG(Service_DSP, "called");
@ -300,7 +300,7 @@ void DSP_DSP::ForceHeadphoneOut(Kernel::HLERequestContext& ctx) {
const u8 force = rp.Pop<u8>(); const u8 force = rp.Pop<u8>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_DEBUG(Service_DSP, "(STUBBED) called, force={}", force); LOG_DEBUG(Service_DSP, "(STUBBED) called, force={}", force);
} }

View file

@ -155,7 +155,7 @@ static void LogGenericInfo(const ErrInfo::ErrInfoCommon& errinfo_common) {
errinfo_common.app_title_id_low); errinfo_common.app_title_id_low);
LOG_CRITICAL(Service_ERR, "ADR: 0x{:08X}", errinfo_common.pc_address); 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, "RSL: 0x{:08X}", result_code.raw);
LOG_CRITICAL(Service_ERR, " Level: {}", static_cast<u32>(result_code.level.Value())); LOG_CRITICAL(Service_ERR, " Level: {}", static_cast<u32>(result_code.level.Value()));
LOG_CRITICAL(Service_ERR, " Summary: {}", static_cast<u32>(result_code.summary.Value())); LOG_CRITICAL(Service_ERR, " Summary: {}", static_cast<u32>(result_code.summary.Value()));
@ -244,7 +244,7 @@ void ERR_F::ThrowFatalError(Kernel::HLERequestContext& ctx) {
} // switch FatalErrType } // switch FatalErrType
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
} }
ERR_F::ERR_F(Core::System& system) : ServiceFramework("err:f", 1), system(system) { ERR_F::ERR_F(Core::System& system) : ServiceFramework("err:f", 1), system(system) {

View file

@ -35,7 +35,7 @@ void Module::Interface::GetMyPresence(Kernel::HLERequestContext& ctx) {
std::memcpy(buffer.data(), &frd->my_presence, buffer.size()); std::memcpy(buffer.data(), &frd->my_presence, buffer.size());
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushStaticBuffer(std::move(buffer), 0); rb.PushStaticBuffer(std::move(buffer), 0);
LOG_WARNING(Service_FRD, "(STUBBED) called"); LOG_WARNING(Service_FRD, "(STUBBED) called");
@ -49,7 +49,7 @@ void Module::Interface::GetFriendKeyList(Kernel::HLERequestContext& ctx) {
std::vector<u8> buffer(sizeof(FriendKey) * frd_count, 0); std::vector<u8> buffer(sizeof(FriendKey) * frd_count, 0);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 2); IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push<u32>(0); // 0 friends rb.Push<u32>(0); // 0 friends
rb.PushStaticBuffer(std::move(buffer), 0); rb.PushStaticBuffer(std::move(buffer), 0);
@ -65,7 +65,7 @@ void Module::Interface::GetFriendProfile(Kernel::HLERequestContext& ctx) {
std::vector<u8> buffer(sizeof(Profile) * count, 0); std::vector<u8> buffer(sizeof(Profile) * count, 0);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushStaticBuffer(std::move(buffer), 0); rb.PushStaticBuffer(std::move(buffer), 0);
LOG_WARNING(Service_FRD, "(STUBBED) called, count={}", count); LOG_WARNING(Service_FRD, "(STUBBED) called, count={}", count);
@ -80,7 +80,7 @@ void Module::Interface::GetFriendAttributeFlags(Kernel::HLERequestContext& ctx)
// TODO:(mailwl) figure out AttributeFlag size and zero all buffer. Assume 1 byte // TODO:(mailwl) figure out AttributeFlag size and zero all buffer. Assume 1 byte
std::vector<u8> buffer(1 * count, 0); std::vector<u8> buffer(1 * count, 0);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushStaticBuffer(std::move(buffer), 0); rb.PushStaticBuffer(std::move(buffer), 0);
LOG_WARNING(Service_FRD, "(STUBBED) called, count={}", count); LOG_WARNING(Service_FRD, "(STUBBED) called, count={}", count);
@ -89,7 +89,7 @@ void Module::Interface::GetFriendAttributeFlags(Kernel::HLERequestContext& ctx)
void Module::Interface::GetMyFriendKey(Kernel::HLERequestContext& ctx) { void Module::Interface::GetMyFriendKey(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx); IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(5, 0); IPC::RequestBuilder rb = rp.MakeBuilder(5, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushRaw(frd->my_friend_key); rb.PushRaw(frd->my_friend_key);
LOG_WARNING(Service_FRD, "(STUBBED) called"); LOG_WARNING(Service_FRD, "(STUBBED) called");
@ -105,7 +105,7 @@ void Module::Interface::GetMyScreenName(Kernel::HLERequestContext& ctx) {
ScreenName screen_name{}; ScreenName screen_name{};
std::memcpy(screen_name.name.data(), username.data(), username.length() * sizeof(char16_t)); std::memcpy(screen_name.name.data(), username.data(), username.length() * sizeof(char16_t));
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushRaw(screen_name); rb.PushRaw(screen_name);
rb.Push(0); rb.Push(0);
@ -118,7 +118,7 @@ void Module::Interface::GetMyComment(Kernel::HLERequestContext& ctx) {
constexpr Comment comment{.name = {u'H', u'e', u'y', '!'}}; constexpr Comment comment{.name = {u'H', u'e', u'y', '!'}};
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushRaw<Comment>(comment); rb.PushRaw<Comment>(comment);
rb.Push(0); rb.Push(0);
@ -133,7 +133,7 @@ void Module::Interface::GetMyMii(Kernel::HLERequestContext& ctx) {
Mii::ChecksummedMiiData mii{}; Mii::ChecksummedMiiData mii{};
mii.SetMiiData(mii_data); mii.SetMiiData(mii_data);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushRaw<Mii::ChecksummedMiiData>(mii); rb.PushRaw<Mii::ChecksummedMiiData>(mii);
LOG_WARNING(Service_FRD, "(STUBBED) called"); LOG_WARNING(Service_FRD, "(STUBBED) called");
@ -145,7 +145,7 @@ void Module::Interface::GetMyProfile(Kernel::HLERequestContext& ctx) {
constexpr Profile profile{.region = 1, .country = 1, .area = 1, .language = 1, .platform = 1}; constexpr Profile profile{.region = 1, .country = 1, .area = 1, .language = 1, .platform = 1};
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushRaw<Profile>(profile); rb.PushRaw<Profile>(profile);
LOG_WARNING(Service_FRD, "(STUBBED) called"); LOG_WARNING(Service_FRD, "(STUBBED) called");
@ -157,7 +157,7 @@ void Module::Interface::GetMyFavoriteGame(Kernel::HLERequestContext& ctx) {
constexpr Game game{.title_id = 0x0004000E00030700, .version = 1}; constexpr Game game{.title_id = 0x0004000E00030700, .version = 1};
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushRaw<Game>(game); rb.PushRaw<Game>(game);
LOG_WARNING(Service_FRD, "(STUBBED) called"); LOG_WARNING(Service_FRD, "(STUBBED) called");
@ -169,7 +169,7 @@ void Module::Interface::GetMyPlayingGame(Kernel::HLERequestContext& ctx) {
constexpr Game game{.title_id = 0x0004000E00030700, .version = 1}; constexpr Game game{.title_id = 0x0004000E00030700, .version = 1};
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushRaw<Game>(game); rb.PushRaw<Game>(game);
LOG_WARNING(Service_FRD, "(STUBBED) called"); LOG_WARNING(Service_FRD, "(STUBBED) called");
@ -183,7 +183,7 @@ void Module::Interface::GetMyPreference(Kernel::HLERequestContext& ctx) {
constexpr u32 show_game = 1; constexpr u32 show_game = 1;
constexpr u32 show_history = 0; constexpr u32 show_history = 0;
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push<u32>(is_public); rb.Push<u32>(is_public);
rb.Push<u32>(show_game); rb.Push<u32>(show_game);
rb.Push<u32>(show_history); rb.Push<u32>(show_history);
@ -218,7 +218,7 @@ void Module::Interface::UnscrambleLocalFriendCode(Kernel::HLERequestContext& ctx
LOG_WARNING(Service_FRD, "(STUBBED) called"); LOG_WARNING(Service_FRD, "(STUBBED) called");
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushStaticBuffer(std::move(unscrambled_friend_codes), 0); rb.PushStaticBuffer(std::move(unscrambled_friend_codes), 0);
} }
@ -228,7 +228,7 @@ void Module::Interface::SetClientSdkVersion(Kernel::HLERequestContext& ctx) {
rp.PopPID(); rp.PopPID();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_WARNING(Service_FRD, "(STUBBED) called, version: 0x{:08X}", version); LOG_WARNING(Service_FRD, "(STUBBED) called, version: 0x{:08X}", version);
} }
@ -237,7 +237,7 @@ void Module::Interface::IsOnline(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx); IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push(frd->logged_in); rb.Push(frd->logged_in);
LOG_WARNING(Service_FRD, "(STUBBED) called"); LOG_WARNING(Service_FRD, "(STUBBED) called");
@ -248,7 +248,7 @@ void Module::Interface::HasLoggedIn(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx); IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push(frd->logged_in); rb.Push(frd->logged_in);
} }
@ -270,7 +270,7 @@ void Module::Interface::Login(Kernel::HLERequestContext& ctx) {
frd->system.CoreTiming().ScheduleEvent(msToCycles(login_delay_ms), frd->login_delay_event); frd->system.CoreTiming().ScheduleEvent(msToCycles(login_delay_ms), frd->login_delay_event);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
} }
void Module::Interface::GetLastResponseResult(Kernel::HLERequestContext& ctx) { void Module::Interface::GetLastResponseResult(Kernel::HLERequestContext& ctx) {
@ -278,7 +278,7 @@ void Module::Interface::GetLastResponseResult(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx); IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
} }
Module::Module(Core::System& system) : system(system){}; Module::Module(Core::System& system) : system(system){};

View file

@ -52,7 +52,7 @@ ResultVal<ArchiveHandle> ArchiveManager::OpenArchive(ArchiveIdCode id_code,
auto itr = id_code_map.find(id_code); auto itr = id_code_map.find(id_code);
if (itr == id_code_map.end()) { if (itr == id_code_map.end()) {
return FileSys::ERROR_NOT_FOUND; return FileSys::ResultNotFound;
} }
CASCADE_RESULT(std::unique_ptr<ArchiveBackend> res, CASCADE_RESULT(std::unique_ptr<ArchiveBackend> res,
@ -66,17 +66,17 @@ ResultVal<ArchiveHandle> ArchiveManager::OpenArchive(ArchiveIdCode id_code,
return next_handle++; return next_handle++;
} }
ResultCode ArchiveManager::CloseArchive(ArchiveHandle handle) { Result ArchiveManager::CloseArchive(ArchiveHandle handle) {
if (handle_map.erase(handle) == 0) if (handle_map.erase(handle) == 0)
return FileSys::ERR_INVALID_ARCHIVE_HANDLE; return FileSys::ResultInvalidArchiveHandle;
else else
return RESULT_SUCCESS; return ResultSuccess;
} }
// TODO(yuriks): This might be what the fs:REG service is for. See the Register/Unregister calls in // 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 // http://3dbrew.org/wiki/Filesystem_services#ProgramRegistry_service_.22fs:REG.22
ResultCode ArchiveManager::RegisterArchiveType(std::unique_ptr<FileSys::ArchiveFactory>&& factory, Result ArchiveManager::RegisterArchiveType(std::unique_ptr<FileSys::ArchiveFactory>&& factory,
ArchiveIdCode id_code) { ArchiveIdCode id_code) {
auto result = id_code_map.emplace(id_code, std::move(factory)); auto result = id_code_map.emplace(id_code, std::move(factory));
bool inserted = result.second; bool inserted = result.second;
@ -85,7 +85,7 @@ ResultCode ArchiveManager::RegisterArchiveType(std::unique_ptr<FileSys::ArchiveF
auto& archive = result.first->second; auto& archive = result.first->second;
LOG_DEBUG(Service_FS, "Registered archive {} with id code 0x{:08X}", archive->GetName(), LOG_DEBUG(Service_FS, "Registered archive {} with id code 0x{:08X}", archive->GetName(),
id_code); id_code);
return RESULT_SUCCESS; return ResultSuccess;
} }
std::pair<ResultVal<std::shared_ptr<File>>, std::chrono::nanoseconds> std::pair<ResultVal<std::shared_ptr<File>>, std::chrono::nanoseconds>
@ -93,7 +93,7 @@ ArchiveManager::OpenFileFromArchive(ArchiveHandle archive_handle, const FileSys:
const FileSys::Mode mode) { const FileSys::Mode mode) {
ArchiveBackend* archive = GetArchive(archive_handle); ArchiveBackend* archive = GetArchive(archive_handle);
if (archive == nullptr) { if (archive == nullptr) {
return std::make_pair(FileSys::ERR_INVALID_ARCHIVE_HANDLE, std::chrono::nanoseconds{0}); return std::make_pair(FileSys::ResultInvalidArchiveHandle, std::chrono::nanoseconds{0});
} }
const std::chrono::nanoseconds open_timeout_ns{archive->GetOpenDelayNs()}; const std::chrono::nanoseconds open_timeout_ns{archive->GetOpenDelayNs()};
@ -106,23 +106,23 @@ ArchiveManager::OpenFileFromArchive(ArchiveHandle archive_handle, const FileSys:
return std::make_pair(std::move(file), open_timeout_ns); return std::make_pair(std::move(file), open_timeout_ns);
} }
ResultCode ArchiveManager::DeleteFileFromArchive(ArchiveHandle archive_handle, Result ArchiveManager::DeleteFileFromArchive(ArchiveHandle archive_handle,
const FileSys::Path& path) { const FileSys::Path& path) {
ArchiveBackend* archive = GetArchive(archive_handle); ArchiveBackend* archive = GetArchive(archive_handle);
if (archive == nullptr) if (archive == nullptr)
return FileSys::ERR_INVALID_ARCHIVE_HANDLE; return FileSys::ResultInvalidArchiveHandle;
return archive->DeleteFile(path); return archive->DeleteFile(path);
} }
ResultCode ArchiveManager::RenameFileBetweenArchives(ArchiveHandle src_archive_handle, Result ArchiveManager::RenameFileBetweenArchives(ArchiveHandle src_archive_handle,
const FileSys::Path& src_path, const FileSys::Path& src_path,
ArchiveHandle dest_archive_handle, ArchiveHandle dest_archive_handle,
const FileSys::Path& dest_path) { const FileSys::Path& dest_path) {
ArchiveBackend* src_archive = GetArchive(src_archive_handle); ArchiveBackend* src_archive = GetArchive(src_archive_handle);
ArchiveBackend* dest_archive = GetArchive(dest_archive_handle); ArchiveBackend* dest_archive = GetArchive(dest_archive_handle);
if (src_archive == nullptr || dest_archive == nullptr) if (src_archive == nullptr || dest_archive == nullptr)
return FileSys::ERR_INVALID_ARCHIVE_HANDLE; return FileSys::ResultInvalidArchiveHandle;
if (src_archive == dest_archive) { if (src_archive == dest_archive) {
return src_archive->RenameFile(src_path, dest_path); return src_archive->RenameFile(src_path, dest_path);
@ -132,50 +132,50 @@ ResultCode ArchiveManager::RenameFileBetweenArchives(ArchiveHandle src_archive_h
} }
} }
ResultCode ArchiveManager::DeleteDirectoryFromArchive(ArchiveHandle archive_handle, Result ArchiveManager::DeleteDirectoryFromArchive(ArchiveHandle archive_handle,
const FileSys::Path& path) { const FileSys::Path& path) {
ArchiveBackend* archive = GetArchive(archive_handle); ArchiveBackend* archive = GetArchive(archive_handle);
if (archive == nullptr) if (archive == nullptr)
return FileSys::ERR_INVALID_ARCHIVE_HANDLE; return FileSys::ResultInvalidArchiveHandle;
return archive->DeleteDirectory(path); return archive->DeleteDirectory(path);
} }
ResultCode ArchiveManager::DeleteDirectoryRecursivelyFromArchive(ArchiveHandle archive_handle, Result ArchiveManager::DeleteDirectoryRecursivelyFromArchive(ArchiveHandle archive_handle,
const FileSys::Path& path) { const FileSys::Path& path) {
ArchiveBackend* archive = GetArchive(archive_handle); ArchiveBackend* archive = GetArchive(archive_handle);
if (archive == nullptr) if (archive == nullptr)
return FileSys::ERR_INVALID_ARCHIVE_HANDLE; return FileSys::ResultInvalidArchiveHandle;
return archive->DeleteDirectoryRecursively(path); return archive->DeleteDirectoryRecursively(path);
} }
ResultCode ArchiveManager::CreateFileInArchive(ArchiveHandle archive_handle, Result ArchiveManager::CreateFileInArchive(ArchiveHandle archive_handle, const FileSys::Path& path,
const FileSys::Path& path, u64 file_size) { u64 file_size) {
ArchiveBackend* archive = GetArchive(archive_handle); ArchiveBackend* archive = GetArchive(archive_handle);
if (archive == nullptr) if (archive == nullptr)
return FileSys::ERR_INVALID_ARCHIVE_HANDLE; return FileSys::ResultInvalidArchiveHandle;
return archive->CreateFile(path, file_size); return archive->CreateFile(path, file_size);
} }
ResultCode ArchiveManager::CreateDirectoryFromArchive(ArchiveHandle archive_handle, Result ArchiveManager::CreateDirectoryFromArchive(ArchiveHandle archive_handle,
const FileSys::Path& path) { const FileSys::Path& path) {
ArchiveBackend* archive = GetArchive(archive_handle); ArchiveBackend* archive = GetArchive(archive_handle);
if (archive == nullptr) if (archive == nullptr)
return FileSys::ERR_INVALID_ARCHIVE_HANDLE; return FileSys::ResultInvalidArchiveHandle;
return archive->CreateDirectory(path); return archive->CreateDirectory(path);
} }
ResultCode ArchiveManager::RenameDirectoryBetweenArchives(ArchiveHandle src_archive_handle, Result ArchiveManager::RenameDirectoryBetweenArchives(ArchiveHandle src_archive_handle,
const FileSys::Path& src_path, const FileSys::Path& src_path,
ArchiveHandle dest_archive_handle, ArchiveHandle dest_archive_handle,
const FileSys::Path& dest_path) { const FileSys::Path& dest_path) {
ArchiveBackend* src_archive = GetArchive(src_archive_handle); ArchiveBackend* src_archive = GetArchive(src_archive_handle);
ArchiveBackend* dest_archive = GetArchive(dest_archive_handle); ArchiveBackend* dest_archive = GetArchive(dest_archive_handle);
if (src_archive == nullptr || dest_archive == nullptr) if (src_archive == nullptr || dest_archive == nullptr)
return FileSys::ERR_INVALID_ARCHIVE_HANDLE; return FileSys::ResultInvalidArchiveHandle;
if (src_archive == dest_archive) { if (src_archive == dest_archive) {
return src_archive->RenameDirectory(src_path, dest_path); return src_archive->RenameDirectory(src_path, dest_path);
@ -189,7 +189,7 @@ ResultVal<std::shared_ptr<Directory>> ArchiveManager::OpenDirectoryFromArchive(
ArchiveHandle archive_handle, const FileSys::Path& path) { ArchiveHandle archive_handle, const FileSys::Path& path) {
ArchiveBackend* archive = GetArchive(archive_handle); ArchiveBackend* archive = GetArchive(archive_handle);
if (archive == nullptr) { if (archive == nullptr) {
return FileSys::ERR_INVALID_ARCHIVE_HANDLE; return FileSys::ResultInvalidArchiveHandle;
} }
auto backend = archive->OpenDirectory(path); auto backend = archive->OpenDirectory(path);
@ -203,14 +203,14 @@ ResultVal<std::shared_ptr<Directory>> ArchiveManager::OpenDirectoryFromArchive(
ResultVal<u64> ArchiveManager::GetFreeBytesInArchive(ArchiveHandle archive_handle) { ResultVal<u64> ArchiveManager::GetFreeBytesInArchive(ArchiveHandle archive_handle) {
const ArchiveBackend* archive = GetArchive(archive_handle); const ArchiveBackend* archive = GetArchive(archive_handle);
if (archive == nullptr) { if (archive == nullptr) {
return FileSys::ERR_INVALID_ARCHIVE_HANDLE; return FileSys::ResultInvalidArchiveHandle;
} }
return archive->GetFreeBytes(); return archive->GetFreeBytes();
} }
ResultCode ArchiveManager::FormatArchive(ArchiveIdCode id_code, Result ArchiveManager::FormatArchive(ArchiveIdCode id_code,
const FileSys::ArchiveFormatInfo& format_info, const FileSys::ArchiveFormatInfo& format_info,
const FileSys::Path& path, u64 program_id) { const FileSys::Path& path, u64 program_id) {
auto archive_itr = id_code_map.find(id_code); auto archive_itr = id_code_map.find(id_code);
if (archive_itr == id_code_map.end()) { if (archive_itr == id_code_map.end()) {
return UnimplementedFunction(ErrorModule::FS); // TODO(Subv): Find the right error return UnimplementedFunction(ErrorModule::FS); // TODO(Subv): Find the right error
@ -229,10 +229,10 @@ ResultVal<FileSys::ArchiveFormatInfo> ArchiveManager::GetArchiveFormatInfo(
return archive->second->GetFormatInfo(archive_path, program_id); return archive->second->GetFormatInfo(archive_path, program_id);
} }
ResultCode ArchiveManager::CreateExtSaveData(MediaType media_type, u32 high, u32 low, Result ArchiveManager::CreateExtSaveData(MediaType media_type, u32 high, u32 low,
std::span<const u8> smdh_icon, std::span<const u8> smdh_icon,
const FileSys::ArchiveFormatInfo& format_info, const FileSys::ArchiveFormatInfo& format_info,
u64 program_id) { u64 program_id) {
// Construct the binary path to the archive first // Construct the binary path to the archive first
FileSys::Path path = FileSys::Path path =
FileSys::ConstructExtDataBinaryPath(static_cast<u32>(media_type), high, low); FileSys::ConstructExtDataBinaryPath(static_cast<u32>(media_type), high, low);
@ -246,16 +246,16 @@ ResultCode ArchiveManager::CreateExtSaveData(MediaType media_type, u32 high, u32
auto ext_savedata = static_cast<FileSys::ArchiveFactory_ExtSaveData*>(archive->second.get()); auto ext_savedata = static_cast<FileSys::ArchiveFactory_ExtSaveData*>(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()) { if (result.IsError()) {
return result; return result;
} }
ext_savedata->WriteIcon(path, smdh_icon); ext_savedata->WriteIcon(path, smdh_icon);
return RESULT_SUCCESS; return ResultSuccess;
} }
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 // Construct the binary path to the archive first
FileSys::Path path = FileSys::Path path =
FileSys::ConstructExtDataBinaryPath(static_cast<u32>(media_type), high, low); FileSys::ConstructExtDataBinaryPath(static_cast<u32>(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); media_type_directory = FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir);
} else { } else {
LOG_ERROR(Service_FS, "Unsupported media type {}", media_type); LOG_ERROR(Service_FS, "Unsupported media type {}", media_type);
return ResultCode(-1); // TODO(Subv): Find the right error code return ResultUnknown; // TODO(Subv): Find the right error code
} }
// Delete all directories (/user, /boss) and the icon file. // 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); FileSys::GetExtDataContainerPath(media_type_directory, media_type == MediaType::NAND);
std::string extsavedata_path = FileSys::GetExtSaveDataPath(base_path, path); std::string extsavedata_path = FileSys::GetExtSaveDataPath(base_path, path);
if (FileUtil::Exists(extsavedata_path) && !FileUtil::DeleteDirRecursively(extsavedata_path)) if (FileUtil::Exists(extsavedata_path) && !FileUtil::DeleteDirRecursively(extsavedata_path))
return ResultCode(-1); // TODO(Subv): Find the right error code return ResultUnknown; // TODO(Subv): Find the right error code
return RESULT_SUCCESS; return ResultSuccess;
} }
ResultCode ArchiveManager::DeleteSystemSaveData(u32 high, u32 low) { Result ArchiveManager::DeleteSystemSaveData(u32 high, u32 low) {
// Construct the binary path to the archive first // Construct the binary path to the archive first
const FileSys::Path path = FileSys::ConstructSystemSaveDataBinaryPath(high, low); 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 base_path = FileSys::GetSystemSaveDataContainerPath(nand_directory);
const std::string systemsavedata_path = FileSys::GetSystemSaveDataPath(base_path, path); const std::string systemsavedata_path = FileSys::GetSystemSaveDataPath(base_path, path);
if (!FileUtil::DeleteDirRecursively(systemsavedata_path)) { if (!FileUtil::DeleteDirRecursively(systemsavedata_path)) {
return ResultCode(-1); // TODO(Subv): Find the right error code return ResultUnknown; // TODO(Subv): Find the right error code
} }
return RESULT_SUCCESS; return ResultSuccess;
} }
ResultCode ArchiveManager::CreateSystemSaveData(u32 high, u32 low) { Result ArchiveManager::CreateSystemSaveData(u32 high, u32 low) {
// Construct the binary path to the archive first // Construct the binary path to the archive first
const FileSys::Path path = FileSys::ConstructSystemSaveDataBinaryPath(high, low); const FileSys::Path path = FileSys::ConstructSystemSaveDataBinaryPath(high, low);
@ -301,10 +301,10 @@ ResultCode ArchiveManager::CreateSystemSaveData(u32 high, u32 low) {
const std::string base_path = FileSys::GetSystemSaveDataContainerPath(nand_directory); const std::string base_path = FileSys::GetSystemSaveDataContainerPath(nand_directory);
const std::string systemsavedata_path = FileSys::GetSystemSaveDataPath(base_path, path); const std::string systemsavedata_path = FileSys::GetSystemSaveDataPath(base_path, path);
if (!FileUtil::CreateFullPath(systemsavedata_path)) { if (!FileUtil::CreateFullPath(systemsavedata_path)) {
return ResultCode(-1); // TODO(Subv): Find the right error code return ResultUnknown; // TODO(Subv): Find the right error code
} }
return RESULT_SUCCESS; return ResultSuccess;
} }
ResultVal<ArchiveResource> ArchiveManager::GetArchiveResource(MediaType media_type) const { ResultVal<ArchiveResource> ArchiveManager::GetArchiveResource(MediaType media_type) const {

View file

@ -88,7 +88,7 @@ public:
* Closes an archive * Closes an archive
* @param handle Handle to the archive to close * @param handle Handle to the archive to close
*/ */
ResultCode CloseArchive(ArchiveHandle handle); Result CloseArchive(ArchiveHandle handle);
/** /**
* Open a File from an Archive * Open a File from an Archive
@ -106,7 +106,7 @@ public:
* @param path Path to the File inside of the Archive * @param path Path to the File inside of the Archive
* @return Whether deletion succeeded * @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 * Rename a File between two Archives
@ -116,10 +116,10 @@ public:
* @param dest_path Path to the File inside of the destination Archive * @param dest_path Path to the File inside of the destination Archive
* @return Whether rename succeeded * @return Whether rename succeeded
*/ */
ResultCode RenameFileBetweenArchives(ArchiveHandle src_archive_handle, Result RenameFileBetweenArchives(ArchiveHandle src_archive_handle,
const FileSys::Path& src_path, const FileSys::Path& src_path,
ArchiveHandle dest_archive_handle, ArchiveHandle dest_archive_handle,
const FileSys::Path& dest_path); const FileSys::Path& dest_path);
/** /**
* Delete a Directory from an Archive * Delete a Directory from an Archive
@ -127,7 +127,7 @@ public:
* @param path Path to the Directory inside of the Archive * @param path Path to the Directory inside of the Archive
* @return Whether deletion succeeded * @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 * 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 * @param path Path to the Directory inside of the Archive
* @return Whether deletion succeeded * @return Whether deletion succeeded
*/ */
ResultCode DeleteDirectoryRecursivelyFromArchive(ArchiveHandle archive_handle, Result DeleteDirectoryRecursivelyFromArchive(ArchiveHandle archive_handle,
const FileSys::Path& path); const FileSys::Path& path);
/** /**
* Create a File in an Archive * Create a File in an Archive
@ -145,8 +145,8 @@ public:
* @param file_size The size of the new file, filled with zeroes * @param file_size The size of the new file, filled with zeroes
* @return File creation result code * @return File creation result code
*/ */
ResultCode CreateFileInArchive(ArchiveHandle archive_handle, const FileSys::Path& path, Result CreateFileInArchive(ArchiveHandle archive_handle, const FileSys::Path& path,
u64 file_size); u64 file_size);
/** /**
* Create a Directory from an Archive * Create a Directory from an Archive
@ -154,7 +154,7 @@ public:
* @param path Path to the Directory inside of the Archive * @param path Path to the Directory inside of the Archive
* @return Whether creation of directory succeeded * @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 * Rename a Directory between two Archives
@ -164,10 +164,10 @@ public:
* @param dest_path Path to the Directory inside of the destination Archive * @param dest_path Path to the Directory inside of the destination Archive
* @return Whether rename succeeded * @return Whether rename succeeded
*/ */
ResultCode RenameDirectoryBetweenArchives(ArchiveHandle src_archive_handle, Result RenameDirectoryBetweenArchives(ArchiveHandle src_archive_handle,
const FileSys::Path& src_path, const FileSys::Path& src_path,
ArchiveHandle dest_archive_handle, ArchiveHandle dest_archive_handle,
const FileSys::Path& dest_path); const FileSys::Path& dest_path);
/** /**
* Open a Directory from an Archive * Open a Directory from an Archive
@ -192,10 +192,10 @@ public:
* @param format_info Format information about the new archive * @param format_info Format information about the new archive
* @param path The path to the archive, if relevant. * @param path The path to the archive, if relevant.
* @param program_id the program ID of the client that requests the operation * @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, Result FormatArchive(ArchiveIdCode id_code, const FileSys::ArchiveFormatInfo& format_info,
const FileSys::Path& path, u64 program_id); const FileSys::Path& path, u64 program_id);
/** /**
* Retrieves the format info about the archive of the specified type and path. * 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 smdh_icon the SMDH icon for this ExtSaveData
* @param format_info Format information about the new archive * @param format_info Format information about the new archive
* @param program_id the program ID of the client that requests the operation * @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, Result CreateExtSaveData(MediaType media_type, u32 high, u32 low, std::span<const u8> smdh_icon,
std::span<const u8> smdh_icon, const FileSys::ArchiveFormatInfo& format_info, u64 program_id);
const FileSys::ArchiveFormatInfo& format_info, u64 program_id);
/** /**
* Deletes the SharedExtSaveData archive for the specified extdata ID * Deletes the SharedExtSaveData archive for the specified extdata ID
* @param media_type The media type of the archive to delete (NAND / SDMC) * @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 high The high word of the extdata id to delete
* @param low The low 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 * Deletes the SystemSaveData archive folder for the specified save data id
* @param high The high word of the SystemSaveData archive to delete * @param high The high word of the SystemSaveData archive to delete
* @param low The low 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 * Creates the SystemSaveData archive folder for the specified save data id
* @param high The high word of the SystemSaveData archive to create * @param high The high word of the SystemSaveData archive to create
* @param low The low 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. * 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 factory File system backend interface to the archive
* @param id_code Id code used to access this type of archive * @param id_code Id code used to access this type of archive
*/ */
ResultCode RegisterArchiveType(std::unique_ptr<FileSys::ArchiveFactory>&& factory, Result RegisterArchiveType(std::unique_ptr<FileSys::ArchiveFactory>&& factory,
ArchiveIdCode id_code); ArchiveIdCode id_code);
/// Register all archive types /// Register all archive types
void RegisterArchiveTypes(); void RegisterArchiveTypes();

View file

@ -51,7 +51,7 @@ void Directory::Read(Kernel::HLERequestContext& ctx) {
buffer.Write(entries.data(), 0, read * sizeof(FileSys::Entry)); buffer.Write(entries.data(), 0, read * sizeof(FileSys::Entry));
IPC::RequestBuilder rb = rp.MakeBuilder(2, 2); IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push(read); rb.Push(read);
rb.PushMappedBuffer(buffer); rb.PushMappedBuffer(buffer);
} }
@ -62,7 +62,7 @@ void Directory::Close(Kernel::HLERequestContext& ctx) {
backend->Close(); backend->Close();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
} }
} // namespace Service::FS } // namespace Service::FS

View file

@ -86,7 +86,7 @@ void File::Read(Kernel::HLERequestContext& ctx) {
rb.Push<u32>(0); rb.Push<u32>(0);
} else { } else {
buffer.Write(*data, 0, *read); buffer.Write(*data, 0, *read);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push<u32>(static_cast<u32>(*read)); rb.Push<u32>(static_cast<u32>(*read));
} }
rb.PushMappedBuffer(buffer); rb.PushMappedBuffer(buffer);
@ -104,7 +104,7 @@ void File::Read(Kernel::HLERequestContext& ctx) {
bool cache_ready; bool cache_ready;
// Output // Output
ResultCode ret{0}; Result ret{0};
Kernel::MappedBuffer* buffer; Kernel::MappedBuffer* buffer;
std::unique_ptr<u8*> data; std::unique_ptr<u8*> data;
size_t read_size; size_t read_size;
@ -130,7 +130,7 @@ void File::Read(Kernel::HLERequestContext& ctx) {
async_data->ret = read.Code(); async_data->ret = read.Code();
async_data->read_size = 0; async_data->read_size = 0;
} else { } else {
async_data->ret = RESULT_SUCCESS; async_data->ret = ResultSuccess;
async_data->read_size = *read; async_data->read_size = *read;
} }
@ -157,7 +157,7 @@ void File::Read(Kernel::HLERequestContext& ctx) {
rb.Push<u32>(0); rb.Push<u32>(0);
} else { } else {
async_data->buffer->Write(*async_data->data, 0, async_data->read_size); async_data->buffer->Write(*async_data->data, 0, async_data->read_size);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push<u32>(static_cast<u32>(async_data->read_size)); rb.Push<u32>(static_cast<u32>(async_data->read_size));
} }
rb.PushMappedBuffer(*async_data->buffer); rb.PushMappedBuffer(*async_data->buffer);
@ -180,7 +180,7 @@ void File::Write(Kernel::HLERequestContext& ctx) {
// Subfiles can not be written to // Subfiles can not be written to
if (file->subfile) { if (file->subfile) {
rb.Push(FileSys::ERROR_UNSUPPORTED_OPEN_FLAGS); rb.Push(FileSys::ResultUnsupportedOpenFlags);
rb.Push<u32>(0); rb.Push<u32>(0);
rb.PushMappedBuffer(buffer); rb.PushMappedBuffer(buffer);
return; return;
@ -197,7 +197,7 @@ void File::Write(Kernel::HLERequestContext& ctx) {
rb.Push(written.Code()); rb.Push(written.Code());
rb.Push<u32>(0); rb.Push<u32>(0);
} else { } else {
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push<u32>(static_cast<u32>(*written)); rb.Push<u32>(static_cast<u32>(*written));
} }
rb.PushMappedBuffer(buffer); rb.PushMappedBuffer(buffer);
@ -209,7 +209,7 @@ void File::GetSize(Kernel::HLERequestContext& ctx) {
const FileSessionSlot* file = GetSessionData(ctx.Session()); const FileSessionSlot* file = GetSessionData(ctx.Session());
IPC::RequestBuilder rb = rp.MakeBuilder(3, 0); IPC::RequestBuilder rb = rp.MakeBuilder(3, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push<u64>(file->size); rb.Push<u64>(file->size);
} }
@ -223,13 +223,13 @@ void File::SetSize(Kernel::HLERequestContext& ctx) {
// SetSize can not be called on subfiles. // SetSize can not be called on subfiles.
if (file->subfile) { if (file->subfile) {
rb.Push(FileSys::ERROR_UNSUPPORTED_OPEN_FLAGS); rb.Push(FileSys::ResultUnsupportedOpenFlags);
return; return;
} }
file->size = size; file->size = size;
backend->SetSize(size); backend->SetSize(size);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
} }
void File::Close(Kernel::HLERequestContext& ctx) { void File::Close(Kernel::HLERequestContext& ctx) {
@ -242,7 +242,7 @@ void File::Close(Kernel::HLERequestContext& ctx) {
backend->Close(); backend->Close();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
} }
void File::Flush(Kernel::HLERequestContext& ctx) { void File::Flush(Kernel::HLERequestContext& ctx) {
@ -254,12 +254,12 @@ void File::Flush(Kernel::HLERequestContext& ctx) {
// Subfiles can not be flushed. // Subfiles can not be flushed.
if (file->subfile) { if (file->subfile) {
rb.Push(FileSys::ERROR_UNSUPPORTED_OPEN_FLAGS); rb.Push(FileSys::ResultUnsupportedOpenFlags);
return; return;
} }
backend->Flush(); backend->Flush();
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
} }
void File::SetPriority(Kernel::HLERequestContext& ctx) { void File::SetPriority(Kernel::HLERequestContext& ctx) {
@ -269,7 +269,7 @@ void File::SetPriority(Kernel::HLERequestContext& ctx) {
file->priority = rp.Pop<u32>(); file->priority = rp.Pop<u32>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
} }
void File::GetPriority(Kernel::HLERequestContext& ctx) { void File::GetPriority(Kernel::HLERequestContext& ctx) {
@ -277,7 +277,7 @@ void File::GetPriority(Kernel::HLERequestContext& ctx) {
const FileSessionSlot* file = GetSessionData(ctx.Session()); const FileSessionSlot* file = GetSessionData(ctx.Session());
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push(file->priority); rb.Push(file->priority);
} }
@ -298,7 +298,7 @@ void File::OpenLinkFile(Kernel::HLERequestContext& ctx) {
slot->size = backend->GetSize(); slot->size = backend->GetSize();
slot->subfile = false; slot->subfile = false;
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushMoveObjects(client); rb.PushMoveObjects(client);
} }
@ -313,21 +313,21 @@ void File::OpenSubFile(Kernel::HLERequestContext& ctx) {
if (original_file->subfile) { if (original_file->subfile) {
// OpenSubFile can not be called on a file which is already as subfile // OpenSubFile can not be called on a file which is already as subfile
rb.Push(FileSys::ERROR_UNSUPPORTED_OPEN_FLAGS); rb.Push(FileSys::ResultUnsupportedOpenFlags);
return; return;
} }
if (offset < 0 || size < 0) { if (offset < 0 || size < 0) {
rb.Push(FileSys::ERR_WRITE_BEYOND_END); rb.Push(FileSys::ResultWriteBeyondEnd);
return; return;
} }
std::size_t end = offset + size; std::size_t end = offset + size;
// TODO(Subv): Check for overflow and return ERR_WRITE_BEYOND_END // TODO(Subv): Check for overflow and return ResultWriteBeyondEnd
if (end > original_file->size) { if (end > original_file->size) {
rb.Push(FileSys::ERR_WRITE_BEYOND_END); rb.Push(FileSys::ResultWriteBeyondEnd);
return; return;
} }
@ -342,7 +342,7 @@ void File::OpenSubFile(Kernel::HLERequestContext& ctx) {
slot->size = size; slot->size = size;
slot->subfile = true; slot->subfile = true;
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushMoveObjects(client); rb.PushMoveObjects(client);
} }

View file

@ -43,7 +43,7 @@ void FS_USER::Initialize(Kernel::HLERequestContext& ctx) {
slot->program_id = system.Kernel().GetProcessById(pid)->codeset->program_id; slot->program_id = system.Kernel().GetProcessById(pid)->codeset->program_id;
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
} }
void FS_USER::OpenFile(Kernel::HLERequestContext& ctx) { void FS_USER::OpenFile(Kernel::HLERequestContext& ctx) {
@ -349,7 +349,7 @@ void FS_USER::ControlArchive(Kernel::HLERequestContext& ctx) {
archive_handle, action, input_size, output_size); archive_handle, action, input_size, output_size);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
} }
void FS_USER::CloseArchive(Kernel::HLERequestContext& ctx) { void FS_USER::CloseArchive(Kernel::HLERequestContext& ctx) {
@ -363,14 +363,14 @@ void FS_USER::CloseArchive(Kernel::HLERequestContext& ctx) {
void FS_USER::IsSdmcDetected(Kernel::HLERequestContext& ctx) { void FS_USER::IsSdmcDetected(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx); IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push(Settings::values.use_virtual_sd.GetValue()); rb.Push(Settings::values.use_virtual_sd.GetValue());
} }
void FS_USER::IsSdmcWriteable(Kernel::HLERequestContext& ctx) { void FS_USER::IsSdmcWriteable(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx); IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
// If the SD isn't enabled, it can't be writeable...else, stubbed true // If the SD isn't enabled, it can't be writeable...else, stubbed true
rb.Push(Settings::values.use_virtual_sd.GetValue()); rb.Push(Settings::values.use_virtual_sd.GetValue());
LOG_DEBUG(Service_FS, " (STUBBED)"); LOG_DEBUG(Service_FS, " (STUBBED)");
@ -398,7 +398,7 @@ void FS_USER::FormatSaveData(Kernel::HLERequestContext& ctx) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
if (archive_id != FS::ArchiveIdCode::SaveData) { if (archive_id != FS::ArchiveIdCode::SaveData) {
LOG_ERROR(Service_FS, "tried to format an archive different than SaveData, {}", archive_id); LOG_ERROR(Service_FS, "tried to format an archive different than SaveData, {}", archive_id);
rb.Push(FileSys::ERROR_INVALID_PATH); rb.Push(FileSys::ResultInvalidPath);
return; return;
} }
@ -471,7 +471,7 @@ void FS_USER::GetSdmcArchiveResource(Kernel::HLERequestContext& ctx) {
} }
IPC::RequestBuilder rb = rp.MakeBuilder(5, 0); IPC::RequestBuilder rb = rp.MakeBuilder(5, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushRaw(*resource); rb.PushRaw(*resource);
} }
@ -488,7 +488,7 @@ void FS_USER::GetNandArchiveResource(Kernel::HLERequestContext& ctx) {
} }
IPC::RequestBuilder rb = rp.MakeBuilder(5, 0); IPC::RequestBuilder rb = rp.MakeBuilder(5, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushRaw(*resource); rb.PushRaw(*resource);
} }
@ -544,7 +544,7 @@ void FS_USER::DeleteExtSaveData(Kernel::HLERequestContext& ctx) {
void FS_USER::CardSlotIsInserted(Kernel::HLERequestContext& ctx) { void FS_USER::CardSlotIsInserted(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx); IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push(false); rb.Push(false);
LOG_WARNING(Service_FS, "(STUBBED) called"); LOG_WARNING(Service_FS, "(STUBBED) called");
} }
@ -614,7 +614,7 @@ void FS_USER::InitializeWithSdkVersion(Kernel::HLERequestContext& ctx) {
LOG_WARNING(Service_FS, "(STUBBED) called, version: 0x{:08X}", version); LOG_WARNING(Service_FS, "(STUBBED) called, version: 0x{:08X}", version);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
} }
void FS_USER::SetPriority(Kernel::HLERequestContext& ctx) { void FS_USER::SetPriority(Kernel::HLERequestContext& ctx) {
@ -623,7 +623,7 @@ void FS_USER::SetPriority(Kernel::HLERequestContext& ctx) {
priority = rp.Pop<u32>(); priority = rp.Pop<u32>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
LOG_DEBUG(Service_FS, "called priority=0x{:X}", priority); LOG_DEBUG(Service_FS, "called priority=0x{:X}", priority);
} }
@ -636,7 +636,7 @@ void FS_USER::GetPriority(Kernel::HLERequestContext& ctx) {
} }
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push(priority); rb.Push(priority);
LOG_DEBUG(Service_FS, "called priority=0x{:X}", priority); LOG_DEBUG(Service_FS, "called priority=0x{:X}", priority);
@ -656,7 +656,7 @@ void FS_USER::GetArchiveResource(Kernel::HLERequestContext& ctx) {
} }
IPC::RequestBuilder rb = rp.MakeBuilder(5, 0); IPC::RequestBuilder rb = rp.MakeBuilder(5, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushRaw(*resource); rb.PushRaw(*resource);
} }
@ -699,12 +699,12 @@ void FS_USER::GetProductInfo(Kernel::HLERequestContext& ctx) {
const auto product_info = GetProductInfo(process_id); const auto product_info = GetProductInfo(process_id);
if (!product_info.has_value()) { if (!product_info.has_value()) {
rb.Push(ResultCode(FileSys::ErrCodes::ArchiveNotMounted, ErrorModule::FS, rb.Push(Result(FileSys::ErrCodes::ArchiveNotMounted, ErrorModule::FS,
ErrorSummary::NotFound, ErrorLevel::Status)); ErrorSummary::NotFound, ErrorLevel::Status));
return; return;
} }
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushRaw<ProductInfo>(product_info.value()); rb.PushRaw<ProductInfo>(product_info.value());
} }
@ -737,7 +737,7 @@ void FS_USER::GetProgramLaunchInfo(Kernel::HLERequestContext& ctx) {
program_info.media_type = MediaType::SDMC; program_info.media_type = MediaType::SDMC;
} }
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.PushRaw<ProgramInfo>(program_info); rb.PushRaw<ProgramInfo>(program_info);
} }
@ -801,7 +801,7 @@ void FS_USER::GetSpecialContentIndex(Kernel::HLERequestContext& ctx) {
if (index.Succeeded()) { if (index.Succeeded()) {
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push(index.Unwrap()); rb.Push(index.Unwrap());
} else { } else {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
@ -812,7 +812,7 @@ void FS_USER::GetSpecialContentIndex(Kernel::HLERequestContext& ctx) {
void FS_USER::GetNumSeeds(Kernel::HLERequestContext& ctx) { void FS_USER::GetNumSeeds(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx); IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
rb.Push<u32>(FileSys::GetSeedCount()); rb.Push<u32>(FileSys::GetSeedCount());
} }
@ -822,7 +822,7 @@ void FS_USER::AddSeed(Kernel::HLERequestContext& ctx) {
FileSys::Seed::Data seed{rp.PopRaw<FileSys::Seed::Data>()}; FileSys::Seed::Data seed{rp.PopRaw<FileSys::Seed::Data>()};
FileSys::AddSeed({title_id, seed, {}}); FileSys::AddSeed({title_id, seed, {}});
IPC::RequestBuilder rb{rp.MakeBuilder(1, 0)}; IPC::RequestBuilder rb{rp.MakeBuilder(1, 0)};
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
} }
void FS_USER::ObsoletedSetSaveDataSecureValue(Kernel::HLERequestContext& ctx) { void FS_USER::ObsoletedSetSaveDataSecureValue(Kernel::HLERequestContext& ctx) {
@ -841,7 +841,7 @@ void FS_USER::ObsoletedSetSaveDataSecureValue(Kernel::HLERequestContext& ctx) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
} }
void FS_USER::ObsoletedGetSaveDataSecureValue(Kernel::HLERequestContext& ctx) { void FS_USER::ObsoletedGetSaveDataSecureValue(Kernel::HLERequestContext& ctx) {
@ -857,7 +857,7 @@ void FS_USER::ObsoletedGetSaveDataSecureValue(Kernel::HLERequestContext& ctx) {
IPC::RequestBuilder rb = rp.MakeBuilder(4, 0); IPC::RequestBuilder rb = rp.MakeBuilder(4, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
// TODO: Implement Secure Value Lookup & Generation // TODO: Implement Secure Value Lookup & Generation
@ -877,7 +877,7 @@ void FS_USER::SetThisSaveDataSecureValue(Kernel::HLERequestContext& ctx) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
} }
void FS_USER::GetThisSaveDataSecureValue(Kernel::HLERequestContext& ctx) { void FS_USER::GetThisSaveDataSecureValue(Kernel::HLERequestContext& ctx) {
@ -888,7 +888,7 @@ void FS_USER::GetThisSaveDataSecureValue(Kernel::HLERequestContext& ctx) {
IPC::RequestBuilder rb = rp.MakeBuilder(5, 0); IPC::RequestBuilder rb = rp.MakeBuilder(5, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
// TODO: Implement Secure Value Lookup & Generation // TODO: Implement Secure Value Lookup & Generation
@ -913,7 +913,7 @@ void FS_USER::SetSaveDataSecureValue(Kernel::HLERequestContext& ctx) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
} }
void FS_USER::GetSaveDataSecureValue(Kernel::HLERequestContext& ctx) { void FS_USER::GetSaveDataSecureValue(Kernel::HLERequestContext& ctx) {
@ -926,7 +926,7 @@ void FS_USER::GetSaveDataSecureValue(Kernel::HLERequestContext& ctx) {
IPC::RequestBuilder rb = rp.MakeBuilder(5, 0); IPC::RequestBuilder rb = rp.MakeBuilder(5, 0);
rb.Push(RESULT_SUCCESS); rb.Push(ResultSuccess);
// TODO: Implement Secure Value Lookup & Generation // TODO: Implement Secure Value Lookup & Generation
@ -966,7 +966,7 @@ ResultVal<u16> FS_USER::GetSpecialContentIndexFromGameCard(u64 title_id, Special
if (type > SpecialContentType::DLPChild) { if (type > SpecialContentType::DLPChild) {
// Maybe type 4 is New 3DS update/partition 6 but this needs more research // Maybe type 4 is New 3DS update/partition 6 but this needs more research
// TODO(B3N30): Find correct result code // TODO(B3N30): Find correct result code
return ResultCode(-1); return ResultUnknown;
} }
switch (type) { switch (type) {
@ -985,7 +985,7 @@ ResultVal<u16> FS_USER::GetSpecialContentIndexFromTMD(MediaType media_type, u64
SpecialContentType type) { SpecialContentType type) {
if (type > SpecialContentType::DLPChild) { if (type > SpecialContentType::DLPChild) {
// TODO(B3N30): Find correct result code // TODO(B3N30): Find correct result code
return ResultCode(-1); return ResultUnknown;
} }
std::string tmd_path = AM::GetTitleMetadataPath(media_type, title_id); std::string tmd_path = AM::GetTitleMetadataPath(media_type, title_id);
@ -993,7 +993,7 @@ ResultVal<u16> FS_USER::GetSpecialContentIndexFromTMD(MediaType media_type, u64
FileSys::TitleMetadata tmd; FileSys::TitleMetadata tmd;
if (tmd.Load(tmd_path) != Loader::ResultStatus::Success || type == SpecialContentType::Update) { if (tmd.Load(tmd_path) != Loader::ResultStatus::Success || type == SpecialContentType::Update) {
// TODO(B3N30): Find correct result code // TODO(B3N30): Find correct result code
return ResultCode(-1); return ResultUnknown;
} }
// TODO(B3N30): Does real 3DS check if content exists in TMD? // TODO(B3N30): Does real 3DS check if content exists in TMD?
@ -1007,7 +1007,7 @@ ResultVal<u16> FS_USER::GetSpecialContentIndexFromTMD(MediaType media_type, u64
ASSERT(false); ASSERT(false);
} }
return ResultCode(-1); return ResultUnknown;
} }
FS_USER::FS_USER(Core::System& system) FS_USER::FS_USER(Core::System& system)

View file

@ -72,8 +72,8 @@ public:
if (info != program_info_map.end()) { if (info != program_info_map.end()) {
return info->second; return info->second;
} else { } else {
return ResultCode(FileSys::ErrCodes::ArchiveNotMounted, ErrorModule::FS, return Result(FileSys::ErrCodes::ArchiveNotMounted, ErrorModule::FS,
ErrorSummary::NotFound, ErrorLevel::Status); ErrorSummary::NotFound, ErrorLevel::Status);
} }
} }

Some files were not shown because too many files have changed in this diff Show more