From 295d3942b806552503243f5cfb36aec6f1b5a9bf Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Tue, 18 Oct 2011 13:43:20 +0000 Subject: Add board_pre_console_putc to deal with early console output This patch adds support for console output before the console is inited. The main purpose of this is to deal with a very early panic() which would otherwise cause a silent hang. A new board_pre_console_putc() function is added to the board API. If provided by the board it will be called in the event of console output before the console is ready. This function should turn on all UARTs and spray the character out if it possibly can. The feature is controlled by a new CONFIG_PRE_CONSOLE_PUTC option. Signed-off-by: Simon Glass Acked-by: Graeme Russ --- common/console.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'common/console.c') diff --git a/common/console.c b/common/console.c index f17875e..d34a0f4 100644 --- a/common/console.c +++ b/common/console.c @@ -329,14 +329,19 @@ int tstc(void) return serial_tstc(); } -#ifdef CONFIG_PRE_CONSOLE_BUFFER +#if defined(CONFIG_PRE_CONSOLE_BUFFER) || defined(CONFIG_PRE_CONSOLE_PUTC) #define CIRC_BUF_IDX(idx) ((idx) % (unsigned long)CONFIG_PRE_CON_BUF_SZ) static void pre_console_putc(const char c) { +#ifdef CONFIG_PRE_CONSOLE_BUFFER char *buffer = (char *)CONFIG_PRE_CON_BUF_ADDR; buffer[CIRC_BUF_IDX(gd->precon_buf_idx++)] = c; +#endif +#ifdef CONFIG_PRE_CONSOLE_PUTC + board_pre_console_putc(c); +#endif } static void pre_console_puts(const char *s) @@ -347,6 +352,7 @@ static void pre_console_puts(const char *s) static void print_pre_console_buffer(void) { +#ifdef CONFIG_PRE_CONSOLE_BUFFER unsigned long i = 0; char *buffer = (char *)CONFIG_PRE_CON_BUF_ADDR; @@ -355,7 +361,9 @@ static void print_pre_console_buffer(void) while (i < gd->precon_buf_idx) putc(buffer[CIRC_BUF_IDX(i++)]); +#endif } + #else static inline void pre_console_putc(const char c) {} static inline void pre_console_puts(const char *s) {} -- cgit v1.1