From bf993110b3386deb895b39c86993e8b5bf807ac0 Mon Sep 17 00:00:00 2001 From: Raul E Rangel Date: Tue, 11 Jan 2022 12:48:50 -0700 Subject: console/cbmem: Add cbmem_dump_console This function is similar to cbmem_dump_console_to_uart except it uses the normally configured consoles. A console_paused flag was added to prevent the cbmem console from writing to itself. BUG=b:213828947 TEST=Boot guybrush Signed-off-by: Raul E Rangel Change-Id: I3fe0f666e2e15c88b4568377923ad447c3ecf27e Reviewed-on: https://review.coreboot.org/c/coreboot/+/61011 Tested-by: build bot (Jenkins) Reviewed-by: Julius Werner Reviewed-by: Karthik Ramasubramanian --- src/include/console/cbmem_console.h | 1 + src/lib/cbmem_console.c | 24 +++++++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/include/console/cbmem_console.h b/src/include/console/cbmem_console.h index 3477a06b0a9e..65cf59c4c54a 100644 --- a/src/include/console/cbmem_console.h +++ b/src/include/console/cbmem_console.h @@ -20,4 +20,5 @@ static inline void __cbmemc_tx_byte(u8 data) {} #endif void cbmem_dump_console_to_uart(void); +void cbmem_dump_console(void); #endif diff --git a/src/lib/cbmem_console.c b/src/lib/cbmem_console.c index 719c8b5088c5..02de8045c21b 100644 --- a/src/lib/cbmem_console.c +++ b/src/lib/cbmem_console.c @@ -1,9 +1,11 @@ /* SPDX-License-Identifier: GPL-2.0-only */ #include +#include #include #include #include +#include /* * Structure describing console buffer. It is overlaid on a flat memory area, @@ -37,6 +39,8 @@ _Static_assert(CONFIG_CONSOLE_CBMEM_BUFFER_SIZE <= MAX_SIZE, static struct cbmem_console *current_console; +static bool console_paused; + /* * While running from ROM, before DRAM is initialized, some area in cache as * RAM space is used for the console buffer storage. The size and location of @@ -88,7 +92,7 @@ void cbmemc_init(void) void cbmemc_tx_byte(unsigned char data) { - if (!current_console || !current_console->size) + if (!current_console || !current_console->size || console_paused) return; u32 flags = current_console->cursor & ~CURSOR_MASK; @@ -169,3 +173,21 @@ void cbmem_dump_console_to_uart(void) uart_tx_byte(0, current_console->body[cursor]); } #endif + +void cbmem_dump_console(void) +{ + u32 cursor; + if (!current_console) + return; + + console_paused = true; + + if (current_console->cursor & OVERFLOW) + for (cursor = current_console->cursor & CURSOR_MASK; + cursor < current_console->size; cursor++) + do_putchar(current_console->body[cursor]); + for (cursor = 0; cursor < (current_console->cursor & CURSOR_MASK); cursor++) + do_putchar(current_console->body[cursor]); + + console_paused = false; +} -- cgit v1.2.3