summaryrefslogtreecommitdiff
path: root/src/console
diff options
context:
space:
mode:
authorJulius Werner <jwerner@chromium.org>2022-02-02 17:21:02 -0800
committerFelix Held <felix-coreboot@felixheld.de>2022-02-04 16:33:36 +0000
commitb6cf642732f59e732c21dffb98bdd91a33324022 (patch)
tree0f3b16762df24c56664b9dc595b87d9f2adf7a41 /src/console
parent8e4742d76de730a29fb9c5d150fb1c9a03c52423 (diff)
downloadcoreboot-b6cf642732f59e732c21dffb98bdd91a33324022.tar.gz
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> Reviewed-on: https://review.coreboot.org/c/coreboot/+/61580 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Raul Rangel <rrangel@chromium.org>
Diffstat (limited to 'src/console')
-rw-r--r--src/console/printk.c32
1 files 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();