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 <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/29420
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
This commit is contained in:
Randall Spangler
2012-08-07 10:32:16 -07:00
committed by Gerrit
parent b383d4c6b8
commit 80e36e0254
3 changed files with 50 additions and 12 deletions

View File

@@ -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);

View File

@@ -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);

View File

@@ -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 */