From 80e36e02549dc3bb121aee1619760198b706c406 Mon Sep 17 00:00:00 2001 From: Randall Spangler Date: Tue, 7 Aug 2012 10:32:16 -0700 Subject: Enhance port 80 logging - 'port80 intprint' toggles printing port 80 codes in interrupt handler (turning that off speeds up port 80 capture a bit, if you're sending port 80 codes very rapidly) - 'port80 flush' flushes the log buffer - log buffer expanded to 256 entries - log buffer tracks S3->S0 power state transitions, so you can tell where each boot starts This uses ~500 bytes more RAM on the EC, but we've got piles of RAM (with this change we're using 17KB out of 32KB). BUG=none TEST=manual - boot system - port80 -> prints data - port80 intprint -> now disabled - reboot; wait for reboot; no port80 debug output during boot - port80 -> prints data from previous boot AND this one - port80 flush - port80 -> nothing in log Change-Id: I64ee72fb13ab0fdd85d04b9640b5390fdac31400 Signed-off-by: Randall Spangler Reviewed-on: https://gerrit.chromium.org/gerrit/29420 Reviewed-by: Bill Richardson Reviewed-by: Duncan Laurie --- common/port80.c | 48 +++++++++++++++++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 11 deletions(-) (limited to 'common') 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); -- cgit v1.2.1