diff options
author | Vincent Palatin <vpalatin@chromium.org> | 2014-06-16 13:46:59 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-07-17 00:40:23 +0000 |
commit | a975c98fb2f378e4fc94cf73c38fe8afa8cb6eeb (patch) | |
tree | 6e12692cd15e1d06892a0cf15333e1e51c6146b0 /common/console_output.c | |
parent | 7746b32e17571b0e0cbdcbd101787b742d35c825 (diff) | |
download | chrome-ec-a975c98fb2f378e4fc94cf73c38fe8afa8cb6eeb.tar.gz |
usb: add USB console driver
Provide access to the EC console through 2 USB bulk endpoints.
(which can be used through the usbserial driver)
Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
BRANCH=none
BUG=none
TEST=run on Fruitpie and use the console over USB
Change-Id: Ia897764f3a030972ee2ed323f293c5fca899765a
Reviewed-on: https://chromium-review.googlesource.com/204167
Reviewed-by: Anton Staaf <robotboy@chromium.org>
Commit-Queue: Vic Yang <victoryang@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
Diffstat (limited to 'common/console_output.c')
-rw-r--r-- | common/console_output.c | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/common/console_output.c b/common/console_output.c index 3bbad84ad4..bc28a8a3b1 100644 --- a/common/console_output.c +++ b/common/console_output.c @@ -7,6 +7,7 @@ #include "console.h" #include "uart.h" +#include "usb_console.h" #include "util.h" /* Default to all channels active */ @@ -68,26 +69,36 @@ BUILD_ASSERT(ARRAY_SIZE(channel_names) == CC_CHANNEL_COUNT); int cputs(enum console_channel channel, const char *outstr) { + int rv1, rv2; + /* Filter out inactive channels */ if (!(CC_MASK(channel) & channel_mask)) return EC_SUCCESS; - return uart_puts(outstr); + rv1 = usb_puts(outstr); + rv2 = uart_puts(outstr); + + return rv1 == EC_SUCCESS ? rv2 : rv1; } int cprintf(enum console_channel channel, const char *format, ...) { - int rv; + int rv1, rv2; va_list args; /* Filter out inactive channels */ if (!(CC_MASK(channel) & channel_mask)) return EC_SUCCESS; + usb_va_start(args, format); + rv1 = usb_vprintf(format, args); + usb_va_end(args); + va_start(args, format); - rv = uart_vprintf(format, args); + rv2 = uart_vprintf(format, args); va_end(args); - return rv; + + return rv1 == EC_SUCCESS ? rv2 : rv1; } int cprints(enum console_channel channel, const char *format, ...) @@ -99,13 +110,21 @@ int cprints(enum console_channel channel, const char *format, ...) if (!(CC_MASK(channel) & channel_mask)) return EC_SUCCESS; + rv = cprintf(channel, "[%T "); + va_start(args, format); - rv = uart_printf("[%T "); r = uart_vprintf(format, args); if (r) rv = r; - r = uart_puts("]\n"); va_end(args); + + usb_va_start(args, format); + r = usb_vprintf(format, args); + if (r) + rv = r; + usb_va_end(args); + + r = cputs(channel, "]\n"); return r ? r : rv; } |