diff options
author | Jack Rosenthal <jrosenth@chromium.org> | 2021-01-22 16:58:36 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-01-26 23:21:35 +0000 |
commit | c10b22901e01e00a9c2c0a5e790a54487f391fe6 (patch) | |
tree | e2a6f406c1bd2223183964237288d671cf92c039 /common/panic_output.c | |
parent | 061b3ee3a305833e061019744add3f96d5fd1529 (diff) | |
download | chrome-ec-c10b22901e01e00a9c2c0a5e790a54487f391fe6.tar.gz |
zephyr: Add support for panic output
Add basic panic implementation for Zephyr. Not using any fancy shared
or always-on memory for now ... need to resolve how that will be
handled later.
BUG=b:178011288
BRANCH=none
TEST=run various crash commands on volteer, observe output
Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Jack Rosenthal <jrosenth@chromium.org>
Change-Id: Ia1ce386f738283a2a2b9b60ef7e0bf97f8317837
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2645687
Diffstat (limited to 'common/panic_output.c')
-rw-r--r-- | common/panic_output.c | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/common/panic_output.c b/common/panic_output.c index a3f34e6d47..66a39a60cc 100644 --- a/common/panic_output.c +++ b/common/panic_output.c @@ -19,6 +19,18 @@ #include "usb_console.h" #include "util.h" +/* + * TODO(b/178011288): use persistent storage for panic data in + * Zephyr OS + */ +#ifdef CONFIG_ZEPHYR +static struct panic_data zephyr_panic_data; +#undef PANIC_DATA_PTR +#undef CONFIG_PANIC_DATA_BASE +#define PANIC_DATA_PTR (&zephyr_panic_data) +#define CONFIG_PANIC_DATA_BASE (&zephyr_panic_data) +#endif + /* Panic data goes at the end of RAM. */ static struct panic_data * const pdata_ptr = PANIC_DATA_PTR; @@ -167,6 +179,9 @@ uintptr_t get_panic_data_start(void) if (pdata_ptr->magic != PANIC_DATA_MAGIC) return 0; + if (IS_ENABLED(CONFIG_ZEPHYR)) + return (uintptr_t)pdata_ptr; + return ((uintptr_t)CONFIG_PANIC_DATA_BASE + CONFIG_PANIC_DATA_SIZE - pdata_ptr->struct_size); @@ -185,7 +200,16 @@ static uint32_t get_panic_data_size(void) * Please note that this function can move jump data and jump tags. * It can also delete panic data from previous boot, so this function * should be used when we are sure that we don't need it. + * + * TODO(b/178011288): figure out an appropriate implementation for + * Zephyr. */ +#ifdef CONFIG_ZEPHYR +struct panic_data *get_panic_data_write(void) +{ + return pdata_ptr; +} +#else struct panic_data *get_panic_data_write(void) { /* @@ -268,6 +292,7 @@ struct panic_data *get_panic_data_write(void) return pdata_ptr; } +#endif /* CONFIG_ZEPHYR */ static void panic_init(void) { @@ -337,9 +362,13 @@ static int command_crash(int argc, char **argv) while (1) ; } else if (!strcasecmp(argv[1], "hang")) { - interrupt_disable(); + uint32_t lock_key = irq_lock(); + while (1) ; + + /* Unreachable, but included for consistency */ + irq_unlock(lock_key); } else { return EC_ERROR_PARAM1; } @@ -354,7 +383,7 @@ DECLARE_CONSOLE_COMMAND(crash, command_crash, #endif " | unaligned | watchdog | hang]", "Crash the system (for testing)"); -#endif +#endif /* CONFIG_CMD_CRASH */ static int command_panicinfo(int argc, char **argv) { |