summaryrefslogtreecommitdiff
path: root/common/port80.c
diff options
context:
space:
mode:
Diffstat (limited to 'common/port80.c')
-rw-r--r--common/port80.c42
1 files changed, 24 insertions, 18 deletions
diff --git a/common/port80.c b/common/port80.c
index 231181cad8..abead59cd9 100644
--- a/common/port80.c
+++ b/common/port80.c
@@ -1,4 +1,4 @@
-/* Copyright 2012 The Chromium OS Authors. All rights reserved.
+/* Copyright 2012 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -11,11 +11,12 @@
#include "hooks.h"
#include "host_command.h"
#include "port80.h"
+#include "printf.h"
#include "task.h"
#include "timer.h"
#include "util.h"
-#define CPRINTF(format, args...) cprintf(CC_PORT80, format, ## args)
+#define CPRINTF(format, args...) cprintf(CC_PORT80, format, ##args)
#ifdef CONFIG_PORT80_4_BYTE
typedef uint32_t port80_code_t;
@@ -23,7 +24,7 @@ typedef uint32_t port80_code_t;
typedef uint16_t port80_code_t;
#endif
static port80_code_t history[CONFIG_PORT80_HISTORY_LEN];
-static int writes; /* Number of port 80 writes so far */
+static int writes; /* Number of port 80 writes so far */
static uint16_t last_boot; /* Last code from previous boot */
static int scroll;
@@ -39,6 +40,8 @@ DECLARE_DEFERRED(port80_dump_buffer);
void port_80_write(int data)
{
+ char ts_str[PRINTF_TIMESTAMP_BUF_SIZE];
+
/*
* By default print_in_int is disabled if:
* 1. CONFIG_BRINGUP is not defined
@@ -53,15 +56,20 @@ void port_80_write(int data)
* dump the current port80 buffer to EC console. This is to allow
* developers to help debug BIOS progress by tracing port80 messages.
*/
- if (print_in_int)
- CPRINTF("%c[%pT Port 80: 0x%02x]",
- scroll ? '\n' : '\r', PRINTF_TIMESTAMP_NOW, data);
+ if (print_in_int) {
+ snprintf_timestamp_now(ts_str, sizeof(ts_str));
+ CPRINTF("%c[%s Port 80: 0x%02x]", scroll ? '\n' : '\r', ts_str,
+ data);
+ }
- hook_call_deferred(&port80_dump_buffer_data, 4 * SECOND);
+ if (!IS_ENABLED(CONFIG_PORT80_QUIET)) {
+ hook_call_deferred(&port80_dump_buffer_data, 4 * SECOND);
+ }
/* Save current port80 code if system is resetting */
if (data == PORT_80_EVENT_RESET && writes) {
- port80_code_t prev = history[(writes-1) % ARRAY_SIZE(history)];
+ port80_code_t prev =
+ history[(writes - 1) % ARRAY_SIZE(history)];
/*
* last_boot only reports 8-bit codes.
@@ -127,7 +135,7 @@ static void port80_dump_buffer(void)
/*****************************************************************************/
/* Console commands */
-static int command_port80(int argc, char **argv)
+static int command_port80(int argc, const char **argv)
{
/*
* 'port80 scroll' toggles whether port 80 output begins with a newline
@@ -154,8 +162,7 @@ static int command_port80(int argc, char **argv)
port80_dump_buffer();
return EC_SUCCESS;
}
-DECLARE_CONSOLE_COMMAND(port80, command_port80,
- "[scroll | intprint | flush]",
+DECLARE_CONSOLE_COMMAND(port80, command_port80, "[scroll | intprint | flush]",
"Print port80 writes or toggle port80 scrolling");
enum ec_status port80_last_boot(struct host_cmd_handler_args *args)
@@ -187,24 +194,23 @@ static enum ec_status port80_command_read(struct host_cmd_handler_args *args)
} else if (p->subcmd == EC_PORT80_READ_BUFFER) {
/* do not allow bad offset or size */
if (offset >= ARRAY_SIZE(history) || entries == 0 ||
- entries > args->response_max)
+ entries > args->response_max)
return EC_RES_INVALID_PARAM;
for (i = 0; i < entries; i++) {
- uint16_t e = history[(i + offset) %
- ARRAY_SIZE(history)];
+ uint16_t e =
+ history[(i + offset) % ARRAY_SIZE(history)];
rsp->data.codes[i] = e;
}
- args->response_size = entries*sizeof(uint16_t);
+ args->response_size = entries * sizeof(uint16_t);
return EC_RES_SUCCESS;
}
return EC_RES_INVALID_PARAM;
}
-DECLARE_HOST_COMMAND(EC_CMD_PORT80_READ,
- port80_command_read,
- EC_VER_MASK(0) | EC_VER_MASK(1));
+DECLARE_HOST_COMMAND(EC_CMD_PORT80_READ, port80_command_read,
+ EC_VER_MASK(0) | EC_VER_MASK(1));
static void port80_log_resume(void)
{