summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaul E Rangel <rrangel@chromium.org>2022-01-11 12:48:50 -0700
committerFelix Held <felix-coreboot@felixheld.de>2022-01-17 15:39:16 +0000
commitbf993110b3386deb895b39c86993e8b5bf807ac0 (patch)
treee06afd4e74db478b566b5581576c85e2a4540578
parent2abb826312a1aa8f69a830156b91dda35c59d2b7 (diff)
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>
-rw-r--r--src/include/console/cbmem_console.h1
-rw-r--r--src/lib/cbmem_console.c24
2 files changed, 24 insertions, 1 deletions
diff --git a/src/include/console/cbmem_console.h b/src/include/console/cbmem_console.h
index 3477a06b0a..65cf59c4c5 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 719c8b5088..02de8045c2 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_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;
+}