diff options
| author | Ard Biesheuvel <ardb@kernel.org> | 2026-09-06 13:15:12 +0200 |
|---|---|---|
| committer | Ard Biesheuvel <ardb@kernel.org> | 2026-10-04 21:53:56 +0200 |
| commit | 1fe625b5df3d28f504677f067ab0be5d4bde10f3 (patch) | |
| tree | 7b5941b24220128b3fe731018c78d33bbbf6dd4c /drivers | |
| parent | 899ff1dbc8842b4b6d1b8ade94a86a2336bbc86c (diff) | |
efi/libstub: Avoid efi_puts() for compile time constant strings
efi_puts() performs a UTF-8 to UTF-16 conversion on its input, as the
EFI console's native character set is UTF-16.
This is pointless for compile time constant strings, since we can
simply define those as UTF-16 to begin with. This takes slightly more
space, but removes any runtime handling of those strings, simplifying
the code.
Note that efi_puts() also performs LF to CR-LF conversion, so this needs
to be taken into account as well.
Reviewed-by: Vincent Mailhol <mailhol@kernel.org>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/firmware/efi/libstub/gop.c | 6 | ||||
| -rw-r--r-- | drivers/firmware/efi/libstub/printk.c | 4 |
2 files changed, 5 insertions, 5 deletions
diff --git a/drivers/firmware/efi/libstub/gop.c b/drivers/firmware/efi/libstub/gop.c index 80dc8cfeb33e..6919e28ba92b 100644 --- a/drivers/firmware/efi/libstub/gop.c +++ b/drivers/firmware/efi/libstub/gop.c @@ -309,12 +309,12 @@ static u32 choose_mode_list(efi_graphics_output_protocol_t *gop) efi_status_t status; efi_printk("Available graphics modes are 0-%u\n", max_mode-1); - efi_puts(" * = current mode\n" - " - = unusable mode\n"); + efi_char16_puts(L" * = current mode\r\n" + " - = unusable mode\r\n"); choose_mode(gop, match_list, (void *)cur_mode); - efi_puts("\nPress any key to continue (or wait 10 seconds)\n"); + efi_char16_puts(L"\r\nPress any key to continue (or wait 10 seconds)\r\n"); status = efi_wait_for_key(10 * EFI_USEC_PER_SEC, &key); if (status != EFI_SUCCESS && status != EFI_TIMEOUT) { efi_err("Unable to read key, continuing in 10 seconds\n"); diff --git a/drivers/firmware/efi/libstub/printk.c b/drivers/firmware/efi/libstub/printk.c index bc599212c05d..f36639886d00 100644 --- a/drivers/firmware/efi/libstub/printk.c +++ b/drivers/firmware/efi/libstub/printk.c @@ -136,7 +136,7 @@ int efi_printk(const char *fmt, ...) return 0; if (loglevel >= 0) - efi_puts("EFI stub: "); + efi_char16_puts(L"EFI stub: "); fmt = printk_skip_level(fmt); @@ -146,7 +146,7 @@ int efi_printk(const char *fmt, ...) efi_puts(printf_buf); if (printed >= sizeof(printf_buf)) { - efi_puts("[Message truncated]\n"); + efi_char16_puts(L"[Message truncated]\r\n"); return -1; } |
