summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2012-08-07 10:32:16 -0700
committerRandall Spangler <rspangler@chromium.org>2012-08-07 14:29:49 -0700
commit590d3735ce2ae29b3b55f603b522796b894aa5d8 (patch)
treef3d34c413998d6dc7fa830cadaf4a695a172905a
parentba43c5bccef8101612f73f5045ce3f6e1195e305 (diff)
downloadchrome-ec-590d3735ce2ae29b3b55f603b522796b894aa5d8.tar.gz
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 Original-Change-Id: I64ee72fb13ab0fdd85d04b9640b5390fdac31400 Signed-off-by: Randall Spangler <rspangler@chromium.org> (cherry picked from commit 80e36e02549dc3bb121aee1619760198b706c406) Change-Id: I83a0adc88c4cf92ed461579696cc701ce231c54e Reviewed-on: https://gerrit.chromium.org/gerrit/29446 Reviewed-by: Randall Spangler <rspangler@chromium.org> Tested-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r--chip/lm4/lpc.c4
-rw-r--r--common/port80.c48
-rw-r--r--include/port80.h10
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 */