summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2012-04-03 11:29:41 -0700
committerRandall Spangler <rspangler@chromium.org>2012-04-03 11:35:47 -0700
commit95462ad4fed6839f0b672d4fdef08d09265e3585 (patch)
treee2d44d80fbda4731018ff25b3c3b24712ad7c348
parented33516e2e7414abf84b62d4426e4b4c61ff7892 (diff)
downloadchrome-ec-95462ad4fed6839f0b672d4fdef08d09265e3585.tar.gz
Add %T format code to print current timestamp.
Signed-off-by: Randall Spangler <rspangler@chromium.org> BUG=chrome-os-partner:8724 TEST=if timestamps show up in the debug output, it works Change-Id: I5264a3a40a07a824cc15b39a7bd81f2db02a3c13
-rw-r--r--chip/lm4/lpc.c2
-rw-r--r--chip/lm4/power_button.c6
-rw-r--r--common/port80.c2
-rw-r--r--common/uart_buffering.c8
-rw-r--r--common/x86_power.c2
-rw-r--r--include/uart.h10
6 files changed, 20 insertions, 10 deletions
diff --git a/chip/lm4/lpc.c b/chip/lm4/lpc.c
index 9d4d8e570f..e07b54d66e 100644
--- a/chip/lm4/lpc.c
+++ b/chip/lm4/lpc.c
@@ -388,7 +388,7 @@ static void lpc_interrupt(void)
/* Debugging: print changes to LPC0RESET */
if (mis & (1 << 31)) {
- uart_printf("[LPC PLTRST# %sasserted]\n",
+ uart_printf("[%T LPC PLTRST# %sasserted]\n",
(LM4_LPC_LPCSTS & (1<<10)) ? "" : "de");
}
}
diff --git a/chip/lm4/power_button.c b/chip/lm4/power_button.c
index 1c68f6d9d7..eb92c0284b 100644
--- a/chip/lm4/power_button.c
+++ b/chip/lm4/power_button.c
@@ -84,7 +84,7 @@ static void update_other_switches(void)
static void set_pwrbtn_to_pch(int high)
{
- uart_printf("[PB PCH pwrbtn=%s]\n", high ? "HIGH" : "LOW");
+ uart_printf("[%T PB PCH pwrbtn=%s]\n", high ? "HIGH" : "LOW");
gpio_set_level(GPIO_PCH_PWRBTNn, high);
}
@@ -150,7 +150,7 @@ static void power_button_changed(uint64_t tnow)
static void lid_switch_changed(uint64_t tnow)
{
int v = gpio_get_level(GPIO_LID_SWITCHn);
- uart_printf("[PB lid %s]\n", v ? "open" : "closed");
+ uart_printf("[%T PB lid %s]\n", v ? "open" : "closed");
lpc_set_host_events(EC_LPC_HOST_EVENT_MASK((v ?
EC_LPC_HOST_EVENT_LID_OPEN : EC_LPC_HOST_EVENT_LID_CLOSED)));
@@ -262,7 +262,7 @@ void power_button_task(void)
* that can't happen - and even if it did, we'd just go
* back to sleep after deciding that we woke up too
* early.) */
- uart_printf("[PB task wait %d]\n", d);
+ uart_printf("[%T PB task wait %d]\n", d);
task_wait_msg(d);
}
}
diff --git a/common/port80.c b/common/port80.c
index 331ea23a48..9e6ba40c1f 100644
--- a/common/port80.c
+++ b/common/port80.c
@@ -24,7 +24,7 @@ void port_80_write(int data)
* itself. Probably not worth the system overhead to buffer the data
* and print it from a task, because we're printing a small amount of
* data and uart_printf() doesn't block. */
- uart_printf("%c[Port 80: 0x%02x]", scroll ? '\n' : '\r', data);
+ uart_printf("%c[%T Port 80: 0x%02x]", scroll ? '\n' : '\r', data);
history[head] = data;
head = (head + 1) & (HISTORY_LEN - 1);
diff --git a/common/uart_buffering.c b/common/uart_buffering.c
index 5f6580d73c..6393ff47be 100644
--- a/common/uart_buffering.c
+++ b/common/uart_buffering.c
@@ -9,6 +9,7 @@
#include "console.h"
#include "task.h"
+#include "timer.h"
#include "uart.h"
#include "util.h"
@@ -458,7 +459,11 @@ int uart_printf(const char *format, ...)
/* TODO: (crosbug.com/p/7490) handle "%l" prefix for
* uint64_t */
- v = va_arg(args, uint32_t);
+ /* Special-case: %T = current time */
+ if (c == 'T')
+ v = get_time().le.lo;
+ else
+ v = va_arg(args, uint32_t);
switch (c) {
case 'd':
@@ -468,6 +473,7 @@ int uart_printf(const char *format, ...)
}
break;
case 'u':
+ case 'T':
break;
case 'x':
case 'p':
diff --git a/common/x86_power.c b/common/x86_power.c
index 182e9b51b2..7bf769e6fc 100644
--- a/common/x86_power.c
+++ b/common/x86_power.c
@@ -307,7 +307,7 @@ void x86_power_task(void)
x86_power_init();
while (1) {
- uart_printf("[x86 power state %d = %s, in 0x%04x]\n",
+ uart_printf("[%T x86 power state %d = %s, in 0x%04x]\n",
state, state_names[state], in_signals);
switch (state) {
diff --git a/include/uart.h b/include/uart.h
index dc64d9ad6f..3ca34c67f1 100644
--- a/include/uart.h
+++ b/include/uart.h
@@ -41,16 +41,20 @@ int uart_puts(const char *outstr);
*
* Returns error if output was truncated.
*
- * Must support format strings for:
+ * Supports the following format strings:
* char (%c)
* string (%s)
* native int (signed/unsigned) (%d / %u / %x)
* int32_t / uint32_t (%d / %x)
- * int64_t / uint64_t (%ld / %lu / %lx)
* pointer (%p)
+ * And the following special format codes:
+ * current time in us (%T)
* including padding (%-5s, %8d, %08x)
*
- * Note: Floating point output (%f / %g) is not required.
+ * Support planned for:
+ * int64_t / uint64_t (%ld / %lu / %lx)
+ *
+ * Note: Floating point output (%f / %g) is not supported.
*/
int uart_printf(const char *format, ...);