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 <rrangel@chromium.org>
Change-Id: I3fe0f666e2e15c88b4568377923ad447c3ecf27e
Reviewed-on: https://review.coreboot.org/c/coreboot/+/61011
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
Reviewed-by: Karthik Ramasubramanian <kramasub@google.com>
diff --git a/src/include/console/cbmem_console.h b/src/include/console/cbmem_console.h
index 3477a06..65cf59c 100644
--- a/src/include/console/cbmem_console.h
+++ b/src/include/console/cbmem_console.h
@@ -20,4 +20,5 @@
#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 719c8b5..02de804 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 <console/cbmem_console.h>
+#include <console/console.h>
#include <console/uart.h>
#include <cbmem.h>
#include <symbols.h>
+#include <types.h>
/*
* Structure describing console buffer. It is overlaid on a flat memory area,
@@ -37,6 +39,8 @@
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_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 @@
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;
+}