From 984d03c492506af0fea22c7c8c94a6a87e1f5342 Mon Sep 17 00:00:00 2001 From: Julius Werner Date: Fri, 21 Jan 2022 15:33:47 -0800 Subject: console: Add loglevel marker codes to stored consoles In order to provide the same loglevel prefixes and highlighting that were recently introduced for "interactive" consoles (e.g. UART) to "stored" consoles (e.g. CBMEM) but minimize the amont of extra storage space wasted on this info, this patch will write a 1-byte control character marker indicating the loglevel to the start of every line logged in those consoles. The `cbmem` utility will then interpret those markers and translate them back into loglevel prefixes and escape sequences as needed. Since coreboot and userspace log readers aren't always in sync, occasionally an older reader may come across these markers and not know how to interpret them... but that should usually be fine, as the range chosen contains non-printable ASCII characters that normally have no effect on the terminal. At worst the outdated reader would display one garbled character at the start of every line which isn't that bad. (Older versions of the `cbmem` utility will translate non-printable characters into `?` question marks.) Signed-off-by: Julius Werner Change-Id: I86073f48aaf1e0a58e97676fb80e2475ec418ffc Reviewed-on: https://review.coreboot.org/c/coreboot/+/61308 Tested-by: build bot (Jenkins) Reviewed-by: Raul Rangel --- src/lib/cbmem_console.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/lib') diff --git a/src/lib/cbmem_console.c b/src/lib/cbmem_console.c index 2faa5d5801..0c56095732 100644 --- a/src/lib/cbmem_console.c +++ b/src/lib/cbmem_console.c @@ -182,12 +182,16 @@ void cbmem_dump_console_to_uart(void) if (current_console->cursor & OVERFLOW) { for (cursor = current_console->cursor & CURSOR_MASK; cursor < current_console->size; cursor++) { + if (BIOS_LOG_IS_MARKER(current_console->body[cursor])) + continue; if (current_console->body[cursor] == '\n') uart_tx_byte(console_index, '\r'); uart_tx_byte(console_index, current_console->body[cursor]); } } for (cursor = 0; cursor < (current_console->cursor & CURSOR_MASK); cursor++) { + if (BIOS_LOG_IS_MARKER(current_console->body[cursor])) + continue; if (current_console->body[cursor] == '\n') uart_tx_byte(console_index, '\r'); uart_tx_byte(console_index, current_console->body[cursor]); @@ -206,9 +210,11 @@ void cbmem_dump_console(void) if (current_console->cursor & OVERFLOW) for (cursor = current_console->cursor & CURSOR_MASK; cursor < current_console->size; cursor++) - do_putchar(current_console->body[cursor]); + if (!BIOS_LOG_IS_MARKER(current_console->body[cursor])) + do_putchar(current_console->body[cursor]); for (cursor = 0; cursor < (current_console->cursor & CURSOR_MASK); cursor++) - do_putchar(current_console->body[cursor]); + if (!BIOS_LOG_IS_MARKER(current_console->body[cursor])) + do_putchar(current_console->body[cursor]); console_paused = false; } -- cgit v1.2.3