diff options
author | David Hendricks <dhendrix@chromium.org> | 2012-09-06 09:12:51 -0700 |
---|---|---|
committer | David Hendricks <dhendrix@chromium.org> | 2012-09-06 09:13:41 -0700 |
commit | 5301485a9db06887428c31f89d7e3bd59e79603f (patch) | |
tree | 4f12d4f94d409794a02169b715841699bfb112f8 | |
parent | d363bf74a600c1129210075bf5d3158c0616c0d9 (diff) | |
download | chrome-ec-5301485a9db06887428c31f89d7e3bd59e79603f.tar.gz |
Revert "Save panic data across reboots, and add panicinfo command"
This reverts commit 5f92fdc0b6ec36beeb5c1d447f052e5f77d29e39
Reverting based on Vincent's comment. Tested locally that this doesn't break compilation for Snow.
Change-Id: I9d05ff300156448096af41b5cb2af972425dccf8
Reviewed-on: https://gerrit.chromium.org/gerrit/32396
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
-rw-r--r-- | common/system_common.c | 24 | ||||
-rw-r--r-- | core/cortex-m/panic.c | 61 | ||||
-rw-r--r-- | include/panic.h | 51 |
3 files changed, 42 insertions, 94 deletions
diff --git a/common/system_common.c b/common/system_common.c index 9b2460992f..3b56ec5198 100644 --- a/common/system_common.c +++ b/common/system_common.c @@ -15,7 +15,6 @@ #include "hooks.h" #include "host_command.h" #include "lpc.h" -#include "panic.h" #include "system.h" #include "task.h" #include "uart.h" @@ -61,8 +60,10 @@ struct jump_data { * data from the previous image. */ }; -/* Jump data (at end of RAM, or preceding panic data) */ -static struct jump_data *jdata; +/* Jump data goes at the end of RAM */ +static struct jump_data * const jdata = + (struct jump_data *)(CONFIG_RAM_BASE + CONFIG_RAM_SIZE + - sizeof(struct jump_data)); /* * Reset flag descriptions. Must be in same order as bits of RESET_FLAG_ @@ -164,7 +165,7 @@ int system_add_jump_tag(uint16_t tag, int version, int size, const void *data) struct jump_tag *t; /* Only allowed during a sysjump */ - if (!jdata || jdata->magic != JUMP_DATA_MAGIC) + if (jdata->magic != JUMP_DATA_MAGIC) return EC_ERROR_UNKNOWN; /* Make room for the new tag */ @@ -187,9 +188,6 @@ const uint8_t *system_get_jump_tag(uint16_t tag, int *version, int *size) const struct jump_tag *t; int used = 0; - if (!jdata) - return NULL; - /* Search through tag data for a match */ while (used < jdata->jump_tag_total) { /* Check the next tag */ @@ -458,18 +456,6 @@ const char *system_get_build_info(void) int system_common_pre_init(void) { - uint32_t addr; - - /* - * Put the jump data before the panic data, or at the end of RAM if - * panic data is not present. - */ - addr = (uint32_t)panic_get_data(); - if (!addr) - addr = CONFIG_RAM_BASE + CONFIG_RAM_SIZE; - - jdata = (struct jump_data *)(addr - sizeof(struct jump_data)); - /* * Check jump data if this is a jump between images. Jumps all show up * as an unknown reset reason, because we jumped directly from one diff --git a/core/cortex-m/panic.c b/core/cortex-m/panic.c index b86295d49d..fabd452052 100644 --- a/core/cortex-m/panic.c +++ b/core/cortex-m/panic.c @@ -19,6 +19,38 @@ /* Whether bus fault is ignored */ static int bus_fault_ignored; +/* 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 + +/* Flags for panic_data.flags */ +#define PANIC_DATA_FLAG_FRAME_VALID (1 << 0) /* panic_data.frame is valid */ + /* * Panic data goes at the end of RAM. This is safe because we don't context * switch away from the panic handler before rebooting, and stacks and data @@ -27,7 +59,6 @@ static int bus_fault_ignored; static struct panic_data * const pdata_ptr = (struct panic_data *)(CONFIG_RAM_BASE + CONFIG_RAM_SIZE - sizeof(struct panic_data)); - /* Preceded by stack, rounded down to nearest 64-bit-aligned boundary */ static const uint32_t pstack_addr = (CONFIG_RAM_BASE + CONFIG_RAM_SIZE - sizeof(struct panic_data)) & ~7; @@ -272,7 +303,7 @@ static void panic_show_extra(const struct panic_data *pdata) panic_printf("mmfs = %x, ", pdata->mmfs); panic_printf("shcsr = %x, ", pdata->shcsr); panic_printf("hfsr = %x, ", pdata->hfsr); - panic_printf("dfsr = %x\n", pdata->dfsr); + panic_printf("dfsr = %x", pdata->dfsr); } #endif /* CONFIG_PANIC_HELP */ @@ -426,10 +457,7 @@ void panic(const char *msg) panic_reboot(); } -struct panic_data *panic_get_data(void) -{ - return pdata_ptr->magic == PANIC_DATA_MAGIC ? pdata_ptr : NULL; -} + /*****************************************************************************/ /* Console commands */ @@ -458,24 +486,3 @@ DECLARE_CONSOLE_COMMAND(crash, command_crash, "[divzero | unaligned]", "Crash the system (for testing)", NULL); - -static int command_panicinfo(int argc, char **argv) -{ - if (pdata_ptr->magic == PANIC_DATA_MAGIC) { - ccprintf("Saved panic data:%s\n", - (pdata_ptr->flags & PANIC_DATA_FLAG_OLD_CONSOLE ? - "" : " (NEW)")); - - panic_print(pdata_ptr); - - /* Data has now been printed */ - pdata_ptr->flags |= PANIC_DATA_FLAG_OLD_CONSOLE; - } else { - ccprintf("No saved panic data available.\n"); - } - return EC_SUCCESS; -} -DECLARE_CONSOLE_COMMAND(panicinfo, command_panicinfo, - NULL, - "Print info from a previous panic", - NULL); diff --git a/include/panic.h b/include/panic.h index bb3e853bd2..ecf6eb0232 100644 --- a/include/panic.h +++ b/include/panic.h @@ -6,47 +6,9 @@ * device, which is currently the UART. */ -#ifndef __CROS_EC_PANIC_H -#define __CROS_EC_PANIC_H - +#ifndef __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 * @@ -94,6 +56,7 @@ void panic_vprintf(const char *format, va_list args); */ void panic_printf(const char *format, ...); + /** * Report an assertion failure and reset * @@ -119,12 +82,4 @@ void panic(const char *msg); */ void ignore_bus_fault(int ignored); -/** - * 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 */ +#endif |