diff options
author | Randall Spangler <rspangler@chromium.org> | 2012-08-31 13:10:16 -0700 |
---|---|---|
committer | Gerrit <chrome-bot@google.com> | 2012-08-31 15:41:36 -0700 |
commit | 96103ab32d9a2c4f6651c83e3993385ed346917a (patch) | |
tree | 77d3a17c28f507b746f7e7950d9314a61c9e0ffb /include/panic.h | |
parent | 66d3ad01709e58cd0299147aa6b59d634322a018 (diff) | |
download | chrome-ec-96103ab32d9a2c4f6651c83e3993385ed346917a.tar.gz |
Save panic data across reboots, and add panicinfo command
Jump data now precedes the panic data, if any, in memory.
BUG=chrome-os-partner:7466
BRANCH=all
TEST=manual
1. boot system
2. sysjump rw --> display should stay on and keyboard should still work
(this verifies jump data is properly read across sysjump still)
3. crash unaligned --> system should reboot
4. panicinfo --> should print the same crash dump as before, with (NEW)
5. panicinfo --> ditto, without (NEW)
6. sysjump rw
7. panicinfo --> ditto, without (NEW)
Change-Id: I88285724e82a15553ab25877e3d8ec4c74a4dd5a
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/32051
Diffstat (limited to 'include/panic.h')
-rw-r--r-- | include/panic.h | 51 |
1 files changed, 48 insertions, 3 deletions
diff --git a/include/panic.h b/include/panic.h index ecf6eb0232..bb3e853bd2 100644 --- a/include/panic.h +++ b/include/panic.h @@ -6,9 +6,47 @@ * device, which is currently the UART. */ -#ifndef __PANIC_H +#ifndef __CROS_EC_PANIC_H +#define __CROS_EC_PANIC_H + #include <stdarg.h> +/* Data saved across reboots */ +struct panic_data { + uint8_t arch; /* Architecture (PANIC_ARCH_*) */ + uint8_t struct_version; /* Structure version (currently 1) */ + uint8_t flags; /* Flags (PANIC_DATA_FLAG_*) */ + uint8_t reserved; /* Reserved; set 0 */ + + uint32_t regs[11]; /* psp, ipsr, lr, r4-r11 */ + uint32_t frame[8]; /* r0-r3, r12, lr, pc, xPSR */ + + uint32_t mmfs; + uint32_t bfar; + uint32_t mfar; + uint32_t shcsr; + uint32_t hfsr; + uint32_t dfsr; + + /* + * These fields go at the END of the struct so we can find it at the + * end of memory. + */ + uint32_t struct_size; /* Size of this struct */ + uint32_t magic; /* PANIC_SAVE_MAGIC if valid */ +}; + +#define PANIC_DATA_MAGIC 0x21636e50 /* "Pnc!" */ +#define PANIC_ARCH_CORTEX_M 1 /* Cortex-M architecture */ + +/* Flags for panic_data.flags */ +/* panic_data.frame is valid */ +#define PANIC_DATA_FLAG_FRAME_VALID (1 << 0) +/* Already printed at console */ +#define PANIC_DATA_FLAG_OLD_CONSOLE (1 << 1) +/* Already returned via host command */ +#define PANIC_DATA_FLAG_OLD_HOSTCMD (1 << 2) + /** * Write a character to the panic reporting device * @@ -56,7 +94,6 @@ void panic_vprintf(const char *format, va_list args); */ void panic_printf(const char *format, ...); - /** * Report an assertion failure and reset * @@ -82,4 +119,12 @@ void panic(const char *msg); */ void ignore_bus_fault(int ignored); -#endif +/** + * Return a pointer to the saved data from a previous panic. + * + * @param pointer to the panic data, or NULL if none available (for example, + * the last reboot was not caused by a panic). + */ +struct panic_data *panic_get_data(void); + +#endif /* __CROS_EC_PANIC_H */ |