diff options
author | Duncan Laurie <dlaurie@chromium.org> | 2012-08-13 09:14:11 -0700 |
---|---|---|
committer | Gerrit <chrome-bot@google.com> | 2012-08-13 14:58:38 -0700 |
commit | 3b8b1bd586f13d8137d2830210c64e12dab1adc6 (patch) | |
tree | e03db5267624ab3df3c8b11bb7afb66e96b99782 | |
parent | 521e97fd135cfaeb199e1de0f87aa2e45b4aa804 (diff) | |
download | chrome-ec-3b8b1bd586f13d8137d2830210c64e12dab1adc6.tar.gz |
port80: Track and export last post code in previous boot
- Add a special port80 event for LPC reset assertion and use that event
to store the previous post code.
- Add a new command to retrive the last saved post code so I can easily
query it at boot/resume and log unusual codes.
BUG=none
TEST=manual (with additional coreboot/mosys changes)
- interrupt boot process by issuing x86reset on EC console or
by using warm reset button on servo
- read event log with mosys on next boot
78 | 2012-08-13 09:24:04 | System boot | 262
79 | 2012-08-13 09:24:04 | Last post code in previous boot | 0x9e
80 | 2012-08-13 09:24:04 | System Reset
Change-Id: I7b9f10442b9c468d89fde4e75adb94b0c07c2c8d
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/29995
Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r-- | chip/lm4/lpc.c | 4 | ||||
-rw-r--r-- | common/port80.c | 33 | ||||
-rw-r--r-- | include/ec_commands.h | 10 | ||||
-rw-r--r-- | include/port80.h | 1 |
4 files changed, 46 insertions, 2 deletions
diff --git a/chip/lm4/lpc.c b/chip/lm4/lpc.c index 8477dbc3d7..41da2ab8b8 100644 --- a/chip/lm4/lpc.c +++ b/chip/lm4/lpc.c @@ -558,6 +558,10 @@ static void lpc_interrupt(void) /* Debugging: print changes to LPC0RESET */ if (mis & (1 << 31)) { + /* Store port 80 event so we know where reset happened */ + if (LM4_LPC_LPCSTS & (1 << 10)) + port_80_write(PORT_80_EVENT_RESET); + CPRINTF("[%T LPC RESET# %sasserted]\n", (LM4_LPC_LPCSTS & (1<<10)) ? "" : "de"); } diff --git a/common/port80.c b/common/port80.c index f8a6c8395d..72b8ccde11 100644 --- a/common/port80.c +++ b/common/port80.c @@ -7,6 +7,7 @@ #include "board.h" #include "console.h" +#include "host_command.h" #include "port80.h" #include "util.h" @@ -16,6 +17,7 @@ static uint16_t history[HISTORY_LEN]; static int writes; /* Number of port 80 writes so far */ +static int last_boot; /* Last code from previous boot */ static int scroll; static int print_in_int = 1; @@ -30,6 +32,15 @@ void port_80_write(int data) if (print_in_int) CPRINTF("%c[%T Port 80: 0x%02x]", scroll ? '\n' : '\r', data); + /* Save current port80 code if system is resetting */ + if (data == PORT_80_EVENT_RESET && writes) { + int prev = history[(writes-1) % ARRAY_SIZE(history)]; + + /* Ignore special event codes */ + if (prev < 0x100) + last_boot = prev; + } + history[writes % ARRAY_SIZE(history)] = data; writes++; } @@ -82,10 +93,16 @@ static int command_port80(int argc, char **argv) ccputs("Port 80 writes:"); for (i = tail; i < head; i++) { int e = history[i % ARRAY_SIZE(history)]; - if (e == PORT_80_EVENT_RESUME) { + switch (e) { + case PORT_80_EVENT_RESUME: ccprintf("\n(S3->S0)"); printed = 0; - } else { + break; + case PORT_80_EVENT_RESET: + ccprintf("\n(RESET)"); + printed = 0; + break; + default: if (!(printed++ % 20)) { ccputs("\n "); cflush(); @@ -100,3 +117,15 @@ DECLARE_CONSOLE_COMMAND(port80, command_port80, "[scroll | intprint | flush]", "Print port80 writes or toggle port80 scrolling", NULL); + +int port80_last_boot(struct host_cmd_handler_args *args) +{ + struct ec_response_port80_last_boot *r = args->response; + + args->response_size = sizeof(*r); + r->code = last_boot; + + return EC_RES_SUCCESS; +} +DECLARE_HOST_COMMAND(EC_CMD_PORT80_LAST_BOOT, + port80_last_boot, EC_VER_MASK(0)); diff --git a/include/ec_commands.h b/include/ec_commands.h index bda5995d55..c1b19bcf1a 100644 --- a/include/ec_commands.h +++ b/include/ec_commands.h @@ -736,6 +736,16 @@ struct ec_response_rtc { #define EC_CMD_RTC_SET_ALARM 0x47 /*****************************************************************************/ +/* Port80 log access */ + +/* Get last port80 code from previous boot */ +#define EC_CMD_PORT80_LAST_BOOT 0x48 + +struct ec_response_port80_last_boot { + uint16_t code; +} __packed; + +/*****************************************************************************/ /* Thermal engine commands */ /* Set thershold value */ diff --git a/include/port80.h b/include/port80.h index 0d251d1d1f..28966750c6 100644 --- a/include/port80.h +++ b/include/port80.h @@ -12,6 +12,7 @@ enum port_80_event { PORT_80_EVENT_RESUME = 0x1001, /* S3->S0 transition */ + PORT_80_EVENT_RESET = 0x1002, /* RESET transition */ }; /** |