Results: Implement namespaced, type-safe results.

Because I was working on multiple things at once, this commit also:
- Adds wrappers for/linker flags to wrap CXX exceptions to make them
  abort. This saves ~0x8000 of memory in every system module.
- Broadly replaces lines of the pattern if (cond) { return ResultX; }
  with R_UNLESS(!cond, ResultX());.
- Reworks the R_TRY_CATCH macros (and the result macros in general).
This commit is contained in:
Michael Scire 2019-10-24 01:40:44 -07:00 committed by SciresM
parent 15773e4755
commit 4059dc6187
169 changed files with 2172 additions and 1868 deletions

View file

@ -31,7 +31,7 @@ DATA := data
INCLUDES := include ../../common/include
EXEFS_SRC := exefs_src
DEFINES := -DRESULT_ABORT_ON_ASSERT -DATMOSPHERE_GIT_BRANCH=\"$(AMSBRANCH)\" -DATMOSPHERE_GIT_REV=\"$(AMSREV)\"
DEFINES := -DATMOSPHERE_GIT_BRANCH=\"$(AMSBRANCH)\" -DATMOSPHERE_GIT_REV=\"$(AMSREV)\"
#---------------------------------------------------------------------------------
# options for code generation
@ -45,8 +45,18 @@ CFLAGS += $(INCLUDE) -D__SWITCH__
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++17
CXXWRAPS := -Wl,--wrap,__cxa_pure_virtual \
-Wl,--wrap,__cxa_throw \
-Wl,--wrap,__cxa_rethrow \
-Wl,--wrap,__cxa_allocate_exception \
-Wl,--wrap,__cxa_begin_catch \
-Wl,--wrap,__cxa_end_catch \
-Wl,--wrap,__cxa_call_unexpected \
-Wl,--wrap,__cxa_call_terminate \
-Wl,--wrap,__gxx_personality_v0
ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) $(CXXWRAPS) -Wl,-Map,$(notdir $*.map)
LIBS := -lstratosphere -lnx

View file

@ -28,5 +28,5 @@ Result BpcAtmosphereService::RebootToFatalError(InBuffer<AtmosphereFatalErrorCon
/* Reboot to fusee with the input context. */
BpcRebootManager::RebootForFatalError(ctx.buffer);
return ResultSuccess;
return ResultSuccess();
}

View file

@ -27,7 +27,7 @@ void BpcMitmService::PostProcess(IMitmServiceObject *obj, IpcResponseContext *ct
Result BpcMitmService::ShutdownSystem() {
/* Use exosphere + reboot to perform real shutdown, instead of fake shutdown. */
PerformShutdownSmc();
return ResultSuccess;
return ResultSuccess();
}
Result BpcMitmService::RebootSystem() {

View file

@ -92,11 +92,11 @@ Result BpcRebootManager::PerformReboot() {
return ResultAtmosphereMitmShouldForwardToSession;
case BpcRebootType::ToRcm:
RebootToRcm();
return ResultSuccess;
return ResultSuccess();
case BpcRebootType::ToPayload:
default:
DoRebootToPayload();
return ResultSuccess;
return ResultSuccess();
}
}

View file

@ -48,7 +48,7 @@ Result FsDirUtils::CopyFile(IFileSystem *dst_fs, IFileSystem *src_fs, const FsPa
offset += read_size;
}
return ResultSuccess;
return ResultSuccess();
}
Result FsDirUtils::CopyDirectoryRecursively(IFileSystem *dst_fs, IFileSystem *src_fs, const FsPath &dst_path, const FsPath &src_path, void *work_buf, size_t work_buf_size) {
@ -75,7 +75,7 @@ Result FsDirUtils::CopyDirectoryRecursively(IFileSystem *dst_fs, IFileSystem *sr
}
p[1] = 0;
return ResultSuccess;
return ResultSuccess();
},
[&](const FsPath &path, const FsDirectoryEntry *dir_ent) -> Result { /* On File */
/* Just copy the file to the new fs. */
@ -113,5 +113,5 @@ Result FsDirUtils::EnsureDirectoryExists(IFileSystem *fs, const FsPath &path) {
}
} R_END_TRY_CATCH;
return ResultSuccess;
return ResultSuccess();
}

View file

@ -71,7 +71,7 @@ class FsDirUtils {
work_path.str[parent_len] = 0;
}
return ResultSuccess;
return ResultSuccess();
}
public:
@ -137,6 +137,6 @@ class FsDirUtils {
} R_END_TRY_CATCH;
}
return ResultSuccess;
return ResultSuccess();
}
};

View file

@ -54,7 +54,7 @@ Result DirectoryRedirectionFileSystem::Initialize(const char *before, const char
this->before_dir_len = strlen(this->before_dir);
this->after_dir_len = strlen(this->after_dir);
return ResultSuccess;
return ResultSuccess();
}
Result DirectoryRedirectionFileSystem::GetFullPath(char *out, size_t out_size, const char *relative_path) {
@ -79,7 +79,7 @@ Result DirectoryRedirectionFileSystem::GetFullPath(char *out, size_t out_size, c
}
std::strncpy(out, this->after_dir, out_size);
out[out_size - 1] = 0;
return ResultSuccess;
return ResultSuccess();
} else {
return FsPathUtils::Normalize(out, out_size, relative_path, nullptr);
}

View file

@ -114,7 +114,7 @@ Result DirectorySaveDataFileSystem::AllocateWorkBuffer(void **out_buf, size_t *o
if (buf != nullptr) {
*out_buf = buf;
*out_size = try_size;
return ResultSuccess;
return ResultSuccess();
}
/* Divide size by two. */
@ -162,7 +162,7 @@ Result DirectorySaveDataFileSystem::CopySaveFromProxy() {
R_TRY(FsDirUtils::CopyDirectoryRecursively(this, this->proxy_save_fs.get(), FsPathUtils::RootPath, FsPathUtils::RootPath, work_buf, work_buf_size));
return this->Commit();
}
return ResultSuccess;
return ResultSuccess();
}
/* ================================================================================================ */
@ -258,7 +258,7 @@ Result DirectorySaveDataFileSystem::OpenFileImpl(std::unique_ptr<IFile> &out_fil
this->open_writable_files++;
}
return ResultSuccess;
return ResultSuccess();
}
Result DirectorySaveDataFileSystem::OpenDirectoryImpl(std::unique_ptr<IDirectory> &out_dir, const FsPath &path, DirectoryOpenMode mode) {
@ -303,7 +303,7 @@ Result DirectorySaveDataFileSystem::CommitImpl() {
R_TRY(FsDirUtils::RetryUntilTargetNotLocked(std::move(RenameSynchDir)));
/* TODO: Should I call this->fs->Commit()? Nintendo does not. */
return ResultSuccess;
return ResultSuccess();
}
Result DirectorySaveDataFileSystem::GetFreeSpaceSizeImpl(uint64_t *out, const FsPath &path) {

View file

@ -25,14 +25,14 @@ Result FileStorage::UpdateSize() {
if (this->size == InvalidSize) {
return this->file->GetSize(&this->size);
}
return ResultSuccess;
return ResultSuccess();
}
Result FileStorage::Read(void *buffer, size_t size, u64 offset) {
u64 read_size;
if (size == 0) {
return ResultSuccess;
return ResultSuccess();
}
if (buffer == nullptr) {
return ResultFsNullptrArgument;
@ -47,12 +47,12 @@ Result FileStorage::Read(void *buffer, size_t size, u64 offset) {
if (read_size != size && read_size) {
return this->Read(reinterpret_cast<void *>(reinterpret_cast<uintptr_t>(buffer) + read_size), size - read_size, offset + read_size);
}
return ResultSuccess;
return ResultSuccess();
}
Result FileStorage::Write(void *buffer, size_t size, u64 offset) {
if (size == 0) {
return ResultSuccess;
return ResultSuccess();
}
if (buffer == nullptr) {
return ResultFsNullptrArgument;
@ -72,7 +72,7 @@ Result FileStorage::Flush() {
Result FileStorage::GetSize(u64 *out_size) {
R_TRY(this->UpdateSize());
*out_size = this->size;
return ResultSuccess;
return ResultSuccess();
}
Result FileStorage::SetSize(u64 size) {
@ -92,7 +92,7 @@ Result FileStorage::OperateRange(FsOperationId operation_type, u64 offset, u64 s
/* N checks for size == sizeof(*out_range_info) here, but that's because their wrapper api is bad. */
std::memset(out_range_info, 0, sizeof(*out_range_info));
}
return ResultSuccess;
return ResultSuccess();
}
R_TRY(this->UpdateSize());
/* N checks for positivity + signed overflow on offset/size here, but we're using unsigned types... */

View file

@ -28,7 +28,7 @@ class IDirectory {
}
if (max_entries == 0) {
*out_count = 0;
return ResultSuccess;
return ResultSuccess();
}
if (out_entries == nullptr) {
return ResultFsNullptrArgument;
@ -107,7 +107,7 @@ class ProxyDirectory : public IDirectory {
R_TRY(fsDirRead(this->base_dir.get(), 0, &count, max_entries, out_entries));
*out_count = count;
return ResultSuccess;
return ResultSuccess();
}
virtual Result GetEntryCountImpl(uint64_t *count) {
return fsDirGetEntryCount(this->base_dir.get(), count);

View file

@ -31,7 +31,7 @@ class IFile {
}
if (size == 0) {
*out = 0;
return ResultSuccess;
return ResultSuccess();
}
if (buffer == nullptr) {
return ResultFsNullptrArgument;
@ -56,7 +56,7 @@ class IFile {
Result Write(uint64_t offset, void *buffer, uint64_t size, uint32_t flags) {
if (size == 0) {
return ResultSuccess;
return ResultSuccess();
}
if (buffer == nullptr) {
return ResultFsNullptrArgument;
@ -66,7 +66,7 @@ class IFile {
Result Write(uint64_t offset, void *buffer, uint64_t size, bool flush = false) {
if (size == 0) {
return ResultSuccess;
return ResultSuccess();
}
if (buffer == nullptr) {
return ResultFsNullptrArgument;
@ -175,7 +175,7 @@ class ProxyFile : public IFile {
R_TRY(fsFileRead(this->base_file.get(), offset, buffer, size, FS_READOPTION_NONE, &out_sz));
*out = out_sz;
return ResultSuccess;
return ResultSuccess();
}
virtual Result GetSizeImpl(u64 *out) override {
return fsFileGetSize(this->base_file.get(), out);

View file

@ -276,7 +276,7 @@ class IFileSystemInterface : public IServiceObject {
R_TRY(this->base_fs->GetEntryType(&type, path));
out_type.SetValue(type);
return ResultSuccess;
return ResultSuccess();
}
virtual Result OpenFile(Out<std::shared_ptr<IFileInterface>> out_intf, InPointer<char> in_path, uint32_t mode) final {
@ -287,7 +287,7 @@ class IFileSystemInterface : public IServiceObject {
R_TRY(this->base_fs->OpenFile(out_file, path, static_cast<OpenMode>(mode)));
out_intf.SetValue(std::make_shared<IFileInterface>(std::move(out_file)));
return ResultSuccess;
return ResultSuccess();
}
virtual Result OpenDirectory(Out<std::shared_ptr<IDirectoryInterface>> out_intf, InPointer<char> in_path, uint32_t mode) final {
@ -298,7 +298,7 @@ class IFileSystemInterface : public IServiceObject {
R_TRY(this->base_fs->OpenDirectory(out_dir, path, static_cast<DirectoryOpenMode>(mode)));
out_intf.SetValue(std::make_shared<IDirectoryInterface>(std::move(out_dir)));
return ResultSuccess;
return ResultSuccess();
}
virtual Result Commit() final {
@ -419,14 +419,14 @@ class ProxyFileSystem : public IFileSystem {
R_TRY(fsFsGetEntryType(this->base_fs.get(), path.str, &type));
*out = static_cast<DirectoryEntryType>(static_cast<u32>(type));
return ResultSuccess;
return ResultSuccess();
}
virtual Result OpenFileImpl(std::unique_ptr<IFile> &out_file, const FsPath &path, OpenMode mode) {
FsFile f;
R_TRY(fsFsOpenFile(this->base_fs.get(), path.str, static_cast<int>(mode), &f));
out_file = std::make_unique<ProxyFile>(f);
return ResultSuccess;
return ResultSuccess();
}
virtual Result OpenDirectoryImpl(std::unique_ptr<IDirectory> &out_dir, const FsPath &path, DirectoryOpenMode mode) {
@ -434,7 +434,7 @@ class ProxyFileSystem : public IFileSystem {
R_TRY(fsFsOpenDirectory(this->base_fs.get(), path.str, static_cast<int>(mode), &d));
out_dir = std::make_unique<ProxyDirectory>(d);
return ResultSuccess;
return ResultSuccess();
}
virtual Result CommitImpl() {

View file

@ -102,7 +102,7 @@ class IROStorage : public IStorage {
return ResultFsUnsupportedOperation;
};
virtual Result Flush() final {
return ResultSuccess;
return ResultSuccess();
};
virtual Result SetSize(u64 size) final {
(void)(size);

View file

@ -28,7 +28,7 @@ Result FsPathUtils::VerifyPath(const char *path, size_t max_path_len, size_t max
const char c = *(cur++);
/* If terminated, we're done. */
if (c == 0) {
return ResultSuccess;
return ResultSuccess();
}
/* TODO: Nintendo converts the path from utf-8 to utf-32, one character at a time. */
@ -110,7 +110,7 @@ Result FsPathUtils::IsNormalized(bool *out, const char *path) {
/* It is unclear why first separator and separator are separate states... */
if (c == '/') {
*out = false;
return ResultSuccess;
return ResultSuccess();
} else if (c == '.') {
state = PathState::CurrentDir;
} else {
@ -120,7 +120,7 @@ Result FsPathUtils::IsNormalized(bool *out, const char *path) {
case PathState::CurrentDir:
if (c == '/') {
*out = false;
return ResultSuccess;
return ResultSuccess();
} else if (c == '.') {
state = PathState::ParentDir;
} else {
@ -130,7 +130,7 @@ Result FsPathUtils::IsNormalized(bool *out, const char *path) {
case PathState::ParentDir:
if (c == '/') {
*out = false;
return ResultSuccess;
return ResultSuccess();
} else {
state = PathState::Normal;
}
@ -138,7 +138,7 @@ Result FsPathUtils::IsNormalized(bool *out, const char *path) {
case PathState::WindowsDriveLetter:
if (c == ':') {
*out = true;
return ResultSuccess;
return ResultSuccess();
} else {
return ResultFsInvalidPathFormat;
}
@ -161,7 +161,7 @@ Result FsPathUtils::IsNormalized(bool *out, const char *path) {
break;
}
return ResultSuccess;
return ResultSuccess();
}
Result FsPathUtils::Normalize(char *out, size_t max_out_size, const char *src, size_t *out_len) {
@ -263,5 +263,5 @@ Result FsPathUtils::Normalize(char *out, size_t max_out_size, const char *src, s
R_ASSERT(FsPathUtils::IsNormalized(&normalized, out));
STS_ASSERT(normalized);
return ResultSuccess;
return ResultSuccess();
}

View file

@ -53,7 +53,7 @@ Result FsSaveUtils::GetSaveDataSpaceIdString(const char **out_str, u8 space_id)
*out_str = str;
}
return ResultSuccess;
return ResultSuccess();
}
Result FsSaveUtils::GetSaveDataTypeString(const char **out_str, u8 save_data_type) {
@ -95,7 +95,7 @@ Result FsSaveUtils::GetSaveDataTypeString(const char **out_str, u8 save_data_typ
*out_str = str;
}
return ResultSuccess;
return ResultSuccess();
}
Result FsSaveUtils::GetSaveDataDirectoryPath(FsPath &out_path, u8 space_id, u8 save_data_type, u64 title_id, u128 user_id, u64 save_id) {
@ -121,5 +121,5 @@ Result FsSaveUtils::GetSaveDataDirectoryPath(FsPath &out_path, u8 space_id, u8 s
return ResultFsTooLongPath;
}
return ResultSuccess;
return ResultSuccess();
}

View file

@ -49,7 +49,7 @@ Result SubDirectoryFileSystem::Initialize(const char *bp) {
std::strncpy(this->base_path, normal_path, this->base_path_len);
this->base_path[this->base_path_len-1] = 0;
return ResultSuccess;
return ResultSuccess();
}
Result SubDirectoryFileSystem::GetFullPath(char *out, size_t out_size, const char *relative_path) {

View file

@ -67,7 +67,7 @@ Result Boot0Storage::Write(void *_buffer, size_t size, u64 offset) {
if (offset < EksEnd) {
if (offset + size < EksEnd) {
/* Ignore writes falling strictly within the region. */
return ResultSuccess;
return ResultSuccess();
} else {
/* Only write past the end of the keyblob region. */
buffer = buffer + (EksEnd - offset);
@ -80,7 +80,7 @@ Result Boot0Storage::Write(void *_buffer, size_t size, u64 offset) {
}
if (size == 0) {
return ResultSuccess;
return ResultSuccess();
}
/* We care about protecting autorcm from NS. */

View file

@ -72,7 +72,7 @@ class SectoredProxyStorage : public ProxyStorage {
}
}
return ResultSuccess;
return ResultSuccess();
}
virtual Result Write(void *_buffer, size_t size, u64 offset) override {
@ -112,7 +112,7 @@ class SectoredProxyStorage : public ProxyStorage {
}
}
return ResultSuccess;
return ResultSuccess();
}
};

View file

@ -48,7 +48,7 @@ LayeredRomFS::LayeredRomFS(std::shared_ptr<IROStorage> s_r, std::shared_ptr<IROS
Result LayeredRomFS::Read(void *buffer, size_t size, u64 offset) {
/* Size zero reads should always succeed. */
if (size == 0) {
return ResultSuccess;
return ResultSuccess();
}
/* Validate size. */
@ -136,16 +136,16 @@ Result LayeredRomFS::Read(void *buffer, size_t size, u64 offset) {
}
}
return ResultSuccess;
return ResultSuccess();
}
Result LayeredRomFS::GetSize(u64 *out_size) {
*out_size = (*this->p_source_infos)[this->p_source_infos->size() - 1].virtual_offset + (*this->p_source_infos)[this->p_source_infos->size() - 1].size;
return ResultSuccess;
return ResultSuccess();
}
Result LayeredRomFS::OperateRange(FsOperationId operation_type, u64 offset, u64 size, FsRangeInfo *out_range_info) {
/* TODO: How should I implement this for a virtual romfs? */
if (operation_type == FsOperationId_QueryRange) {
*out_range_info = {0};
}
return ResultSuccess;
return ResultSuccess();
}

View file

@ -42,7 +42,7 @@ class RomFileStorage : public IROStorage {
if (out_sz != size && out_sz) {
R_TRY(this->Read((void *)((uintptr_t)buffer + out_sz), size - out_sz, offset + out_sz));
}
return ResultSuccess;
return ResultSuccess();
};
Result GetSize(u64 *out_size) override {
return fsFileGetSize(this->base_file, out_size);

View file

@ -92,7 +92,7 @@ Result FsMitmService::OpenHblWebContentFileSystem(Out<std::shared_ptr<IFileSyste
out_fs.ChangeObjectId(sd_fs.s.object_id);
}
return ResultSuccess;
return ResultSuccess();
}
Result FsMitmService::OpenFileSystemWithPatch(Out<std::shared_ptr<IFileSystemInterface>> out_fs, u64 title_id, u32 filesystem_type) {
@ -163,7 +163,7 @@ Result FsMitmService::OpenSdCardFileSystem(Out<std::shared_ptr<IFileSystemInterf
out_fs.ChangeObjectId(sd_fs.s.object_id);
}
return ResultSuccess;
return ResultSuccess();
}
Result FsMitmService::OpenSaveDataFileSystem(Out<std::shared_ptr<IFileSystemInterface>> out_fs, u8 space_id, FsSave save_struct) {
@ -222,7 +222,7 @@ Result FsMitmService::OpenSaveDataFileSystem(Out<std::shared_ptr<IFileSystemInte
out_fs.ChangeObjectId(sd_fs.s.object_id);
}
return ResultSuccess;
return ResultSuccess();
}
}
@ -272,7 +272,7 @@ Result FsMitmService::OpenBisStorage(Out<std::shared_ptr<IStorageInterface>> out
out_storage.ChangeObjectId(bis_storage.s.object_id);
}
return ResultSuccess;
return ResultSuccess();
}
/* Add redirection for RomFS to the SD card. */
@ -299,7 +299,7 @@ Result FsMitmService::OpenDataStorageByCurrentProcess(Out<std::shared_ptr<IStora
out_storage.ChangeObjectId(s.s.object_id);
}
out_storage.SetValue(std::move(cached_storage));
return ResultSuccess;
return ResultSuccess();
}
}
@ -326,7 +326,7 @@ Result FsMitmService::OpenDataStorageByCurrentProcess(Out<std::shared_ptr<IStora
}
}
return ResultSuccess;
return ResultSuccess();
}
/* Add redirection for System Data Archives to the SD card. */
@ -355,7 +355,7 @@ Result FsMitmService::OpenDataStorageByDataId(Out<std::shared_ptr<IStorageInterf
out_storage.ChangeObjectId(s.s.object_id);
}
out_storage.SetValue(std::move(cached_storage));
return ResultSuccess;
return ResultSuccess();
}
}
@ -382,5 +382,5 @@ Result FsMitmService::OpenDataStorageByDataId(Out<std::shared_ptr<IStorageInterf
}
}
return ResultSuccess;
return ResultSuccess();
}

View file

@ -32,7 +32,7 @@ Result NsAmMitmService::ResolveApplicationContentPath(u64 title_id, u8 storage_t
/* Always succeed for web applet asking about HBL. */
if (Utils::IsWebAppletTid(static_cast<u64>(this->title_id)) && Utils::IsHblTid(title_id)) {
nsamResolveApplicationContentPathFwd(this->forward_service.get(), title_id, static_cast<FsStorageId>(storage_type));
return ResultSuccess;
return ResultSuccess();
}
return nsamResolveApplicationContentPathFwd(this->forward_service.get(), title_id, static_cast<FsStorageId>(storage_type));

View file

@ -34,7 +34,7 @@ Result NsWebMitmService::GetDocumentInterface(Out<std::shared_ptr<NsDocumentServ
out_intf.ChangeObjectId(doc.s.object_id);
}
return ResultSuccess;
return ResultSuccess();
}
Result NsDocumentService::GetApplicationContentPath(OutBuffer<u8> out_path, u64 app_id, u8 storage_type) {
@ -45,7 +45,7 @@ Result NsDocumentService::ResolveApplicationContentPath(u64 title_id, u8 storage
/* Always succeed for web applet asking about HBL. */
if (Utils::IsWebAppletTid(static_cast<u64>(this->title_id)) && Utils::IsHblTid(title_id)) {
nswebResolveApplicationContentPath(this->srv.get(), title_id, static_cast<FsStorageId>(storage_type));
return ResultSuccess;
return ResultSuccess();
}
return nswebResolveApplicationContentPath(this->srv.get(), title_id, static_cast<FsStorageId>(storage_type));

View file

@ -79,7 +79,7 @@ Result SetMitmService::EnsureLocale() {
}
}
return ResultSuccess;
return ResultSuccess();
}
Result SetMitmService::GetLanguageCode(Out<u64> out_lang_code) {
@ -90,7 +90,7 @@ Result SetMitmService::GetLanguageCode(Out<u64> out_lang_code) {
}
out_lang_code.SetValue(this->locale.language_code);
return ResultSuccess;
return ResultSuccess();
}
Result SetMitmService::GetRegionCode(Out<u32> out_region_code) {
@ -101,5 +101,5 @@ Result SetMitmService::GetRegionCode(Out<u32> out_region_code) {
}
out_region_code.SetValue(this->locale.region_code);
return ResultSuccess;
return ResultSuccess();
}

View file

@ -75,5 +75,5 @@ Result VersionManager::GetFirmwareVersion(sts::ncm::TitleId title_id, SetSysFirm
*out = g_fw_version;
}
return ResultSuccess;
return ResultSuccess();
}

View file

@ -32,7 +32,7 @@ Result SetSysMitmService::GetFirmwareVersion(OutPointerWithServerSize<SetSysFirm
/* GetFirmwareVersion sanitizes these fields. */
out.pointer->revision_major = 0;
out.pointer->revision_minor = 0;
return ResultSuccess;
return ResultSuccess();
}
Result SetSysMitmService::GetFirmwareVersion2(OutPointerWithServerSize<SetSysFirmwareVersion, 0x1> out) {
@ -64,7 +64,7 @@ Result SetSysMitmService::GetSettingsItemValueSize(Out<u64> out_size, InPointer<
R_TRY(setsysGetSettingsItemValueSize(name, key, out_size.GetPointer()));
}
return ResultSuccess;
return ResultSuccess();
}
Result SetSysMitmService::GetSettingsItemValue(Out<u64> out_size, OutBuffer<u8> out_value, InPointer<char> in_name, InPointer<char> in_key) {
@ -96,5 +96,5 @@ Result SetSysMitmService::GetSettingsItemValue(Out<u64> out_size, OutBuffer<u8>
R_TRY(setsysGetSettingsItemValueFwd(this->forward_service.get(), name, key, out_value.buffer, out_value.num_elements, out_size.GetPointer()));
}
return ResultSuccess;
return ResultSuccess();
}

View file

@ -84,7 +84,7 @@ Result SettingsItemManager::ValidateName(const char *name, size_t max_size) {
return ResultSettingsItemNameInvalidFormat;
}
return ResultSuccess;
return ResultSuccess();
}
Result SettingsItemManager::ValidateName(const char *name) {
@ -107,7 +107,7 @@ Result SettingsItemManager::ValidateKey(const char *key, size_t max_size) {
return ResultSettingsItemKeyInvalidFormat;
}
return ResultSuccess;
return ResultSuccess();
}
Result SettingsItemManager::ValidateKey(const char *key) {
@ -219,7 +219,7 @@ static Result ParseValue(const char *name, const char *key, const char *val_tup)
}
g_settings_items[kv] = value;
return ResultSuccess;
return ResultSuccess();
}
static Result ParseSettingsItemValue(const char *name, const char *key, const char *value) {
@ -227,7 +227,7 @@ static Result ParseSettingsItemValue(const char *name, const char *key, const ch
R_TRY(SettingsItemManager::ValidateName(name));
R_TRY(SettingsItemManager::ValidateKey(name));
R_TRY(ParseValue(name, key, value));
return ResultSuccess;
return ResultSuccess();
}
static int SettingsItemIniHandler(void *user, const char *name, const char *key, const char *value) {
@ -282,7 +282,7 @@ Result SettingsItemManager::GetValueSize(const char *name, const char *key, u64
}
*out_size = it->second.size;
return ResultSuccess;
return ResultSuccess();
}
Result SettingsItemManager::GetValue(const char *name, const char *key, void *out, size_t max_size, u64 *out_size) {
@ -300,5 +300,5 @@ Result SettingsItemManager::GetValue(const char *name, const char *key, void *ou
*out_size = copy_size;
memcpy(out, it->second.data, copy_size);
return ResultSuccess;
return ResultSuccess();
}

View file

@ -451,7 +451,7 @@ Result Utils::SaveSdFileForAtmosphere(u64 title_id, const char *fn, void *data,
/* Try to write the data. */
R_TRY(fsFileWrite(&f, 0, data, size, FS_WRITEOPTION_FLUSH));
return ResultSuccess;
return ResultSuccess();
}
bool Utils::IsHblTid(u64 _tid) {
@ -539,7 +539,7 @@ Result Utils::GetKeysHeld(u64 *keys) {
*keys |= hidKeysHeld((HidControllerID) controller);
}
return ResultSuccess;
return ResultSuccess();
}
static bool HasOverrideKey(OverrideKey *cfg) {
@ -793,7 +793,7 @@ Result Utils::GetSettingsItemBooleanValue(const char *name, const char *key, boo
if (out) {
*out = val != 0;
}
return ResultSuccess;
return ResultSuccess();
}
void Utils::RebootToFatalError(AtmosphereFatalErrorContext *ctx) {

View file

@ -38,7 +38,7 @@ DATA := data
INCLUDES := include ../../common/include
EXEFS_SRC := exefs_src
DEFINES := -DRESULT_ABORT_ON_ASSERT -DATMOSPHERE_GIT_BRANCH=\"$(AMSBRANCH)\" -DATMOSPHERE_GIT_REV=\"$(AMSREV)\"
DEFINES := -DATMOSPHERE_GIT_BRANCH=\"$(AMSBRANCH)\" -DATMOSPHERE_GIT_REV=\"$(AMSREV)\"
#---------------------------------------------------------------------------------
# options for code generation
@ -52,8 +52,18 @@ CFLAGS += $(INCLUDE) -D__SWITCH__
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++17
CXXWRAPS := -Wl,--wrap,__cxa_pure_virtual \
-Wl,--wrap,__cxa_throw \
-Wl,--wrap,__cxa_rethrow \
-Wl,--wrap,__cxa_allocate_exception \
-Wl,--wrap,__cxa_begin_catch \
-Wl,--wrap,__cxa_end_catch \
-Wl,--wrap,__cxa_call_unexpected \
-Wl,--wrap,__cxa_call_terminate \
-Wl,--wrap,__gxx_personality_v0
ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) $(CXXWRAPS) -Wl,-Map,$(notdir $*.map)
LIBS := -lstratosphere -lnx

View file

@ -67,7 +67,7 @@ namespace sts::boot {
const u16 new_val = (cur_val & ~mask) | val;
R_TRY(this->Write(addr, new_val));
return ResultSuccess;
return ResultSuccess();
}
bool BatteryDriver::WriteValidate(u8 addr, u16 val) {
@ -99,20 +99,20 @@ namespace sts::boot {
Result BatteryDriver::LockModelTable() {
R_TRY(this->Write(Max17050ModelAccess0, 0x0000));
R_TRY(this->Write(Max17050ModelAccess1, 0x0000));
return ResultSuccess;
return ResultSuccess();
}
Result BatteryDriver::UnlockModelTable() {
R_TRY(this->Write(Max17050ModelAccess0, 0x0059));
R_TRY(this->Write(Max17050ModelAccess1, 0x00C4));
return ResultSuccess;
return ResultSuccess();
}
Result BatteryDriver::SetModelTable(const u16 *model_table) {
for (size_t i = 0; i < Max17050ModelChrTblSize; i++) {
R_TRY(this->Write(Max17050ModelChrTblStart + i, model_table[i]));
}
return ResultSuccess;
return ResultSuccess();
}
bool BatteryDriver::IsModelTableLocked() {
@ -173,7 +173,7 @@ namespace sts::boot {
if (lock_i >= 8) {
/* This is regarded as guaranteed success. */
return ResultSuccess;
return ResultSuccess();
}
}
@ -235,7 +235,7 @@ namespace sts::boot {
R_TRY(this->Write(Max17050CGain, 0x7FFF));
}
return ResultSuccess;
return ResultSuccess();
}
Result BatteryDriver::IsBatteryRemoved(bool *out) {
@ -243,28 +243,28 @@ namespace sts::boot {
u16 val = 0;
R_TRY(this->Read(Max17050Status, &val));
*out = (val & 0x0008) == 0x0008;
return ResultSuccess;
return ResultSuccess();
}
Result BatteryDriver::GetTemperature(double *out) {
u16 val = 0;
R_TRY(this->Read(Max17050Temperature, &val));
*out = static_cast<double>(val) * double(0.00390625);
return ResultSuccess;
return ResultSuccess();
}
Result BatteryDriver::GetAverageVCell(u32 *out) {
u16 val = 0;
R_TRY(this->Read(Max17050AverageVCell, &val));
*out = (625 * u32(val >> 3)) / 1000;
return ResultSuccess;
return ResultSuccess();
}
Result BatteryDriver::GetSocRep(double *out) {
u16 val = 0;
R_TRY(this->Read(Max17050SocRep, &val));
*out = static_cast<double>(val) * double(0.00390625);
return ResultSuccess;
return ResultSuccess();
}
Result BatteryDriver::GetBatteryPercentage(size_t *out) {
@ -278,7 +278,7 @@ namespace sts::boot {
} else {
*out = static_cast<size_t>(converted_percentage);
}
return ResultSuccess;
return ResultSuccess();
}
Result BatteryDriver::SetShutdownTimer() {
@ -289,7 +289,7 @@ namespace sts::boot {
u16 val = 0;
R_TRY(this->Read(Max17050Config, &val));
*out = (val & 0x0040) != 0;
return ResultSuccess;
return ResultSuccess();
}
Result BatteryDriver::SetShutdownEnabled(bool enabled) {

View file

@ -29,8 +29,6 @@ namespace sts::boot {
constexpr u32 DefaultBatteryVendor = static_cast<u32>('A');
constexpr u32 DefaultBatteryVersion = 0;
constexpr Result ResultCalInvalidCrc = 0xCAC6; /* TODO: Verify this really is cal, move to libstrat results. */
/* Helpers. */
constexpr u16 GetCrc16(const void *data, size_t size) {
constexpr u16 s_crc_table[0x10] = {
@ -51,10 +49,9 @@ namespace sts::boot {
Result ValidateCalibrationCrc16(const void *data, size_t size) {
const u8 *data_u8 = reinterpret_cast<const u8 *>(data);
if (GetCrc16(data, size - sizeof(u16)) != *(reinterpret_cast<const u16 *>(&data_u8[size - sizeof(u16)]))) {
return ResultCalInvalidCrc;
}
return ResultSuccess;
const bool crc_valid = GetCrc16(data, size - sizeof(u16)) == *(reinterpret_cast<const u16 *>(&data_u8[size - sizeof(u16)]));
R_UNLESS(crc_valid, cal::ResultCalibrationDataCrcError());
return ResultSuccess();
}
Result GetBatteryVendorImpl(u32 *vendor) {
@ -68,7 +65,7 @@ namespace sts::boot {
R_TRY(ValidateCalibrationCrc16(battery_lot, sizeof(battery_lot)));
*vendor = battery_lot[7];
return ResultSuccess;
return ResultSuccess();
}
Result GetBatteryVersionImpl(u32 *version) {
@ -82,7 +79,7 @@ namespace sts::boot {
R_TRY(ValidateCalibrationCrc16(battery_version, sizeof(battery_version)));
*version = battery_version[0];
return ResultSuccess;
return ResultSuccess();
}
}

View file

@ -35,7 +35,7 @@ namespace sts::boot {
const u8 new_val = (cur_val & ~mask) | val;
R_TRY(this->Write(addr, new_val));
return ResultSuccess;
return ResultSuccess();
}
Result ChargerDriver::Initialize() {
@ -59,7 +59,7 @@ namespace sts::boot {
R_TRY(this->SetBoostModeCurrentLimit(bq24193::BoostModeCurrentLimit_500mA));
R_TRY(this->SetHiZEnabled(false));
return ResultSuccess;
return ResultSuccess();
}
Result ChargerDriver::SetChargeEnabled(bool enabled) {
@ -123,14 +123,14 @@ namespace sts::boot {
u8 limit;
R_TRY(this->Read(bq24193::InputSourceControl, &limit));
*out = static_cast<bq24193::InputCurrentLimit>(limit);
return ResultSuccess;
return ResultSuccess();
}
Result ChargerDriver::GetChargeVoltageLimit(u32 *out) {
u8 reg;
R_TRY(this->Read(bq24193::ChargeVoltageControl, &reg));
*out = bq24193::DecodeChargeVoltageLimit(reg);
return ResultSuccess;
return ResultSuccess();
}
}

View file

@ -27,14 +27,16 @@ namespace sts::boot {
u64 cur_time = 0;
while (true) {
R_TRY_CLEANUP(f(), {
cur_time += retry_interval;
if (cur_time < timeout) {
svcSleepThread(retry_interval);
continue;
}
});
return ResultSuccess;
const auto retry_result = f();
R_UNLESS(R_FAILED(retry_result), ResultSuccess());
cur_time += retry_interval;
if (cur_time < timeout) {
svcSleepThread(retry_interval);
continue;
}
return retry_result;
}
}

View file

@ -72,6 +72,12 @@ namespace sts::ams {
}
namespace sts::result {
bool CallFatalOnResultAssertion = false;
}
using namespace sts;
void __libnx_exception_handler(ThreadExceptionDump *ctx) {

View file

@ -44,19 +44,19 @@ namespace sts::pcv {
reg::ReadWrite(regs.clk_src_reg, 0, 0xE0000000);
svcSleepThread(2000ul);
return ResultSuccess;
return ResultSuccess();
}
Result SetClockEnabled(PcvModule module, bool enabled) {
return ResultSuccess;
return ResultSuccess();
}
Result SetVoltageEnabled(u32 domain, bool enabled) {
return ResultSuccess;
return ResultSuccess();
}
Result SetVoltageValue(u32 domain, u32 voltage) {
return ResultSuccess;
return ResultSuccess();
}
Result SetReset(PcvModule module, bool reset) {
@ -71,7 +71,7 @@ namespace sts::pcv {
reg::ClearBits(regs.rst_reg, regs.mask);
}
return ResultSuccess;
return ResultSuccess();
}
}

View file

@ -34,7 +34,7 @@ namespace sts::boot {
u8 power_status;
R_TRY(this->GetPowerStatus(&power_status));
*out = (power_status & 0x02) != 0;
return ResultSuccess;
return ResultSuccess();
}
Result PmicDriver::GetPowerIntr(u8 *out) {
@ -56,7 +56,7 @@ namespace sts::boot {
u8 power_intr;
R_TRY(this->GetPowerIntr(&power_intr));
*out = (power_intr & 0x08) != 0;
return ResultSuccess;
return ResultSuccess();
}
Result PmicDriver::ShutdownSystem(bool reboot) {

View file

@ -40,7 +40,7 @@ namespace sts::i2c::driver {
R_TRY(Send(session, *cur_cmd, num_bytes, option));
(*cur_cmd) += num_bytes;
return ResultSuccess;
return ResultSuccess();
}
Result ReceiveHandler(const u8 **cur_cmd, u8 **cur_dst, Session& session) {
@ -55,7 +55,7 @@ namespace sts::i2c::driver {
R_TRY(Receive(session, *cur_dst, num_bytes, option));
(*cur_dst) += num_bytes;
return ResultSuccess;
return ResultSuccess();
}
Result SubCommandHandler(const u8 **cur_cmd, u8 **cur_dst, Session& session) {
@ -72,7 +72,7 @@ namespace sts::i2c::driver {
break;
STS_UNREACHABLE_DEFAULT_CASE();
}
return ResultSuccess;
return ResultSuccess();
}
/* Command handler list. */
@ -155,7 +155,7 @@ namespace sts::i2c::driver {
R_TRY(g_cmd_handlers[static_cast<size_t>(cmd)](&cur_cmd, &cur_dst, session));
}
return ResultSuccess;
return ResultSuccess();
}
/* Power management. */

View file

@ -118,7 +118,7 @@ namespace sts::i2c::driver::impl {
Result BusAccessor::StartTransaction(Command command, AddressingMode addressing_mode, u32 slave_address) {
/* Nothing actually happens here... */
return ResultSuccess;
return ResultSuccess();
}
Result BusAccessor::Send(const u8 *data, size_t num_bytes, I2cTransactionOption option, AddressingMode addressing_mode, u32 slave_address) {
@ -158,9 +158,9 @@ namespace sts::i2c::driver::impl {
this->interrupt_event.Reset();
if (!this->interrupt_event.TimedWait(InterruptTimeout)) {
this->HandleTransactionResult(ResultI2cBusBusy);
this->HandleTransactionResult(i2c::ResultBusBusy());
this->interrupt_event.Reset();
return ResultI2cTimedOut;
return i2c::ResultTimedOut();
}
R_TRY(this->GetAndHandleTransactionResult());
@ -181,13 +181,13 @@ namespace sts::i2c::driver::impl {
this->interrupt_event.Reset();
if (!this->interrupt_event.TimedWait(InterruptTimeout)) {
this->HandleTransactionResult(ResultI2cBusBusy);
this->HandleTransactionResult(i2c::ResultBusBusy());
this->interrupt_event.Reset();
return ResultI2cTimedOut;
return i2c::ResultTimedOut();
}
}
return ResultSuccess;
return ResultSuccess();
}
Result BusAccessor::Receive(u8 *out_data, size_t num_bytes, I2cTransactionOption option, AddressingMode addressing_mode, u32 slave_address) {
@ -206,10 +206,10 @@ namespace sts::i2c::driver::impl {
while (remaining > 0) {
this->interrupt_event.Reset();
if (!this->interrupt_event.TimedWait(InterruptTimeout)) {
this->HandleTransactionResult(ResultI2cBusBusy);
this->HandleTransactionResult(i2c::ResultBusBusy());
this->ClearInterruptMask();
this->interrupt_event.Reset();
return ResultI2cTimedOut;
return i2c::ResultTimedOut();
}
R_TRY(this->GetAndHandleTransactionResult());
@ -230,7 +230,7 @@ namespace sts::i2c::driver::impl {
}
/* N doesn't do ClearInterruptMask. */
return ResultSuccess;
return ResultSuccess();
}
void BusAccessor::SetBus(Bus bus) {
@ -383,13 +383,11 @@ namespace sts::i2c::driver::impl {
/* Wait for flush to finish, check every ms for 5 ms. */
for (size_t i = 0; i < 5; i++) {
if (!(reg::Read(&this->i2c_registers->I2C_FIFO_CONTROL_0) & 3)) {
return ResultSuccess;
}
R_UNLESS((reg::Read(&this->i2c_registers->I2C_FIFO_CONTROL_0) & 3), ResultSuccess());
svcSleepThread(1'000'000ul);
}
return ResultI2cBusBusy;
return i2c::ResultBusBusy();
}
Result BusAccessor::GetTransactionResult() const {
@ -397,22 +395,23 @@ namespace sts::i2c::driver::impl {
const u32 interrupt_status = reg::Read(&this->i2c_registers->I2C_INTERRUPT_STATUS_REGISTER_0);
/* Check for no ack. */
if ((packet_status & 0xC) || (interrupt_status & 0x8)) {
return ResultI2cNoAck;
}
R_UNLESS(!(packet_status & 0xC), i2c::ResultNoAck());
R_UNLESS(!(interrupt_status & 0x8), i2c::ResultNoAck());
/* Check for arb lost. */
if ((packet_status & 0x2) || (interrupt_status & 0x4)) {
this->ClearBus();
return ResultI2cBusBusy;
{
auto bus_guard = SCOPE_GUARD { this->ClearBus(); };
R_UNLESS(!(packet_status & 0x2), i2c::ResultBusBusy());
R_UNLESS(!(interrupt_status & 0x4), i2c::ResultBusBusy());
bus_guard.Cancel();
}
return ResultSuccess;
return ResultSuccess();
}
void BusAccessor::HandleTransactionResult(Result result) {
R_TRY_CATCH(result) {
R_CATCH_MANY(ResultI2cNoAck, ResultI2cBusBusy) {
R_CATCH(i2c::ResultNoAck, i2c::ResultBusBusy) {
this->ResetController();
this->SetClock(this->speed_mode);
this->SetPacketMode();
@ -422,12 +421,12 @@ namespace sts::i2c::driver::impl {
}
Result BusAccessor::GetAndHandleTransactionResult() {
R_TRY_CLEANUP(this->GetTransactionResult(), {
this->HandleTransactionResult(R_CLEANUP_RESULT);
this->ClearInterruptMask();
this->interrupt_event.Reset();
});
return ResultSuccess;
const auto transaction_result = this->GetTransactionResult();
R_UNLESS(R_FAILED(transaction_result), ResultSuccess());
this->HandleTransactionResult(transaction_result);
this->ClearInterruptMask();
this->interrupt_event.Reset();
return transaction_result;
}
void BusAccessor::WriteTransferHeader(TransferMode transfer_mode, I2cTransactionOption option, AddressingMode addressing_mode, u32 slave_address, size_t num_bytes) {

View file

@ -60,9 +60,7 @@ namespace sts::i2c::driver::impl {
Result Session::DoTransaction(void *dst, const void *src, size_t num_bytes, I2cTransactionOption option, Command command) {
std::scoped_lock lk(this->bus_accessor_mutex);
if (this->bus_accessor->GetBusy()) {
return ResultI2cBusBusy;
}
R_UNLESS(!this->bus_accessor->GetBusy(), i2c::ResultBusBusy());
this->bus_accessor->OnStartTransaction();
ON_SCOPE_EXIT { this->bus_accessor->OnStopTransaction(); };
@ -79,23 +77,22 @@ namespace sts::i2c::driver::impl {
STS_UNREACHABLE_DEFAULT_CASE();
}
return ResultSuccess;
return ResultSuccess();
}
Result Session::DoTransactionWithRetry(void *dst, const void *src, size_t num_bytes, I2cTransactionOption option, Command command) {
size_t i = 0;
while (true) {
R_TRY_CATCH(this->DoTransaction(dst, src, num_bytes, option, command)) {
R_CATCH(ResultI2cTimedOut) {
i++;
if (i <= this->max_retries) {
R_CATCH(i2c::ResultTimedOut) {
if ((++i) <= this->max_retries) {
svcSleepThread(this->retry_wait_time);
continue;
}
return ResultI2cBusBusy;
return i2c::ResultBusBusy();
}
} R_END_TRY_CATCH;
return ResultSuccess;
return ResultSuccess();
}
}

View file

@ -32,10 +32,8 @@ namespace sts::i2c {
}
Result CommandListFormatter::CanEnqueue(size_t size) const {
if (this->cmd_list_size - this->cur_index < size) {
return ResultI2cFullCommandList;
}
return ResultSuccess;
R_UNLESS(this->cmd_list_size - this->cur_index >= size, ResultFullCommandList());
return ResultSuccess();
}
Result CommandListFormatter::EnqueueSendCommand(I2cTransactionOption option, const void *src, size_t size) {
@ -52,7 +50,7 @@ namespace sts::i2c {
for (size_t i = 0; i < size; i++) {
this->cmd_list[this->cur_index++] = src_u8[i];
}
return ResultSuccess;
return ResultSuccess();
}
Result CommandListFormatter::EnqueueReceiveCommand(I2cTransactionOption option, size_t size) {
@ -64,7 +62,7 @@ namespace sts::i2c {
this->cur_index++;
this->cmd_list[this->cur_index++] = size;
return ResultSuccess;
return ResultSuccess();
}
Result CommandListFormatter::EnqueueSleepCommand(size_t us) {
@ -75,7 +73,7 @@ namespace sts::i2c {
this->cur_index++;
this->cmd_list[this->cur_index++] = us;
return ResultSuccess;
return ResultSuccess();
}
}

View file

@ -31,7 +31,7 @@ DATA := data
INCLUDES := include ../../common/include
EXEFS_SRC := exefs_src
DEFINES := -DDISABLE_IPC -DATMOSPHERE_GIT_BRANCH=\"$(AMSBRANCH)\" -DATMOSPHERE_GIT_REV=\"$(AMSREV)\" -DINI_MAX_LINE=768
DEFINES := -DATMOSPHERE_GIT_BRANCH=\"$(AMSBRANCH)\" -DATMOSPHERE_GIT_REV=\"$(AMSREV)\" -DINI_MAX_LINE=768
#---------------------------------------------------------------------------------
# options for code generation
@ -45,8 +45,18 @@ CFLAGS += $(INCLUDE) -D__SWITCH__
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++17
CXXWRAPS := -Wl,--wrap,__cxa_pure_virtual \
-Wl,--wrap,__cxa_throw \
-Wl,--wrap,__cxa_rethrow \
-Wl,--wrap,__cxa_allocate_exception \
-Wl,--wrap,__cxa_begin_catch \
-Wl,--wrap,__cxa_end_catch \
-Wl,--wrap,__cxa_call_unexpected \
-Wl,--wrap,__cxa_call_terminate \
-Wl,--wrap,__gxx_personality_v0
ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) $(CXXWRAPS) -Wl,-Map,$(notdir $*.map)
LIBS := -lstratosphere -lnx

View file

@ -46,6 +46,12 @@ namespace sts::ams {
}
namespace sts::result {
bool CallFatalOnResultAssertion = false;
}
using namespace sts;
void __libnx_exception_handler(ThreadExceptionDump *ctx) {

View file

@ -31,7 +31,7 @@ DATA := data
INCLUDES := include ../../common/include
EXEFS_SRC := exefs_src
DEFINES := -DDISABLE_IPC -DATMOSPHERE_GIT_BRANCH=\"$(AMSBRANCH)\" -DATMOSPHERE_GIT_REV=\"$(AMSREV)\"
DEFINES := -DATMOSPHERE_GIT_BRANCH=\"$(AMSBRANCH)\" -DATMOSPHERE_GIT_REV=\"$(AMSREV)\"
#---------------------------------------------------------------------------------
# options for code generation
@ -45,8 +45,18 @@ CFLAGS += $(INCLUDE) -D__SWITCH__
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++17
CXXWRAPS := -Wl,--wrap,__cxa_pure_virtual \
-Wl,--wrap,__cxa_throw \
-Wl,--wrap,__cxa_rethrow \
-Wl,--wrap,__cxa_allocate_exception \
-Wl,--wrap,__cxa_begin_catch \
-Wl,--wrap,__cxa_end_catch \
-Wl,--wrap,__cxa_call_unexpected \
-Wl,--wrap,__cxa_call_terminate \
-Wl,--wrap,__gxx_personality_v0
ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) $(CXXWRAPS) -Wl,-Map,$(notdir $*.map)
LIBS := -lstratosphere -lnx

View file

@ -212,29 +212,29 @@ namespace sts::creport {
void CrashReport::HandleDebugEventInfoException(const svc::DebugEventInfo &d) {
switch (d.info.exception.type) {
case svc::DebugExceptionType::UndefinedInstruction:
this->result = ResultCreportUndefinedInstruction;
this->result = ResultUndefinedInstruction();
break;
case svc::DebugExceptionType::InstructionAbort:
this->result = ResultCreportInstructionAbort;
this->result = ResultInstructionAbort();
break;
case svc::DebugExceptionType::DataAbort:
this->result = ResultCreportDataAbort;
this->result = ResultDataAbort();
break;
case svc::DebugExceptionType::AlignmentFault:
this->result = ResultCreportAlignmentFault;
this->result = ResultAlignmentFault();
break;
case svc::DebugExceptionType::UserBreak:
this->result = ResultCreportUserBreak;
this->result = ResultUserBreak();
/* Try to parse out the user break result. */
if (hos::GetVersion() >= hos::Version_500) {
svcReadDebugProcessMemory(&this->result, this->debug_handle, d.info.exception.specific.user_break.address, sizeof(this->result));
}
break;
case svc::DebugExceptionType::UndefinedSystemCall:
this->result = ResultCreportUndefinedSystemCall;
this->result = ResultUndefinedSystemCall();
break;
case svc::DebugExceptionType::SystemMemoryError:
this->result = ResultCreportSystemMemoryError;
this->result = ResultSystemMemoryError();
break;
case svc::DebugExceptionType::DebuggerAttached:
case svc::DebugExceptionType::BreakPoint:
@ -306,7 +306,7 @@ namespace sts::creport {
void CrashReport::SaveToFile(FILE *f_report) {
fprintf(f_report, "Atmosphère Crash Report (v1.4):\n");
fprintf(f_report, "Result: 0x%X (2%03d-%04d)\n\n", this->result, R_MODULE(this->result), R_DESCRIPTION(this->result));
fprintf(f_report, "Result: 0x%X (2%03d-%04d)\n\n", this->result.GetValue(), this->result.GetModule(), this->result.GetDescription());
/* Process Info. */
char name_buf[0x10] = {};

View file

@ -30,7 +30,7 @@ namespace sts::creport {
private:
Handle debug_handle = INVALID_HANDLE;
bool has_extra_info = true;
Result result = ResultCreportIncompleteReport;
Result result = ResultIncompleteReport();
/* Attach process info. */
svc::DebugInfoAttachProcess process_info = {};
@ -55,7 +55,7 @@ namespace sts::creport {
}
bool IsComplete() const {
return this->result != ResultCreportIncompleteReport;
return !ResultIncompleteReport::Includes(this->result);
}
bool IsOpen() const {

View file

@ -52,6 +52,12 @@ namespace sts::ams {
}
namespace sts::result {
bool CallFatalOnResultAssertion = true;
}
using namespace sts;
void __libnx_exception_handler(ThreadExceptionDump *ctx) {
@ -136,5 +142,5 @@ int main(int argc, char **argv) {
/* Throw fatal error. */
FatalContext ctx;
g_crash_report.GetFatalContext(&ctx);
fatalWithContext(g_crash_report.GetResult(), FatalType_ErrorScreen, &ctx);
fatalWithContext(g_crash_report.GetResult().GetValue(), FatalType_ErrorScreen, &ctx);
}

View file

@ -31,7 +31,7 @@ DATA := data
INCLUDES := include ../../common/include
EXEFS_SRC := exefs_src
DEFINES := -DDISABLE_IPC -DATMOSPHERE_GIT_BRANCH=\"$(AMSBRANCH)\" -DATMOSPHERE_GIT_REV=\"$(AMSREV)\"
DEFINES := -DATMOSPHERE_GIT_BRANCH=\"$(AMSBRANCH)\" -DATMOSPHERE_GIT_REV=\"$(AMSREV)\"
#---------------------------------------------------------------------------------
# options for code generation
@ -45,8 +45,18 @@ CFLAGS += $(INCLUDE) -D__SWITCH__
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++17
CXXWRAPS := -Wl,--wrap,__cxa_pure_virtual \
-Wl,--wrap,__cxa_throw \
-Wl,--wrap,__cxa_rethrow \
-Wl,--wrap,__cxa_allocate_exception \
-Wl,--wrap,__cxa_begin_catch \
-Wl,--wrap,__cxa_end_catch \
-Wl,--wrap,__cxa_call_unexpected \
-Wl,--wrap,__cxa_call_terminate \
-Wl,--wrap,__gxx_personality_v0
ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) $(CXXWRAPS) -Wl,-Map,$(notdir $*.map)
LIBS := -lstratosphere -lnx

View file

@ -37,11 +37,8 @@ namespace sts::dmnt::cheat {
}
Result CheatService::ForceOpenCheatProcess() {
if (R_FAILED(dmnt::cheat::impl::ForceOpenCheatProcess())) {
return ResultDmntCheatNotAttached;
}
return ResultSuccess;
R_UNLESS(R_SUCCEEDED(dmnt::cheat::impl::ForceOpenCheatProcess()), ResultCheatNotAttached());
return ResultSuccess();
}
/* ========================================================================================= */
@ -53,26 +50,17 @@ namespace sts::dmnt::cheat {
}
Result CheatService::GetCheatProcessMappings(const sf::OutArray<MemoryInfo> &mappings, sf::Out<u64> out_count, u64 offset) {
if (mappings.GetPointer() == nullptr) {
return ResultDmntCheatNullBuffer;
}
R_UNLESS(mappings.GetPointer() != nullptr, ResultCheatNullBuffer());
return dmnt::cheat::impl::GetCheatProcessMappings(mappings.GetPointer(), mappings.GetSize(), out_count.GetPointer(), offset);
}
Result CheatService::ReadCheatProcessMemory(const sf::OutBuffer &buffer, u64 address, u64 out_size) {
if (buffer.GetPointer() == nullptr) {
return ResultDmntCheatNullBuffer;
}
R_UNLESS(buffer.GetPointer() != nullptr, ResultCheatNullBuffer());
return dmnt::cheat::impl::ReadCheatProcessMemory(address, buffer.GetPointer(), std::min(out_size, buffer.GetSize()));
}
Result CheatService::WriteCheatProcessMemory(const sf::InBuffer &buffer, u64 address, u64 in_size) {
if (buffer.GetPointer() == nullptr) {
return ResultDmntCheatNullBuffer;
}
R_UNLESS(buffer.GetPointer() != nullptr, ResultCheatNullBuffer());
return dmnt::cheat::impl::WriteCheatProcessMemory(address, buffer.GetPointer(), std::min(in_size, buffer.GetSize()));
}
@ -89,10 +77,7 @@ namespace sts::dmnt::cheat {
}
Result CheatService::GetCheats(const sf::OutArray<CheatEntry> &cheats, sf::Out<u64> out_count, u64 offset) {
if (cheats.GetPointer() == nullptr) {
return ResultDmntCheatNullBuffer;
}
R_UNLESS(cheats.GetPointer() != nullptr, ResultCheatNullBuffer());
return dmnt::cheat::impl::GetCheats(cheats.GetPointer(), cheats.GetSize(), out_count.GetPointer(), offset);
}
@ -121,10 +106,7 @@ namespace sts::dmnt::cheat {
}
Result CheatService::GetFrozenAddresses(const sf::OutArray<FrozenAddressEntry> &addresses, sf::Out<u64> out_count, u64 offset) {
if (addresses.GetPointer() == nullptr) {
return ResultDmntCheatNullBuffer;
}
R_UNLESS(addresses.GetPointer() != nullptr, ResultCheatNullBuffer());
return dmnt::cheat::impl::GetFrozenAddresses(addresses.GetPointer(), addresses.GetSize(), out_count.GetPointer(), offset);
}
@ -133,16 +115,10 @@ namespace sts::dmnt::cheat {
}
Result CheatService::EnableFrozenAddress(sf::Out<u64> out_value, u64 address, u64 width) {
switch (width) {
case 1:
case 2:
case 4:
case 8:
break;
default:
return ResultDmntCheatInvalidFreezeWidth;
}
/* Width needs to be a power of two <= 8. */
R_UNLESS(width > 0, ResultFrozenAddressInvalidWidth());
R_UNLESS(width <= sizeof(u64), ResultFrozenAddressInvalidWidth());
R_UNLESS((width & (width - 1)) == 0, ResultFrozenAddressInvalidWidth());
return dmnt::cheat::impl::EnableFrozenAddress(out_value.GetPointer(), address, width);
}

View file

@ -169,10 +169,8 @@ namespace sts::dmnt::cheat::impl {
}
Result EnsureCheatProcess() {
if (!this->HasActiveCheatProcess()) {
return ResultDmntCheatNotAttached;
}
return ResultSuccess;
R_UNLESS(this->HasActiveCheatProcess(), ResultCheatNotAttached());
return ResultSuccess();
}
Handle GetCheatProcessHandle() const {
@ -235,7 +233,7 @@ namespace sts::dmnt::cheat::impl {
R_TRY(this->EnsureCheatProcess());
std::memcpy(out, &this->cheat_process_metadata, sizeof(*out));
return ResultSuccess;
return ResultSuccess();
}
Result ForceOpenCheatProcess() {
@ -263,7 +261,7 @@ namespace sts::dmnt::cheat::impl {
}
}
return ResultSuccess;
return ResultSuccess();
}
Result GetCheatProcessMappingCount(u64 *out_count) {
@ -288,7 +286,7 @@ namespace sts::dmnt::cheat::impl {
} while (address != 0);
*out_count = count;
return ResultSuccess;
return ResultSuccess();
}
Result GetCheatProcessMappings(MemoryInfo *mappings, size_t max_count, u64 *out_count, u64 offset) {
@ -316,7 +314,7 @@ namespace sts::dmnt::cheat::impl {
} while (address != 0 && written_count < max_count);
*out_count = written_count;
return ResultSuccess;
return ResultSuccess();
}
Result ReadCheatProcessMemory(u64 proc_addr, void *out_data, size_t size) {
@ -357,7 +355,7 @@ namespace sts::dmnt::cheat::impl {
}
*out_count = count;
return ResultSuccess;
return ResultSuccess();
}
Result GetCheats(CheatEntry *out_cheats, size_t max_count, u64 *out_count, u64 offset) {
@ -376,7 +374,7 @@ namespace sts::dmnt::cheat::impl {
}
*out_count = count;
return ResultSuccess;
return ResultSuccess();
}
Result GetCheatById(CheatEntry *out_cheat, u32 cheat_id) {
@ -385,12 +383,11 @@ namespace sts::dmnt::cheat::impl {
R_TRY(this->EnsureCheatProcess());
const CheatEntry *entry = this->GetCheatEntryById(cheat_id);
if (entry == nullptr || entry->definition.num_opcodes == 0) {
return ResultDmntCheatUnknownChtId;
}
R_UNLESS(entry != nullptr, ResultCheatUnknownId());
R_UNLESS(entry->definition.num_opcodes != 0, ResultCheatUnknownId());
*out_cheat = *entry;
return ResultSuccess;
return ResultSuccess();
}
Result ToggleCheat(u32 cheat_id) {
@ -399,20 +396,17 @@ namespace sts::dmnt::cheat::impl {
R_TRY(this->EnsureCheatProcess());
CheatEntry *entry = this->GetCheatEntryById(cheat_id);
if (entry == nullptr || entry->definition.num_opcodes == 0) {
return ResultDmntCheatUnknownChtId;
}
R_UNLESS(entry != nullptr, ResultCheatUnknownId());
R_UNLESS(entry->definition.num_opcodes != 0, ResultCheatUnknownId());
if (cheat_id == 0) {
return ResultDmntCheatCannotDisableMasterCheat;
}
R_UNLESS(cheat_id != 0, ResultCheatCannotDisable());
entry->enabled = !entry->enabled;
/* Trigger a VM reload. */
this->SetNeedsReloadVm(true);
return ResultSuccess;
return ResultSuccess();
}
Result AddCheat(u32 *out_id, const CheatDefinition &def, bool enabled) {
@ -420,14 +414,11 @@ namespace sts::dmnt::cheat::impl {
R_TRY(this->EnsureCheatProcess());
if (def.num_opcodes == 0 || def.num_opcodes > util::size(def.opcodes)) {
return ResultDmntCheatInvalidCheat;
}
R_UNLESS(def.num_opcodes != 0, ResultCheatInvalid());
R_UNLESS(def.num_opcodes <= util::size(def.opcodes), ResultCheatInvalid());
CheatEntry *new_entry = this->GetFreeCheatEntry();
if (new_entry == nullptr) {
return ResultDmntCheatOutOfCheats;
}
R_UNLESS(new_entry != nullptr, ResultCheatOutOfResource());
new_entry->enabled = enabled;
new_entry->definition = def;
@ -435,24 +426,21 @@ namespace sts::dmnt::cheat::impl {
/* Trigger a VM reload. */
this->SetNeedsReloadVm(true);
return ResultSuccess;
return ResultSuccess();
}
Result RemoveCheat(u32 cheat_id) {
std::scoped_lock lk(this->cheat_lock);
R_TRY(this->EnsureCheatProcess());
if (cheat_id >= MaxCheatCount) {
return ResultDmntCheatUnknownChtId;
}
R_UNLESS(cheat_id < MaxCheatCount, ResultCheatUnknownId());
this->ResetCheatEntry(cheat_id);
/* Trigger a VM reload. */
this->SetNeedsReloadVm(true);
return ResultSuccess;
return ResultSuccess();
}
Result GetFrozenAddressCount(u64 *out_count) {
@ -461,7 +449,7 @@ namespace sts::dmnt::cheat::impl {
R_TRY(this->EnsureCheatProcess());
*out_count = this->frozen_addresses_map.size();
return ResultSuccess;
return ResultSuccess();
}
Result GetFrozenAddresses(FrozenAddressEntry *frz_addrs, size_t max_count, u64 *out_count, u64 offset) {
@ -484,7 +472,7 @@ namespace sts::dmnt::cheat::impl {
}
*out_count = written_count;
return ResultSuccess;
return ResultSuccess();
}
Result GetFrozenAddress(FrozenAddressEntry *frz_addr, u64 address) {
@ -493,13 +481,11 @@ namespace sts::dmnt::cheat::impl {
R_TRY(this->EnsureCheatProcess());
const auto it = this->frozen_addresses_map.find(address);
if (it == this->frozen_addresses_map.end()) {
return ResultDmntCheatAddressNotFrozen;
}
R_UNLESS(it != this->frozen_addresses_map.end(), ResultFrozenAddressNotFound());
frz_addr->address = it->first;
frz_addr->value = it->second;
return ResultSuccess;
return ResultSuccess();
}
Result EnableFrozenAddress(u64 *out_value, u64 address, u64 width) {
@ -507,14 +493,10 @@ namespace sts::dmnt::cheat::impl {
R_TRY(this->EnsureCheatProcess());
if (this->frozen_addresses_map.size() >= MaxFrozenAddressCount) {
return ResultDmntCheatTooManyFrozenAddresses;
}
R_UNLESS(this->frozen_addresses_map.size() < MaxFrozenAddressCount, ResultFrozenAddressOutOfResource());
const auto it = this->frozen_addresses_map.find(address);
if (it != this->frozen_addresses_map.end()) {
return ResultDmntCheatAddressAlreadyFrozen;
}
R_UNLESS(it == this->frozen_addresses_map.end(), ResultFrozenAddressAlreadyExists());
FrozenAddressValue value = {};
value.width = width;
@ -522,7 +504,7 @@ namespace sts::dmnt::cheat::impl {
this->frozen_addresses_map[address] = value;
*out_value = value.value;
return ResultSuccess;
return ResultSuccess();
}
Result DisableFrozenAddress(u64 address) {
@ -531,12 +513,10 @@ namespace sts::dmnt::cheat::impl {
R_TRY(this->EnsureCheatProcess());
const auto it = this->frozen_addresses_map.find(address);
if (it == this->frozen_addresses_map.end()) {
return ResultDmntCheatAddressNotFrozen;
}
R_UNLESS(it != this->frozen_addresses_map.end(), ResultFrozenAddressNotFound());
this->frozen_addresses_map.erase(it);
return ResultSuccess;
return ResultSuccess();
}
};
@ -626,9 +606,7 @@ namespace sts::dmnt::cheat::impl {
{
if (this->HasActiveCheatProcess()) {
/* When forcing attach, we're done. */
if (!on_process_launch) {
return ResultSuccess;
}
R_UNLESS(on_process_launch, ResultSuccess());
}
/* Detach from the current process, if it's open. */
@ -667,9 +645,7 @@ namespace sts::dmnt::cheat::impl {
/* If new process launch, we may not want to actually attach. */
if (on_process_launch) {
if (!cfg::IsCheatEnableKeyHeld(this->cheat_process_metadata.title_id)) {
return ResultDmntCheatNotAttached;
}
R_UNLESS(cfg::IsCheatEnableKeyHeld(this->cheat_process_metadata.title_id), ResultCheatNotAttached());
}
/* Get module information from loader. */
@ -689,7 +665,7 @@ namespace sts::dmnt::cheat::impl {
} else if (num_modules == 1 && !on_process_launch) {
proc_module = &proc_modules[0];
} else {
return ResultDmntCheatNotAttached;
return ResultCheatNotAttached();
}
this->cheat_process_metadata.main_nso_extents.base = proc_module->base_address;
@ -701,9 +677,7 @@ namespace sts::dmnt::cheat::impl {
if (!this->LoadCheats(this->cheat_process_metadata.title_id, this->cheat_process_metadata.main_nso_build_id) ||
!this->LoadCheatToggles(this->cheat_process_metadata.title_id)) {
/* If new process launch, require success. */
if (on_process_launch) {
return ResultDmntCheatNotAttached;
}
R_UNLESS(!on_process_launch, ResultCheatNotAttached());
}
/* Open a debug handle. */
@ -723,7 +697,7 @@ namespace sts::dmnt::cheat::impl {
/* Signal to our fans. */
this->cheat_process_event.Signal();
return ResultSuccess;
return ResultSuccess();
}
#undef R_ASSERT_IF_NEW_PROCESS

View file

@ -631,7 +631,7 @@ namespace sts::dmnt::cheat::impl {
/* However, I don't actually believe it is possible for this to happen. */
/* I guess we'll throw a fatal error here, so as to encourage me to fix the VM */
/* in the event that someone triggers it? I don't know how you'd do that. */
fatalSimple(ResultDmntCheatVmInvalidCondDepth);
R_ASSERT(ResultVirtualMachineInvalidConditionDepth());
}
}

View file

@ -49,6 +49,12 @@ namespace sts::ams {
}
namespace sts::result {
bool CallFatalOnResultAssertion = true;
}
using namespace sts;
void __libnx_initheap(void) {

View file

@ -41,12 +41,10 @@ namespace sts::dmnt {
Result DebugMonitorService::GetProcessHandle(sf::Out<Handle> out_hnd, os::ProcessId pid) {
R_TRY_CATCH(svcDebugActiveProcess(out_hnd.GetPointer(), static_cast<u64>(pid))) {
R_CATCH(ResultKernelAlreadyExists) {
return ResultDebugAlreadyAttached;
}
R_CONVERT(svc::ResultBusy, dbg::ResultAlreadyAttached());
} R_END_TRY_CATCH;
return ResultSuccess;
return ResultSuccess();
}
Result DebugMonitorService::WaitSynchronization(Handle hnd, u64 ns) {

View file

@ -51,13 +51,11 @@ namespace sts::dmnt {
Result EnsureSdInitialized() {
std::scoped_lock lk(g_sd_lock);
if (g_sd_initialized) {
return ResultSuccess;
}
R_UNLESS(!g_sd_initialized, ResultSuccess());
R_TRY(fsOpenSdCardFileSystem(&g_sd_fs));
g_sd_initialized = true;
return ResultSuccess;
return ResultSuccess();
}
TargetIOFileHandle GetNewFileHandle(FsFile f) {
@ -73,10 +71,10 @@ namespace sts::dmnt {
if (g_file_handles.find(handle) != g_file_handles.end()) {
*out = g_file_handles[handle];
return ResultSuccess;
return ResultSuccess();
}
return ResultFsInvalidArgument;
return fs::ResultInvalidArgument();
}
Result CloseFileByHandle(TargetIOFileHandle handle) {
@ -85,10 +83,10 @@ namespace sts::dmnt {
if (g_file_handles.find(handle) != g_file_handles.end()) {
fsFileClose(&g_file_handles[handle]);
g_file_handles.erase(handle);
return ResultSuccess;
return ResultSuccess();
}
return ResultFsInvalidArgument;
return fs::ResultInvalidArgument();
}
void FixPath(char *dst, size_t dst_size, const sf::InBuffer &path) {
@ -139,9 +137,7 @@ namespace sts::dmnt {
/* Open the file, guard to prevent failure to close. */
FsFile f;
R_TRY(fsFsOpenFile(&g_sd_fs, fs_path, open_mode, &f));
auto file_guard = SCOPE_GUARD {
fsFileClose(&f);
};
auto file_guard = SCOPE_GUARD { fsFileClose(&f); };
/* Set size if needed. */
if (create_mode == TIOCreateOption_ResetSize) {
@ -152,7 +148,7 @@ namespace sts::dmnt {
file_guard.Cancel();
out_hnd.SetValue(GetNewFileHandle(f));
return ResultSuccess;
return ResultSuccess();
}
Result DebugMonitorService::TargetIO_FileClose(TargetIOFileHandle hnd) {
@ -167,7 +163,7 @@ namespace sts::dmnt {
R_TRY(fsFileRead(&f, offset, out_data.GetPointer(), out_data.GetSize(), FsReadOption_None, &read));
out_read.SetValue(static_cast<u32>(read));
return ResultSuccess;
return ResultSuccess();
}
Result DebugMonitorService::TargetIO_FileWrite(TargetIOFileHandle hnd, const sf::InNonSecureBuffer &data, sf::Out<u32> out_written, u64 offset) {
@ -177,13 +173,13 @@ namespace sts::dmnt {
R_TRY(fsFileWrite(&f, offset, data.GetPointer(), data.GetSize(), FsWriteOption_None));
out_written.SetValue(data.GetSize());
return ResultSuccess;
return ResultSuccess();
}
Result DebugMonitorService::TargetIO_FileSetAttributes(const sf::InBuffer &path, const sf::InBuffer &attributes) {
/* I don't really know why this command exists, Horizon doesn't allow you to set any attributes. */
/* N just returns ResultSuccess unconditionally here. */
return ResultSuccess;
return ResultSuccess();
}
Result DebugMonitorService::TargetIO_FileGetInformation(const sf::InBuffer &path, const sf::OutArray<u64> &out_info, sf::Out<int> is_directory) {
@ -214,12 +210,12 @@ namespace sts::dmnt {
is_directory.SetValue(1);
}
return ResultSuccess;
return ResultSuccess();
}
Result DebugMonitorService::TargetIO_FileSetTime(const sf::InBuffer &path, u64 create, u64 access, u64 modify) {
/* This is another function that doesn't really need to exist, because Horizon doesn't let you set anything. */
return ResultSuccess;
return ResultSuccess();
}
Result DebugMonitorService::TargetIO_FileSetSize(const sf::InBuffer &input, u64 size) {
@ -229,9 +225,7 @@ namespace sts::dmnt {
/* We will try to be better than N, here. N only treats input as a path. */
FsFile f;
if (input.GetSize() == sizeof(TargetIOFileHandle)) {
if (R_SUCCEEDED(GetFileByHandle(&f, *reinterpret_cast<const TargetIOFileHandle *>(input.GetPointer())))) {
return fsFileSetSize(&f, size);
}
R_UNLESS(R_FAILED(GetFileByHandle(&f, *reinterpret_cast<const TargetIOFileHandle *>(input.GetPointer()))), fsFileSetSize(&f, size));
}
char fs_path[FS_MAX_PATH];

View file

@ -31,7 +31,7 @@ DATA := data
INCLUDES := include ../../common/include
EXEFS_SRC := exefs_src
DEFINES := -DDISABLE_IPC -DATMOSPHERE_GIT_BRANCH=\"$(AMSBRANCH)\" -DATMOSPHERE_GIT_REV=\"$(AMSREV)\" -DINI_MAX_LINE=768
DEFINES := -DATMOSPHERE_GIT_BRANCH=\"$(AMSBRANCH)\" -DATMOSPHERE_GIT_REV=\"$(AMSREV)\" -DINI_MAX_LINE=768
#---------------------------------------------------------------------------------
# options for code generation
@ -45,8 +45,18 @@ CFLAGS += $(INCLUDE) -D__SWITCH__
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++17
CXXWRAPS := -Wl,--wrap,__cxa_pure_virtual \
-Wl,--wrap,__cxa_throw \
-Wl,--wrap,__cxa_rethrow \
-Wl,--wrap,__cxa_allocate_exception \
-Wl,--wrap,__cxa_begin_catch \
-Wl,--wrap,__cxa_end_catch \
-Wl,--wrap,__cxa_call_unexpected \
-Wl,--wrap,__cxa_call_terminate \
-Wl,--wrap,__gxx_personality_v0
ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) $(CXXWRAPS) -Wl,-Map,$(notdir $*.map)
LIBS := -lstratosphere -lnx

View file

@ -48,6 +48,12 @@ namespace sts::ams {
}
namespace sts::result {
bool CallFatalOnResultAssertion = false;
}
using namespace sts;
void __libnx_exception_handler(ThreadExceptionDump *ctx) {

View file

@ -31,7 +31,7 @@ DATA := data
INCLUDES := include ../../common/include
EXEFS_SRC := exefs_src
DEFINES := -DRESULT_ABORT_ON_ASSERT -DATMOSPHERE_GIT_BRANCH=\"$(AMSBRANCH)\" -DATMOSPHERE_GIT_REV=\"$(AMSREV)\"
DEFINES := -DATMOSPHERE_GIT_BRANCH=\"$(AMSBRANCH)\" -DATMOSPHERE_GIT_REV=\"$(AMSREV)\"
#---------------------------------------------------------------------------------
# options for code generation
@ -45,8 +45,18 @@ CFLAGS += $(INCLUDE) -D__SWITCH__ `freetype-config --cflags`
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++17
CXXWRAPS := -Wl,--wrap,__cxa_pure_virtual \
-Wl,--wrap,__cxa_throw \
-Wl,--wrap,__cxa_rethrow \
-Wl,--wrap,__cxa_allocate_exception \
-Wl,--wrap,__cxa_begin_catch \
-Wl,--wrap,__cxa_end_catch \
-Wl,--wrap,__cxa_call_unexpected \
-Wl,--wrap,__cxa_call_terminate \
-Wl,--wrap,__gxx_personality_v0
ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) $(CXXWRAPS) -Wl,-Map,$(notdir $*.map)
LIBS := `freetype-config --libs` -lstratosphere -lnx

View file

@ -28,7 +28,7 @@ namespace sts::fatal::srv {
u64 lr;
};
bool IsThreadFatalCaller(u32 error_code, u32 debug_handle, u64 thread_id, u64 thread_tls_addr, ThreadContext *thread_ctx) {
bool IsThreadFatalCaller(Result result, u32 debug_handle, u64 thread_id, u64 thread_tls_addr, ThreadContext *thread_ctx) {
/* Verify that the thread is running or waiting. */
{
u64 _;
@ -71,7 +71,7 @@ namespace sts::fatal::srv {
const struct {
CmifInHeader header;
u32 error_code;
Result result;
} *in_data = decltype(in_data)(request.data.data_words);
static_assert(sizeof(*in_data) == 0x14, "InData!");
@ -112,7 +112,7 @@ namespace sts::fatal::srv {
return false;
}
if (in_data->error_code != error_code) {
if (in_data->result.GetValue() != result.GetValue()) {
return false;
}
}
@ -226,7 +226,7 @@ namespace sts::fatal::srv {
continue;
}
if (IsThreadFatalCaller(ctx->error_code, debug_handle.Get(), cur_thread_id, thread_id_to_tls[cur_thread_id], &thread_ctx)) {
if (IsThreadFatalCaller(ctx->result, debug_handle.Get(), cur_thread_id, thread_id_to_tls[cur_thread_id], &thread_ctx)) {
thread_id = cur_thread_id;
found_fatal_caller = true;
break;

View file

@ -29,12 +29,10 @@ namespace sts::fatal::srv {
std::scoped_lock lk{this->lock};
/* Only allow GetEvent to succeed NumFatalEvents times. */
if (this->num_events_gotten >= FatalEventManager::NumFatalEvents) {
return ResultFatalTooManyEvents;
}
R_UNLESS(this->num_events_gotten < FatalEventManager::NumFatalEvents, ResultTooManyEvents());
*out = this->events[this->num_events_gotten++].revent;
return ResultSuccess;
return ResultSuccess();
}
void FatalEventManager::SignalEvents() {

View file

@ -57,6 +57,12 @@ namespace sts::ams {
}
namespace sts::result {
bool CallFatalOnResultAssertion = false;
}
using namespace sts;
void __libnx_exception_handler(ThreadExceptionDump *ctx) {

View file

@ -106,11 +106,11 @@ namespace sts::fatal::srv {
void CheckRepairStatus() {
if (IsInRepairWithoutVolHeld()) {
ThrowFatalForSelf(ResultFatalInRepairWithoutVolHeld);
ThrowFatalForSelf(ResultInRepairWithoutVolHeld());
}
if (IsInRepairWithoutTimeReviserCartridge()) {
ThrowFatalForSelf(ResultFatalInRepairWithoutTimeReviserCartridge);
ThrowFatalForSelf(ResultInRepairWithoutTimeReviserCartridge());
}
}

View file

@ -33,11 +33,9 @@ namespace sts::fatal::srv {
bool has_thrown;
private:
Result TrySetHasThrown() {
if (this->has_thrown) {
return ResultFatalAlreadyThrown;
}
R_UNLESS(!this->has_thrown, ResultAlreadyThrown());
this->has_thrown = true;
return ResultSuccess;
return ResultSuccess();
}
public:
ServiceContext() {
@ -51,32 +49,30 @@ namespace sts::fatal::srv {
return this->event_manager.GetEvent(out);
}
Result ThrowFatal(u32 error_code, os::ProcessId process_id) {
return this->ThrowFatalWithCpuContext(error_code, process_id, FatalType_ErrorReportAndErrorScreen, {});
Result ThrowFatal(Result result, os::ProcessId process_id) {
return this->ThrowFatalWithCpuContext(result, process_id, FatalType_ErrorReportAndErrorScreen, {});
}
Result ThrowFatalWithPolicy(u32 error_code, os::ProcessId process_id, FatalType policy) {
return this->ThrowFatalWithCpuContext(error_code, process_id, policy, {});
Result ThrowFatalWithPolicy(Result result, os::ProcessId process_id, FatalType policy) {
return this->ThrowFatalWithCpuContext(result, process_id, policy, {});
}
Result ThrowFatalWithCpuContext(u32 error_code, os::ProcessId process_id, FatalType policy, const CpuContext &cpu_ctx);
Result ThrowFatalWithCpuContext(Result result, os::ProcessId process_id, FatalType policy, const CpuContext &cpu_ctx);
};
/* Context global. */
ServiceContext g_context;
/* Throw implementation. */
Result ServiceContext::ThrowFatalWithCpuContext(u32 error_code, os::ProcessId process_id, FatalType policy, const CpuContext &cpu_ctx) {
Result ServiceContext::ThrowFatalWithCpuContext(Result result, os::ProcessId process_id, FatalType policy, const CpuContext &cpu_ctx) {
/* We don't support Error Report only fatals. */
if (policy == FatalType_ErrorReport) {
return ResultSuccess;
}
R_UNLESS(policy != FatalType_ErrorReport, ResultSuccess());
/* Note that we've thrown fatal. */
R_TRY(this->TrySetHasThrown());
/* At this point we have exclusive access to this->context. */
this->context.error_code = error_code;
this->context.result = result;
this->context.cpu_ctx = cpu_ctx;
/* Cap the stack trace to a sane limit. */
@ -108,8 +104,8 @@ namespace sts::fatal::srv {
this->context.generate_error_report = (policy == FatalType_ErrorReportAndErrorScreen);
/* Adjust error code (2000-0000 -> 2162-0002). */
if (this->context.error_code == ResultSuccess) {
this->context.error_code = ResultErrSystemModuleAborted;
if (R_SUCCEEDED(this->context.result)) {
this->context.result = err::ResultSystemModuleAborted();
}
switch (policy) {
@ -126,25 +122,25 @@ namespace sts::fatal::srv {
STS_UNREACHABLE_DEFAULT_CASE();
}
return ResultSuccess;
return ResultSuccess();
}
}
Result ThrowFatalForSelf(Result error_code) {
return g_context.ThrowFatalWithPolicy(static_cast<u32>(error_code), os::GetCurrentProcessId(), FatalType_ErrorScreen);
Result ThrowFatalForSelf(Result result) {
return g_context.ThrowFatalWithPolicy(result, os::GetCurrentProcessId(), FatalType_ErrorScreen);
}
Result UserService::ThrowFatal(u32 error, const sf::ClientProcessId &client_pid) {
return g_context.ThrowFatal(error, client_pid.GetValue());
Result UserService::ThrowFatal(Result result, const sf::ClientProcessId &client_pid) {
return g_context.ThrowFatal(result, client_pid.GetValue());
}
Result UserService::ThrowFatalWithPolicy(u32 error, const sf::ClientProcessId &client_pid, FatalType policy) {
return g_context.ThrowFatalWithPolicy(error, client_pid.GetValue(), policy);
Result UserService::ThrowFatalWithPolicy(Result result, const sf::ClientProcessId &client_pid, FatalType policy) {
return g_context.ThrowFatalWithPolicy(result, client_pid.GetValue(), policy);
}
Result UserService::ThrowFatalWithCpuContext(u32 error, const sf::ClientProcessId &client_pid, FatalType policy, const CpuContext &cpu_ctx) {
return g_context.ThrowFatalWithCpuContext(error, client_pid.GetValue(), policy, cpu_ctx);
Result UserService::ThrowFatalWithCpuContext(Result result, const sf::ClientProcessId &client_pid, FatalType policy, const CpuContext &cpu_ctx) {
return g_context.ThrowFatalWithCpuContext(result, client_pid.GetValue(), policy, cpu_ctx);
}
Result PrivateService::GetFatalEvent(sf::OutCopyHandle out_h) {

View file

@ -29,9 +29,9 @@ namespace sts::fatal::srv {
};
private:
/* Actual commands. */
Result ThrowFatal(u32 error, const sf::ClientProcessId &client_pid);
Result ThrowFatalWithPolicy(u32 error, const sf::ClientProcessId &client_pid, FatalType policy);
Result ThrowFatalWithCpuContext(u32 error, const sf::ClientProcessId &client_pid, FatalType policy, const CpuContext &cpu_ctx);
Result ThrowFatal(Result error, const sf::ClientProcessId &client_pid);
Result ThrowFatalWithPolicy(Result error, const sf::ClientProcessId &client_pid, FatalType policy);
Result ThrowFatalWithCpuContext(Result error, const sf::ClientProcessId &client_pid, FatalType policy, const CpuContext &cpu_ctx);
public:
DEFINE_SERVICE_DISPATCH_TABLE {
MAKE_SERVICE_COMMAND_META(ThrowFatal),

View file

@ -53,7 +53,7 @@ namespace sts::fatal::srv {
R_TRY(pcvSetClockRate(module, hz));
}
return ResultSuccess;
return ResultSuccess();
}
Result AdjustClockTask::AdjustClock() {
@ -66,7 +66,7 @@ namespace sts::fatal::srv {
R_TRY(AdjustClockForModule(PcvModule_GPU, GPU_CLOCK_307MHZ));
R_TRY(AdjustClockForModule(PcvModule_EMC, EMC_CLOCK_1331MHZ));
return ResultSuccess;
return ResultSuccess();
}
Result AdjustClockTask::Run() {

View file

@ -86,7 +86,7 @@ namespace sts::fatal::srv {
ON_SCOPE_EXIT { fclose(f_report); };
fprintf(f_report, "Atmosphère Fatal Report (v1.0):\n");
fprintf(f_report, "Result: 0x%X (2%03d-%04d)\n\n", this->context->error_code, R_MODULE(this->context->error_code), R_DESCRIPTION(this->context->error_code));
fprintf(f_report, "Result: 0x%X (2%03d-%04d)\n\n", this->context->result.GetValue(), this->context->result.GetModule(), this->context->result.GetDescription());
fprintf(f_report, "Title ID: %016lx\n", static_cast<u64>(this->context->title_id));
if (strlen(this->context->proc_name)) {
fprintf(f_report, "Process Name: %s\n", this->context->proc_name);
@ -144,7 +144,7 @@ namespace sts::fatal::srv {
/* Signal we're done with our job. */
eventFire(const_cast<Event *>(&this->context->erpt_event));
return ResultSuccess;
return ResultSuccess();
}
}

View file

@ -178,18 +178,18 @@ namespace sts::fatal::srv {
Result PowerControlTask::Run() {
this->MonitorBatteryState();
return ResultSuccess;
return ResultSuccess();
}
Result PowerButtonObserveTask::Run() {
this->WaitForPowerButton();
return ResultSuccess;
return ResultSuccess();
}
Result StateTransitionStopTask::Run() {
/* Nintendo ignores the output of this call... */
spsmPutErrorState();
return ResultSuccess;
return ResultSuccess();
}
}

View file

@ -90,9 +90,7 @@ namespace sts::fatal::srv {
ViDisplay temp_display;
/* Try to open the display. */
R_TRY_CATCH(viOpenDisplay("Internal", &temp_display)) {
R_CATCH(ResultViNotFound) {
return ResultSuccess;
}
R_CONVERT(vi::ResultNotFound, ResultSuccess());
} R_END_TRY_CATCH;
/* Guarantee we close the display. */
@ -109,16 +107,14 @@ namespace sts::fatal::srv {
/* Set alpha to 1.0f. */
R_TRY(viSetDisplayAlpha(&temp_display, 1.0f));
return ResultSuccess;
return ResultSuccess();
}
Result ShowFatalTask::SetupDisplayExternal() {
ViDisplay temp_display;
/* Try to open the display. */
R_TRY_CATCH(viOpenDisplay("External", &temp_display)) {
R_CATCH(ResultViNotFound) {
return ResultSuccess;
}
R_CONVERT(vi::ResultNotFound, ResultSuccess());
} R_END_TRY_CATCH;
/* Guarantee we close the display. */
@ -127,7 +123,7 @@ namespace sts::fatal::srv {
/* Set alpha to 1.0f. */
R_TRY(viSetDisplayAlpha(&temp_display, 1.0f));
return ResultSuccess;
return ResultSuccess();
}
Result ShowFatalTask::PrepareScreenForDrawing() {
@ -182,7 +178,7 @@ namespace sts::fatal::srv {
R_TRY(framebufferCreate(&this->fb, &this->win, raw_width, raw_height, PIXEL_FORMAT_RGB_565, 1));
}
return ResultSuccess;
return ResultSuccess();
}
Result ShowFatalTask::ShowFatal() {
@ -195,9 +191,7 @@ namespace sts::fatal::srv {
/* Dequeue a buffer. */
u16 *tiled_buf = reinterpret_cast<u16 *>(framebufferBegin(&this->fb, NULL));
if (tiled_buf == nullptr) {
return ResultFatalNullGraphicsBuffer;
}
R_UNLESS(tiled_buf != nullptr, ResultNullGraphicsBuffer());
/* Let the font manager know about our framebuffer. */
font::ConfigureFontFramebuffer(tiled_buf, GetPixelOffset);
@ -218,13 +212,13 @@ namespace sts::fatal::srv {
/* TODO: Actually draw meaningful shit here. */
font::SetPosition(32, 64);
font::SetFontSize(16.0f);
font::PrintFormat(config.GetErrorMessage(), R_MODULE(this->context->error_code), R_DESCRIPTION(this->context->error_code), this->context->error_code);
font::PrintFormat(config.GetErrorMessage(), this->context->result.GetModule(), this->context->result.GetDescription(), this->context->result.GetValue());
font::AddSpacingLines(0.5f);
font::PrintFormatLine("Title: %016lX", static_cast<u64>(this->context->title_id));
font::AddSpacingLines(0.5f);
font::PrintFormatLine(u8"Firmware: %s (Atmosphère %u.%u.%u-%s)", config.GetFirmwareVersion().display_version, ATMOSPHERE_RELEASE_VERSION, ams::GetGitRevision());
font::AddSpacingLines(1.5f);
if (this->context->error_code != ResultAtmosphereVersionMismatch) {
if (!ams::ResultVersionMismatch::Includes(this->context->result)) {
font::Print(config.GetErrorDescription());
} else {
/* Print a special message for atmosphere version mismatch. */
@ -415,7 +409,7 @@ namespace sts::fatal::srv {
/* Enqueue the buffer. */
framebufferEnd(&fb);
return ResultSuccess;
return ResultSuccess();
}
Result ShowFatalTask::Run() {
@ -431,7 +425,7 @@ namespace sts::fatal::srv {
Result BacklightControlTask::Run() {
TurnOnBacklight();
return ResultSuccess;
return ResultSuccess();
}
}

View file

@ -86,7 +86,7 @@ namespace sts::fatal::srv {
Result StopSoundTask::Run() {
StopSound();
return ResultSuccess;
return ResultSuccess();
}
}

View file

@ -16,7 +16,7 @@ include $(DEVKITPRO)/libnx/switch_rules
# INCLUDES is a list of directories containing header files
#---------------------------------------------------------------------------------
TARGET := $(notdir $(CURDIR))
SOURCES := source source/ams source/os source/os/impl source/dd source/sf source/sf/cmif source/sf/hipc source/dmnt source/spl source/spl/smc source/updater source/patcher source/map source/rnd source/util source/sm source/cfg source/pm source/hid source/ldr source/kvdb source/boot2
SOURCES := source source/ams source/result source/os source/os/impl source/dd source/sf source/sf/cmif source/sf/hipc source/dmnt source/spl source/spl/smc source/updater source/patcher source/map source/rnd source/util source/sm source/cfg source/pm source/hid source/ldr source/kvdb source/boot2
DATA := data
INCLUDES := include

View file

@ -40,7 +40,7 @@ namespace sts::ams {
const u32 build_version = GetVersion(ATMOSPHERE_RELEASE_VERSION);
if (runtime_version < build_version) {
R_ASSERT(ResultAtmosphereVersionMismatch);
R_ASSERT(ams::ResultVersionMismatch());
}
}

View file

@ -33,6 +33,7 @@
cls& operator=(cls&&) = delete
#define ALIGNED(algn) __attribute__((aligned(algn)))
#define NORETURN __attribute__((noreturn))
#define WEAK __attribute__((weak))

View file

@ -320,7 +320,7 @@ namespace sts::fatal {
namespace srv {
struct ThrowContext {
u32 error_code;
Result result;
ncm::TitleId title_id;
char proc_name[0xD];
bool is_creport;
@ -332,7 +332,16 @@ namespace sts::fatal {
u8 stack_dump[0x100];
void ClearState() {
std::memset(this, 0, sizeof(*this));
this->result = ResultSuccess();
this->title_id = ncm::TitleId::Invalid;
std::memset(this->proc_name, 0, sizeof(this->proc_name));
this->is_creport = false;
std::memset(&this->cpu_ctx, 0, sizeof(this->cpu_ctx));
this->generate_error_report = false;
std::memset(&this->erpt_event, 0, sizeof(this->erpt_event));
std::memset(&this->battery_event, 0, sizeof(this->battery_event));
this->stack_dump_size = 0;
std::memset(this->stack_dump, 0, sizeof(this->stack_dump));
}
};

View file

@ -73,10 +73,10 @@ namespace sts::kvdb {
/* Allocate a buffer. */
this->buffer = static_cast<u8 *>(std::malloc(size));
if (this->buffer == nullptr) {
return ResultKvdbAllocationFailed;
return ResultAllocationFailed();
}
this->size = size;
return ResultSuccess;
return ResultSuccess();
}
Result Initialize(const void *buf, size_t size) {
@ -86,7 +86,7 @@ namespace sts::kvdb {
/* Copy the input data in. */
std::memcpy(this->buffer, buf, size);
return ResultSuccess;
return ResultSuccess();
}
};
}

View file

@ -56,7 +56,7 @@ namespace sts::kvdb {
return fsdevGetLastResult();
}
return ResultSuccess;
return ResultSuccess();
}
private:
void RemoveIndex(size_t i) {
@ -105,7 +105,7 @@ namespace sts::kvdb {
}
}
return ResultSuccess;
return ResultSuccess();
}
Result Save() {
@ -129,7 +129,7 @@ namespace sts::kvdb {
/* Flush. */
fflush(fp);
return ResultSuccess;
return ResultSuccess();
}
size_t GetCount() const {
@ -235,7 +235,7 @@ namespace sts::kvdb {
R_CATCH(ResultFsPathNotFound) {
/* If the path doesn't exist, nothing has gone wrong. */
*out = false;
return ResultSuccess;
return ResultSuccess();
}
} R_END_TRY_CATCH;
}
@ -246,7 +246,7 @@ namespace sts::kvdb {
}
*out = true;
return ResultSuccess;
return ResultSuccess();
}
static Result DirectoryExists(bool *out, const char *path) {
@ -264,7 +264,7 @@ namespace sts::kvdb {
return fsdevGetLastResult();
}
return ResultSuccess;
return ResultSuccess();
}
static Result ValidateExistingCache(const char *dir) {
@ -283,7 +283,7 @@ namespace sts::kvdb {
return ResultKvdbInvalidFilesystemState;
}
return ResultSuccess;
return ResultSuccess();
}
private:
void RemoveOldestKey() {
@ -305,7 +305,7 @@ namespace sts::kvdb {
/* layout it can't really be fixed without breaking existing devices... */
R_TRY(this->kvs.Initialize(dir));
return ResultSuccess;
return ResultSuccess();
}
size_t GetCount() const {
@ -380,7 +380,7 @@ namespace sts::kvdb {
/* Save the list. */
R_TRY(this->lru_list.Save());
return ResultSuccess;
return ResultSuccess();
}
template<typename Value>
@ -394,7 +394,7 @@ namespace sts::kvdb {
R_TRY(this->kvs.Remove(key));
R_TRY(this->lru_list.Save());
return ResultSuccess;
return ResultSuccess();
}
Result RemoveAll() {
@ -404,7 +404,7 @@ namespace sts::kvdb {
}
R_TRY(this->lru_list.Save());
return ResultSuccess;
return ResultSuccess();
}
};

View file

@ -97,7 +97,7 @@ namespace sts::kvdb {
size_t size = 0;
R_TRY(this->Get(&size, out_value, sizeof(Value), key));
STS_ASSERT(size >= sizeof(Value));
return ResultSuccess;
return ResultSuccess();
}
template<typename Key>

View file

@ -128,7 +128,7 @@ namespace sts::kvdb {
return ResultKvdbAllocationFailed;
}
this->capacity = capacity;
return ResultSuccess;
return ResultSuccess();
}
Result Set(const Key &key, const void *value, size_t value_size) {
@ -156,7 +156,7 @@ namespace sts::kvdb {
/* Save the new Entry in the map. */
*it = Entry(key, new_value, value_size);
return ResultSuccess;
return ResultSuccess();
}
Result AddUnsafe(const Key &key, void *value, size_t value_size) {
@ -165,7 +165,7 @@ namespace sts::kvdb {
}
this->entries[this->count++] = Entry(key, value, value_size);
return ResultSuccess;
return ResultSuccess();
}
Result Remove(const Key &key) {
@ -178,7 +178,7 @@ namespace sts::kvdb {
std::free(it->GetValuePointer());
std::memmove(it, it + 1, sizeof(*it) * (this->end() - (it + 1)));
this->count--;
return ResultSuccess;
return ResultSuccess();
}
/* If it's not, we didn't remove it. */
@ -292,7 +292,7 @@ namespace sts::kvdb {
/* Initialize our index. */
R_TRY(this->index.Initialize(capacity));
return ResultSuccess;
return ResultSuccess();
}
Result Initialize(size_t capacity) {
@ -303,7 +303,7 @@ namespace sts::kvdb {
/* Initialize our index. */
R_TRY(this->index.Initialize(capacity));
return ResultSuccess;
return ResultSuccess();
}
size_t GetCount() const {
@ -323,7 +323,7 @@ namespace sts::kvdb {
AutoBuffer buffer;
R_TRY_CATCH(this->ReadArchiveFile(&buffer)) {
R_CATCH(ResultFsPathNotFound) {
return ResultSuccess;
return ResultSuccess();
}
} R_END_TRY_CATCH;
@ -356,7 +356,7 @@ namespace sts::kvdb {
}
}
return ResultSuccess;
return ResultSuccess();
}
Result Save() {
@ -406,7 +406,7 @@ namespace sts::kvdb {
size_t size = std::min(max_out_size, it->GetValueSize());
std::memcpy(out_value, it->GetValuePointer(), size);
*out_size = size;
return ResultSuccess;
return ResultSuccess();
}
template<typename Value = void>
@ -418,7 +418,7 @@ namespace sts::kvdb {
}
*out_value = it->template GetValuePointer<Value>();
return ResultSuccess;
return ResultSuccess();
}
template<typename Value = void>
@ -430,7 +430,7 @@ namespace sts::kvdb {
}
*out_value = it->template GetValuePointer<Value>();
return ResultSuccess;
return ResultSuccess();
}
template<typename Value>
@ -442,7 +442,7 @@ namespace sts::kvdb {
}
*out_value = it->template GetValue<Value>();
return ResultSuccess;
return ResultSuccess();
}
Result GetValueSize(size_t *out_size, const Key &key) const {
@ -453,7 +453,7 @@ namespace sts::kvdb {
}
*out_size = it->GetValueSize();
return ResultSuccess;
return ResultSuccess();
}
Result Remove(const Key &key) {
@ -528,7 +528,7 @@ namespace sts::kvdb {
return fsdevGetLastResult();
}
return ResultSuccess;
return ResultSuccess();
}
size_t GetArchiveSize() const {
@ -560,7 +560,7 @@ namespace sts::kvdb {
return fsdevGetLastResult();
}
return ResultSuccess;
return ResultSuccess();
}
};

View file

@ -50,7 +50,7 @@ namespace sts::os {
Result Join() {
R_TRY(threadWaitForExit(&this->thr));
R_TRY(threadClose(&this->thr));
return ResultSuccess;
return ResultSuccess();
}
Result CancelSynchronization() {
@ -92,7 +92,7 @@ namespace sts::os {
Result Join() {
R_TRY(threadWaitForExit(&this->thr));
R_TRY(threadClose(&this->thr));
return ResultSuccess;
return ResultSuccess();
}
Result CancelSynchronization() {

View file

@ -17,9 +17,10 @@
#pragma once
/* Utilities. */
#include "results/utilities.h"
#include "results/results_common.hpp"
/* Official. */
#include "results/cal_results.hpp"
#include "results/creport_results.hpp"
#include "results/debug_results.hpp"
#include "results/dmnt_results.hpp"
@ -28,7 +29,6 @@
#include "results/fs_results.hpp"
#include "results/hipc_results.hpp"
#include "results/i2c_results.hpp"
#include "results/kernel_results.hpp"
#include "results/kvdb_results.hpp"
#include "results/loader_results.hpp"
#include "results/lr_results.hpp"
@ -40,10 +40,9 @@
#include "results/sf_results.hpp"
#include "results/sm_results.hpp"
#include "results/spl_results.hpp"
#include "results/svc_results.hpp"
#include "results/updater_results.hpp"
#include "results/vi_results.hpp"
/* Unofficial. */
#include "results/ams_results.hpp"
static constexpr Result ResultSuccess = 0;

View file

@ -15,17 +15,24 @@
*/
#pragma once
#include <switch.h>
#include "results_common.hpp"
/* Please note: These results are all custom, and not official. */
namespace sts::ams {
static constexpr u32 Module_Atmosphere = 444;
/* Please note: These results are all custom, and not official. */
R_DEFINE_NAMESPACE_RESULT_MODULE(444);
/* Result 1-1000 reserved for Atmosphere. */
static constexpr Result ResultAtmosphereExosphereNotPresent = MAKERESULT(Module_Atmosphere, 1);
static constexpr Result ResultAtmosphereVersionMismatch = MAKERESULT(Module_Atmosphere, 2);
/* Results 1000-2000 reserved for Atmosphere Mitm. */
static constexpr Result ResultAtmosphereMitmShouldForwardToSession = MAKERESULT(Module_Atmosphere, 1000);
static constexpr Result ResultAtmosphereMitmProcessNotAssociated = MAKERESULT(Module_Atmosphere, 1100);
/* Result 1-1000 reserved for Atmosphere. */
R_DEFINE_ERROR_RESULT(ExosphereNotPresent, 1);
R_DEFINE_ERROR_RESULT(VersionMismatch, 2);
/* Results 1000-2000 reserved for Atmosphere Mitm. */
namespace mitm {
R_DEFINE_ERROR_RESULT(ShouldForwardToSession, 1000);
R_DEFINE_ERROR_RESULT(ProcessNotAssociated, 1100);
}
}

View file

@ -0,0 +1,26 @@
/*
* Copyright (c) 2018-2019 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "results_common.hpp"
namespace sts::cal {
R_DEFINE_NAMESPACE_RESULT_MODULE(198);
R_DEFINE_ERROR_RESULT(CalibrationDataCrcError, 101);
}

View file

@ -15,19 +15,23 @@
*/
#pragma once
#include <switch.h>
#include "results_common.hpp"
static constexpr u32 Module_Creport = 168;
namespace sts::creport {
static constexpr Result ResultCreportUndefinedInstruction = MAKERESULT(Module_Creport, 0);
static constexpr Result ResultCreportInstructionAbort = MAKERESULT(Module_Creport, 1);
static constexpr Result ResultCreportDataAbort = MAKERESULT(Module_Creport, 2);
static constexpr Result ResultCreportAlignmentFault = MAKERESULT(Module_Creport, 3);
static constexpr Result ResultCreportDebuggerAttached = MAKERESULT(Module_Creport, 4);
static constexpr Result ResultCreportBreakPoint = MAKERESULT(Module_Creport, 5);
static constexpr Result ResultCreportUserBreak = MAKERESULT(Module_Creport, 6);
static constexpr Result ResultCreportDebuggerBreak = MAKERESULT(Module_Creport, 7);
static constexpr Result ResultCreportUndefinedSystemCall = MAKERESULT(Module_Creport, 8);
static constexpr Result ResultCreportSystemMemoryError = MAKERESULT(Module_Creport, 9);
R_DEFINE_NAMESPACE_RESULT_MODULE(168);
static constexpr Result ResultCreportIncompleteReport = MAKERESULT(Module_Creport, 99);
R_DEFINE_ERROR_RESULT(UndefinedInstruction, 0);
R_DEFINE_ERROR_RESULT(InstructionAbort, 1);
R_DEFINE_ERROR_RESULT(DataAbort, 2);
R_DEFINE_ERROR_RESULT(AlignmentFault, 3);
R_DEFINE_ERROR_RESULT(DebuggerAttached, 4);
R_DEFINE_ERROR_RESULT(BreakPoint, 5);
R_DEFINE_ERROR_RESULT(UserBreak, 6);
R_DEFINE_ERROR_RESULT(DebuggerBreak, 7);
R_DEFINE_ERROR_RESULT(UndefinedSystemCall, 8);
R_DEFINE_ERROR_RESULT(SystemMemoryError, 9);
R_DEFINE_ERROR_RESULT(IncompleteReport, 99);
}

View file

@ -15,10 +15,14 @@
*/
#pragma once
#include <switch.h>
#include "results_common.hpp"
static constexpr u32 Module_Debug = 183;
namespace sts::dbg {
static constexpr Result ResultDebugCannotDebug = MAKERESULT(Module_Debug, 1);
static constexpr Result ResultDebugAlreadyAttached = MAKERESULT(Module_Debug, 2);
static constexpr Result ResultDebugCancelled = MAKERESULT(Module_Debug, 3);
R_DEFINE_NAMESPACE_RESULT_MODULE(183);
R_DEFINE_ERROR_RESULT(CannotDebug, 1);
R_DEFINE_ERROR_RESULT(AlreadyAttached, 2);
R_DEFINE_ERROR_RESULT(Cancelled, 3);
}

View file

@ -15,24 +15,36 @@
*/
#pragma once
#include <switch.h>
#include "results_common.hpp"
static constexpr u32 Module_Dmnt = 13;
namespace sts::dmnt {
static constexpr Result ResultDmntUnknown = MAKERESULT(Module_Dmnt, 1);
static constexpr Result ResultDmntDebuggingDisabled = MAKERESULT(Module_Dmnt, 2);
R_DEFINE_NAMESPACE_RESULT_MODULE(13);
static constexpr Result ResultDmntCheatNotAttached = MAKERESULT(Module_Dmnt, 6500);
static constexpr Result ResultDmntCheatNullBuffer = MAKERESULT(Module_Dmnt, 6501);
static constexpr Result ResultDmntCheatInvalidBuffer = MAKERESULT(Module_Dmnt, 6502);
static constexpr Result ResultDmntCheatUnknownChtId = MAKERESULT(Module_Dmnt, 6503);
static constexpr Result ResultDmntCheatOutOfCheats = MAKERESULT(Module_Dmnt, 6504);
static constexpr Result ResultDmntCheatInvalidCheat = MAKERESULT(Module_Dmnt, 6505);
static constexpr Result ResultDmntCheatCannotDisableMasterCheat = MAKERESULT(Module_Dmnt, 6505);
R_DEFINE_ERROR_RESULT(Unknown, 1);
R_DEFINE_ERROR_RESULT(DebuggingDisabled, 2);
static constexpr Result ResultDmntCheatInvalidFreezeWidth = MAKERESULT(Module_Dmnt, 6600);
static constexpr Result ResultDmntCheatAddressAlreadyFrozen = MAKERESULT(Module_Dmnt, 6601);
static constexpr Result ResultDmntCheatAddressNotFrozen = MAKERESULT(Module_Dmnt, 6602);
static constexpr Result ResultDmntCheatTooManyFrozenAddresses = MAKERESULT(Module_Dmnt, 6603);
/* Atmosphere extension. */
namespace cheat {
static constexpr Result ResultDmntCheatVmInvalidCondDepth = MAKERESULT(Module_Dmnt, 6700);
R_DEFINE_ABSTRACT_ERROR_RANGE(CheatError, 6500, 6599);
R_DEFINE_ERROR_RESULT(CheatNotAttached, 6500);
R_DEFINE_ERROR_RESULT(CheatNullBuffer, 6501);
R_DEFINE_ERROR_RESULT(CheatInvalidBuffer, 6502);
R_DEFINE_ERROR_RESULT(CheatUnknownId, 6503);
R_DEFINE_ERROR_RESULT(CheatOutOfResource, 6504);
R_DEFINE_ERROR_RESULT(CheatInvalid, 6505);
R_DEFINE_ERROR_RESULT(CheatCannotDisable, 6506);
R_DEFINE_ABSTRACT_ERROR_RANGE(FrozenAddressError, 6600, 6699);
R_DEFINE_ERROR_RESULT(FrozenAddressInvalidWidth, 6600);
R_DEFINE_ERROR_RESULT(FrozenAddressAlreadyExists, 6601);
R_DEFINE_ERROR_RESULT(FrozenAddressNotFound, 6602);
R_DEFINE_ERROR_RESULT(FrozenAddressOutOfResource, 6603);
R_DEFINE_ABSTRACT_ERROR_RANGE(VirtualMachineError, 6700, 6799);
R_DEFINE_ERROR_RESULT(VirtualMachineInvalidConditionDepth, 6700);
}
}

View file

@ -15,9 +15,13 @@
*/
#pragma once
#include <switch.h>
#include "results_common.hpp"
static constexpr u32 Module_Err = 162;
namespace sts::err {
static constexpr Result ResultErrApplicationAborted = MAKERESULT(Module_Err, 1);
static constexpr Result ResultErrSystemModuleAborted = MAKERESULT(Module_Err, 2);
R_DEFINE_NAMESPACE_RESULT_MODULE(162);
R_DEFINE_ERROR_RESULT(ApplicationAborted, 1);
R_DEFINE_ERROR_RESULT(SystemModuleAborted, 2);
}

View file

@ -15,13 +15,17 @@
*/
#pragma once
#include <switch.h>
#include "results_common.hpp"
static constexpr u32 Module_Fatal = 163;
namespace sts::fatal {
static constexpr Result ResultFatalAllocationFailed = MAKERESULT(Module_Fatal, 1);
static constexpr Result ResultFatalNullGraphicsBuffer = MAKERESULT(Module_Fatal, 2);
static constexpr Result ResultFatalAlreadyThrown = MAKERESULT(Module_Fatal, 3);
static constexpr Result ResultFatalTooManyEvents = MAKERESULT(Module_Fatal, 4);
static constexpr Result ResultFatalInRepairWithoutVolHeld = MAKERESULT(Module_Fatal, 5);
static constexpr Result ResultFatalInRepairWithoutTimeReviserCartridge = MAKERESULT(Module_Fatal, 6);
R_DEFINE_NAMESPACE_RESULT_MODULE(163);
R_DEFINE_ERROR_RESULT(AllocationFailed, 1);
R_DEFINE_ERROR_RESULT(NullGraphicsBuffer, 2);
R_DEFINE_ERROR_RESULT(AlreadyThrown, 3);
R_DEFINE_ERROR_RESULT(TooManyEvents, 4);
R_DEFINE_ERROR_RESULT(InRepairWithoutVolHeld, 5);
R_DEFINE_ERROR_RESULT(InRepairWithoutTimeReviserCartridge, 6);
}

View file

@ -15,53 +15,102 @@
*/
#pragma once
#include <switch.h>
#include "results_common.hpp"
static constexpr u32 Module_Fs = 2;
namespace sts::fs {
static constexpr Result ResultFsPathNotFound = MAKERESULT(Module_Fs, 1);
static constexpr Result ResultFsPathAlreadyExists = MAKERESULT(Module_Fs, 2);
R_DEFINE_NAMESPACE_RESULT_MODULE(2);
static constexpr Result ResultFsTargetLocked = MAKERESULT(Module_Fs, 7);
static constexpr Result ResultFsDirectoryNotEmpty = MAKERESULT(Module_Fs, 8);
R_DEFINE_ERROR_RESULT(PathNotFound, 1);
R_DEFINE_ERROR_RESULT(PathAlreadyExists, 2);
static constexpr Result ResultFsNotEnoughFreeSpaceRangeStart = MAKERESULT(Module_Fs, 30);
static constexpr Result ResultFsNotEnoughFreeSpaceBisRangeStart = MAKERESULT(Module_Fs, 34);
static constexpr Result ResultFsNotEnoughFreeSpaceBisCalibration = MAKERESULT(Module_Fs, 35);
static constexpr Result ResultFsNotEnoughFreeSpaceBisSafe = MAKERESULT(Module_Fs, 36);
static constexpr Result ResultFsNotEnoughFreeSpaceBisUser = MAKERESULT(Module_Fs, 37);
static constexpr Result ResultFsNotEnoughFreeSpaceBisSystem = MAKERESULT(Module_Fs, 38);
static constexpr Result ResultFsNotEnoughFreeSpaceBisRangeEnd = MAKERESULT(Module_Fs, 39);
static constexpr Result ResultFsNotEnoughFreeSpaceSdCard = MAKERESULT(Module_Fs, 39);
static constexpr Result ResultFsNotEnoughFreeSpaceRangeEnd = MAKERESULT(Module_Fs, 45);
R_DEFINE_ERROR_RESULT(TargetLocked, 7);
R_DEFINE_ERROR_RESULT(DirectoryNotEmpty, 8);
static constexpr Result ResultFsMountNameAlreadyExists = MAKERESULT(Module_Fs, 60);
R_DEFINE_ERROR_RANGE (NotEnoughFreeSpace, 30, 45);
R_DEFINE_ERROR_RANGE(NotEnoughFreeSpaceBis, 34, 38);
R_DEFINE_ERROR_RESULT(NotEnoughFreeSpaceBisCalibration, 35);
R_DEFINE_ERROR_RESULT(NotEnoughFreeSpaceBisSafe, 36);
R_DEFINE_ERROR_RESULT(NotEnoughFreeSpaceBisUser, 37);
R_DEFINE_ERROR_RESULT(NotEnoughFreeSpaceBisSystem, 38);
R_DEFINE_ERROR_RESULT(NotEnoughFreeSpaceSdCard, 39);
static constexpr Result ResultFsTargetNotFound = MAKERESULT(Module_Fs, 1002);
R_DEFINE_ERROR_RESULT(MountNameAlreadyExists, 60);
static constexpr Result ResultFsSdCardNotPresent = MAKERESULT(Module_Fs, 2001);
R_DEFINE_ERROR_RESULT(TargetNotFound, 1002);
static constexpr Result ResultFsNotImplemented = MAKERESULT(Module_Fs, 3001);
static constexpr Result ResultFsOutOfRange = MAKERESULT(Module_Fs, 3005);
R_DEFINE_ERROR_RANGE(SdCardAccessFailed, 2000, 2499);
R_DEFINE_ERROR_RESULT(SdCardNotPresent, 2001);
static constexpr Result ResultFsAllocationFailureInDirectorySaveDataFileSystem = MAKERESULT(Module_Fs, 3321);
static constexpr Result ResultFsAllocationFailureInSubDirectoryFileSystem = MAKERESULT(Module_Fs, 3355);
R_DEFINE_ERROR_RANGE(GameCardAccessFailed, 2500, 2999);
static constexpr Result ResultFsPreconditionViolation = MAKERESULT(Module_Fs, 6000);
static constexpr Result ResultFsInvalidArgument = MAKERESULT(Module_Fs, 6001);
static constexpr Result ResultFsInvalidPath = MAKERESULT(Module_Fs, 6002);
static constexpr Result ResultFsTooLongPath = MAKERESULT(Module_Fs, 6003);
static constexpr Result ResultFsInvalidCharacter = MAKERESULT(Module_Fs, 6004);
static constexpr Result ResultFsInvalidPathFormat = MAKERESULT(Module_Fs, 6005);
static constexpr Result ResultFsDirectoryUnobtainable = MAKERESULT(Module_Fs, 6006);
static constexpr Result ResultFsNotNormalized = MAKERESULT(Module_Fs, 6007);
R_DEFINE_ERROR_RESULT(NotImplemented, 3001);
R_DEFINE_ERROR_RESULT(OutOfRange, 3005);
static constexpr Result ResultFsInvalidOffset = MAKERESULT(Module_Fs, 6061);
static constexpr Result ResultFsInvalidSize = MAKERESULT(Module_Fs, 6062);
static constexpr Result ResultFsNullptrArgument = MAKERESULT(Module_Fs, 6063);
R_DEFINE_ERROR_RANGE(AllocationFailure, 3200, 3499);
R_DEFINE_ERROR_RESULT(AllocationFailureInDirectorySaveDataFileSystem, 3321);
R_DEFINE_ERROR_RESULT(AllocationFailureInSubDirectoryFileSystem, 3355);
static constexpr Result ResultFsInvalidSaveDataSpaceId = MAKERESULT(Module_Fs, 6082);
R_DEFINE_ERROR_RANGE(MmcAccessFailed, 3500, 3999);
static constexpr Result ResultFsUnsupportedOperation = MAKERESULT(Module_Fs, 6300);
R_DEFINE_ERROR_RANGE(DataCorrupted, 4000, 4999);
R_DEFINE_ERROR_RANGE(RomCorrupted, 4001, 4299);
R_DEFINE_ERROR_RANGE(SaveDataCorrupted, 4301, 4499);
R_DEFINE_ERROR_RANGE(NcaCorrupted, 4501, 4599);
R_DEFINE_ERROR_RANGE(IntegrityVerificationStorageCorrupted, 4601, 4639);
R_DEFINE_ERROR_RANGE(PartitionFileSystemCorrupted, 4641, 4659);
R_DEFINE_ERROR_RANGE(BuiltInStorageCorrupted, 4661, 4679);
R_DEFINE_ERROR_RANGE(HostFileSystemCorrupted, 4701, 4719);
R_DEFINE_ERROR_RANGE(DatabaseCorrupted, 4721, 4739);
R_DEFINE_ERROR_RANGE(AesXtsFileSystemCorrupted, 4741, 4759);
R_DEFINE_ERROR_RANGE(SaveDataTransferDataCorrupted, 4761, 4769);
R_DEFINE_ERROR_RANGE(SignedSystemPartitionDataCorrupted, 4771, 4779);
static constexpr Result ResultFsPermissionDenied = MAKERESULT(Module_Fs, 6400);
R_DEFINE_ERROR_RESULT(GameCardLogoDataCorrupted, 4781);
R_DEFINE_ERROR_RANGE(Unexpected, 5000, 5999);
R_DEFINE_ERROR_RANGE(PreconditionViolation, 6000, 6499);
R_DEFINE_ERROR_RANGE(InvalidArgument, 6001, 6199);
R_DEFINE_ERROR_RANGE(InvalidPath, 6002, 6029);
R_DEFINE_ERROR_RESULT(TooLongPath, 6003);
R_DEFINE_ERROR_RESULT(InvalidCharacter, 6004);
R_DEFINE_ERROR_RESULT(InvalidPathFormat, 6005);
R_DEFINE_ERROR_RESULT(DirectoryUnobtainable, 6006);
R_DEFINE_ERROR_RESULT(NotNormalized, 6007);
R_DEFINE_ERROR_RESULT(InvalidOffset, 6061);
R_DEFINE_ERROR_RESULT(InvalidSize, 6062);
R_DEFINE_ERROR_RESULT(NullptrArgument, 6063);
R_DEFINE_ERROR_RESULT(InvalidAlignment, 6064);
R_DEFINE_ERROR_RESULT(InvalidMountName, 6065);
R_DEFINE_ERROR_RESULT(ExtensionSizeTooLarge, 6066);
R_DEFINE_ERROR_RESULT(ExtensionSizeInvalid, 6067);
R_DEFINE_ERROR_RANGE(InvalidEnumValue, 6080, 6099);
R_DEFINE_ERROR_RESULT(InvalidSaveDataState, 6081);
R_DEFINE_ERROR_RESULT(InvalidSaveDataSpaceId, 6082);
R_DEFINE_ERROR_RANGE(InvalidOperationForOpenMode, 6200, 6299);
R_DEFINE_ERROR_RESULT(FileExtensionWithoutOpenModeAllowAppend, 6201);
R_DEFINE_ERROR_RANGE(UnsupportedOperation, 6300, 6399);
R_DEFINE_ERROR_RANGE(PermissionDenied, 6400, 6449);
R_DEFINE_ERROR_RESULT(WriteModeFileNotClosed, 6457);
R_DEFINE_ERROR_RESULT(AllocatorAlignmentViolation, 6461);
R_DEFINE_ERROR_RESULT(UserNotExist, 6465);
R_DEFINE_ERROR_RANGE(OutOfResource, 6700, 6799);
R_DEFINE_ERROR_RESULT(MappingTableFull, 6706);
R_DEFINE_ERROR_RESULT(OpenCountLimit, 6709);
R_DEFINE_ERROR_RANGE(MappingFailed, 6800, 6899);
R_DEFINE_ERROR_RESULT(MapFull, 6811);
R_DEFINE_ERROR_RANGE(BadState, 6900, 6999);
R_DEFINE_ERROR_RESULT(NotMounted, 6905);
}

View file

@ -15,23 +15,27 @@
*/
#pragma once
#include <switch.h>
#include "results_common.hpp"
static constexpr u32 Module_Hipc = 11;
namespace sts::sf::hipc {
static constexpr Result ResultHipcSessionAllocationFailure = MAKERESULT(Module_Hipc, 102);
R_DEFINE_NAMESPACE_RESULT_MODULE(11);
static constexpr Result ResultHipcOutOfSessions = MAKERESULT(Module_Hipc, 131);
static constexpr Result ResultHipcPointerBufferTooSmall = MAKERESULT(Module_Hipc, 141);
R_DEFINE_ABSTRACT_ERROR_RANGE(OutOfResource, 100, 299);
R_DEFINE_ERROR_RESULT(OutOfSessionMemory, 102);
R_DEFINE_ERROR_RANGE (OutOfSessions, 131, 139);
R_DEFINE_ERROR_RESULT(PointerBufferTooSmall, 141);
static constexpr Result ResultHipcOutOfDomains = MAKERESULT(Module_Hipc, 200);
R_DEFINE_ERROR_RESULT(OutOfDomains, 200);
static constexpr Result ResultHipcSessionClosed = MAKERESULT(Module_Hipc, 301);
R_DEFINE_ERROR_RESULT(SessionClosed, 301);
static constexpr Result ResultHipcInvalidRequestSize = MAKERESULT(Module_Hipc, 402);
static constexpr Result ResultHipcUnknownCommandType = MAKERESULT(Module_Hipc, 403);
R_DEFINE_ERROR_RESULT(InvalidRequestSize, 402);
R_DEFINE_ERROR_RESULT(UnknownCommandType, 403);
static constexpr Result ResultHipcInvalidRequest = MAKERESULT(Module_Hipc, 420);
R_DEFINE_ERROR_RESULT(InvalidCmifRequest, 420);
static constexpr Result ResultHipcTargetNotDomain = MAKERESULT(Module_Hipc, 491);
static constexpr Result ResultHipcDomainObjectNotFound = MAKERESULT(Module_Hipc, 492);
R_DEFINE_ERROR_RESULT(TargetNotDomain, 491);
R_DEFINE_ERROR_RESULT(DomainObjectNotFound, 492);
}

View file

@ -15,12 +15,16 @@
*/
#pragma once
#include <switch.h>
#include "results_common.hpp"
static constexpr u32 Module_I2c = 101;
namespace sts::i2c {
static constexpr Result ResultI2cNoAck = MAKERESULT(Module_I2c, 1);
static constexpr Result ResultI2cBusBusy = MAKERESULT(Module_I2c, 2);
static constexpr Result ResultI2cFullCommandList = MAKERESULT(Module_I2c, 3);
static constexpr Result ResultI2cTimedOut = MAKERESULT(Module_I2c, 4);
static constexpr Result ResultI2cUnknownDevice = MAKERESULT(Module_I2c, 5);
R_DEFINE_NAMESPACE_RESULT_MODULE(101);
R_DEFINE_ERROR_RESULT(NoAck, 1);
R_DEFINE_ERROR_RESULT(BusBusy, 2);
R_DEFINE_ERROR_RESULT(FullCommandList, 3);
R_DEFINE_ERROR_RESULT(TimedOut, 4);
R_DEFINE_ERROR_RESULT(UnknownDevice, 5);
}

View file

@ -1,64 +0,0 @@
/*
* Copyright (c) 2018-2019 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <switch.h>
/* libnx already has: static constexpr u32 Module_Kernel = 1; */
static constexpr Result ResultKernelOutOfSessions = MAKERESULT(Module_Kernel, KernelError_OutOfSessions);
static constexpr Result ResultKernelInvalidCapabilityDescriptor = MAKERESULT(Module_Kernel, KernelError_InvalidCapabilityDescriptor);
static constexpr Result ResultKernelNotImplemented = MAKERESULT(Module_Kernel, KernelError_NotImplemented);
static constexpr Result ResultKernelThreadTerminating = MAKERESULT(Module_Kernel, KernelError_ThreadTerminating);
static constexpr Result ResultKernelOutOfDebugEvents = MAKERESULT(Module_Kernel, KernelError_OutOfDebugEvents);
static constexpr Result ResultKernelInvalidSize = MAKERESULT(Module_Kernel, KernelError_InvalidSize);
static constexpr Result ResultKernelInvalidAddress = MAKERESULT(Module_Kernel, KernelError_InvalidAddress);
static constexpr Result ResultKernelResourceExhausted = MAKERESULT(Module_Kernel, KernelError_ResourceExhausted);
static constexpr Result ResultKernelOutOfMemory = MAKERESULT(Module_Kernel, KernelError_OutOfMemory);
static constexpr Result ResultKernelOutOfHandles = MAKERESULT(Module_Kernel, KernelError_OutOfHandles);
static constexpr Result ResultKernelInvalidMemoryState = MAKERESULT(Module_Kernel, KernelError_InvalidMemoryState);
static constexpr Result ResultKernelInvalidMemoryPermissions = MAKERESULT(Module_Kernel, KernelError_InvalidMemoryPermissions);
static constexpr Result ResultKernelInvalidMemoryRange = MAKERESULT(Module_Kernel, KernelError_InvalidMemoryRange);
static constexpr Result ResultKernelInvalidPriority = MAKERESULT(Module_Kernel, KernelError_InvalidPriority);
static constexpr Result ResultKernelInvalidCoreId = MAKERESULT(Module_Kernel, KernelError_InvalidCoreId);
static constexpr Result ResultKernelInvalidHandle = MAKERESULT(Module_Kernel, KernelError_InvalidHandle);
static constexpr Result ResultKernelInvalidUserBuffer = MAKERESULT(Module_Kernel, KernelError_InvalidUserBuffer);
static constexpr Result ResultKernelInvalidCombination = MAKERESULT(Module_Kernel, KernelError_InvalidCombination);
static constexpr Result ResultKernelTimedOut = MAKERESULT(Module_Kernel, KernelError_TimedOut);
static constexpr Result ResultKernelCancelled = MAKERESULT(Module_Kernel, KernelError_Cancelled);
static constexpr Result ResultKernelOutOfRange = MAKERESULT(Module_Kernel, KernelError_OutOfRange);
static constexpr Result ResultKernelInvalidEnumValue = MAKERESULT(Module_Kernel, KernelError_InvalidEnumValue);
static constexpr Result ResultKernelNotFound = MAKERESULT(Module_Kernel, KernelError_NotFound);
static constexpr Result ResultKernelAlreadyExists = MAKERESULT(Module_Kernel, KernelError_AlreadyExists);
static constexpr Result ResultKernelConnectionClosed = MAKERESULT(Module_Kernel, KernelError_ConnectionClosed);
static constexpr Result ResultKernelUnhandledUserInterrupt = MAKERESULT(Module_Kernel, KernelError_UnhandledUserInterrupt);
static constexpr Result ResultKernelInvalidState = MAKERESULT(Module_Kernel, KernelError_InvalidState);
static constexpr Result ResultKernelReservedValue = MAKERESULT(Module_Kernel, KernelError_ReservedValue);
static constexpr Result ResultKernelInvalidHwBreakpoint = MAKERESULT(Module_Kernel, KernelError_InvalidHwBreakpoint);
static constexpr Result ResultKernelFatalUserException = MAKERESULT(Module_Kernel, KernelError_FatalUserException);
static constexpr Result ResultKernelOwnedByAnotherProcess = MAKERESULT(Module_Kernel, KernelError_OwnedByAnotherProcess);
static constexpr Result ResultKernelConnectionRefused = MAKERESULT(Module_Kernel, KernelError_ConnectionRefused);
static constexpr Result ResultKernelLimitReached = MAKERESULT(Module_Kernel, 132 /* KernelError_OutOfResource */);
static constexpr Result ResultKernelReceiveListBroken = MAKERESULT(Module_Kernel, 258);
static constexpr Result ResultKernelIpcMapFailed = MAKERESULT(Module_Kernel, KernelError_IpcMapFailed);
static constexpr Result ResultKernelIpcCmdBufTooSmall = MAKERESULT(Module_Kernel, KernelError_IpcCmdbufTooSmall);
static constexpr Result ResultKernelNotDebugged = MAKERESULT(Module_Kernel, KernelError_NotDebugged);

View file

@ -15,15 +15,19 @@
*/
#pragma once
#include <switch.h>
#include "results_common.hpp"
static constexpr u32 Module_Kvdb = 20;
namespace sts::kvdb {
static constexpr Result ResultKvdbKeyCapacityInsufficient = MAKERESULT(Module_Kvdb, 1);
static constexpr Result ResultKvdbKeyNotFound = MAKERESULT(Module_Kvdb, 2);
static constexpr Result ResultKvdbAllocationFailed = MAKERESULT(Module_Kvdb, 4);
static constexpr Result ResultKvdbInvalidKeyValue = MAKERESULT(Module_Kvdb, 5);
static constexpr Result ResultKvdbBufferInsufficient = MAKERESULT(Module_Kvdb, 6);
R_DEFINE_NAMESPACE_RESULT_MODULE(20);
static constexpr Result ResultKvdbInvalidFilesystemState = MAKERESULT(Module_Kvdb, 8);
static constexpr Result ResultKvdbNotCreated = MAKERESULT(Module_Kvdb, 9);
R_DEFINE_ERROR_RESULT(KeyCapacityInsufficient, 1);
R_DEFINE_ERROR_RESULT(KeyNotFound, 2);
R_DEFINE_ERROR_RESULT(AllocationFailed, 4);
R_DEFINE_ERROR_RESULT(InvalidKeyValue, 5);
R_DEFINE_ERROR_RESULT(BufferInsufficient, 6);
R_DEFINE_ERROR_RESULT(InvalidFilesystemState, 8);
R_DEFINE_ERROR_RESULT(NotCreated, 9);
}

View file

@ -15,45 +15,49 @@
*/
#pragma once
#include <switch.h>
#include "results_common.hpp"
static constexpr u32 Module_Loader = 9;
namespace sts::ldr {
static constexpr Result ResultLoaderTooLongArgument = MAKERESULT(Module_Loader, 1);
static constexpr Result ResultLoaderTooManyArguments = MAKERESULT(Module_Loader, 2);
static constexpr Result ResultLoaderTooLargeMeta = MAKERESULT(Module_Loader, 3);
static constexpr Result ResultLoaderInvalidMeta = MAKERESULT(Module_Loader, 4);
static constexpr Result ResultLoaderInvalidNso = MAKERESULT(Module_Loader, 5);
static constexpr Result ResultLoaderInvalidPath = MAKERESULT(Module_Loader, 6);
static constexpr Result ResultLoaderTooManyProcesses = MAKERESULT(Module_Loader, 7);
static constexpr Result ResultLoaderNotPinned = MAKERESULT(Module_Loader, 8);
static constexpr Result ResultLoaderInvalidProgramId = MAKERESULT(Module_Loader, 9);
static constexpr Result ResultLoaderInvalidVersion = MAKERESULT(Module_Loader, 10);
R_DEFINE_NAMESPACE_RESULT_MODULE(9);
static constexpr Result ResultLoaderInsufficientAddressSpace = MAKERESULT(Module_Loader, 51);
static constexpr Result ResultLoaderInvalidNro = MAKERESULT(Module_Loader, 52);
static constexpr Result ResultLoaderInvalidNrr = MAKERESULT(Module_Loader, 53);
static constexpr Result ResultLoaderInvalidSignature = MAKERESULT(Module_Loader, 54);
static constexpr Result ResultLoaderInsufficientNroRegistrations = MAKERESULT(Module_Loader, 55);
static constexpr Result ResultLoaderInsufficientNrrRegistrations = MAKERESULT(Module_Loader, 56);
static constexpr Result ResultLoaderNroAlreadyLoaded = MAKERESULT(Module_Loader, 57);
R_DEFINE_ERROR_RESULT(TooLongArgument, 1);
R_DEFINE_ERROR_RESULT(TooManyArguments, 2);
R_DEFINE_ERROR_RESULT(TooLargeMeta, 3);
R_DEFINE_ERROR_RESULT(InvalidMeta, 4);
R_DEFINE_ERROR_RESULT(InvalidNso, 5);
R_DEFINE_ERROR_RESULT(InvalidPath, 6);
R_DEFINE_ERROR_RESULT(TooManyProcesses, 7);
R_DEFINE_ERROR_RESULT(NotPinned, 8);
R_DEFINE_ERROR_RESULT(InvalidProgramId, 9);
R_DEFINE_ERROR_RESULT(InvalidVersion, 10);
static constexpr Result ResultLoaderInvalidAddress = MAKERESULT(Module_Loader, 81);
static constexpr Result ResultLoaderInvalidSize = MAKERESULT(Module_Loader, 82);
static constexpr Result ResultLoaderNotLoaded = MAKERESULT(Module_Loader, 84);
static constexpr Result ResultLoaderNotRegistered = MAKERESULT(Module_Loader, 85);
static constexpr Result ResultLoaderInvalidSession = MAKERESULT(Module_Loader, 86);
static constexpr Result ResultLoaderInvalidProcess = MAKERESULT(Module_Loader, 87);
R_DEFINE_ERROR_RESULT(InsufficientAddressSpace, 51);
R_DEFINE_ERROR_RESULT(InvalidNro, 52);
R_DEFINE_ERROR_RESULT(InvalidNrr, 53);
R_DEFINE_ERROR_RESULT(InvalidSignature, 54);
R_DEFINE_ERROR_RESULT(InsufficientNroRegistrations, 55);
R_DEFINE_ERROR_RESULT(InsufficientNrrRegistrations, 56);
R_DEFINE_ERROR_RESULT(NroAlreadyLoaded, 57);
static constexpr Result ResultLoaderUnknownCapability = MAKERESULT(Module_Loader, 100);
static constexpr Result ResultLoaderInvalidCapabilityKernelFlags = MAKERESULT(Module_Loader, 103);
static constexpr Result ResultLoaderInvalidCapabilitySyscallMask = MAKERESULT(Module_Loader, 104);
static constexpr Result ResultLoaderInvalidCapabilityMapRange = MAKERESULT(Module_Loader, 106);
static constexpr Result ResultLoaderInvalidCapabilityMapPage = MAKERESULT(Module_Loader, 107);
static constexpr Result ResultLoaderInvalidCapabilityInterruptPair = MAKERESULT(Module_Loader, 111);
static constexpr Result ResultLoaderInvalidCapabilityApplicationType = MAKERESULT(Module_Loader, 113);
static constexpr Result ResultLoaderInvalidCapabilityKernelVersion = MAKERESULT(Module_Loader, 114);
static constexpr Result ResultLoaderInvalidCapabilityHandleTable = MAKERESULT(Module_Loader, 115);
static constexpr Result ResultLoaderInvalidCapabilityDebugFlags = MAKERESULT(Module_Loader, 116);
R_DEFINE_ERROR_RESULT(InvalidAddress, 81);
R_DEFINE_ERROR_RESULT(InvalidSize, 82);
R_DEFINE_ERROR_RESULT(NotLoaded, 84);
R_DEFINE_ERROR_RESULT(NotRegistered, 85);
R_DEFINE_ERROR_RESULT(InvalidSession, 86);
R_DEFINE_ERROR_RESULT(InvalidProcess, 87);
static constexpr Result ResultLoaderInternalError = MAKERESULT(Module_Loader, 200);
R_DEFINE_ERROR_RESULT(UnknownCapability, 100);
R_DEFINE_ERROR_RESULT(InvalidCapabilityKernelFlags, 103);
R_DEFINE_ERROR_RESULT(InvalidCapabilitySyscallMask, 104);
R_DEFINE_ERROR_RESULT(InvalidCapabilityMapRange, 106);
R_DEFINE_ERROR_RESULT(InvalidCapabilityMapPage, 107);
R_DEFINE_ERROR_RESULT(InvalidCapabilityInterruptPair, 111);
R_DEFINE_ERROR_RESULT(InvalidCapabilityApplicationType, 113);
R_DEFINE_ERROR_RESULT(InvalidCapabilityKernelVersion, 114);
R_DEFINE_ERROR_RESULT(InvalidCapabilityHandleTable, 115);
R_DEFINE_ERROR_RESULT(InvalidCapabilityDebugFlags, 116);
R_DEFINE_ERROR_RESULT(InternalError, 200);
}

View file

@ -15,16 +15,20 @@
*/
#pragma once
#include <switch.h>
#include "results_common.hpp"
static constexpr u32 Module_Lr = 8;
namespace sts::lr {
static constexpr Result ResultLrProgramNotFound = MAKERESULT(Module_Lr, 2);
static constexpr Result ResultLrDataNotFound = MAKERESULT(Module_Lr, 3);
static constexpr Result ResultLrUnknownStorageId = MAKERESULT(Module_Lr, 4);
static constexpr Result ResultLrHtmlDocumentNotFound = MAKERESULT(Module_Lr, 6);
static constexpr Result ResultLrAddOnContentNotFound = MAKERESULT(Module_Lr, 7);
static constexpr Result ResultLrControlNotFound = MAKERESULT(Module_Lr, 8);
static constexpr Result ResultLrLegalInformationNotFound = MAKERESULT(Module_Lr, 9);
R_DEFINE_NAMESPACE_RESULT_MODULE(8);
static constexpr Result ResultLrTooManyRegisteredPaths = MAKERESULT(Module_Lr, 90);
R_DEFINE_ERROR_RESULT(ProgramNotFound, 2);
R_DEFINE_ERROR_RESULT(DataNotFound, 3);
R_DEFINE_ERROR_RESULT(UnknownStorageId, 4);
R_DEFINE_ERROR_RESULT(HtmlDocumentNotFound, 6);
R_DEFINE_ERROR_RESULT(AddOnContentNotFound, 7);
R_DEFINE_ERROR_RESULT(ControlNotFound, 8);
R_DEFINE_ERROR_RESULT(LegalInformationNotFound, 9);
R_DEFINE_ERROR_RESULT(TooManyRegisteredPaths, 90);
}

View file

@ -15,37 +15,41 @@
*/
#pragma once
#include <switch.h>
#include "results_common.hpp"
static constexpr u32 Module_Ncm = 5;
namespace sts::ncm {
static constexpr Result ResultNcmPlaceHolderAlreadyExists = MAKERESULT(Module_Ncm, 2);
static constexpr Result ResultNcmPlaceHolderNotFound = MAKERESULT(Module_Ncm, 3);
static constexpr Result ResultNcmContentAlreadyExists = MAKERESULT(Module_Ncm, 4);
static constexpr Result ResultNcmContentNotFound = MAKERESULT(Module_Ncm, 5);
static constexpr Result ResultNcmContentMetaNotFound = MAKERESULT(Module_Ncm, 7);
static constexpr Result ResultNcmAllocationFailed = MAKERESULT(Module_Ncm, 8);
static constexpr Result ResultNcmUnknownStorage = MAKERESULT(Module_Ncm, 12);
R_DEFINE_NAMESPACE_RESULT_MODULE(5);
static constexpr Result ResultNcmInvalidContentStorage = MAKERESULT(Module_Ncm, 100);
static constexpr Result ResultNcmInvalidContentMetaDatabase = MAKERESULT(Module_Ncm, 110);
R_DEFINE_ERROR_RESULT(PlaceHolderAlreadyExists, 2);
R_DEFINE_ERROR_RESULT(PlaceHolderNotFound, 3);
R_DEFINE_ERROR_RESULT(ContentAlreadyExists, 4);
R_DEFINE_ERROR_RESULT(ContentNotFound, 5);
R_DEFINE_ERROR_RESULT(ContentMetaNotFound, 7);
R_DEFINE_ERROR_RESULT(AllocationFailed, 8);
R_DEFINE_ERROR_RESULT(UnknownStorage, 12);
static constexpr Result ResultNcmBufferInsufficient = MAKERESULT(Module_Ncm, 180);
static constexpr Result ResultNcmInvalidContentMetaKey = MAKERESULT(Module_Ncm, 240);
R_DEFINE_ERROR_RESULT(InvalidContentStorage, 100);
R_DEFINE_ERROR_RESULT(InvalidContentMetaDatabase, 110);
static constexpr Result ResultNcmContentStorageNotActive = MAKERESULT(Module_Ncm, 250);
static constexpr Result ResultNcmGameCardContentStorageNotActive = MAKERESULT(Module_Ncm, 251);
static constexpr Result ResultNcmNandSystemContentStorageNotActive = MAKERESULT(Module_Ncm, 252);
static constexpr Result ResultNcmNandUserContentStorageNotActive = MAKERESULT(Module_Ncm, 253);
static constexpr Result ResultNcmSdCardContentStorageNotActive = MAKERESULT(Module_Ncm, 254);
static constexpr Result ResultNcmUnknownContentStorageNotActive = MAKERESULT(Module_Ncm, 258);
R_DEFINE_ERROR_RESULT(BufferInsufficient, 180);
R_DEFINE_ERROR_RESULT(InvalidContentMetaKey, 240);
static constexpr Result ResultNcmContentMetaDatabaseNotActive = MAKERESULT(Module_Ncm, 260);
static constexpr Result ResultNcmGameCardContentMetaDatabaseNotActive = MAKERESULT(Module_Ncm, 261);
static constexpr Result ResultNcmNandSystemContentMetaDatabaseNotActive = MAKERESULT(Module_Ncm, 262);
static constexpr Result ResultNcmNandUserContentMetaDatabaseNotActive = MAKERESULT(Module_Ncm, 263);
static constexpr Result ResultNcmSdCardContentMetaDatabaseNotActive = MAKERESULT(Module_Ncm, 264);
static constexpr Result ResultNcmUnknownContentMetaDatabaseNotActive = MAKERESULT(Module_Ncm, 268);
R_DEFINE_ERROR_RANGE(ContentStorageNotActive, 250, 258);
R_DEFINE_ERROR_RESULT(GameCardContentStorageNotActive, 251);
R_DEFINE_ERROR_RESULT(NandSystemContentStorageNotActive, 252);
R_DEFINE_ERROR_RESULT(NandUserContentStorageNotActive, 253);
R_DEFINE_ERROR_RESULT(SdCardContentStorageNotActive, 254);
R_DEFINE_ERROR_RESULT(UnknownContentStorageNotActive, 258);
static constexpr Result ResultNcmInvalidArgument = MAKERESULT(Module_Ncm, 8181);
static constexpr Result ResultNcmInvalidOffset = MAKERESULT(Module_Ncm, 8182);
R_DEFINE_ERROR_RANGE(ContentMetaDatabaseNotActive, 260, 268);
R_DEFINE_ERROR_RESULT(GameCardContentMetaDatabaseNotActive, 261);
R_DEFINE_ERROR_RESULT(NandSystemContentMetaDatabaseNotActive, 262);
R_DEFINE_ERROR_RESULT(NandUserContentMetaDatabaseNotActive, 263);
R_DEFINE_ERROR_RESULT(SdCardContentMetaDatabaseNotActive, 264);
R_DEFINE_ERROR_RESULT(UnknownContentMetaDatabaseNotActive, 268);
R_DEFINE_ERROR_RANGE(InvalidArgument, 8181, 8191);
R_DEFINE_ERROR_RESULT(InvalidOffset, 8182);
}

View file

@ -15,9 +15,18 @@
*/
#pragma once
#include <switch.h>
#include "results_common.hpp"
static constexpr u32 Module_Os = 3;
namespace sts::os {
static constexpr Result ResultOsOutOfMemory = MAKERESULT(Module_Os, 8);
static constexpr Result ResultOsResourceExhausted = MAKERESULT(Module_Os, 9);
R_DEFINE_NAMESPACE_RESULT_MODULE(3);
R_DEFINE_ERROR_RESULT(Busy, 4);
R_DEFINE_ERROR_RESULT(OutOfMemory, 8);
R_DEFINE_ERROR_RESULT(OutOfResource, 9);
R_DEFINE_ERROR_RESULT(OutOfVirtualAddressSpace, 12);
R_DEFINE_ERROR_RESULT(ResourceLimit, 13);
}

View file

@ -15,13 +15,17 @@
*/
#pragma once
#include <switch.h>
#include "results_common.hpp"
static constexpr u32 Module_Pm = 15;
namespace sts::pm {
static constexpr Result ResultPmProcessNotFound = MAKERESULT(Module_Pm, 1);
static constexpr Result ResultPmAlreadyStarted = MAKERESULT(Module_Pm, 2);
static constexpr Result ResultPmNotExited = MAKERESULT(Module_Pm, 3);
static constexpr Result ResultPmDebugHookInUse = MAKERESULT(Module_Pm, 4);
static constexpr Result ResultPmApplicationRunning = MAKERESULT(Module_Pm, 5);
static constexpr Result ResultPmInvalidSize = MAKERESULT(Module_Pm, 6);
R_DEFINE_NAMESPACE_RESULT_MODULE(15);
R_DEFINE_ERROR_RESULT(ProcessNotFound, 1);
R_DEFINE_ERROR_RESULT(AlreadyStarted, 2);
R_DEFINE_ERROR_RESULT(NotExited, 3);
R_DEFINE_ERROR_RESULT(DebugHookInUse, 4);
R_DEFINE_ERROR_RESULT(ApplicationRunning, 5);
R_DEFINE_ERROR_RESULT(InvalidSize, 6);
}

View file

@ -0,0 +1,288 @@
/*
* Copyright (c) 2018-2019 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <switch.h>
#include <climits>
#include "../defines.hpp"
namespace sts {
namespace result::impl {
class ResultTraits {
public:
using BaseType = u32;
static_assert(std::is_same<BaseType, ::Result>::value, "std::is_same<BaseType, ::Result>::value");
static constexpr BaseType SuccessValue = BaseType();
static constexpr BaseType ModuleBits = 9;
static constexpr BaseType DescriptionBits = 13;
static constexpr BaseType ReservedBits = 10;
static_assert(ModuleBits + DescriptionBits + ReservedBits == sizeof(BaseType) * CHAR_BIT, "ModuleBits + DescriptionBits + ReservedBits == sizeof(BaseType) * CHAR_BIT");
public:
NX_CONSTEXPR BaseType MakeValue(BaseType module, BaseType description) {
return (module) | (description << ModuleBits);
}
template<BaseType module, BaseType description>
struct MakeStaticValue : public std::integral_constant<BaseType, MakeValue(module, description)> {
static_assert(module < (1 << ModuleBits), "Invalid Module");
static_assert(description < (1 << DescriptionBits), "Invalid Description");
};
NX_CONSTEXPR BaseType GetModuleFromValue(BaseType value) {
return value & ~(~BaseType() << ModuleBits);
}
NX_CONSTEXPR BaseType GetDescriptionFromValue(BaseType value) {
return ((value >> ModuleBits) & ~(~BaseType() << DescriptionBits));
}
};
/* Use CRTP for Results. */
template<typename Self>
class ResultBase {
public:
using BaseType = typename ResultTraits::BaseType;
static constexpr BaseType SuccessValue = ResultTraits::SuccessValue;
public:
constexpr inline BaseType GetModule() const { return ResultTraits::GetModuleFromValue(static_cast<const Self *>(this)->GetValue()); }
constexpr inline BaseType GetDescription() const { return ResultTraits::GetDescriptionFromValue(static_cast<const Self *>(this)->GetValue()); }
};
class ResultConstructor;
}
class ResultSuccess;
class Result final : public result::impl::ResultBase<Result> {
friend class ResultConstructor;
public:
using Base = typename result::impl::ResultBase<Result>;
private:
typename Base::BaseType value;
private:
/* TODO: Maybe one-day, the result constructor. */
public:
Result() { /* ... */ }
/* TODO: It sure would be nice to make this private. */
constexpr Result(typename Base::BaseType v) : value(v) { static_assert(std::is_same<typename Base::BaseType, ::Result>::value); }
constexpr inline operator ResultSuccess() const;
NX_CONSTEXPR bool CanAccept(Result result) { return true; }
constexpr inline bool IsSuccess() const { return this->GetValue() == Base::SuccessValue; }
constexpr inline bool IsFailure() const { return !this->IsSuccess(); }
constexpr inline typename Base::BaseType GetModule() const { return Base::GetModule(); }
constexpr inline typename Base::BaseType GetDescription() const { return Base::GetDescription(); }
constexpr inline typename Base::BaseType GetValue() const { return this->value; }
};
static_assert(sizeof(Result) == sizeof(Result::Base::BaseType), "sizeof(Result) == sizeof(Result::Base::BaseType)");
static_assert(std::is_trivially_destructible<Result>::value, "std::is_trivially_destructible<Result>::value");
namespace result::impl {
class ResultConstructor {
public:
static constexpr inline Result MakeResult(ResultTraits::BaseType value) {
return Result(value);
}
};
constexpr inline Result MakeResult(ResultTraits::BaseType value) {
return ResultConstructor::MakeResult(value);
}
}
class ResultSuccess final : public result::impl::ResultBase<ResultSuccess> {
public:
using Base = typename result::impl::ResultBase<ResultSuccess>;
public:
constexpr operator Result() const { return result::impl::MakeResult(Base::SuccessValue); }
NX_CONSTEXPR bool CanAccept(Result result) { return result.IsSuccess(); }
constexpr inline bool IsSuccess() const { return true; }
constexpr inline bool IsFailure() const { return !this->IsSuccess(); }
constexpr inline typename Base::BaseType GetModule() const { return Base::GetModule(); }
constexpr inline typename Base::BaseType GetDescription() const { return Base::GetDescription(); }
constexpr inline typename Base::BaseType GetValue() const { return Base::SuccessValue; }
};
namespace result::impl {
NORETURN void OnResultAssertion(Result result);
}
constexpr inline Result::operator ResultSuccess() const {
if (!ResultSuccess::CanAccept(*this)) {
result::impl::OnResultAssertion(*this);
}
return ResultSuccess();
}
namespace result::impl {
template<ResultTraits::BaseType _Module, ResultTraits::BaseType _Description>
class ResultErrorBase : public ResultBase<ResultErrorBase<_Module, _Description>> {
public:
using Base = typename result::impl::ResultBase<ResultErrorBase<_Module, _Description>>;
static constexpr typename Base::BaseType Module = _Module;
static constexpr typename Base::BaseType Description = _Description;
static constexpr typename Base::BaseType Value = ResultTraits::MakeStaticValue<Module, Description>::value;
static_assert(Value != Base::SuccessValue, "Value != Base::SuccessValue");
public:
constexpr operator Result() const { return MakeResult(Value); }
constexpr operator ResultSuccess() const { OnResultAssertion(Value); }
constexpr inline bool IsSuccess() const { return false; }
constexpr inline bool IsFailure() const { return !this->IsSuccess(); }
constexpr inline typename Base::BaseType GetValue() const { return Value; }
};
template<ResultTraits::BaseType _Module, ResultTraits::BaseType DescStart, ResultTraits::BaseType DescEnd>
class ResultErrorRangeBase {
public:
static constexpr ResultTraits::BaseType Module = _Module;
static constexpr ResultTraits::BaseType DescriptionStart = DescStart;
static constexpr ResultTraits::BaseType DescriptionEnd = DescEnd;
static_assert(DescriptionStart <= DescriptionEnd, "DescriptionStart <= DescriptionEnd");
static constexpr typename ResultTraits::BaseType StartValue = ResultTraits::MakeStaticValue<Module, DescriptionStart>::value;
static constexpr typename ResultTraits::BaseType EndValue = ResultTraits::MakeStaticValue<Module, DescriptionEnd>::value;
public:
NX_CONSTEXPR bool Includes(Result result) {
return StartValue <= result.GetValue() && result.GetValue() <= EndValue;
}
};
}
}
/* Macros for defining new results. */
#define R_DEFINE_NAMESPACE_RESULT_MODULE(value) namespace impl::result { static constexpr inline ::sts::result::impl::ResultTraits::BaseType ResultModuleId = value; }
#define R_CURRENT_NAMESPACE_RESULT_MODULE impl::result::ResultModuleId
#define R_NAMESPACE_MODULE_ID(nmspc) nmspc::R_CURRENT_NAMESPACE_RESULT_MODULE
#define R_MAKE_NAMESPACE_RESULT(nmspc, desc) static_cast<::sts::Result>(::sts::result::impl::ResultTraits::MakeValue(R_NAMESPACE_MODULE_ID(nmspc), desc))
#define R_DEFINE_ERROR_RESULT_IMPL(name, desc_start, desc_end) \
class Result##name final : public ::sts::result::impl::ResultErrorBase<R_CURRENT_NAMESPACE_RESULT_MODULE, desc_start>, public ::sts::result::impl::ResultErrorRangeBase<R_CURRENT_NAMESPACE_RESULT_MODULE, desc_start, desc_end> {}
#define R_DEFINE_ABSTRACT_ERROR_RESULT_IMPL(name, desc_start, desc_end) \
class Result##name final : public ::sts::result::impl::ResultErrorRangeBase<R_CURRENT_NAMESPACE_RESULT_MODULE, desc_start, desc_end> {}
#define R_DEFINE_ERROR_RESULT(name, desc) R_DEFINE_ERROR_RESULT_IMPL(name, desc, desc)
#define R_DEFINE_ERROR_RANGE(name, start, end) R_DEFINE_ERROR_RESULT_IMPL(name, start, end)
#define R_DEFINE_ABSTRACT_ERROR_RESULT(name, desc) R_DEFINE_ABSTRACT_ERROR_RESULT_IMPL(name, desc, desc)
#define R_DEFINE_ABSTRACT_ERROR_RANGE(name, start, end) R_DEFINE_ABSTRACT_ERROR_RESULT_IMPL(name, start, end)
/* Remove libnx macros, replace with our own. */
#ifndef R_SUCCEEDED
#error "R_SUCCEEDED not defined."
#endif
#undef R_SUCCEEDED
#ifndef R_FAILED
#error "R_FAILED not defined"
#endif
#undef R_FAILED
#define R_SUCCEEDED(res) (static_cast<::sts::Result>(res).IsSuccess())
#define R_FAILED(res) (static_cast<::sts::Result>(res).IsFailure())
/// 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 an expression that returns a result, and fatals the result if it would fail.
#define R_ASSERT(res_expr) \
({ \
const auto _tmp_r_assert_rc = res_expr; \
if (R_FAILED(_tmp_r_assert_rc)) { \
::sts::result::impl::OnResultAssertion(_tmp_r_assert_rc); \
} \
})
/// Evaluates a boolean expression, and returns a result unless that expression is true.
#define R_UNLESS(expr, res) \
({ \
if (!(expr)) { \
return static_cast<::sts::Result>(res); \
} \
})
/// Helpers for pattern-matching on a result expression, if the result would fail.
#define R_CURRENT_RESULT _tmp_r_current_result
#define R_TRY_CATCH(res_expr) \
({ \
const auto R_CURRENT_RESULT = res_expr; \
if (R_FAILED(R_CURRENT_RESULT)) { \
if (false)
namespace sts::result::impl {
template<typename... Rs>
NX_CONSTEXPR bool AnyIncludes(Result result) {
return (Rs::Includes(result) || ...);
}
}
#define R_CATCH(...) \
} else if (::sts::result::impl::AnyIncludes<__VA_ARGS__>(R_CURRENT_RESULT)) { \
if (true)
#define R_CONVERT(catch_type, convert_type) \
R_CATCH(catch_type) { return static_cast<::sts::Result>(convert_type); }
#define R_CATCH_ALL() \
} else if (R_FAILED(R_CURRENT_RESULT)) { \
if (true)
#define R_CONVERT_ALL(convert_type) \
R_CATCH_ALL() { return static_cast<::sts::Result>(convert_type); }
#define R_END_TRY_CATCH \
else if (R_FAILED(R_CURRENT_RESULT)) { \
return R_CURRENT_RESULT; \
} \
} \
})
#define R_END_TRY_CATCH_WITH_ASSERT \
else { \
R_ASSERT(R_CURRENT_RESULT); \
} \
} \
})

View file

@ -15,26 +15,31 @@
*/
#pragma once
#include <switch.h>
#include "results_common.hpp"
static constexpr u32 Module_Ro = 22;
namespace sts::ro {
static constexpr Result ResultRoInsufficientAddressSpace = MAKERESULT(Module_Ro, 2);
static constexpr Result ResultRoAlreadyLoaded = MAKERESULT(Module_Ro, 3);
static constexpr Result ResultRoInvalidNro = MAKERESULT(Module_Ro, 4);
R_DEFINE_NAMESPACE_RESULT_MODULE(22);
static constexpr Result ResultRoInvalidNrr = MAKERESULT(Module_Ro, 6);
static constexpr Result ResultRoTooManyNro = MAKERESULT(Module_Ro, 7);
static constexpr Result ResultRoTooManyNrr = MAKERESULT(Module_Ro, 8);
static constexpr Result ResultRoNotAuthorized = MAKERESULT(Module_Ro, 9);
static constexpr Result ResultRoInvalidNrrType = MAKERESULT(Module_Ro, 10);
R_DEFINE_ERROR_RANGE(RoError, 1, 1023);
R_DEFINE_ERROR_RESULT(OutOfAddressSpace, 2);
R_DEFINE_ERROR_RESULT(AlreadyLoaded, 3);
R_DEFINE_ERROR_RESULT(InvalidNro, 4);
static constexpr Result ResultRoInternalError = MAKERESULT(Module_Ro, 1023);
R_DEFINE_ERROR_RESULT(InvalidNrr, 6);
R_DEFINE_ERROR_RESULT(TooManyNro, 7);
R_DEFINE_ERROR_RESULT(TooManyNrr, 8);
R_DEFINE_ERROR_RESULT(NotAuthorized, 9);
R_DEFINE_ERROR_RESULT(InvalidNrrType, 10);
static constexpr Result ResultRoInvalidAddress = MAKERESULT(Module_Ro, 1025);
static constexpr Result ResultRoInvalidSize = MAKERESULT(Module_Ro, 1026);
R_DEFINE_ERROR_RESULT(InternalError, 1023);
static constexpr Result ResultRoNotLoaded = MAKERESULT(Module_Ro, 1028);
static constexpr Result ResultRoNotRegistered = MAKERESULT(Module_Ro, 1029);
static constexpr Result ResultRoInvalidSession = MAKERESULT(Module_Ro, 1030);
static constexpr Result ResultRoInvalidProcess = MAKERESULT(Module_Ro, 1031);
R_DEFINE_ERROR_RESULT(InvalidAddress, 1025);
R_DEFINE_ERROR_RESULT(InvalidSize, 1026);
R_DEFINE_ERROR_RESULT(NotLoaded, 1028);
R_DEFINE_ERROR_RESULT(NotRegistered, 1029);
R_DEFINE_ERROR_RESULT(InvalidSession, 1030);
R_DEFINE_ERROR_RESULT(InvalidProcess, 1031);
}

View file

@ -15,27 +15,33 @@
*/
#pragma once
#include <switch.h>
#include "results_common.hpp"
static constexpr u32 Module_Settings = 105;
namespace sts::settings {
static constexpr Result ResultSettingsItemNotFound = MAKERESULT(Module_Settings, 11);
R_DEFINE_NAMESPACE_RESULT_MODULE(105);
static constexpr Result ResultSettingsItemKeyAllocationFailed = MAKERESULT(Module_Settings, 101);
static constexpr Result ResultSettingsItemValueAllocationFailed = MAKERESULT(Module_Settings, 102);
R_DEFINE_ERROR_RESULT(ItemNotFound, 11);
static constexpr Result ResultSettingsItemNameNull = MAKERESULT(Module_Settings, 201);
static constexpr Result ResultSettingsItemKeyNull = MAKERESULT(Module_Settings, 202);
static constexpr Result ResultSettingsItemValueNull = MAKERESULT(Module_Settings, 203);
static constexpr Result ResultSettingsItemKeyBufferNull = MAKERESULT(Module_Settings, 204);
static constexpr Result ResultSettingsItemValueBufferNull = MAKERESULT(Module_Settings, 205);
R_DEFINE_ERROR_RANGE(InternalError, 100, 149);
R_DEFINE_ERROR_RESULT(ItemKeyAllocationFailed, 101);
R_DEFINE_ERROR_RESULT(ItemValueAllocationFailed, 102);
static constexpr Result ResultSettingsItemNameEmpty = MAKERESULT(Module_Settings, 221);
static constexpr Result ResultSettingsItemKeyEmpty = MAKERESULT(Module_Settings, 222);
R_DEFINE_ERROR_RANGE(InvalidArgument, 200, 399);
R_DEFINE_ERROR_RESULT(SettingsNameNull, 201);
R_DEFINE_ERROR_RESULT(SettingsItemKeyNull, 202);
R_DEFINE_ERROR_RESULT(SettingsItemValueNull, 203);
R_DEFINE_ERROR_RESULT(SettingsItemKeyBufferNull, 204);
R_DEFINE_ERROR_RESULT(SettingsItemValueBufferNull, 205);
static constexpr Result ResultSettingsItemNameTooLong = MAKERESULT(Module_Settings, 241);
static constexpr Result ResultSettingsItemKeyTooLong = MAKERESULT(Module_Settings, 242);
R_DEFINE_ERROR_RESULT(SettingsNameEmpty, 221);
R_DEFINE_ERROR_RESULT(SettingsItemKeyEmpty, 222);
static constexpr Result ResultSettingsItemNameInvalidFormat = MAKERESULT(Module_Settings, 261);
static constexpr Result ResultSettingsItemKeyInvalidFormat = MAKERESULT(Module_Settings, 262);
static constexpr Result ResultSettingsItemValueInvalidFormat = MAKERESULT(Module_Settings, 263);
R_DEFINE_ERROR_RESULT(SettingsNameTooLong, 241);
R_DEFINE_ERROR_RESULT(SettingsItemKeyTooLong, 242);
R_DEFINE_ERROR_RESULT(SettingsNameInvalidFormat, 261);
R_DEFINE_ERROR_RESULT(SettingsItemKeyInvalidFormat, 262);
R_DEFINE_ERROR_RESULT(SettingsItemValueInvalidFormat, 263);
}

View file

@ -15,25 +15,40 @@
*/
#pragma once
#include <switch.h>
#include "results_common.hpp"
static constexpr u32 Module_ServiceFramework = 10;
namespace sts::sf {
static constexpr Result ResultServiceFrameworkNotSupported = MAKERESULT(Module_ServiceFramework, 1);
static constexpr Result ResultServiceFrameworkPreconditionViolation = MAKERESULT(Module_ServiceFramework, 3);
R_DEFINE_NAMESPACE_RESULT_MODULE(10);
static constexpr Result ResultServiceFrameworkInvalidCmifHeaderSize = MAKERESULT(Module_ServiceFramework, 202);
static constexpr Result ResultServiceFrameworkInvalidCmifInHeader = MAKERESULT(Module_ServiceFramework, 211);
static constexpr Result ResultServiceFrameworkUnknownCmifCommandId = MAKERESULT(Module_ServiceFramework, 221);
static constexpr Result ResultServiceFrameworkInvalidCmifOutRawSize = MAKERESULT(Module_ServiceFramework, 232);
static constexpr Result ResultServiceFrameworkInvalidCmifNumInObjects = MAKERESULT(Module_ServiceFramework, 235);
static constexpr Result ResultServiceFrameworkInvalidCmifNumOutObjects = MAKERESULT(Module_ServiceFramework, 236);
static constexpr Result ResultServiceFrameworkInvalidCmifInObject = MAKERESULT(Module_ServiceFramework, 239);
R_DEFINE_ERROR_RESULT(NotSupported, 1);
R_DEFINE_ERROR_RESULT(PreconditionViolation, 3);
static constexpr Result ResultServiceFrameworkTargetNotFound = MAKERESULT(Module_ServiceFramework, 261);
namespace cmif {
static constexpr Result ResultServiceFrameworkOutOfDomainEntries = MAKERESULT(Module_ServiceFramework, 301);
R_DEFINE_ERROR_RESULT(InvalidHeaderSize, 202);
R_DEFINE_ERROR_RESULT(InvalidInHeader, 211);
R_DEFINE_ERROR_RESULT(UnknownCommandId, 221);
R_DEFINE_ERROR_RESULT(InvalidOutRawSize, 232);
R_DEFINE_ERROR_RESULT(InvalidNumInObjects, 235);
R_DEFINE_ERROR_RESULT(InvalidNumOutObjects, 236);
R_DEFINE_ERROR_RESULT(InvalidInObject, 239);
R_DEFINE_ERROR_RESULT(TargetNotFound, 261);
static constexpr Result ResultServiceFrameworkRequestDeferred = MAKERESULT(Module_ServiceFramework, 811);
static constexpr Result ResultServiceFrameworkRequestDeferredByUser = MAKERESULT(Module_ServiceFramework, 812);
R_DEFINE_ERROR_RESULT(OutOfDomainEntries, 301);
}
namespace impl {
R_DEFINE_ABSTRACT_ERROR_RANGE(RequestContextChanged, 800, 899);
R_DEFINE_ABSTRACT_ERROR_RANGE(RequestInvalidated, 801, 809);
R_DEFINE_ERROR_RESULT(RequestInvalidatedByUser, 802);
}
R_DEFINE_ABSTRACT_ERROR_RANGE(RequestDeferred, 811, 819);
R_DEFINE_ERROR_RESULT(RequestDeferredByUser, 812);
}

View file

@ -15,16 +15,20 @@
*/
#pragma once
#include <switch.h>
#include "results_common.hpp"
static constexpr u32 Module_Sm = 21;
namespace sts::sm {
static constexpr Result ResultSmInsufficientProcesses = MAKERESULT(Module_Sm, 1);
static constexpr Result ResultSmInvalidClient = MAKERESULT(Module_Sm, 2);
static constexpr Result ResultSmInsufficientSessions = MAKERESULT(Module_Sm, 3);
static constexpr Result ResultSmAlreadyRegistered = MAKERESULT(Module_Sm, 4);
static constexpr Result ResultSmInsufficientServices = MAKERESULT(Module_Sm, 5);
static constexpr Result ResultSmInvalidServiceName = MAKERESULT(Module_Sm, 6);
static constexpr Result ResultSmNotRegistered = MAKERESULT(Module_Sm, 7);
static constexpr Result ResultSmNotAllowed = MAKERESULT(Module_Sm, 8);
static constexpr Result ResultSmTooLargeAccessControl = MAKERESULT(Module_Sm, 9);
R_DEFINE_NAMESPACE_RESULT_MODULE(21);
R_DEFINE_ERROR_RESULT(OutOfProcesses, 1);
R_DEFINE_ERROR_RESULT(InvalidClient, 2);
R_DEFINE_ERROR_RESULT(OutOfSessions, 3);
R_DEFINE_ERROR_RESULT(AlreadyRegistered, 4);
R_DEFINE_ERROR_RESULT(OutOfServices, 5);
R_DEFINE_ERROR_RESULT(InvalidServiceName, 6);
R_DEFINE_ERROR_RESULT(NotRegistered, 7);
R_DEFINE_ERROR_RESULT(NotAllowed, 8);
R_DEFINE_ERROR_RESULT(TooLargeAccessControl, 9);
}

View file

@ -15,25 +15,28 @@
*/
#pragma once
#include <switch.h>
#include "results_common.hpp"
static constexpr u32 Module_Spl = 26;
namespace sts::spl {
/* Results 1-99 are converted smc results. */
static constexpr Result ResultSplSmcNotImplemented = MAKERESULT(Module_Spl, 1);
static constexpr Result ResultSplSmcInvalidArgument = MAKERESULT(Module_Spl, 2);
static constexpr Result ResultSplSmcInProgress = MAKERESULT(Module_Spl, 3);
static constexpr Result ResultSplSmcNoAsyncOperation = MAKERESULT(Module_Spl, 4);
static constexpr Result ResultSplSmcInvalidAsyncOperation = MAKERESULT(Module_Spl, 5);
static constexpr Result ResultSplSmcBlacklisted = MAKERESULT(Module_Spl, 6);
R_DEFINE_NAMESPACE_RESULT_MODULE(26);
/* Results 100+ are spl results. */
static constexpr Result ResultSplInvalidSize = MAKERESULT(Module_Spl, 100);
static constexpr Result ResultSplUnknownSmcResult = MAKERESULT(Module_Spl, 101);
static constexpr Result ResultSplDecryptionFailed = MAKERESULT(Module_Spl, 102);
R_DEFINE_ERROR_RANGE(SecureMonitorError, 0, 99);
R_DEFINE_ERROR_RESULT(SecureMonitorNotImplemented, 1);
R_DEFINE_ERROR_RESULT(SecureMonitorInvalidArgument, 2);
R_DEFINE_ERROR_RESULT(SecureMonitorBusy, 3);
R_DEFINE_ERROR_RESULT(SecureMonitorNoAsyncOperation, 4);
R_DEFINE_ERROR_RESULT(SecureMonitorInvalidAsyncOperation, 5);
R_DEFINE_ERROR_RESULT(SecureMonitorNotPermitted, 6);
static constexpr Result ResultSplOutOfKeyslots = MAKERESULT(Module_Spl, 104);
static constexpr Result ResultSplInvalidKeyslot = MAKERESULT(Module_Spl, 105);
static constexpr Result ResultSplBootReasonAlreadySet = MAKERESULT(Module_Spl, 106);
static constexpr Result ResultSplBootReasonNotSet = MAKERESULT(Module_Spl, 107);
static constexpr Result ResultSplInvalidArgument = MAKERESULT(Module_Spl, 108);
R_DEFINE_ERROR_RESULT(InvalidSize, 100);
R_DEFINE_ERROR_RESULT(UnknownSecureMonitorError, 101);
R_DEFINE_ERROR_RESULT(DecryptionFailed, 102);
R_DEFINE_ERROR_RESULT(OutOfKeyslots, 104);
R_DEFINE_ERROR_RESULT(InvalidKeyslot, 105);
R_DEFINE_ERROR_RESULT(BootReasonAlreadySet, 106);
R_DEFINE_ERROR_RESULT(BootReasonNotSet, 107);
R_DEFINE_ERROR_RESULT(InvalidArgument, 108);
}

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