mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-11-05 19:51:45 +00:00
sept: prepare for reboot immediately
This commit is contained in:
parent
61b057c37d
commit
b63061a505
3 changed files with 12 additions and 3 deletions
|
@ -57,6 +57,10 @@ static void exfiltrate_keys_and_reboot_if_needed(void) {
|
||||||
uint8_t *dec_se_state = (uint8_t *)0x4003F000;
|
uint8_t *dec_se_state = (uint8_t *)0x4003F000;
|
||||||
|
|
||||||
if (!has_rebooted()) {
|
if (!has_rebooted()) {
|
||||||
|
/* Prepare for a reboot before doing anything else. */
|
||||||
|
prepare_for_reboot_to_self();
|
||||||
|
set_has_rebooted(true);
|
||||||
|
|
||||||
/* Save the security engine context. */
|
/* Save the security engine context. */
|
||||||
se_get_regs()->_0x4 = 0x0;
|
se_get_regs()->_0x4 = 0x0;
|
||||||
se_set_in_context_save_mode(true);
|
se_set_in_context_save_mode(true);
|
||||||
|
@ -67,8 +71,7 @@ static void exfiltrate_keys_and_reboot_if_needed(void) {
|
||||||
for (size_t k = 0; k < 0x10; k++) {
|
for (size_t k = 0; k < 0x10; k++) {
|
||||||
clear_aes_keyslot(k);
|
clear_aes_keyslot(k);
|
||||||
}
|
}
|
||||||
|
|
||||||
set_has_rebooted(true);
|
|
||||||
reboot_to_self();
|
reboot_to_self();
|
||||||
} else {
|
} else {
|
||||||
/* Decrypt the security engine state. */
|
/* Decrypt the security engine state. */
|
||||||
|
|
|
@ -65,7 +65,7 @@ __attribute__((noreturn)) void pmc_reboot(uint32_t scratch0) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__((noreturn)) void reboot_to_self(void) {
|
void prepare_for_reboot_to_self(void) {
|
||||||
/* Patch SDRAM init to perform an SVC immediately after second write */
|
/* Patch SDRAM init to perform an SVC immediately after second write */
|
||||||
APBDEV_PMC_SCRATCH45_0 = 0x2E38DFFF;
|
APBDEV_PMC_SCRATCH45_0 = 0x2E38DFFF;
|
||||||
APBDEV_PMC_SCRATCH46_0 = 0x6001DC28;
|
APBDEV_PMC_SCRATCH46_0 = 0x6001DC28;
|
||||||
|
@ -77,6 +77,11 @@ __attribute__((noreturn)) void reboot_to_self(void) {
|
||||||
for (size_t i = 0; i < rebootstub_bin_size; i += sizeof(uint32_t)) {
|
for (size_t i = 0; i < rebootstub_bin_size; i += sizeof(uint32_t)) {
|
||||||
write32le((void *)0x4003F000, i, read32le(rebootstub_bin, i));
|
write32le((void *)0x4003F000, i, read32le(rebootstub_bin, i));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__((noreturn)) void reboot_to_self(void) {
|
||||||
|
/* Prep IRAM for reboot. */
|
||||||
|
prepare_for_reboot_to_self();
|
||||||
|
|
||||||
/* Trigger warm reboot. */
|
/* Trigger warm reboot. */
|
||||||
pmc_reboot(1 << 0);
|
pmc_reboot(1 << 0);
|
||||||
|
|
|
@ -121,6 +121,7 @@ void hexdump(const void* data, size_t size, uintptr_t addrbase);
|
||||||
|
|
||||||
__attribute__((noreturn)) void watchdog_reboot(void);
|
__attribute__((noreturn)) void watchdog_reboot(void);
|
||||||
__attribute__((noreturn)) void pmc_reboot(uint32_t scratch0);
|
__attribute__((noreturn)) void pmc_reboot(uint32_t scratch0);
|
||||||
|
void prepare_for_reboot_to_self(void);
|
||||||
__attribute__((noreturn)) void reboot_to_self(void);
|
__attribute__((noreturn)) void reboot_to_self(void);
|
||||||
__attribute__((noreturn)) void wait_for_button_and_reboot(void);
|
__attribute__((noreturn)) void wait_for_button_and_reboot(void);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue