summaryrefslogtreecommitdiff
path: root/common/uart_buffering.c
diff options
context:
space:
mode:
authorJack Rosenthal <jrosenth@chromium.org>2021-02-10 13:25:03 -0700
committerCommit Bot <commit-bot@chromium.org>2021-02-11 17:19:42 +0000
commitfdf60424cfa7552e7a29bd09dd10aba137e108a3 (patch)
treed3dee323ce3a1630722ee686ee7cd7899ec37a83 /common/uart_buffering.c
parent7991e4d1f705c84966b382219f194804380b79ab (diff)
downloadchrome-ec-fdf60424cfa7552e7a29bd09dd10aba137e108a3.tar.gz
common: uart: split off printf and like functions into separate module
This separates the high-level uart output functions like uart_printf and uart_putc from the uart buffering module, allowing the buffering to be implemented separately from the output functions. The contract between this module and the uart_buffering layer is to implement uart_tx_char_raw and uart_tx_start. BUG=b:178033156 BRANCH=none TEST=buildall Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I5fb62ca2be1fea04654eaadd7a3806ac0c586929 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2685411 Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'common/uart_buffering.c')
-rw-r--r--common/uart_buffering.c90
1 files changed, 1 insertions, 89 deletions
diff --git a/common/uart_buffering.c b/common/uart_buffering.c
index 38bbd67d2d..78dc06e5f4 100644
--- a/common/uart_buffering.c
+++ b/common/uart_buffering.c
@@ -71,16 +71,7 @@ void uart_init_buffer(void)
}
}
-/**
- * Put a single character into the transmit buffer.
- *
- * Does not enable the transmit interrupt; assumes that happens elsewhere.
- *
- * @param context Context; ignored.
- * @param c Character to write.
- * @return 0 if the character was transmitted, 1 if it was dropped.
- */
-static int __tx_char_raw(void *context, int c)
+int uart_tx_char_raw(void *context, int c)
{
int tx_buf_next, tx_buf_new_tail;
@@ -118,14 +109,6 @@ static int __tx_char_raw(void *context, int c)
return 0;
}
-static int __tx_char(void *context, int c)
-{
- /* Translate '\n' to '\r\n' */
- if (c == '\n' && __tx_char_raw(NULL, '\r'))
- return 1;
- return __tx_char_raw(context, c);
-}
-
#ifdef CONFIG_UART_TX_DMA
/**
@@ -265,77 +248,6 @@ void uart_clear_input(void)
#endif /* !CONFIG_UART_RX_DMA */
-int uart_putc(int c)
-{
- int rv = __tx_char(NULL, c);
-
- uart_tx_start();
-
- return rv ? EC_ERROR_OVERFLOW : EC_SUCCESS;
-}
-
-int uart_puts(const char *outstr)
-{
- /* Put all characters in the output buffer */
- while (*outstr) {
- if (__tx_char(NULL, *outstr++) != 0)
- break;
- }
-
- uart_tx_start();
-
- /* Successful if we consumed all output */
- return *outstr ? EC_ERROR_OVERFLOW : EC_SUCCESS;
-}
-
-int uart_put(const char *out, int len)
-{
- /* Put all characters in the output buffer */
- while (len--) {
- if (__tx_char(NULL, *out++) != 0)
- break;
- }
-
- uart_tx_start();
-
- /* Successful if we consumed all output */
- return len ? EC_ERROR_OVERFLOW : EC_SUCCESS;
-}
-
-int uart_put_raw(const char *out, int len)
-{
- /* Put all characters in the output buffer */
- while (len--) {
- if (__tx_char_raw(NULL, *out++) != 0)
- break;
- }
-
- uart_tx_start();
-
- /* Successful if we consumed all output */
- return len ? EC_ERROR_OVERFLOW : EC_SUCCESS;
-}
-
-int uart_vprintf(const char *format, va_list args)
-{
- int rv = vfnprintf(__tx_char, NULL, format, args);
-
- uart_tx_start();
-
- return rv;
-}
-
-int uart_printf(const char *format, ...)
-{
- int rv;
- va_list args;
-
- va_start(args, format);
- rv = uart_vprintf(format, args);
- va_end(args);
- return rv;
-}
-
void uart_flush_output(void)
{
/* If UART not initialized ignore flush request. */