From 4cb72436403069baf58c0d5187149db7ab76fb85 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 10 May 2025 14:54:38 +0200 Subject: efi_loader: Disable ANSI output for tests We don't want ANSI escape-sequences written in tests since it is a pain to check the output with ut_assert_nextline() et al. Provide a way to tests to request that these characters not be sent. Add a proper function comment while we are here, to encourage others. Signed-off-by: Simon Glass Reviewed-by: Heinrich Schuchardt --- lib/efi_loader/efi_console.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'lib/efi_loader/efi_console.c') diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c index 9d9f786a6db..e310f2f53ae 100644 --- a/lib/efi_loader/efi_console.c +++ b/lib/efi_loader/efi_console.c @@ -30,6 +30,17 @@ struct cout_mode { __maybe_unused static struct efi_object uart_obj; +/* + * suppress emission of ANSI escape-characters for use by unit tests. Leave it + * as 0 for the default behaviour + */ +static bool no_ansi; + +void efi_console_set_ansi(bool allow_ansi) +{ + no_ansi = !allow_ansi; +} + static struct cout_mode efi_cout_modes[] = { /* EFI Mode 0 is 80x25 and always present */ { @@ -348,13 +359,6 @@ static int __maybe_unused query_vidconsole(int *rows, int *cols) return 0; } -/** - * efi_setup_console_size() - update the mode table. - * - * By default the only mode available is 80x25. If the console has at least 50 - * lines, enable mode 80x50. If we can query the console size and it is neither - * 80x25 nor 80x50, set it as an additional mode. - */ void efi_setup_console_size(void) { int rows = 25, cols = 80; @@ -362,8 +366,12 @@ void efi_setup_console_size(void) if (IS_ENABLED(CONFIG_VIDEO)) ret = query_vidconsole(&rows, &cols); - if (ret) - ret = query_console_serial(&rows, &cols); + if (ret) { + if (no_ansi) + ret = 0; + else + ret = query_console_serial(&rows, &cols); + } if (ret) return; -- cgit v1.2.3 From f4bbd7b9faa4c20e5b838d7ea609ebadc7305ba0 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 24 May 2025 11:28:21 -0600 Subject: efi_loader: Separate device path into its own header These functions are useful for the EFI app. As a first step towards making these available outside lib/efi_loader, create a separate header file and include it where needed. Add proper comments to the functions, since many are missing at present. Signed-off-by: Simon Glass Reviewed-by: Heinrich Schuchardt --- lib/efi_loader/efi_console.c | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/efi_loader/efi_console.c') diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c index e310f2f53ae..953f6831466 100644 --- a/lib/efi_loader/efi_console.c +++ b/lib/efi_loader/efi_console.c @@ -9,6 +9,7 @@ #include #include +#include #include #include #include -- cgit v1.2.3