diff options
-rw-r--r-- | chip/lm4/lpc.c | 4 | ||||
-rw-r--r-- | common/port80.c | 48 | ||||
-rw-r--r-- | include/port80.h | 10 |
3 files changed, 50 insertions, 12 deletions
diff --git a/chip/lm4/lpc.c b/chip/lm4/lpc.c index c7e1d988cf..8477dbc3d7 100644 --- a/chip/lm4/lpc.c +++ b/chip/lm4/lpc.c @@ -758,6 +758,10 @@ static int lpc_resume(void) lpc_set_host_event_mask(LPC_HOST_EVENT_SMI, 0); lpc_set_host_event_mask(LPC_HOST_EVENT_SCI, 0); lpc_set_host_event_mask(LPC_HOST_EVENT_WAKE, 0); + + /* Store port 80 event so we know where resume happened */ + port_80_write(PORT_80_EVENT_RESUME); + return EC_SUCCESS; } DECLARE_HOOK(HOOK_CHIPSET_RESUME, lpc_resume, HOOK_PRIO_DEFAULT); diff --git a/common/port80.c b/common/port80.c index 64b203e57b..f8a6c8395d 100644 --- a/common/port80.c +++ b/common/port80.c @@ -12,12 +12,12 @@ #define CPRINTF(format, args...) cprintf(CC_PORT80, format, ## args) -#define HISTORY_LEN 16 +#define HISTORY_LEN 256 -static uint8_t history[HISTORY_LEN]; +static uint16_t history[HISTORY_LEN]; static int writes; /* Number of port 80 writes so far */ static int scroll; - +static int print_in_int = 1; void port_80_write(int data) { @@ -27,7 +27,8 @@ void port_80_write(int data) * and print it from a task, because we're printing a small amount of * data and cprintf() doesn't block. */ - CPRINTF("%c[%T Port 80: 0x%02x]", scroll ? '\n' : '\r', data); + if (print_in_int) + CPRINTF("%c[%T Port 80: 0x%02x]", scroll ? '\n' : '\r', data); history[writes % ARRAY_SIZE(history)] = data; writes++; @@ -39,16 +40,29 @@ void port_80_write(int data) static int command_port80(int argc, char **argv) { int head, tail; + int printed = 0; int i; /* * 'port80 scroll' toggles whether port 80 output begins with a newline * (scrolling) or CR (non-scrolling). */ - if (argc > 1 && !strcasecmp(argv[1], "scroll")) { - scroll = !scroll; - ccprintf("scroll %sabled\n", scroll ? "en" : "dis"); - return EC_SUCCESS; + if (argc > 1) { + if (!strcasecmp(argv[1], "scroll")) { + scroll = !scroll; + ccprintf("scroll %sabled\n", scroll ? "en" : "dis"); + return EC_SUCCESS; + } else if (!strcasecmp(argv[1], "intprint")) { + print_in_int = !print_in_int; + ccprintf("printing in interrupt %sabled\n", + print_in_int ? "en" : "dis"); + return EC_SUCCESS; + } else if (!strcasecmp(argv[1], "flush")) { + writes = 0; + return EC_SUCCESS; + } else { + return EC_ERROR_PARAM1; + } } /* @@ -65,12 +79,24 @@ static int command_port80(int argc, char **argv) else tail = 0; - for (i = tail; i < head; i++) - ccprintf(" %02x", history[i % ARRAY_SIZE(history)]); + ccputs("Port 80 writes:"); + for (i = tail; i < head; i++) { + int e = history[i % ARRAY_SIZE(history)]; + if (e == PORT_80_EVENT_RESUME) { + ccprintf("\n(S3->S0)"); + printed = 0; + } else { + if (!(printed++ % 20)) { + ccputs("\n "); + cflush(); + } + ccprintf(" %02x", e); + } + } ccputs(" <--new\n"); return EC_SUCCESS; } DECLARE_CONSOLE_COMMAND(port80, command_port80, - "[scroll]", + "[scroll | intprint | flush]", "Print port80 writes or toggle port80 scrolling", NULL); diff --git a/include/port80.h b/include/port80.h index 787af8c169..0d251d1d1f 100644 --- a/include/port80.h +++ b/include/port80.h @@ -10,7 +10,15 @@ #include "common.h" -/* Called by LPC module when a byte of data is written to port 80. */ +enum port_80_event { + PORT_80_EVENT_RESUME = 0x1001, /* S3->S0 transition */ +}; + +/** + * Store data from a LPC write to port 80, or a port_80_event code. + * + * @param data Data written to port 80. + */ void port_80_write(int data); #endif /* __CROS_EC_PORT80_H */ |