summaryrefslogtreecommitdiff
path: root/core/cortex-m/panic.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2012-06-03 10:09:55 -0700
committerGerrit <chrome-bot@google.com>2012-06-15 18:25:34 -0700
commit8c55761613bd5f0b2bcac6c769256842218d96c1 (patch)
tree95ee4016c3b74bbd8a0b47f8bbf4ce3657c998ae /core/cortex-m/panic.c
parent8db2c7f910661661b3dfb67fb2eb99a16ee14de5 (diff)
downloadchrome-ec-8c55761613bd5f0b2bcac6c769256842218d96c1.tar.gz
Add an option to report panics in a new stack
For particularly nasty errors the stack or stack pointer may be corrupt, or in a place that we do not want overwritten. Provide and option to place the stack in a fresh place, assuming you can reach exception_panic(). Note that exception_panic() does not write anything to stack itself. BUG=chrome-os-partner:10146 TEST=manual: build for all boards On snow, cause a panic and see that it is reported correctly. Change-Id: I21d8b9bb12455758309d54ef20de66640d8a2df6 Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/24504
Diffstat (limited to 'core/cortex-m/panic.c')
-rw-r--r--core/cortex-m/panic.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/core/cortex-m/panic.c b/core/cortex-m/panic.c
index cbdef6a96f..8e022857ef 100644
--- a/core/cortex-m/panic.c
+++ b/core/cortex-m/panic.c
@@ -16,9 +16,15 @@
#include "watchdog.h"
+/* This is the size of our private panic stack, if we have one */
+#define STACK_SIZE_WORDS 64
+
/* We save registers here for display by report_panic() */
static struct save_area
{
+#ifdef CONFIG_PANIC_NEW_STACK
+ uint32_t stack[STACK_SIZE_WORDS];
+#endif
uint32_t saved_regs[11]; /* psp, ipsr, lr, r4-r11 */
} save_area __attribute__((aligned(8)));
@@ -207,6 +213,9 @@ void exception_panic(void)
"mrs r2, ipsr\n"
"mov r3, lr\n"
"stmia r0, {r1-r11}\n"
+#ifdef CONFIG_PANIC_NEW_STACK
+ "mov sp, r0\n"
+#endif
"mov r1, r0\n"
"mov r0, #0\n"
"b report_panic" : :