Raul Rangel has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/61575 )
Change subject: HACK: Enable color in console ......................................................................
HACK: Enable color in console
Signed-off-by: Raul E Rangel rrangel@chromium.org Change-Id: Ic6639bf5202525b5fb32e57b9120450a33afed2b --- M src/console/printk.c 1 file changed, 21 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/75/61575/1
diff --git a/src/console/printk.c b/src/console/printk.c index 1ed39cb..73c776e 100644 --- a/src/console/printk.c +++ b/src/console/printk.c @@ -68,10 +68,18 @@ { __cbmemc_tx_byte(byte); } +static void print_color(int msg_level, ...) +{ + va_list args; + + va_start(args, msg_level); + vtxprintf(wrap_putchar, "%s", args, NULL); + va_end(args); +}
int vprintk(int msg_level, const char *fmt, va_list args) { - int i, log_this; + int i, log_this, color=0;
if (CONFIG(SQUELCH_EARLY_SMP) && ENV_ROMSTAGE_OR_BEFORE && !boot_cpu()) return 0; @@ -87,7 +95,19 @@ if (log_this == CONSOLE_LOG_FAST) { i = vtxprintf(wrap_putchar_cbmemc, fmt, args, NULL); } else { + if (msg_level <= BIOS_ERR) { + print_color(msg_level, "\x1b[31;1m"); + color = 1; + } else if (msg_level == BIOS_WARNING) { + print_color(msg_level,"\x1b[31;33m"); + color = 1; + } + i = vtxprintf(wrap_putchar, fmt, args, NULL); + + if (color) + print_color(msg_level, "\x1b[31;0m"); // Reset + console_tx_flush(); }