diff --git a/fusee/fusee-primary/src/panic.c b/fusee/fusee-primary/src/panic.c index 918b23a66..b5c4591b6 100644 --- a/fusee/fusee-primary/src/panic.c +++ b/fusee/fusee-primary/src/panic.c @@ -60,7 +60,7 @@ void check_and_display_panic(void) { } display_color_screen(color); - wait_for_button_and_pmc_reboot(); + wait_for_button_and_reboot(); } else { g_panic_code = 0; APBDEV_PMC_SCRATCH200_0 = 0; diff --git a/fusee/fusee-primary/src/utils.c b/fusee/fusee-primary/src/utils.c index e73bea32a..2966c48b2 100644 --- a/fusee/fusee-primary/src/utils.c +++ b/fusee/fusee-primary/src/utils.c @@ -6,6 +6,7 @@ #include "pmc.h" #include "timers.h" #include "panic.h" +#include "car.h" #include "lib/printk.h" #include "hwinit/btn.h" @@ -33,16 +34,21 @@ __attribute__((noreturn)) void pmc_reboot(uint32_t scratch0) { } } -__attribute__((noreturn)) void wait_for_button_and_pmc_reboot(void) { +__attribute__((noreturn)) void car_reboot(void) { + /* Reset the processor. */ + car_get_regs()->rst_dev_l |= 1<<2; + + while (true) { + /* Wait for reboot. */ + } +} + +__attribute__((noreturn)) void wait_for_button_and_reboot(void) { uint32_t button; while (true) { button = btn_read(); if (button & BTN_POWER) { - /* Reboot into RCM. */ - pmc_reboot(BIT(1) | 0); - } else if (button & (BTN_VOL_UP | BTN_VOL_DOWN)) { - /* Reboot normally. */ - pmc_reboot(0); + car_reboot(); } } } @@ -57,10 +63,8 @@ __attribute__((noreturn)) void fatal_error(const char *fmt, ...) { va_start(args, fmt); vprintk(fmt, args); va_end(args); - printk("\nHanging...\n"); - while(true); - //printk("\nPress POWER to reboot into RCM, VOL+/VOL- to reboot normally.\n"); - //wait_for_button_and_pmc_reboot(); + printk("\nPress POWER to reboot\n"); + wait_for_button_and_reboot(); } __attribute__((noinline)) bool overlaps(uint64_t as, uint64_t ae, uint64_t bs, uint64_t be) diff --git a/fusee/fusee-primary/src/utils.h b/fusee/fusee-primary/src/utils.h index c5327acfa..819529f21 100644 --- a/fusee/fusee-primary/src/utils.h +++ b/fusee/fusee-primary/src/utils.h @@ -103,7 +103,8 @@ static inline bool check_32bit_address_range_in_program(uintptr_t addr, size_t s __attribute__((noreturn)) void watchdog_reboot(void); __attribute__((noreturn)) void pmc_reboot(uint32_t scratch0); -__attribute__((noreturn)) void wait_for_button_and_pmc_reboot(void); +__attribute__((noreturn)) void car_reboot(void); +__attribute__((noreturn)) void wait_for_button_and_reboot(void); __attribute__((noreturn)) void generic_panic(void); diff --git a/fusee/fusee-secondary/src/panic.c b/fusee/fusee-secondary/src/panic.c index 918b23a66..b5c4591b6 100644 --- a/fusee/fusee-secondary/src/panic.c +++ b/fusee/fusee-secondary/src/panic.c @@ -60,7 +60,7 @@ void check_and_display_panic(void) { } display_color_screen(color); - wait_for_button_and_pmc_reboot(); + wait_for_button_and_reboot(); } else { g_panic_code = 0; APBDEV_PMC_SCRATCH200_0 = 0; diff --git a/fusee/fusee-secondary/src/utils.c b/fusee/fusee-secondary/src/utils.c index a7859f1e2..d5f6bebf2 100644 --- a/fusee/fusee-secondary/src/utils.c +++ b/fusee/fusee-secondary/src/utils.c @@ -4,6 +4,7 @@ #include "se.h" #include "fuse.h" #include "pmc.h" +#include "car.h" #include "timers.h" #include "hwinit/btn.h" #include "panic.h" @@ -33,16 +34,21 @@ __attribute__((noreturn)) void pmc_reboot(uint32_t scratch0) { } } -__attribute__((noreturn)) void wait_for_button_and_pmc_reboot(void) { +__attribute__((noreturn)) void car_reboot(void) { + /* Reset the processor. */ + car_get_regs()->rst_dev_l |= 1<<2; + + while (true) { + /* Wait for reboot. */ + } +} + +__attribute__((noreturn)) void wait_for_button_and_reboot(void) { uint32_t button; while (true) { button = btn_read(); if (button & BTN_POWER) { - /* Reboot into RCM. */ - pmc_reboot(BIT(1) | 0); - } else if (button & (BTN_VOL_UP | BTN_VOL_DOWN)) { - /* Reboot normally. */ - pmc_reboot(0); + car_reboot(); } } } @@ -57,10 +63,8 @@ __attribute__((noreturn)) void fatal_error(const char *fmt, ...) { va_start(args, fmt); vprintf(fmt, args); va_end(args); - printf("Hanging...\n"); - while(true); - //printf("\n Press POWER to reboot into RCM, VOL+/VOL- to reboot normally.\n"); - //wait_for_button_and_pmc_reboot(); + printf("\n Press POWER to reboot.\n"); + wait_for_button_and_reboot(); } __attribute__((noinline)) bool overlaps(uint64_t as, uint64_t ae, uint64_t bs, uint64_t be) diff --git a/fusee/fusee-secondary/src/utils.h b/fusee/fusee-secondary/src/utils.h index d8b04c8c2..e811651a3 100644 --- a/fusee/fusee-secondary/src/utils.h +++ b/fusee/fusee-secondary/src/utils.h @@ -106,7 +106,8 @@ void hexdump(const void* data, size_t size, uintptr_t addrbase); __attribute__((noreturn)) void watchdog_reboot(void); __attribute__((noreturn)) void pmc_reboot(uint32_t scratch0); -__attribute__((noreturn)) void wait_for_button_and_pmc_reboot(void); +__attribute__((noreturn)) void car_reboot(void); +__attribute__((noreturn)) void wait_for_button_and_reboot(void); __attribute__((noreturn)) void generic_panic(void);