From b6cf642732f59e732c21dffb98bdd91a33324022 Mon Sep 17 00:00:00 2001 From: Julius Werner Date: Wed, 2 Feb 2022 17:21:02 -0800 Subject: console: Pass log_state to vtxprintf() This patch makes a slight change in the way CONSOLE_LOG_FAST and CONSOLE_LOG_ALL are differentiated, by no longer passing a different tx_byte() function pointer and instead using the `data` argument to vtxprintf() to encode the difference. It also passes the message log level through to the tx_byte() function this way, which will be needed in the next patch. Change-Id: I0bba134cd3e70c2032689abac83ff53d7cdf2d7f Signed-off-by: Julius Werner Reviewed-on: https://review.coreboot.org/c/coreboot/+/61580 Tested-by: build bot (Jenkins) Reviewed-by: Raul Rangel --- src/console/printk.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/src/console/printk.c b/src/console/printk.c index 1ed39cb5ff..ef3d29f490 100644 --- a/src/console/printk.c +++ b/src/console/printk.c @@ -59,37 +59,43 @@ void do_putchar(unsigned char byte) console_time_stop(); } +union log_state { + void *as_ptr; + struct { + uint8_t level; + uint8_t speed; + }; +}; + static void wrap_putchar(unsigned char byte, void *data) { - console_tx_byte(byte); -} + union log_state state = { .as_ptr = data }; -static void wrap_putchar_cbmemc(unsigned char byte, void *data) -{ - __cbmemc_tx_byte(byte); + if (state.speed == CONSOLE_LOG_FAST) + __cbmemc_tx_byte(byte); + else + console_tx_byte(byte); } int vprintk(int msg_level, const char *fmt, va_list args) { - int i, log_this; + union log_state state = { .level = msg_level }; + int i; if (CONFIG(SQUELCH_EARLY_SMP) && ENV_ROMSTAGE_OR_BEFORE && !boot_cpu()) return 0; - log_this = console_log_level(msg_level); - if (log_this < CONSOLE_LOG_FAST) + state.speed = console_log_level(msg_level); + if (state.speed < CONSOLE_LOG_FAST) return 0; spin_lock(&console_lock); console_time_run(); - if (log_this == CONSOLE_LOG_FAST) { - i = vtxprintf(wrap_putchar_cbmemc, fmt, args, NULL); - } else { - i = vtxprintf(wrap_putchar, fmt, args, NULL); + i = vtxprintf(wrap_putchar, fmt, args, state.as_ptr); + if (state.speed != CONSOLE_LOG_FAST) console_tx_flush(); - } console_time_stop(); -- cgit v1.2.3