Fusee use CAR reboot for fatal errors

This commit is contained in:
TuxSH 2018-05-20 23:52:09 +02:00
parent 4ec7d0fc82
commit 83d9d874e6
6 changed files with 34 additions and 24 deletions

View file

@ -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;

View file

@ -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)

View file

@ -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);

View file

@ -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;

View file

@ -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)

View file

@ -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);