diff options
-rw-r--r-- | board/keyborg/runtime.c | 7 | ||||
-rw-r--r-- | board/zinger/debug.c | 4 | ||||
-rw-r--r-- | board/zinger/runtime.c | 26 | ||||
-rw-r--r-- | core/cortex-m/init.S | 3 | ||||
-rw-r--r-- | core/cortex-m0/div.S | 2 | ||||
-rw-r--r-- | core/cortex-m0/init.S | 6 |
6 files changed, 36 insertions, 12 deletions
diff --git a/board/keyborg/runtime.c b/board/keyborg/runtime.c index 6cabd1e5c3..e3a8021ef1 100644 --- a/board/keyborg/runtime.c +++ b/board/keyborg/runtime.c @@ -128,6 +128,13 @@ void system_reboot(void) ; } +/* Unhandled exception panic */ +void exception_panic(void) +{ + debug_printf("PANIC\n"); + system_reboot(); +} + /* --- stubs --- */ void __hw_timer_enable_clock(int n, int enable) { /* Done in hardware init */ } diff --git a/board/zinger/debug.c b/board/zinger/debug.c index 2cf62996bf..74d58c105b 100644 --- a/board/zinger/debug.c +++ b/board/zinger/debug.c @@ -35,7 +35,3 @@ void debug_printf(const char *format, ...) vfnprintf(debug_txchar, NULL, format, args); va_end(args); } - -void panic(const char *msg) -{ -} diff --git a/board/zinger/runtime.c b/board/zinger/runtime.c index e418031aed..775afdccec 100644 --- a/board/zinger/runtime.c +++ b/board/zinger/runtime.c @@ -103,6 +103,32 @@ void cpu_reset(void) ; } +/** + * Default exception handler, which reports a panic. + * + * Declare this as a naked call so we can extract the real LR and SP. + */ +void exception_panic(void) __attribute__((naked)); +void exception_panic(void) +{ + asm volatile( +#ifdef CONFIG_DEBUG_PRINTF + "mov r0, %0\n" + "mov r3, sp\n" + "ldr r1, [r3, #6*4]\n" /* retrieve exception PC */ + "ldr r2, [r3, #5*4]\n" /* retrieve exception LR */ + "bl debug_printf\n" +#endif + "b cpu_reset\n" + : : "r"("PANIC PC=%08x LR=%08x\n\n")); +} + +void panic_reboot(void) +{ /* for div / 0 */ + debug_printf("DIV0 PANIC\n\n"); + cpu_reset(); +} + /* --- stubs --- */ void __hw_timer_enable_clock(int n, int enable) { /* Done in hardware init */ } diff --git a/core/cortex-m/init.S b/core/cortex-m/init.S index 0f5a3e2310..ac16fa83c7 100644 --- a/core/cortex-m/init.S +++ b/core/cortex-m/init.S @@ -384,10 +384,7 @@ fini_loop: /* Default exception handler */ .thumb_func default_handler: -#ifdef CONFIG_COMMON_PANIC_OUTPUT b exception_panic -#endif - b reset .align 2 _bss_start: diff --git a/core/cortex-m0/div.S b/core/cortex-m0/div.S index 8e055b8e0f..c20804e274 100644 --- a/core/cortex-m0/div.S +++ b/core/cortex-m0/div.S @@ -180,4 +180,4 @@ L_dont_sub0: bx lr __aeabi_idiv0: - bl panic + bl panic_reboot diff --git a/core/cortex-m0/init.S b/core/cortex-m0/init.S index 98bdb89e19..92dc386959 100644 --- a/core/cortex-m0/init.S +++ b/core/cortex-m0/init.S @@ -133,10 +133,8 @@ fini_loop: /* Default exception handler */ .thumb_func default_handler: -#ifdef CONFIG_COMMON_PANIC_OUTPUT - b exception_panic -#endif - b reset + ldr r0, =exception_panic + bx r0 .align 2 _bss_start: |