diff options
Diffstat (limited to 'core/cortex-m/panic.c')
-rw-r--r-- | core/cortex-m/panic.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/core/cortex-m/panic.c b/core/cortex-m/panic.c index afdb3d858d..8fabaf4b21 100644 --- a/core/cortex-m/panic.c +++ b/core/cortex-m/panic.c @@ -289,6 +289,10 @@ void panic_data_print(const struct panic_data *pdata) void __keep report_panic(void) { + /* + * Don't need to get pointer via get_panic_data_write() + * because memory below pdata_ptr is stack now (see exception_panic()) + */ struct panic_data *pdata = pdata_ptr; uint32_t sp; @@ -372,14 +376,17 @@ void software_panic(uint32_t reason, uint32_t info) void panic_set_reason(uint32_t reason, uint32_t info, uint8_t exception) { - uint32_t *lregs = pdata_ptr->cm.regs; + struct panic_data * const pdata = get_panic_data_write(); + uint32_t *lregs; + + lregs = pdata->cm.regs; /* Setup panic data structure */ - memset(pdata_ptr, 0, sizeof(*pdata_ptr)); - pdata_ptr->magic = PANIC_DATA_MAGIC; - pdata_ptr->struct_size = sizeof(*pdata_ptr); - pdata_ptr->struct_version = 2; - pdata_ptr->arch = PANIC_ARCH_CORTEX_M; + memset(pdata, 0, CONFIG_PANIC_DATA_SIZE); + pdata->magic = PANIC_DATA_MAGIC; + pdata->struct_size = CONFIG_PANIC_DATA_SIZE; + pdata->struct_version = 2; + pdata->arch = PANIC_ARCH_CORTEX_M; /* Log panic cause */ lregs[1] = exception; @@ -389,10 +396,11 @@ void panic_set_reason(uint32_t reason, uint32_t info, uint8_t exception) void panic_get_reason(uint32_t *reason, uint32_t *info, uint8_t *exception) { - uint32_t *lregs = pdata_ptr->cm.regs; + struct panic_data * const pdata = panic_get_data(); + uint32_t *lregs; - if (pdata_ptr->magic == PANIC_DATA_MAGIC && - pdata_ptr->struct_version == 2) { + if (pdata && pdata->struct_version == 2) { + lregs = pdata->cm.regs; *exception = lregs[1]; *reason = lregs[3]; *info = lregs[4]; |