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>
This commit is contained in:
Julius Werner 2022-02-02 17:21:02 -08:00 committed by Felix Held
parent 8e4742d76d
commit b6cf642732

View File

@ -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)
{
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();