From 59093116be94d99b15be0a94411c8902ce9262b4 Mon Sep 17 00:00:00 2001 From: Vadim Bendebury Date: Wed, 26 Jun 2019 17:12:29 -0700 Subject: uart_buffering: add tx_buffer_full() API To aid in system level UART console performance testing a test function needs to know when the UART console buffer is full. This patch provides an API for that. BRANCH=none BUG=b:38448364 TEST=verified proper operation of the chargen CLI command which uses this API. Change-Id: I5fbc6cf4031a5077c91cd4bb85ab6f4dfb18821e Signed-off-by: Vadim Bendebury Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1679710 Reviewed-by: Randall Spangler Reviewed-by: Daisuke Nojiri (cherry picked from commit 88f6aafde91413eebca7d9c856fcca194b92f873) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2340249 Tested-by: Namyoon Woo Reviewed-by: Jett Rink Reviewed-by: Marco Chen Commit-Queue: Namyoon Woo --- common/uart_buffering.c | 6 ++++++ include/uart.h | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/common/uart_buffering.c b/common/uart_buffering.c index 7b4b864c09..1039bece0e 100644 --- a/common/uart_buffering.c +++ b/common/uart_buffering.c @@ -316,6 +316,11 @@ int uart_buffer_empty(void) return tx_buf_head == tx_buf_tail; } +int uart_buffer_full(void) +{ + return TX_BUF_NEXT(tx_buf_head) == tx_buf_tail; +} + #ifdef CONFIG_UART_RX_DMA static void uart_rx_dma_init(void) { @@ -444,3 +449,4 @@ int uart_console_read_buffer(uint8_t type, return EC_RES_SUCCESS; } + diff --git a/include/uart.h b/include/uart.h index e40b0e866f..3bc06682f7 100644 --- a/include/uart.h +++ b/include/uart.h @@ -194,6 +194,11 @@ void uart_process_output(void); */ int uart_buffer_empty(void); +/** + * Return boolean expressing whether UART buffer is full or not. + */ +int uart_buffer_full(void); + /** * Disable the EC console UART and convert the UART RX pin to a generic GPIO * with an edge detect interrupt. -- cgit v1.2.1