diff options
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 */ |