Attention is currently required from: Raul Rangel. Hello Raul Rangel,
I'd like you to do a code review. Please visit
https://review.coreboot.org/c/coreboot/+/61580
to review the following change.
Change subject: console: Pass log_state to vtxprintf() ......................................................................
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 jwerner@chromium.org --- M src/console/printk.c 1 file changed, 19 insertions(+), 13 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/80/61580/1
diff --git a/src/console/printk.c b/src/console/printk.c index 1ed39cb..ef3d29f 100644 --- a/src/console/printk.c +++ b/src/console/printk.c @@ -59,37 +59,43 @@ 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();