diff options
author | Patryk Duda <pdk@semihalf.com> | 2020-08-28 10:58:22 +0200 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-10-01 14:48:17 +0000 |
commit | f79968bd74e562707905e94e01c7d41fed8a5eaa (patch) | |
tree | 4621e2298fe3e865d9c0591dbe6165438579c001 /core/cortex-m0 | |
parent | 49023b8ab95634cfb16bef4346e77461008c368e (diff) | |
download | chrome-ec-f79968bd74e562707905e94e01c7d41fed8a5eaa.tar.gz |
cortex-m0/panic: Use newly provided functions to access panic data
This change removes usage of PANIC_DATA_PTR where possible. Now panic
data is accessed through functions that performs more checks and in case
of writing also moves other data when necessary.
BUG=b:165773837, b:162254118
BRANCH=none
TEST=make -j buildall
Signed-off-by: Patryk Duda <pdk@semihalf.com>
Change-Id: I2a5b474b03a65ce4a5c77cf5f5b671d1d72095f2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2381711
Reviewed-by: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'core/cortex-m0')
-rw-r--r-- | core/cortex-m0/panic.c | 26 |
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]; |