diff --git a/stratosphere/boot/Makefile b/stratosphere/boot/Makefile index 1a8be006b..0fcdbf618 100644 --- a/stratosphere/boot/Makefile +++ b/stratosphere/boot/Makefile @@ -38,7 +38,7 @@ DATA := data INCLUDES := include ../../common/include EXEFS_SRC := exefs_src -DEFINES := -DDISABLE_IPC -DATMOSPHERE_GIT_BRANCH=\"$(AMSBRANCH)\" -DATMOSPHERE_GIT_REV=\"$(AMSREV)\" +DEFINES := -DRESULT_ABORT_ON_ASSERT -DATMOSPHERE_GIT_BRANCH=\"$(AMSBRANCH)\" -DATMOSPHERE_GIT_REV=\"$(AMSREV)\" #--------------------------------------------------------------------------------- # options for code generation diff --git a/stratosphere/boot/source/boot_i2c_utils.cpp b/stratosphere/boot/source/boot_i2c_utils.cpp index 6487ccea9..f42276add 100644 --- a/stratosphere/boot/source/boot_i2c_utils.cpp +++ b/stratosphere/boot/source/boot_i2c_utils.cpp @@ -36,7 +36,6 @@ static Result RetryUntilSuccess(F f) { } Result Boot::ReadI2cRegister(I2cSessionImpl &session, u8 *dst, size_t dst_size, const u8 *cmd, size_t cmd_size) { - Result rc; if (dst == nullptr || dst_size == 0 || cmd == nullptr || cmd_size == 0) { std::abort(); } @@ -44,12 +43,8 @@ Result Boot::ReadI2cRegister(I2cSessionImpl &session, u8 *dst, size_t dst_size, u8 cmd_list[I2cCommandListFormatter::MaxCommandListSize]; I2cCommandListFormatter formatter(cmd_list, sizeof(cmd_list)); - if (R_FAILED((rc = formatter.EnqueueSendCommand(I2cTransactionOption_Start, cmd, cmd_size)))) { - std::abort(); - } - if (R_FAILED((rc = formatter.EnqueueReceiveCommand(static_cast(I2cTransactionOption_Start | I2cTransactionOption_Stop), dst_size)))) { - std::abort(); - } + R_ASSERT(formatter.EnqueueSendCommand(I2cTransactionOption_Start, cmd, cmd_size)); + R_ASSERT(formatter.EnqueueReceiveCommand(static_cast(I2cTransactionOption_Start | I2cTransactionOption_Stop), dst_size)); return RetryUntilSuccess([&]() { return I2cDriver::ExecuteCommandList(session, dst, dst_size, cmd_list, formatter.GetCurrentSize()); }); } diff --git a/stratosphere/boot/source/boot_main.cpp b/stratosphere/boot/source/boot_main.cpp index 945d7e35c..95a7062c2 100644 --- a/stratosphere/boot/source/boot_main.cpp +++ b/stratosphere/boot/source/boot_main.cpp @@ -69,26 +69,13 @@ void __libnx_initheap(void) { } void __appInit(void) { - Result rc; - SetFirmwareVersionForLibnx(); /* Initialize services we need (TODO: NCM) */ DoWithSmSession([&]() { - rc = fsInitialize(); - if (R_FAILED(rc)) { - std::abort(); - } - - rc = splInitialize(); - if (R_FAILED(rc)) { - std::abort(); - } - - rc = pmshellInitialize(); - if (R_FAILED(rc)) { - std::abort(); - } + R_ASSERT(fsInitialize()); + R_ASSERT(splInitialize()); + R_ASSERT(pmshellInitialize()); }); CheckAtmosphereVersion(CURRENT_ATMOSPHERE_VERSION); diff --git a/stratosphere/boot/source/boot_repair_boot_images.cpp b/stratosphere/boot/source/boot_repair_boot_images.cpp index a05e7d1dc..8b020cc75 100644 --- a/stratosphere/boot/source/boot_repair_boot_images.cpp +++ b/stratosphere/boot/source/boot_repair_boot_images.cpp @@ -23,8 +23,7 @@ void Boot::CheckAndRepairBootImages() { const BootImageUpdateType boot_image_update_type = Updater::GetBootImageUpdateType(Boot::GetHardwareType()); bool repaired_normal, repaired_safe; - Result rc = Updater::VerifyBootImagesAndRepairIfNeeded(&repaired_normal, &repaired_safe, g_boot_image_work_buffer, sizeof(g_boot_image_work_buffer), boot_image_update_type); - if (R_SUCCEEDED(rc) && repaired_normal) { + if (R_SUCCEEDED(Updater::VerifyBootImagesAndRepairIfNeeded(&repaired_normal, &repaired_safe, g_boot_image_work_buffer, sizeof(g_boot_image_work_buffer), boot_image_update_type)) && repaired_normal) { /* Nintendo only performs a reboot on successful normal repair. */ Boot::RebootSystem(); } diff --git a/stratosphere/creport/source/creport_main.cpp b/stratosphere/creport/source/creport_main.cpp index 0a9c0943d..f536c779d 100644 --- a/stratosphere/creport/source/creport_main.cpp +++ b/stratosphere/creport/source/creport_main.cpp @@ -65,21 +65,13 @@ void __libnx_initheap(void) { } void __appInit(void) { - Result rc; - SetFirmwareVersionForLibnx(); DoWithSmSession([&]() { - rc = fsInitialize(); - if (R_FAILED(rc)) { - fatalSimple(MAKERESULT(Module_Libnx, LibnxError_InitFail_FS)); - } + R_ASSERT(fsInitialize()); }); - rc = fsdevMountSdmc(); - if (R_FAILED(rc)) { - fatalSimple(MAKERESULT(Module_Libnx, LibnxError_InitFail_FS)); - } + R_ASSERT(fsdevMountSdmc()); } void __appExit(void) { diff --git a/stratosphere/dmnt/source/dmnt_cheat_debug_events_manager.cpp b/stratosphere/dmnt/source/dmnt_cheat_debug_events_manager.cpp index 638533025..ab9c36a39 100644 --- a/stratosphere/dmnt/source/dmnt_cheat_debug_events_manager.cpp +++ b/stratosphere/dmnt/source/dmnt_cheat_debug_events_manager.cpp @@ -61,12 +61,7 @@ void DmntCheatDebugEventsManager::ContinueCheatProcess(Handle cheat_dbg_hnd) { if (dbg_event.type == DebugEventType::AttachThread) { u64 out64; u32 out32; - Result rc = svcGetDebugThreadParam(&out64, &out32, cheat_dbg_hnd, dbg_event.info.attach_thread.thread_id, DebugThreadParam_CurrentCore); - if (R_FAILED(rc)) { - fatalSimple(rc); - } - - + R_ASSERT(svcGetDebugThreadParam(&out64, &out32, cheat_dbg_hnd, dbg_event.info.attach_thread.thread_id, DebugThreadParam_CurrentCore)); target_core = out32; } diff --git a/stratosphere/dmnt/source/dmnt_cheat_manager.cpp b/stratosphere/dmnt/source/dmnt_cheat_manager.cpp index 543115c99..e569f4ace 100644 --- a/stratosphere/dmnt/source/dmnt_cheat_manager.cpp +++ b/stratosphere/dmnt/source/dmnt_cheat_manager.cpp @@ -54,15 +54,8 @@ void DmntCheatManager::StartDebugEventsThread() { /* Spawn the debug events thread. */ if (!g_has_debug_events_thread) { - Result rc; - - if (R_FAILED((rc = g_debug_events_thread.Initialize(&DmntCheatManager::DebugEventsThread, nullptr, 0x4000, 48)))) { - return fatalSimple(rc); - } - - if (R_FAILED((rc = g_debug_events_thread.Start()))) { - return fatalSimple(rc); - } + R_ASSERT(g_debug_events_thread.Initialize(&DmntCheatManager::DebugEventsThread, nullptr, 0x4000, 48)); + R_ASSERT(g_debug_events_thread.Start()); g_has_debug_events_thread = true; } @@ -799,33 +792,22 @@ Result DmntCheatManager::DisableFrozenAddress(u64 address) { } Handle DmntCheatManager::PrepareDebugNextApplication() { - Result rc; Handle event_h; - if (R_FAILED((rc = pmdmntEnableDebugForApplication(&event_h)))) { - fatalSimple(rc); - } + R_ASSERT(pmdmntEnableDebugForApplication(&event_h)); return event_h; } static void PopulateMemoryExtents(MemoryRegionExtents *extents, Handle p_h, u64 id_base, u64 id_size) { - Result rc; /* Get base extent. */ - if (R_FAILED((rc = svcGetInfo(&extents->base, id_base, p_h, 0)))) { - fatalSimple(rc); - } + R_ASSERT(svcGetInfo(&extents->base, id_base, p_h, 0)); /* Get size extent. */ - if (R_FAILED((rc = svcGetInfo(&extents->size, id_size, p_h, 0)))) { - fatalSimple(rc); - } + R_ASSERT(svcGetInfo(&extents->size, id_size, p_h, 0)); } static void StartDebugProcess(u64 pid) { - Result rc = pmdmntStartProcess(pid); - if (R_FAILED(rc)) { - fatalSimple(rc); - } + R_ASSERT(pmdmntStartProcess(pid)); } Result DmntCheatManager::ForceOpenCheatProcess() { @@ -921,7 +903,6 @@ Result DmntCheatManager::ForceOpenCheatProcess() { void DmntCheatManager::OnNewApplicationLaunch() { std::scoped_lock attach_lk(g_attach_lock); - Result rc; { std::scoped_lock lk(g_cheat_lock); @@ -937,18 +918,14 @@ void DmntCheatManager::OnNewApplicationLaunch() { std::scoped_lock lk(g_cheat_lock); /* Get the new application's process ID. */ - if (R_FAILED((rc = pmdmntGetApplicationPid(&g_cheat_process_metadata.process_id)))) { - fatalSimple(rc); - } + R_ASSERT(pmdmntGetApplicationPid(&g_cheat_process_metadata.process_id)); /* Get process handle, use it to learn memory extents. */ { Handle proc_h = 0; ON_SCOPE_EXIT { if (proc_h != 0) { svcCloseHandle(proc_h); } }; - if (R_FAILED((rc = pmdmntAtmosphereGetProcessInfo(&proc_h, &g_cheat_process_metadata.title_id, nullptr, g_cheat_process_metadata.process_id)))) { - fatalSimple(rc); - } + R_ASSERT(pmdmntAtmosphereGetProcessInfo(&proc_h, &g_cheat_process_metadata.title_id, nullptr, g_cheat_process_metadata.process_id)); /* Get memory extents. */ PopulateMemoryExtents(&g_cheat_process_metadata.heap_extents, proc_h, 4, 5); @@ -972,9 +949,7 @@ void DmntCheatManager::OnNewApplicationLaunch() { { LoaderModuleInfo proc_modules[2]; u32 num_modules; - if (R_FAILED((rc = ldrDmntGetModuleInfos(g_cheat_process_metadata.process_id, proc_modules, sizeof(proc_modules)/sizeof(proc_modules[0]), &num_modules)))) { - fatalSimple(rc); - } + R_ASSERT(ldrDmntGetModuleInfos(g_cheat_process_metadata.process_id, proc_modules, sizeof(proc_modules)/sizeof(proc_modules[0]), &num_modules)); /* All applications must have two modules. */ /* If we only have one, we must be e.g. mitming HBL. */ @@ -999,9 +974,7 @@ void DmntCheatManager::OnNewApplicationLaunch() { } /* Open a debug handle. */ - if (R_FAILED((rc = svcDebugActiveProcess(&g_cheat_process_debug_hnd, g_cheat_process_metadata.process_id)))) { - fatalSimple(rc); - } + R_ASSERT(svcDebugActiveProcess(&g_cheat_process_debug_hnd, g_cheat_process_metadata.process_id)); /* Start the process. */ StartDebugProcess(g_cheat_process_metadata.process_id); diff --git a/stratosphere/dmnt/source/dmnt_main.cpp b/stratosphere/dmnt/source/dmnt_main.cpp index d63c466a2..ac4d435ab 100644 --- a/stratosphere/dmnt/source/dmnt_main.cpp +++ b/stratosphere/dmnt/source/dmnt_main.cpp @@ -59,64 +59,23 @@ void __libnx_initheap(void) { } void __appInit(void) { - Result rc; - SetFirmwareVersionForLibnx(); DoWithSmSession([&]() { - rc = pmdmntInitialize(); - if (R_FAILED(rc)) { - fatalSimple(rc); - } - - rc = ldrDmntInitialize(); - if (R_FAILED(rc)) { - fatalSimple(rc); - } - + R_ASSERT(pmdmntInitialize()); + R_ASSERT(ldrDmntInitialize()); /* TODO: We provide this on every sysver via ro. Do we need a shim? */ if (GetRuntimeFirmwareVersion() >= FirmwareVersion_300) { - rc = roDmntInitialize(); - if (R_FAILED(rc)) { - fatalSimple(rc); - } - } - - rc = nsdevInitialize(); - if (R_FAILED(rc)) { - fatalSimple(rc); - } - - rc = lrInitialize(); - if (R_FAILED(rc)) { - fatalSimple(rc); - } - - rc = setInitialize(); - if (R_FAILED(rc)) { - fatalSimple(rc); - } - - rc = setsysInitialize(); - if (R_FAILED(rc)) { - fatalSimple(rc); - } - - rc = hidInitialize(); - if (R_FAILED(rc)) { - fatalSimple(rc); - } - - rc = fsInitialize(); - if (R_FAILED(rc)) { - fatalSimple(rc); + R_ASSERT(roDmntInitialize()); } + R_ASSERT(nsdevInitialize()); + R_ASSERT(lrInitialize()); + R_ASSERT(setInitialize()); + R_ASSERT(setsysInitialize()); + R_ASSERT(fsInitialize()); }); - rc = fsdevMountSdmc(); - if (R_FAILED(rc)) { - fatalSimple(rc); - } + R_ASSERT(fsdevMountSdmc()); CheckAtmosphereVersion(CURRENT_ATMOSPHERE_VERSION); } diff --git a/stratosphere/fatal/Makefile b/stratosphere/fatal/Makefile index fbbe7ae9c..ad916c1c4 100644 --- a/stratosphere/fatal/Makefile +++ b/stratosphere/fatal/Makefile @@ -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 := -DRESULT_ABORT_ON_ASSERT -DATMOSPHERE_GIT_BRANCH=\"$(AMSBRANCH)\" -DATMOSPHERE_GIT_REV=\"$(AMSREV)\" #--------------------------------------------------------------------------------- # options for code generation diff --git a/stratosphere/fatal/source/fatal_main.cpp b/stratosphere/fatal/source/fatal_main.cpp index 22c1ac6e2..39bf8a86e 100644 --- a/stratosphere/fatal/source/fatal_main.cpp +++ b/stratosphere/fatal/source/fatal_main.cpp @@ -72,83 +72,30 @@ void __libnx_initheap(void) { } void __appInit(void) { - Result rc; - SetFirmwareVersionForLibnx(); DoWithSmSession([&]() { - rc = setInitialize(); - if (R_FAILED(rc)) { - std::abort(); - } - - rc = setsysInitialize(); - if (R_FAILED(rc)) { - std::abort(); - } - - rc = pminfoInitialize(); - if (R_FAILED(rc)) { - std::abort(); - } - - rc = i2cInitialize(); - if (R_FAILED(rc)) { - std::abort(); - } - - rc = bpcInitialize(); - if (R_FAILED(rc)) { - std::abort(); - } + R_ASSERT(setInitialize()); + R_ASSERT(setsysInitialize()); + R_ASSERT(pminfoInitialize()); + R_ASSERT(i2cInitialize()); + R_ASSERT(bpcInitialize()); if (GetRuntimeFirmwareVersion() >= FirmwareVersion_800) { - rc = clkrstInitialize(); - if (R_FAILED(rc)) { - std::abort(); - } + R_ASSERT(clkrstInitialize()); } else { - rc = pcvInitialize(); - if (R_FAILED(rc)) { - std::abort(); - } + R_ASSERT(pcvInitialize()); } - rc = lblInitialize(); - if (R_FAILED(rc)) { - std::abort(); - } - - rc = psmInitialize(); - if (R_FAILED(rc)) { - std::abort(); - } - - rc = spsmInitialize(); - if (R_FAILED(rc)) { - std::abort(); - } - - rc = plInitialize(); - if (R_FAILED(rc)) { - std::abort(); - } - - rc = gpioInitialize(); - if (R_FAILED(rc)) { - std::abort(); - } - - rc = fsInitialize(); - if (R_FAILED(rc)) { - std::abort(); - } + R_ASSERT(lblInitialize()); + R_ASSERT(psmInitialize()); + R_ASSERT(spsmInitialize()); + R_ASSERT(plInitialize()); + R_ASSERT(gpioInitialize()); + R_ASSERT(fsInitialize()); }); - rc = fsdevMountSdmc(); - if (R_FAILED(rc)) { - std::abort(); - } + R_ASSERT(fsdevMountSdmc()); /* fatal cannot throw fatal, so don't do: CheckAtmosphereVersion(CURRENT_ATMOSPHERE_VERSION); */ } diff --git a/stratosphere/fatal/source/fatal_task.cpp b/stratosphere/fatal/source/fatal_task.cpp index dd3cf9b36..8289d4a70 100644 --- a/stratosphere/fatal/source/fatal_task.cpp +++ b/stratosphere/fatal/source/fatal_task.cpp @@ -33,8 +33,7 @@ static size_t g_num_threads = 0; static void RunTaskThreadFunc(void *arg) { IFatalTask *task = reinterpret_cast(arg); - Result rc = task->Run(); - if (R_FAILED(rc)) { + if (R_FAILED(task->Run())) { /* TODO: Log task failure, somehow? */ } diff --git a/stratosphere/fatal/source/fatal_task_power.cpp b/stratosphere/fatal/source/fatal_task_power.cpp index 2813d0468..1c2bb0522 100644 --- a/stratosphere/fatal/source/fatal_task_power.cpp +++ b/stratosphere/fatal/source/fatal_task_power.cpp @@ -122,22 +122,20 @@ void PowerButtonObserveTask::WaitForPowerButton() { BpcSleepButtonState state; GpioValue val; while (true) { - Result rc = ResultSuccess; - if (config->is_auto_reboot_enabled && auto_reboot_helper.TimedOut() ) { bpcRebootSystem(); return; } - if (check_vol_up && R_SUCCEEDED((rc = gpioPadGetValue(&vol_up_btn, &val))) && val == GpioValue_Low) { + if (check_vol_up && R_SUCCEEDED(gpioPadGetValue(&vol_up_btn, &val)) && val == GpioValue_Low) { bpcRebootSystem(); } - if (check_vol_down && R_SUCCEEDED((rc = gpioPadGetValue(&vol_down_btn, &val))) && val == GpioValue_Low) { + if (check_vol_down && R_SUCCEEDED(gpioPadGetValue(&vol_down_btn, &val)) && val == GpioValue_Low) { bpcRebootSystem(); } - if ((R_SUCCEEDED(rc = bpcGetSleepButtonState(&state)) && state == BpcSleepButtonState_Held) || (config->quest_flag && reboot_helper.TimedOut())) { + if ((R_SUCCEEDED(bpcGetSleepButtonState(&state)) && state == BpcSleepButtonState_Held) || (config->quest_flag && reboot_helper.TimedOut())) { bpcRebootSystem(); return; } diff --git a/stratosphere/fatal/source/fatal_task_screen.cpp b/stratosphere/fatal/source/fatal_task_screen.cpp index a1fa670c8..3ce541b1d 100644 --- a/stratosphere/fatal/source/fatal_task_screen.cpp +++ b/stratosphere/fatal/source/fatal_task_screen.cpp @@ -145,9 +145,7 @@ Result ShowFatalTask::ShowFatal() { /* Prepare screen for drawing. */ DoWithSmSession([&]() { - Result rc = PrepareScreenForDrawing(); - if (R_FAILED(rc)) { - *(volatile u32 *)(0xCAFEBABE) = rc; + if (R_FAILED(PrepareScreenForDrawing())) { std::abort(); } }); diff --git a/stratosphere/libstratosphere b/stratosphere/libstratosphere index 3274848b5..7c9df9cfd 160000 --- a/stratosphere/libstratosphere +++ b/stratosphere/libstratosphere @@ -1 +1 @@ -Subproject commit 3274848b5612a9fa3a7306c7c4ca0a4b041c150c +Subproject commit 7c9df9cfd8293c01934050ceafc1213622645fee diff --git a/stratosphere/loader/Makefile b/stratosphere/loader/Makefile index 4ebc8f6d9..cd7b81cb1 100644 --- a/stratosphere/loader/Makefile +++ b/stratosphere/loader/Makefile @@ -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 := -DRESULT_ABORT_ON_ASSERT -DATMOSPHERE_GIT_BRANCH=\"$(AMSBRANCH)\" -DATMOSPHERE_GIT_REV=\"$(AMSREV)\" #--------------------------------------------------------------------------------- # options for code generation diff --git a/stratosphere/loader/source/ldr_content_management.cpp b/stratosphere/loader/source/ldr_content_management.cpp index 77ac3042f..d07b0cf34 100644 --- a/stratosphere/loader/source/ldr_content_management.cpp +++ b/stratosphere/loader/source/ldr_content_management.cpp @@ -92,9 +92,7 @@ Result ContentManagement::MountCode(u64 tid, FsStorageId sid) { /* Always re-initialize fsp-ldr, in case it's closed */ DoWithSmSession([&]() { - if (R_FAILED(fsldrInitialize())) { - std::abort(); - } + R_ASSERT(fsldrInitialize()); }); ON_SCOPE_EXIT { fsldrExit(); }; diff --git a/stratosphere/loader/source/ldr_hid.cpp b/stratosphere/loader/source/ldr_hid.cpp index eb9c58075..20ad55995 100644 --- a/stratosphere/loader/source/ldr_hid.cpp +++ b/stratosphere/loader/source/ldr_hid.cpp @@ -26,11 +26,13 @@ Result HidManagement::GetKeysHeld(u64 *keys) { } if (!serviceIsActive(hidGetSessionService())) { - Result rc; + bool initialized = false; DoWithSmSession([&]() { - rc = hidInitialize(); + if (R_SUCCEEDED(hidInitialize())) { + initialized = true; + } }); - if (R_FAILED(rc)) { + if (!initialized) { return MAKERESULT(Module_Libnx, LibnxError_InitFail_HID); } } diff --git a/stratosphere/loader/source/ldr_main.cpp b/stratosphere/loader/source/ldr_main.cpp index ae36c0ac6..badf71771 100644 --- a/stratosphere/loader/source/ldr_main.cpp +++ b/stratosphere/loader/source/ldr_main.cpp @@ -66,26 +66,13 @@ void __libnx_initheap(void) { } void __appInit(void) { - Result rc; - SetFirmwareVersionForLibnx(); /* Initialize services we need (TODO: SPL) */ DoWithSmSession([&]() { - rc = fsInitialize(); - if (R_FAILED(rc)) { - std::abort(); - } - - rc = lrInitialize(); - if (R_FAILED(rc)) { - std::abort(); - } - - rc = fsldrInitialize(); - if (R_FAILED(rc)) { - std::abort(); - } + R_ASSERT(fsInitialize()); + R_ASSERT(lrInitialize()); + R_ASSERT(fsldrInitialize()); }); diff --git a/stratosphere/loader/source/ldr_map.cpp b/stratosphere/loader/source/ldr_map.cpp index f98c207a6..3d8b95eae 100644 --- a/stratosphere/loader/source/ldr_map.cpp +++ b/stratosphere/loader/source/ldr_map.cpp @@ -56,9 +56,7 @@ Result MapUtils::LocateSpaceForMapModern(u64 *out, u64 out_size) { } cur_base = address_space.map_end; } else { - if (R_FAILED(svcQueryMemory(&mem_info, &page_info, cur_base))) { - std::abort(); - } + R_ASSERT(svcQueryMemory(&mem_info, &page_info, cur_base)); if (mem_info.type == 0 && mem_info.addr - cur_base + mem_info.size >= out_size) { *out = cur_base; return ResultSuccess; diff --git a/stratosphere/loader/source/ldr_map.hpp b/stratosphere/loader/source/ldr_map.hpp index eca5105ab..8cdb0ccab 100644 --- a/stratosphere/loader/source/ldr_map.hpp +++ b/stratosphere/loader/source/ldr_map.hpp @@ -71,9 +71,7 @@ class AutoCloseMap { void Close() { if (this->mapped_address) { - if (R_FAILED(svcUnmapProcessMemory(this->mapped_address, this->process_handle, this->base_address, this->size))) { - std::abort(); - } + R_ASSERT(svcUnmapProcessMemory(this->mapped_address, this->process_handle, this->base_address, this->size)); this->mapped_address = NULL; } } diff --git a/stratosphere/loader/source/ldr_process_creation.cpp b/stratosphere/loader/source/ldr_process_creation.cpp index e76cdf20f..228150655 100644 --- a/stratosphere/loader/source/ldr_process_creation.cpp +++ b/stratosphere/loader/source/ldr_process_creation.cpp @@ -165,8 +165,9 @@ Result ProcessCreation::CreateProcess(Handle *out_process_h, u64 index, char *nc } ON_SCOPE_EXIT { if (mounted_code) { - if (R_FAILED(ContentManagement::UnmountCode()) && target_process->tid_sid.storage_id != FsStorageId_None) { - std::abort(); + const Result unmount_res = ContentManagement::UnmountCode(); + if (target_process->tid_sid.storage_id != FsStorageId_None) { + R_ASSERT(unmount_res); } } }; diff --git a/stratosphere/loader/source/ldr_registration.cpp b/stratosphere/loader/source/ldr_registration.cpp index d02925fed..29be5f842 100644 --- a/stratosphere/loader/source/ldr_registration.cpp +++ b/stratosphere/loader/source/ldr_registration.cpp @@ -139,8 +139,9 @@ void Registration::AssociatePidTidForMitM(u64 index) { } Handle sm_hnd; - Result rc = svcConnectToNamedPort(&sm_hnd, "sm:"); - if (R_SUCCEEDED(rc)) { + if (R_SUCCEEDED(svcConnectToNamedPort(&sm_hnd, "sm:"))) { + ON_SCOPE_EXIT { svcCloseHandle(sm_hnd); }; + /* Initialize. */ { IpcCommand c; @@ -158,22 +159,25 @@ void Registration::AssociatePidTidForMitM(u64 index) { raw->cmd_id = 0; raw->zero = 0; - rc = ipcDispatch(sm_hnd); + if (R_FAILED(ipcDispatch(sm_hnd))) { + return; + } - if (R_SUCCEEDED(rc)) { - IpcParsedCommand r; - ipcParse(&r); + IpcParsedCommand r; + ipcParse(&r); - struct { - u64 magic; - u64 result; - } *resp = (decltype(resp))r.Raw; + struct { + u64 magic; + u64 result; + } *resp = (decltype(resp))r.Raw; - rc = resp->result; + if (R_FAILED(resp->result)) { + return; } } + /* Associate. */ - if (R_SUCCEEDED(rc)) { + { IpcCommand c; ipcInitialize(&c); struct { @@ -190,6 +194,5 @@ void Registration::AssociatePidTidForMitM(u64 index) { ipcDispatch(sm_hnd); } - svcCloseHandle(sm_hnd); } } \ No newline at end of file diff --git a/stratosphere/pm/Makefile b/stratosphere/pm/Makefile index 766f33dd4..41eae74cb 100644 --- a/stratosphere/pm/Makefile +++ b/stratosphere/pm/Makefile @@ -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 := -DRESULT_ABORT_ON_ASSERT -DATMOSPHERE_GIT_BRANCH=\"$(AMSBRANCH)\" -DATMOSPHERE_GIT_REV=\"$(AMSREV)\" #--------------------------------------------------------------------------------- # options for code generation diff --git a/stratosphere/pm/source/pm_boot2.cpp b/stratosphere/pm/source/pm_boot2.cpp index 9511f168c..e51c7bd14 100644 --- a/stratosphere/pm/source/pm_boot2.cpp +++ b/stratosphere/pm/source/pm_boot2.cpp @@ -60,31 +60,26 @@ static void LaunchTitle(u64 title_id, FsStorageId storage_id, u32 launch_flags, return; } - Result rc = Registration::LaunchProcessByTidSid(Registration::TidSid{title_id, storage_id}, launch_flags, &local_pid); - switch (rc) { + switch (Registration::LaunchProcessByTidSid(Registration::TidSid{title_id, storage_id}, launch_flags, &local_pid)) { case ResultKernelResourceExhausted: /* Out of resource! */ std::abort(); - break; case ResultKernelOutOfMemory: /* Out of memory! */ std::abort(); - break; case ResultKernelLimitReached: /* Limit Reached! */ std::abort(); - break; default: /* We don't care about other issues. */ break; } + if (pid) { *pid = local_pid; } - if (R_SUCCEEDED(rc)) { - SetLaunchedTitle(title_id); - } + SetLaunchedTitle(title_id); } static bool GetGpioPadLow(GpioPadName pad) { @@ -105,11 +100,10 @@ static bool GetGpioPadLow(GpioPadName pad) { static bool IsMaintenanceMode() { /* Contact set:sys, retrieve boot!force_maintenance. */ - Result rc; DoWithSmSession([&]() { - rc = setsysInitialize(); + R_ASSERT(setsysInitialize()); }); - if (R_SUCCEEDED(rc)) { + { ON_SCOPE_EXIT { setsysExit(); }; u8 force_maintenance = 1; @@ -121,9 +115,9 @@ static bool IsMaintenanceMode() { /* Contact GPIO, read plus/minus buttons. */ DoWithSmSession([&]() { - rc = gpioInitialize(); + R_ASSERT(gpioInitialize()); }); - if (R_SUCCEEDED(rc)) { + { ON_SCOPE_EXIT { gpioExit(); }; return GetGpioPadLow(GpioPadName_ButtonVolUp) && GetGpioPadLow(GpioPadName_ButtonVolDown); @@ -179,11 +173,8 @@ static void MountSdCard() { Handle tmp_hnd = 0; static const char * const required_active_services[] = {"pcv", "gpio", "pinmux", "psc:c"}; for (unsigned int i = 0; i < sizeof(required_active_services) / sizeof(required_active_services[0]); i++) { - if (R_FAILED(smGetServiceOriginal(&tmp_hnd, smEncodeName(required_active_services[i])))) { - std::abort(); - } else { - svcCloseHandle(tmp_hnd); - } + R_ASSERT(smGetServiceOriginal(&tmp_hnd, smEncodeName(required_active_services[i]))); + svcCloseHandle(tmp_hnd); } }); fsdevMountSdmc(); @@ -192,21 +183,17 @@ static void MountSdCard() { static void WaitForMitm(const char *service) { bool mitm_installed = false; - Result rc; DoWithSmSession([&]() { - if (R_FAILED((rc = smManagerAmsInitialize()))) { - std::abort(); - } + R_ASSERT(smManagerAmsInitialize()); }); + ON_SCOPE_EXIT { smManagerAmsExit(); }; - while (R_FAILED((rc = smManagerAmsHasMitm(&mitm_installed, service))) || !mitm_installed) { - if (R_FAILED(rc)) { - std::abort(); + while (!mitm_installed) { + R_ASSERT(smManagerAmsHasMitm(&mitm_installed, service)); + if (!mitm_installed) { + svcSleepThread(1000000ull); } - svcSleepThread(1000000ull); } - - smManagerAmsExit(); } void EmbeddedBoot2::Main() { diff --git a/stratosphere/pm/source/pm_main.cpp b/stratosphere/pm/source/pm_main.cpp index 58a0c6c23..d67811c19 100644 --- a/stratosphere/pm/source/pm_main.cpp +++ b/stratosphere/pm/source/pm_main.cpp @@ -95,51 +95,26 @@ void RegisterPrivilegedProcessesWithFs() { } void __appInit(void) { - Result rc; - SetFirmwareVersionForLibnx(); DoWithSmSession([&]() { - rc = fsprInitialize(); - if (R_FAILED(rc)) { - std::abort(); - } + R_ASSERT(fsprInitialize()); /* This works around a bug with process permissions on < 4.0.0. */ RegisterPrivilegedProcessesWithFs(); - rc = smManagerAmsInitialize(); - if (R_SUCCEEDED(rc)) { + /* Use AMS manager extension to tell SM that FS has been worked around. */ + { + R_ASSERT(smManagerAmsInitialize()); smManagerAmsEndInitialDefers(); smManagerAmsExit(); - } else { - std::abort(); } - rc = smManagerInitialize(); - if (R_FAILED(rc)) { - std::abort(); - } - - rc = lrInitialize(); - if (R_FAILED(rc)) { - std::abort(); - } - - rc = ldrPmInitialize(); - if (R_FAILED(rc)) { - std::abort(); - } - - rc = splInitialize(); - if (R_FAILED(rc)) { - std::abort(); - } - - rc = fsInitialize(); - if (R_FAILED(rc)) { - std::abort(); - } + R_ASSERT(smManagerInitialize()); + R_ASSERT(lrInitialize()); + R_ASSERT(ldrPmInitialize()); + R_ASSERT(splInitialize()); + R_ASSERT(fsInitialize()); }); CheckAtmosphereVersion(CURRENT_ATMOSPHERE_VERSION); @@ -163,12 +138,8 @@ int main(int argc, char **argv) /* Initialize and spawn the Process Tracking thread. */ Registration::InitializeSystemResources(); - if (R_FAILED(process_track_thread.Initialize(&ProcessTracking::MainLoop, NULL, 0x4000, 0x15))) { - std::abort(); - } - if (R_FAILED(process_track_thread.Start())) { - std::abort(); - } + R_ASSERT(process_track_thread.Initialize(&ProcessTracking::MainLoop, NULL, 0x4000, 0x15)); + R_ASSERT(process_track_thread.Start()); /* Create Server Manager. */ static auto s_server_manager = WaitableManager(1); diff --git a/stratosphere/pm/source/pm_registration.cpp b/stratosphere/pm/source/pm_registration.cpp index b51d27684..f5943addd 100644 --- a/stratosphere/pm/source/pm_registration.cpp +++ b/stratosphere/pm/source/pm_registration.cpp @@ -100,9 +100,7 @@ Result Registration::LaunchProcess(u64 *out_pid, const TidSid tid_sid, const u64 }; /* Get the new process's id. */ - if (R_FAILED(svcGetProcessId(&new_process.pid, new_process.handle))) { - std::abort(); - } + R_ASSERT(svcGetProcessId(&new_process.pid, new_process.handle)); /* Register with FS. */ memcpy(fac, program_info.ac_buffer + program_info.acid_sac_size + program_info.aci0_sac_size, program_info.acid_fac_size); @@ -283,18 +281,10 @@ void Registration::FinalizeExitedProcess(std::shared_ptr signal_debug_process_5x = (GetRuntimeFirmwareVersion() >= FirmwareVersion_500) && process->flags & PROCESSFLAGS_NOTIFYWHENEXITED; - /* Unregister with FS. */ - if (R_FAILED(fsprUnregisterProgram(process->pid))) { - std::abort(); - } - /* Unregister with SM. */ - if (R_FAILED(smManagerUnregisterProcess(process->pid))) { - std::abort(); - } - /* Unregister with LDR. */ - if (R_FAILED(ldrPmUnregisterTitle(process->ldr_queue_index))) { - std::abort(); - } + /* Unregister with FS, SM, and LDR. */ + R_ASSERT(fsprUnregisterProgram(process->pid)); + R_ASSERT(smManagerUnregisterProcess(process->pid)); + R_ASSERT(ldrPmUnregisterTitle(process->ldr_queue_index)); /* Close the process's handle. */ svcCloseHandle(process->handle); diff --git a/stratosphere/pm/source/pm_resource_limits.cpp b/stratosphere/pm/source/pm_resource_limits.cpp index 804ea2961..f76cbb059 100644 --- a/stratosphere/pm/source/pm_resource_limits.cpp +++ b/stratosphere/pm/source/pm_resource_limits.cpp @@ -105,14 +105,10 @@ void ResourceLimitUtils::InitializeLimits() { /* Create Resource Limits. */ for (unsigned int i = 0; i < 3; i++) { if (i > 0) { - if (R_FAILED(svcCreateResourceLimit(&g_resource_limit_handles[i]))) { - std::abort(); - } + R_ASSERT(svcCreateResourceLimit(&g_resource_limit_handles[i])); } else { u64 out = 0; - if (R_FAILED(svcGetInfo(&out, 9, 0, 0))) { - std::abort(); - } + R_ASSERT(svcGetInfo(&out, 9, 0, 0)); g_resource_limit_handles[i] = (Handle)out; } } @@ -144,15 +140,11 @@ void ResourceLimitUtils::InitializeLimits() { /* Get total memory available. */ u64 total_memory = 0; - if (R_FAILED(svcGetResourceLimitLimitValue(&total_memory, g_resource_limit_handles[0], LimitableResource_Memory))) { - std::abort(); - } + R_ASSERT(svcGetResourceLimitLimitValue(&total_memory, g_resource_limit_handles[0], LimitableResource_Memory)); /* Get and save application + applet memory. */ - if (R_FAILED(svcGetSystemInfo(&g_memory_resource_limits[g_memory_limit_type][1], 0, 0, 0)) || - R_FAILED(svcGetSystemInfo(&g_memory_resource_limits[g_memory_limit_type][2], 0, 0, 1))) { - std::abort(); - } + R_ASSERT(svcGetSystemInfo(&g_memory_resource_limits[g_memory_limit_type][1], 0, 0, 0)); + R_ASSERT(svcGetSystemInfo(&g_memory_resource_limits[g_memory_limit_type][2], 0, 0, 1)); const u64 application_size = g_memory_resource_limits[g_memory_limit_type][1]; const u64 applet_size = g_memory_resource_limits[g_memory_limit_type][2]; @@ -168,9 +160,7 @@ void ResourceLimitUtils::InitializeLimits() { } else { /* Get memory limits. */ u64 memory_arrangement; - if (R_FAILED(splGetConfig(SplConfigItem_MemoryArrange, &memory_arrangement))) { - std::abort(); - } + R_ASSERT(splGetConfig(SplConfigItem_MemoryArrange, &memory_arrangement)); memory_arrangement &= 0x3F; switch (memory_arrangement) { case 2: @@ -205,9 +195,7 @@ void ResourceLimitUtils::InitializeLimits() { /* Set resource limits. */ for (unsigned int i = 0; i < 3; i++) { g_resource_limits[i][LimitableResource_Memory] = g_memory_resource_limits[g_memory_limit_type][i]; - if (R_FAILED(SetResourceLimits((ResourceLimitCategory)i, g_memory_resource_limits[g_memory_limit_type][i]))) { - std::abort(); - } + R_ASSERT(SetResourceLimits((ResourceLimitCategory)i, g_memory_resource_limits[g_memory_limit_type][i])); } } @@ -225,9 +213,7 @@ void ResourceLimitUtils::EnsureApplicationResourcesAvailable() { if (GetRuntimeFirmwareVersion() >= FirmwareVersion_500) { u64 result; do { - if (R_FAILED(svcGetSystemInfo(&result, 1, 0, 0))) { - std::abort(); - } + R_ASSERT(svcGetSystemInfo(&result, 1, 0, 0)); svcSleepThread(1000000ULL); } while (result); } diff --git a/stratosphere/pm/source/pm_shell.cpp b/stratosphere/pm/source/pm_shell.cpp index 5b1959c2c..ab1af5b03 100644 --- a/stratosphere/pm/source/pm_shell.cpp +++ b/stratosphere/pm/source/pm_shell.cpp @@ -120,7 +120,8 @@ void ShellService::GetBootFinishedEvent(Out event) { /* We will signal it always, but only allow this function to succeed on safe mode. */ { u64 is_recovery_boot = 0; - if (R_FAILED(SmcGetConfig(SplConfigItem_IsRecoveryBoot, &is_recovery_boot)) || !is_recovery_boot) { + R_ASSERT(SmcGetConfig(SplConfigItem_IsRecoveryBoot, &is_recovery_boot)); + if (!is_recovery_boot) { std::abort(); } } diff --git a/stratosphere/ro/Makefile b/stratosphere/ro/Makefile index 2d3bf2862..e43faaab2 100644 --- a/stratosphere/ro/Makefile +++ b/stratosphere/ro/Makefile @@ -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 diff --git a/stratosphere/ro/source/ro_main.cpp b/stratosphere/ro/source/ro_main.cpp index b77c4b0a1..486c0e4de 100644 --- a/stratosphere/ro/source/ro_main.cpp +++ b/stratosphere/ro/source/ro_main.cpp @@ -61,34 +61,18 @@ void __libnx_initheap(void) { } void __appInit(void) { - Result rc; - SetFirmwareVersionForLibnx(); DoWithSmSession([&]() { - rc = setsysInitialize(); - if (R_FAILED(rc)) { - std::abort(); - } - - rc = fsInitialize(); - if (R_FAILED(rc)) { - std::abort(); - } - + R_ASSERT(setsysInitialize()); + R_ASSERT(fsInitialize()); if (GetRuntimeFirmwareVersion() < FirmwareVersion_300) { - rc = pminfoInitialize(); - if (R_FAILED(rc)) { - std::abort(); - } - } - - rc = fsdevMountSdmc(); - if (R_FAILED(rc)) { - std::abort(); + R_ASSERT(pminfoInitialize()); } }); + R_ASSERT(fsdevMountSdmc()); + CheckAtmosphereVersion(CURRENT_ATMOSPHERE_VERSION); } diff --git a/stratosphere/ro/source/ro_map.cpp b/stratosphere/ro/source/ro_map.cpp index 1fedba718..9dec810c3 100644 --- a/stratosphere/ro/source/ro_map.cpp +++ b/stratosphere/ro/source/ro_map.cpp @@ -25,13 +25,9 @@ bool MapUtils::CanAddGuardRegions(Handle process_handle, u64 address, u64 size) /* Nintendo doesn't validate SVC return values at all. */ /* TODO: Should we allow these to fail? */ - if (R_FAILED(svcQueryProcessMemory(&mem_info, &page_info, process_handle, address - 1))) { - std::abort(); - } + R_ASSERT(svcQueryProcessMemory(&mem_info, &page_info, process_handle, address - 1)); if (mem_info.type == MemType_Unmapped && address - GuardRegionSize >= mem_info.addr) { - if (R_FAILED(svcQueryProcessMemory(&mem_info, &page_info, process_handle, address + size))) { - std::abort(); - } + R_ASSERT(svcQueryProcessMemory(&mem_info, &page_info, process_handle, address + size)); return mem_info.type == MemType_Unmapped && address + size + GuardRegionSize <= mem_info.addr + mem_info.size; } @@ -50,11 +46,10 @@ Result MapUtils::MapCodeMemoryForProcess(MappedCodeMemory &out_mcm, Handle proce if (GetRuntimeFirmwareVersion() >= FirmwareVersion_200) { return MapCodeMemoryForProcessModern(out_mcm, process_handle, base_address, size); } else { - Result rc = MapCodeMemoryForProcessDeprecated(out_mcm, process_handle, true, base_address, size); - if (R_FAILED(rc)) { - rc = MapCodeMemoryForProcessDeprecated(out_mcm, process_handle, false, base_address, size); + if (R_FAILED(MapCodeMemoryForProcessDeprecated(out_mcm, process_handle, true, base_address, size))) { + R_TRY(MapCodeMemoryForProcessDeprecated(out_mcm, process_handle, false, base_address, size)); } - return rc; + return ResultSuccess; } } @@ -87,9 +82,7 @@ Result MapUtils::LocateSpaceForMapModern(u64 *out, u64 out_size) { } cur_base = address_space.map_end; } else { - if (R_FAILED(svcQueryMemory(&mem_info, &page_info, cur_base))) { - std::abort(); - } + R_ASSERT(svcQueryMemory(&mem_info, &page_info, cur_base)); if (mem_info.type == 0 && mem_info.addr - cur_base + mem_info.size >= out_size) { *out = cur_base; return ResultSuccess; diff --git a/stratosphere/ro/source/ro_map.hpp b/stratosphere/ro/source/ro_map.hpp index 10bc2674a..d03e72342 100644 --- a/stratosphere/ro/source/ro_map.hpp +++ b/stratosphere/ro/source/ro_map.hpp @@ -36,9 +36,7 @@ class MappedCodeMemory { ~MappedCodeMemory() { if (this->process_handle != INVALID_HANDLE && this->size > 0 && R_SUCCEEDED(this->result)) { - if (R_FAILED((this->result = svcUnmapProcessCodeMemory(this->process_handle, this->dst_address, this->src_address, this->size)))) { - std::abort(); - } + R_ASSERT((this->result = svcUnmapProcessCodeMemory(this->process_handle, this->dst_address, this->src_address, this->size))); } } @@ -86,9 +84,7 @@ class AutoCloseMap { ~AutoCloseMap() { if (this->process_handle != INVALID_HANDLE && R_SUCCEEDED(this->result)) { - if (R_FAILED((this->result = svcUnmapProcessMemory(this->mapped_address, this->process_handle, this->base_address, this->size)))) { - std::abort(); - } + R_ASSERT((this->result = svcUnmapProcessMemory(this->mapped_address, this->process_handle, this->base_address, this->size))); } } diff --git a/stratosphere/ro/source/ro_registration.cpp b/stratosphere/ro/source/ro_registration.cpp index 0a12063ea..7ecff50b3 100644 --- a/stratosphere/ro/source/ro_registration.cpp +++ b/stratosphere/ro/source/ro_registration.cpp @@ -31,21 +31,15 @@ static bool g_is_development_hardware, g_is_development_function_enabled; void Registration::Initialize() { DoWithSmSession([&]() { - if (R_FAILED(splInitialize())) { - std::abort(); - } + R_ASSERT(splInitialize()); }); ON_SCOPE_EXIT { splExit(); }; - if (R_FAILED(splIsDevelopment(&g_is_development_hardware))) { - std::abort(); - } + R_ASSERT(splIsDevelopment(&g_is_development_hardware)); { u64 out_val = 0; - if (R_FAILED(splGetConfig(SplConfigItem_IsDebugMode, &out_val))) { - std::abort(); - } + R_ASSERT(splGetConfig(SplConfigItem_IsDebugMode, &out_val)); g_is_development_function_enabled = out_val != 0; } } diff --git a/stratosphere/ro/source/ro_service.cpp b/stratosphere/ro/source/ro_service.cpp index 0b0a9e7c6..d03562f3e 100644 --- a/stratosphere/ro/source/ro_service.cpp +++ b/stratosphere/ro/source/ro_service.cpp @@ -13,7 +13,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - + #include #include #include @@ -33,7 +33,7 @@ bool RelocatableObjectsService::IsProcessIdValid(u64 process_id) { if (!this->IsInitialized()) { return false; } - + return this->context->process_id == process_id; } @@ -41,18 +41,12 @@ u64 RelocatableObjectsService::GetTitleId(Handle process_handle) { u64 title_id = 0; if (GetRuntimeFirmwareVersion() >= FirmwareVersion_300) { /* 3.0.0+: Use svcGetInfo. */ - if (R_FAILED(svcGetInfo(&title_id, 18, process_handle, 0))) { - std::abort(); - } + R_ASSERT(svcGetInfo(&title_id, 18, process_handle, 0)); } else { /* 1.0.0-2.3.0: We're not inside loader, so ask pm. */ u64 process_id = 0; - if (R_FAILED(svcGetProcessId(&process_id, process_handle))) { - std::abort(); - } - if (R_FAILED(pminfoGetTitleId(&title_id, process_id))) { - std::abort(); - } + R_ASSERT(svcGetProcessId(&process_id, process_handle)); + R_ASSERT(pminfoGetTitleId(&title_id, process_id)); } return title_id; } @@ -61,7 +55,7 @@ Result RelocatableObjectsService::LoadNro(Out load_address, PidDescriptor p if (!this->IsProcessIdValid(pid_desc.pid)) { return ResultRoInvalidProcess; } - + return Registration::LoadNro(load_address.GetPointer(), this->context, nro_address, nro_size, bss_address, bss_size); } @@ -69,7 +63,7 @@ Result RelocatableObjectsService::UnloadNro(PidDescriptor pid_desc, u64 nro_addr if (!this->IsProcessIdValid(pid_desc.pid)) { return ResultRoInvalidProcess; } - + return Registration::UnloadNro(this->context, nro_address); } diff --git a/stratosphere/sm/Makefile b/stratosphere/sm/Makefile index b73b78a53..10829cfd0 100644 --- a/stratosphere/sm/Makefile +++ b/stratosphere/sm/Makefile @@ -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 := -DRESULT_ABORT_ON_ASSERT -DATMOSPHERE_GIT_BRANCH=\"$(AMSBRANCH)\" -DATMOSPHERE_GIT_REV=\"$(AMSREV)\" #--------------------------------------------------------------------------------- # options for code generation diff --git a/stratosphere/sm/source/sm_main.cpp b/stratosphere/sm/source/sm_main.cpp index 4d403ff55..012118c1d 100644 --- a/stratosphere/sm/source/sm_main.cpp +++ b/stratosphere/sm/source/sm_main.cpp @@ -90,18 +90,14 @@ int main(int argc, char **argv) /* Create sm:m manually. */ Handle smm_h; - if (R_FAILED(Registration::RegisterServiceForSelf(smEncodeName("sm:m"), 1, false, &smm_h))) { - std::abort(); - } + R_ASSERT(Registration::RegisterServiceForSelf(smEncodeName("sm:m"), 1, false, &smm_h)); server_manager->AddWaitable(new ExistingPortServer(smm_h, 1)); /*===== ATMOSPHERE EXTENSION =====*/ /* Create sm:dmnt manually. */ Handle smdmnt_h; - if (R_FAILED(Registration::RegisterServiceForSelf(smEncodeName("sm:dmnt"), 1, false, &smdmnt_h))) { - std::abort(); - } + R_ASSERT(Registration::RegisterServiceForSelf(smEncodeName("sm:dmnt"), 1, false, &smdmnt_h)); server_manager->AddWaitable(new ExistingPortServer(smm_h, 1));; /*================================*/ diff --git a/stratosphere/spl/Makefile b/stratosphere/spl/Makefile index 4ebc8f6d9..cd7b81cb1 100644 --- a/stratosphere/spl/Makefile +++ b/stratosphere/spl/Makefile @@ -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 := -DRESULT_ABORT_ON_ASSERT -DATMOSPHERE_GIT_BRANCH=\"$(AMSBRANCH)\" -DATMOSPHERE_GIT_REV=\"$(AMSREV)\" #--------------------------------------------------------------------------------- # options for code generation diff --git a/stratosphere/spl/source/spl_secmon_wrapper.cpp b/stratosphere/spl/source/spl_secmon_wrapper.cpp index 7ce14d0c8..c816dc1cc 100644 --- a/stratosphere/spl/source/spl_secmon_wrapper.cpp +++ b/stratosphere/spl/source/spl_secmon_wrapper.cpp @@ -54,14 +54,10 @@ class DeviceAddressSpaceMapHelper { u32 perm; public: DeviceAddressSpaceMapHelper(Handle h, u64 dst, u64 src, size_t sz, u32 p) : das_hnd(h), dst_addr(dst), src_addr(src), size(sz), perm(p) { - if (R_FAILED(svcMapDeviceAddressSpaceAligned(this->das_hnd, CUR_PROCESS_HANDLE, this->src_addr, this->size, this->dst_addr, this->perm))) { - std::abort(); - } + R_ASSERT(svcMapDeviceAddressSpaceAligned(this->das_hnd, CUR_PROCESS_HANDLE, this->src_addr, this->size, this->dst_addr, this->perm)); } ~DeviceAddressSpaceMapHelper() { - if (R_FAILED(svcUnmapDeviceAddressSpace(this->das_hnd, CUR_PROCESS_HANDLE, this->src_addr, this->size, this->dst_addr))) { - std::abort(); - } + R_ASSERT(svcUnmapDeviceAddressSpace(this->das_hnd, CUR_PROCESS_HANDLE, this->src_addr, this->size, this->dst_addr)); } }; @@ -91,9 +87,7 @@ void SecureMonitorWrapper::InitializeSeEvents() { u64 irq_num; SmcWrapper::GetConfig(&irq_num, 1, SplConfigItem_SecurityEngineIrqNumber); Handle hnd; - if (R_FAILED(svcCreateInterruptEvent(&hnd, irq_num, 1))) { - std::abort(); - } + R_ASSERT(svcCreateInterruptEvent(&hnd, irq_num, 1)); eventLoadRemote(&g_se_event, hnd, true); g_se_keyslot_available_event = CreateWriteOnlySystemEvent(); @@ -104,21 +98,16 @@ void SecureMonitorWrapper::InitializeDeviceAddressSpace() { constexpr u64 DeviceName_SE = 29; /* Create Address Space. */ - if (R_FAILED(svcCreateDeviceAddressSpace(&g_se_das_hnd, 0, (1ul << 32)))) { - std::abort(); - } + R_ASSERT(svcCreateDeviceAddressSpace(&g_se_das_hnd, 0, (1ul << 32))); + /* Attach it to the SE. */ - if (R_FAILED(svcAttachDeviceAddressSpace(DeviceName_SE, g_se_das_hnd))) { - std::abort(); - } + R_ASSERT(svcAttachDeviceAddressSpace(DeviceName_SE, g_se_das_hnd)); const u64 work_buffer_addr = reinterpret_cast(g_work_buffer); g_se_mapped_work_buffer_addr = WorkBufferMapBase + (work_buffer_addr & DeviceAddressSpaceAlignMask); /* Map the work buffer for the SE. */ - if (R_FAILED(svcMapDeviceAddressSpaceAligned(g_se_das_hnd, CUR_PROCESS_HANDLE, work_buffer_addr, sizeof(g_work_buffer), g_se_mapped_work_buffer_addr, 3))) { - std::abort(); - } + R_ASSERT(svcMapDeviceAddressSpaceAligned(g_se_das_hnd, CUR_PROCESS_HANDLE, work_buffer_addr, sizeof(g_work_buffer), g_se_mapped_work_buffer_addr, 3)); } void SecureMonitorWrapper::Initialize() {