summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2020-03-18 19:03:58 -0700
committerCommit Bot <commit-bot@chromium.org>2020-03-31 23:24:38 +0000
commitddbada80f6561cf721fc967ffab965e77b3ae5c3 (patch)
tree8f30a78ba10ef8cc5847f167b7319675f1f1c580 /common
parenta795c626a156a92813e7992bc14c764b1ae1f994 (diff)
downloadchrome-ec-ddbada80f6561cf721fc967ffab965e77b3ae5c3.tar.gz
Prepare for transitioning to packet mode console
A very few changes are needed to support the packet mode: - provide functions to report how much room is left in USB/UART transmit buffers; - compile out cprintf/cprints/cputs just in case to be able to catch cases where util_precompile.py fails to convert them for whatever reason; - do not add CR to every LF, this messes up packet transmissions, and the terminal is doing the right thing anyways - there is a problem with the USB channel in packet mode: the device reboots as soon as an attempt to send something to the host is undertaken. The problem can be rectified by disabling the deferred function path in the Cr50 console USB channel. A bug was open to track it down, but in packet mode using deferred function in this path is less critical, as the amount of sent data always is at least as much as the packet header size BUG=b:149964350, b:152116489 TEST=with the rest of the patches applied packet mode console works fine. When packet mode is disabled the conventional mode console works fine. Change-Id: Ib010cede36adc87cf80f49e5d76ec9e274d9e608 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2114238 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Namyoon Woo <namyoon@chromium.org>
Diffstat (limited to 'common')
-rw-r--r--common/console.c5
-rw-r--r--common/console_output.c3
-rw-r--r--common/uart_buffering.c7
-rw-r--r--common/usb_console_stream.c15
4 files changed, 26 insertions, 4 deletions
diff --git a/common/console.c b/common/console.c
index 8f42dffbf5..9ee3dc5b13 100644
--- a/common/console.c
+++ b/common/console.c
@@ -279,10 +279,7 @@ static void console_init(void)
static int console_putc(int c)
{
- int rv1 = uart_putc(c);
- int rv2 = usb_putc(c);
-
- return rv1 == EC_SUCCESS ? rv2 : rv1;
+ return ccprintf("%c", c);
}
#ifndef CONFIG_EXPERIMENTAL_CONSOLE
diff --git a/common/console_output.c b/common/console_output.c
index 2fe1ac99a9..6d883f7030 100644
--- a/common/console_output.c
+++ b/common/console_output.c
@@ -37,6 +37,8 @@ BUILD_ASSERT(ARRAY_SIZE(channel_names) == CC_CHANNEL_COUNT);
BUILD_ASSERT(CC_CHANNEL_COUNT <= 8*sizeof(uint32_t));
#endif /* CONFIG_CONSOLE_CHANNEL */
+#ifndef CONFIG_EXTRACT_PRINTF_STRINGS
+
/*****************************************************************************/
/* Channel-based console output */
@@ -106,6 +108,7 @@ int cprints(enum console_channel channel, const char *format, ...)
r = cputs(channel, "]\n");
return r ? r : rv;
}
+#endif /* ^^^^^^^^ CONFIG_EXTRACT_PRINTF_STRINGS NOT defined. */
void cflush(void)
{
diff --git a/common/uart_buffering.c b/common/uart_buffering.c
index e3b7e73fbd..c54cbf98dd 100644
--- a/common/uart_buffering.c
+++ b/common/uart_buffering.c
@@ -84,9 +84,11 @@ static int __tx_char(void *context, int c)
{
int tx_buf_next, tx_buf_new_tail;
+#ifndef CONFIG_EXTRACT_PRINTF_STRINGS
/* Do newline to CRLF translation */
if (c == '\n' && __tx_char(NULL, '\r'))
return 1;
+#endif
#if defined CONFIG_POLLING_UART
(void) tx_buf_next;
@@ -122,6 +124,11 @@ static int __tx_char(void *context, int c)
return 0;
}
+size_t uart_buffer_room(void)
+{
+ return (tx_buf_tail - tx_buf_head - 1) & (CONFIG_UART_TX_BUF_SIZE - 1);
+}
+
#ifdef CONFIG_UART_TX_DMA
/**
diff --git a/common/usb_console_stream.c b/common/usb_console_stream.c
index 40bbc07e3c..6ba1f484a4 100644
--- a/common/usb_console_stream.c
+++ b/common/usb_console_stream.c
@@ -162,6 +162,21 @@ static int __tx_char(void *context, int c)
#endif
}
+size_t usb_buffer_room(void)
+{
+ if (!is_enabled)
+ return 0;
+
+ return queue_space(&tx_q);
+}
+
+int usb_put(const char *s, int len)
+{
+ QUEUE_ADD_UNITS(&tx_q, s, len);
+ handle_output();
+ return EC_SUCCESS;
+}
+
/*
* Public USB console implementation below.
*/