summaryrefslogtreecommitdiff
path: root/core/cortex-m
diff options
context:
space:
mode:
Diffstat (limited to 'core/cortex-m')
-rw-r--r--core/cortex-m/watchdog.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/core/cortex-m/watchdog.c b/core/cortex-m/watchdog.c
index 9e4a82c7b0..c9faf54b2b 100644
--- a/core/cortex-m/watchdog.c
+++ b/core/cortex-m/watchdog.c
@@ -12,6 +12,14 @@
#include "timer.h"
#include "watchdog.h"
+/*
+ * As defined by Armv7-M Reference Manual B1.5.6 "Exception Entry Behavior",
+ * the structure of the saved context on the stack is:
+ * r0, r1, r2, r3, r12, lr, pc, psr, ...
+ */
+#define STACK_IDX_REG_LR 5
+#define STACK_IDX_REG_PC 6
+
void __keep watchdog_trace(uint32_t excep_lr, uint32_t excep_sp)
{
uint32_t psp;
@@ -26,7 +34,7 @@ void __keep watchdog_trace(uint32_t excep_lr, uint32_t excep_sp)
stack = (uint32_t *)psp;
}
- panic_set_reason(PANIC_SW_WATCHDOG, stack[6],
+ panic_set_reason(PANIC_SW_WATCHDOG, stack[STACK_IDX_REG_PC],
(excep_lr & 0xf) == 1 ? 0xff : task_get_current());
/*
@@ -37,7 +45,7 @@ void __keep watchdog_trace(uint32_t excep_lr, uint32_t excep_sp)
cpu_clean_invalidate_dcache();
panic_printf("### WATCHDOG PC=%08x / LR=%08x / pSP=%08x ",
- stack[6], stack[5], psp);
+ stack[STACK_IDX_REG_PC], stack[STACK_IDX_REG_LR], psp);
if ((excep_lr & 0xf) == 1)
panic_puts("(exc) ###\n");
else