From 8d3b8354c30480625862da5f24a4c10d9bd19673 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Fri, 30 Nov 2018 04:57:17 -0800 Subject: [PATCH] Exosphere: Add extension to perform a reboot to rcm. --- exosphere/src/configitem.c | 21 ++++++++++++++++++--- exosphere/src/configitem.h | 3 ++- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/exosphere/src/configitem.c b/exosphere/src/configitem.c index f03fee2bf..1f70343bb 100644 --- a/exosphere/src/configitem.c +++ b/exosphere/src/configitem.c @@ -31,11 +31,22 @@ static bool g_battery_profile = false; static bool g_debugmode_override_user = false, g_debugmode_override_priv = false; uint32_t configitem_set(bool privileged, ConfigItem item, uint64_t value) { - if (item != CONFIGITEM_BATTERYPROFILE) { - return 2; + switch (item) { + case CONFIGITEM_BATTERYPROFILE: + g_battery_profile = (value != 0); + break; + case CONFIGITEM_NEEDS_REBOOT_TO_RCM: + /* Force a reboot to RCM. */ + { + MAKE_REG32(0x7000E450) = 0x2; + MAKE_REG32(0x7000E400) = 0x10; + while (1) { } + } + break; + default: + return 2; } - g_battery_profile = (value != 0); return 0; } @@ -167,6 +178,10 @@ uint32_t configitem_get(bool privileged, ConfigItem item, uint64_t *p_outvalue) ((uint64_t)(exosphere_get_target_firmware() & 0xFF) << 8ull) | ((uint64_t)(mkey_get_revision() & 0xFF) << 0ull); break; + case CONFIGITEM_NEEDS_REBOOT_TO_RCM: + /* UNOFFICIAL: The fact that we are executing means we aren't in the process of rebooting to rcm. */ + *p_outvalue = 0; + break; default: result = 2; break; diff --git a/exosphere/src/configitem.h b/exosphere/src/configitem.h index f73c5469b..8aef4e975 100644 --- a/exosphere/src/configitem.h +++ b/exosphere/src/configitem.h @@ -40,7 +40,8 @@ typedef enum { CONFIGITEM_PACKAGE2HASH_5X = 17, /* These are unofficial, for usage by Exosphere. */ - CONFIGITEM_EXOSPHERE_VERSION = 65000 + CONFIGITEM_EXOSPHERE_VERSION = 65000, + CONFIGITEM_NEEDS_REBOOT_TO_RCM = 65001, } ConfigItem; uint32_t configitem_set(bool privileged, ConfigItem item, uint64_t value);