diff --git a/exosphere/src/configitem.c b/exosphere/src/configitem.c index 1f70343bb..9aa1e6fa8 100644 --- a/exosphere/src/configitem.c +++ b/exosphere/src/configitem.c @@ -36,8 +36,8 @@ uint32_t configitem_set(bool privileged, ConfigItem item, uint64_t value) { g_battery_profile = (value != 0); break; case CONFIGITEM_NEEDS_REBOOT_TO_RCM: - /* Force a reboot to RCM. */ - { + /* Force a reboot to RCM, if requested. */ + if (value != 0) { MAKE_REG32(0x7000E450) = 0x2; MAKE_REG32(0x7000E400) = 0x10; while (1) { } diff --git a/stratosphere/fatal/fatal.json b/stratosphere/fatal/fatal.json index 76bce7e4f..201875895 100644 --- a/stratosphere/fatal/fatal.json +++ b/stratosphere/fatal/fatal.json @@ -83,7 +83,8 @@ "svcGetDebugThreadContext": "0x67", "svcQueryDebugProcessMemory": "0x69", "svcReadDebugProcessMemory": "0x6a", - "svcGetDebugThreadParam": "0x6d" + "svcGetDebugThreadParam": "0x6d", + "svcCallSecureMonitor": "0x7f" } }, { "type": "min_kernel_version", diff --git a/stratosphere/fatal/source/fatal_config.cpp b/stratosphere/fatal/source/fatal_config.cpp index fd1703137..11cc32420 100644 --- a/stratosphere/fatal/source/fatal_config.cpp +++ b/stratosphere/fatal/source/fatal_config.cpp @@ -58,9 +58,9 @@ static void SetupConfigLanguages() { config->error_desc = u8"Please call 1-800-875-1852 for service.\n"; } else { config->error_desc = u8"An error has occured.\n\n" - u8"Please press the POWER Button to restart the console. If you are\n" - u8"unable to restart the console, hold the POWER Button for 12 seconds\n" - u8"to turn the console off.\n\n" + u8"Please press the POWER Button to restart the console, or a VOL button\n" + u8"to restart the console in RCM mode. If you are unable to restart the\n" + u8"console, hold the POWER Button for 12 seconds to turn the console off.\n\n" u8"If the problem persists, refer to the Nintendo Support Website.\n" u8"support.nintendo.com/switch/error\n"; } diff --git a/stratosphere/fatal/source/fatal_main.cpp b/stratosphere/fatal/source/fatal_main.cpp index 7790e85b7..733dc6eff 100644 --- a/stratosphere/fatal/source/fatal_main.cpp +++ b/stratosphere/fatal/source/fatal_main.cpp @@ -118,7 +118,7 @@ void __appInit(void) { std::abort(); } - rc = fsInitialize(); + rc = gpioInitialize(); if (R_FAILED(rc)) { std::abort(); } @@ -141,6 +141,7 @@ void __appExit(void) { fsdevUnmountAll(); fsExit(); plExit(); + gpioExit(); spsmExit(); psmExit(); lblExit(); diff --git a/stratosphere/fatal/source/fatal_repair.cpp b/stratosphere/fatal/source/fatal_repair.cpp index 432384cf7..b884c1aef 100644 --- a/stratosphere/fatal/source/fatal_repair.cpp +++ b/stratosphere/fatal/source/fatal_repair.cpp @@ -52,7 +52,7 @@ static bool InRepairWithoutVolHeld() { /* Sleep for 100 ms. */ svcSleepThread(100000000UL); - } + } } return false; diff --git a/stratosphere/fatal/source/fatal_task_power.cpp b/stratosphere/fatal/source/fatal_task_power.cpp index a804d6ff5..41954a0f5 100644 --- a/stratosphere/fatal/source/fatal_task_power.cpp +++ b/stratosphere/fatal/source/fatal_task_power.cpp @@ -94,14 +94,45 @@ void PowerButtonObserveTask::WaitForPowerButton() { /* Force a reboot after some time if kiosk unit. */ const FatalConfig *config = GetFatalConfig(); - TimeoutHelper reboot_helper(config->quest_reboot_interval_second * 1000000000UL); + TimeoutHelper reboot_helper(config->quest_reboot_interval_second * 1000000000UL); + + bool check_vol_up = true, check_vol_down = true; + GpioPadSession vol_up_btn, vol_down_btn; + if (R_FAILED(gpioOpenSession(&vol_up_btn, GpioPadName_ButtonVolUp))) { + check_vol_up = false; + } + if (R_FAILED(gpioOpenSession(&vol_down_btn, GpioPadName_ButtonVolDown))) { + check_vol_down = false; + } + + /* Ensure we close on early return. */ + ON_SCOPE_EXIT { if (check_vol_up) { gpioPadClose(&vol_up_btn); } }; + ON_SCOPE_EXIT { if (check_vol_down) { gpioPadClose(&vol_down_btn); } }; + + /* Set direction input. */ + if (check_vol_up) { + gpioPadSetDirection(&vol_up_btn, GpioDirection_Input); + } + if (check_vol_down) { + gpioPadSetDirection(&vol_down_btn, GpioDirection_Input); + } BpcSleepButtonState state; + GpioValue val; while (true) { + Result rc = 0; + if (check_vol_up && R_SUCCEEDED((rc = gpioPadGetValue(&vol_up_btn, &val))) && val == GpioValue_Low) { + /* Tell exosphere to reboot to RCM. */ + RebootToRcm(); + } - Result rc = bpcGetSleepButtonState(&state); - if ((R_SUCCEEDED(rc) && state == BpcSleepButtonState_Held) || (config->quest_flag && reboot_helper.TimedOut())) { + if (check_vol_down && R_SUCCEEDED((rc = gpioPadGetValue(&vol_down_btn, &val))) && val == GpioValue_Low) { + /* Tell exosphere to reboot to RCM. */ + RebootToRcm(); + } + + if ((R_SUCCEEDED(rc = 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 4ca01cee9..144935406 100644 --- a/stratosphere/fatal/source/fatal_task_screen.cpp +++ b/stratosphere/fatal/source/fatal_task_screen.cpp @@ -215,9 +215,9 @@ Result ShowFatalTask::ShowFatal() { } else { /* Print a special message for atmosphere version mismatch. */ FontManager::Print(u8"Atmosphère version mismatch detected.\n\n" - u8"Please press the POWER Button to restart the console. If you are\n" - u8"unable to restart the console, hold the POWER Button for 12 seconds\n" - u8"to turn the console off.\n\n" + u8"Please press the POWER Button to restart the console, or a VOL button\n" + u8"to restart the console in RCM mode. If you are unable to restart the\n" + u8"console, hold the POWER Button for 12 seconds to turn the console off.\n\n" u8"Please ensure that all Atmosphère components are updated.\n" u8"github.com/Atmosphere-NX/Atmosphere/releases\n"); } diff --git a/stratosphere/libstratosphere b/stratosphere/libstratosphere index dd31b3d2e..05015b935 160000 --- a/stratosphere/libstratosphere +++ b/stratosphere/libstratosphere @@ -1 +1 @@ -Subproject commit dd31b3d2e2450a458ef9c0d6268f3780fe70e083 +Subproject commit 05015b9354d3df80e0836aa95d1d4dcfc2aef4b7