[PATCH 4/4] EFI: console: improve vidconsole unicode output

Heinrich Schuchardt xypron.glpk at gmx.de
Thu Aug 5 14:01:30 CEST 2021


On 8/4/21 12:22 PM, Artem Lapkin wrote:
> If EFI_CONSOLE_UTF_SAFE is enabled and vidconsole is active, unicode
> characters will be replaced with "." for all console outputs.

The TrueType console is meant to support Unicode including the special
characters used by GRUB like left and right triangle.

So this patch is based on a wrong assumption.

Best regards

Heinrich

>
> Vidconsole does not support unicode output, and your console will suffer
> display issues if EFI_CONSOLE_UTF_SAFE is disabled.
>
> Signed-off-by: Artem Lapkin <art at khadas.com>
> ---
>   lib/efi_loader/Kconfig       | 9 +++++++++
>   lib/efi_loader/efi_console.c | 6 +++++-
>   2 files changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
> index 7d00d6cde5..886e0ce111 100644
> --- a/lib/efi_loader/Kconfig
> +++ b/lib/efi_loader/Kconfig
> @@ -393,4 +393,13 @@ config EFI_CONSOLE_MAX_COLS
>   	help
>   	  Set console max rows limit or set to zero to disable limit.
>
> +config EFI_CONSOLE_UTF_SAFE
> +	bool "If vidconsole is active, unicode characters will be replaced with '.'"
> +	default n
> +	help
> +	  If EFI_CONSOLE_UTF_SAFE is enabled and vidconsole is active, unicode
> +	  characters will be replaced with "." for all console outputs.
> +	  Vidconsole does not support unicode output, and your console will
> +	  suffer display issues if EFI_CONSOLE_UTF_SAFE is disabled.
> +
>   endif
> diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c
> index b5d79d788f..bd1c14995d 100644
> --- a/lib/efi_loader/efi_console.c
> +++ b/lib/efi_loader/efi_console.c
> @@ -19,6 +19,8 @@
>   #define EFI_COUT_MODE_2 2
>   #define EFI_MAX_COUT_MODE 3
>
> +static int vidconsole_active;
> +
>   struct cout_mode {
>   	unsigned long columns;
>   	unsigned long rows;
> @@ -163,7 +165,8 @@ static efi_status_t EFIAPI efi_cout_output_string(
>   	}
>   	pos = buf;
>   	utf16_utf8_strcpy(&pos, string);
> -	fputs(stdout, buf);
> +	fputs(stdout, IS_ENABLED(CONFIG_EFI_CONSOLE_UTF_SAFE) &&
> +	      strlen(buf) > 1 && vidconsole_active ? "." : buf);
>   	free(buf);
>
>   	/*
> @@ -327,6 +330,7 @@ static int __maybe_unused query_vidconsole(int *rows, int *cols)
>   		return -ENODEV;
>   	*rows = priv->rows;
>   	*cols = priv->cols;
> +	vidconsole_active = 1;
>   	return 0;
>   }
>
>



More information about the U-Boot mailing list