diff options
author | Randall Spangler <rspangler@chromium.org> | 2012-02-14 09:24:42 -0800 |
---|---|---|
committer | Randall Spangler <rspangler@chromium.org> | 2012-02-14 09:34:02 -0800 |
commit | 1dd47c8ef3d41b175a0d04f661eca56754c1a2b4 (patch) | |
tree | 2cf2cbfab7630383fa5926d4797ee29869ebe801 | |
parent | 938649ac67a8bf0440a8b0533f40996c94adf25b (diff) | |
download | chrome-ec-1dd47c8ef3d41b175a0d04f661eca56754c1a2b4.tar.gz |
Make port 80 output less scrolly
It was scrolling so much that the EC debug output for power state
transitions was getting lost. Now it uses CR instead of LF.
Use 'port80 scroll' to turn scrolling back on (it's off by default).
Port 80 history is still visible via the 'port80' command, in all cases.
Signed-off-by: Randall Spangler <rspangler@chromium.org>
BUG=none
TEST=powerbtn ; power on; should not scroll screen
port80 ; confirm history is still there
port80 scroll ; enable scrolling
powerbtn ; turn system off
powerbtn ; turn system back on; should scroll screen
port80 ; confirm history is still there
Change-Id: I85d058ff0b2b9d3d5296060747bde5e872b85817
-rw-r--r-- | common/port80.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/common/port80.c b/common/port80.c index 114f1cf520..34b418d76d 100644 --- a/common/port80.c +++ b/common/port80.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2011 The Chromium OS Authors. All rights reserved. +/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ @@ -11,28 +11,29 @@ #include "uart.h" #include "util.h" - #define HISTORY_LEN 16 static uint8_t history[HISTORY_LEN]; static int head = 0; /* Next index to use / oldest previous entry */ -static int last_data = -1; /* Last data written to port 80 */ +static int scroll = 0; void port_80_write(int data) { #ifndef CONFIG_PORT80_PRINT_DUPLICATES + static int last_data = -1; /* Last data written to port 80 */ + /* Ignore duplicate writes, since the linux kernel writes to port 80 * as a delay mechanism during boot. */ if (data == last_data) return; + + last_data = data; #endif /* TODO: post to SWI and print from there? This currently * prints from inside the LPC interrupt itself. */ - - uart_printf("[Port 80: 0x%02x]\n", data); - last_data = data; + uart_printf("%c[Port 80: 0x%02x]", scroll ? '\n' : '\r', data); history[head] = data; head = (head + 1) & (HISTORY_LEN - 1); @@ -47,10 +48,18 @@ static int command_port80(int argc, char **argv) int h = head; 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; + uart_printf("port80 scrolling %sabled\n", + scroll ? "en" : "dis"); + return EC_SUCCESS; + } + /* Technically, if a port 80 write comes in while we're * printing this, we could print an incorrect history. * Probably not worth the complexity to work around that. */ - uart_puts("Last port 80 writes:"); for (i = 0; i < HISTORY_LEN; i++) uart_printf(" %02x", history[(h + i) & (HISTORY_LEN - 1)]); |