summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/cortex-m0/panic.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/core/cortex-m0/panic.c b/core/cortex-m0/panic.c
index 630c542c4a..4fe69fddb1 100644
--- a/core/cortex-m0/panic.c
+++ b/core/cortex-m0/panic.c
@@ -106,6 +106,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;
@@ -177,14 +181,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;
@@ -194,10 +201,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];