Kyösti Mälkki has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/31370
Change subject: [WIP] console: Split loglevel for fast and slow ......................................................................
[WIP] console: Split loglevel for fast and slow
For fast CBMEM console use minimum BIOS_DEBUG level. For other consoles, Kconfig and/or nvram settings apply.
Change-Id: Iff56a0a3182f258200cac80e013957d598cc2130 Signed-off-by: Kyösti Mälkki kyosti.malkki@gmail.com --- M src/console/console.c M src/console/init.c M src/console/printk.c M src/include/console/console.h M src/include/console/streams.h 5 files changed, 38 insertions(+), 13 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/70/31370/1
diff --git a/src/console/console.c b/src/console/console.c index 1a6aec1..73a1937 100644 --- a/src/console/console.c +++ b/src/console/console.c @@ -36,9 +36,12 @@ __flashconsole_init(); }
-void console_tx_byte(unsigned char byte) +void console_tx_byte_split(int fast_only, unsigned char byte) { __cbmemc_tx_byte(byte); + if (fast_only) + return; + __spkmodem_tx_byte(byte); __qemu_debugcon_tx_byte(byte);
@@ -57,8 +60,16 @@ __flashconsole_tx_byte(byte); }
-void console_tx_flush(void) +void console_tx_byte(unsigned char byte) { + console_tx_byte_split(0, byte); +} + +void console_tx_flush(int fast_only) +{ + if (fast_only) + return; + __uart_tx_flush(); __ne2k_tx_flush(); __usb_tx_flush(); @@ -67,18 +78,19 @@
void console_write_line(uint8_t *buffer, size_t number_of_bytes) { + int fast_only = 0; + /* Finish displaying all of the console data if requested */ if (number_of_bytes == 0) { - console_tx_flush(); + console_tx_flush(fast_only); return; }
/* Output the console data */ while (number_of_bytes--) - console_tx_byte(*buffer++); + console_tx_byte_split(fast_only, *buffer++); }
- #if IS_ENABLED(CONFIG_GDB_STUB) && (ENV_ROMSTAGE || ENV_RAMSTAGE) void gdb_hw_init(void) { diff --git a/src/console/init.c b/src/console/init.c index 7d1f31a..6640fb8 100644 --- a/src/console/init.c +++ b/src/console/init.c @@ -62,11 +62,18 @@ set_log_level(debug_level); }
-int console_log_level(int msg_level) +int console_slowlog_level(int msg_level) { return (get_log_level() >= msg_level); }
+int console_log_level(int msg_level) +{ + if (car_get_var(console_inited) == 0) + return 0; + return (BIOS_DEBUG >= msg_level); +} + asmlinkage void console_init(void) { init_log_level(); diff --git a/src/console/printk.c b/src/console/printk.c index 735876e..74094fa 100644 --- a/src/console/printk.c +++ b/src/console/printk.c @@ -36,13 +36,14 @@
static void wrap_putchar(unsigned char byte, void *data) { - do_putchar(byte); + int fast_only = *(int *)data; + console_tx_byte_split(fast_only, byte); }
int do_printk(int msg_level, const char *fmt, ...) { va_list args; - int i; + int i, fast_only;
if (IS_ENABLED(CONFIG_SQUELCH_EARLY_SMP) && ENV_CACHE_AS_RAM && !boot_cpu()) @@ -50,6 +51,7 @@
if (!console_log_level(msg_level)) return 0; + fast_only = !console_slowlog_level(msg_level);
DISABLE_TRACE; #ifdef __PRE_RAM__ @@ -61,10 +63,10 @@ #endif
va_start(args, fmt); - i = vtxprintf(wrap_putchar, fmt, args, NULL); + i = vtxprintf(wrap_putchar, fmt, args, &fast_only); va_end(args);
- console_tx_flush(); + console_tx_flush(fast_only);
#ifdef __PRE_RAM__ #if IS_ENABLED(CONFIG_HAVE_ROMSTAGE_CONSOLE_SPINLOCK) @@ -83,7 +85,8 @@ { if (!console_log_level(msg_level)) return; - vtxprintf(wrap_putchar, fmt, args, NULL); - console_tx_flush(); + int fast_only = !console_slowlog_level(msg_level); + vtxprintf(wrap_putchar, fmt, args, &fast_only); + console_tx_flush(fast_only); } #endif /* CONFIG_VBOOT */ diff --git a/src/include/console/console.h b/src/include/console/console.h index 7ab61ea..91a0c61 100644 --- a/src/include/console/console.h +++ b/src/include/console/console.h @@ -56,6 +56,7 @@ #if __CONSOLE_ENABLE__ asmlinkage void console_init(void); int console_log_level(int msg_level); +int console_slowlog_level(int msg_level); int do_printk(int msg_level, const char *fmt, ...) __attribute__((format(printf, 2, 3))); void do_putchar(unsigned char byte); @@ -78,6 +79,7 @@ #else static inline void console_init(void) {} static inline int console_log_level(int msg_level) { return 0; } +static inline int console_slowlog_level(int msg_level) { return 0; } static inline void printk(int LEVEL, const char *fmt, ...) {} static inline void do_putchar(unsigned char byte) {} #endif diff --git a/src/include/console/streams.h b/src/include/console/streams.h index 6e944a6..051fa08 100644 --- a/src/include/console/streams.h +++ b/src/include/console/streams.h @@ -19,7 +19,8 @@
void console_hw_init(void); void console_tx_byte(unsigned char byte); -void console_tx_flush(void); +void console_tx_byte_split(int fast_only, unsigned char byte); +void console_tx_flush(int fast_only);
/* * Write number_of_bytes data bytes from buffer to the serial device.