diff options
author | Randall Spangler <rspangler@chromium.org> | 2012-07-07 14:19:00 -0700 |
---|---|---|
committer | Gerrit <chrome-bot@google.com> | 2012-07-07 23:05:50 -0700 |
commit | 1c287d0486de1821b77ecdfcd321d7f98c17c57d (patch) | |
tree | da1fb3da89a56971600be2d93ee60c85dac92b66 /common | |
parent | 114b7c844eee61e985d8279bdb8caf656d9a714b (diff) | |
download | chrome-ec-1c287d0486de1821b77ecdfcd321d7f98c17c57d.tar.gz |
Increase UART output buffer size on LM4
512 bytes isn't enough to capture all the debug output early in the
init process, and Link EC has lots of unused RAM. stm32 doesn't, so
only do this for LM4 processor.
BUG=none
TEST=build; debug output during init shouldn't be garbled
Change-Id: Ie4fd204fa4e0c6ca99ea7eae94b095ef175836e4
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/26877
Diffstat (limited to 'common')
-rw-r--r-- | common/uart_buffering.c | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/common/uart_buffering.c b/common/uart_buffering.c index 5743351412..a50d9a0267 100644 --- a/common/uart_buffering.c +++ b/common/uart_buffering.c @@ -7,35 +7,46 @@ #include <stdarg.h> +#include "common.h" #include "console.h" +#include "printf.h" #include "task.h" #include "uart.h" #include "util.h" -#include "printf.h" -/* Buffer sizes; should be power of 2 */ -#define TX_BUF_SIZE 512 -#define RX_BUF_SIZE 128 /* suggest larger than 80 to copy&paste script. */ +/* + * Transmit and receive buffer sizes must be power of 2 for the macros below + * to work properly. + */ +#ifndef CONFIG_UART_TX_BUF_SIZE +#define CONFIG_UART_TX_BUF_SIZE 512 +#endif + +#ifndef CONFIG_UART_RX_BUF_SIZE +/* Must be larger than RX_LINE_SIZE to copy and paste scripts */ +#define CONFIG_UART_RX_BUF_SIZE 128 +#endif + #define HISTORY_SIZE 8 /* The size limit of single command */ #define RX_LINE_SIZE 80 /* Macros to advance in the circular buffers */ -#define TX_BUF_NEXT(i) (((i) + 1) & (TX_BUF_SIZE - 1)) -#define RX_BUF_NEXT(i) (((i) + 1) & (RX_BUF_SIZE - 1)) -#define RX_BUF_PREV(i) (((i) - 1) & (RX_BUF_SIZE - 1)) +#define TX_BUF_NEXT(i) (((i) + 1) & (CONFIG_UART_TX_BUF_SIZE - 1)) +#define RX_BUF_NEXT(i) (((i) + 1) & (CONFIG_UART_RX_BUF_SIZE - 1)) +#define RX_BUF_PREV(i) (((i) - 1) & (CONFIG_UART_RX_BUF_SIZE - 1)) #define CMD_HIST_NEXT(i) (((i) + 1) & (HISTORY_SIZE - 1)) #define CMD_HIST_PREV(i) (((i) - 1) & (HISTORY_SIZE - 1)) /* Macro to calculate difference of pointers in the circular receive buffer. */ -#define RX_BUF_DIFF(i, j) (((i) - (j)) & (RX_BUF_SIZE - 1)) +#define RX_BUF_DIFF(i, j) (((i) - (j)) & (CONFIG_UART_RX_BUF_SIZE - 1)) /* Transmit and receive buffers */ -static volatile char tx_buf[TX_BUF_SIZE]; +static volatile char tx_buf[CONFIG_UART_TX_BUF_SIZE]; static volatile int tx_buf_head; static volatile int tx_buf_tail; -static volatile char rx_buf[RX_BUF_SIZE]; +static volatile char rx_buf[CONFIG_UART_RX_BUF_SIZE]; static volatile int rx_buf_head; static volatile int rx_buf_tail; static volatile char rx_cur_buf[RX_LINE_SIZE]; @@ -176,7 +187,7 @@ static void insert_char(char c) static int rx_buf_space_available(void) { if (cmd_history_head == cmd_history_tail) - return RX_BUF_SIZE; + return CONFIG_UART_RX_BUF_SIZE; return RX_BUF_DIFF(cmd_history[cmd_history_tail].tail, cmd_history[CMD_HIST_PREV(cmd_history_head)].head); } @@ -257,7 +268,7 @@ static void history_prev(void) int last_id = CMD_HIST_PREV(cmd_history_head); int last_len = RX_BUF_DIFF(cmd_history[last_id].head, cmd_history[last_id].tail); - if (last_len + rx_cur_buf_head > RX_BUF_SIZE) + if (last_len + rx_cur_buf_head > CONFIG_UART_RX_BUF_SIZE) return; history_save(); |