diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/charset.c | 9 | ||||
-rw-r--r-- | lib/ecdsa/ecdsa-verify.c | 5 | ||||
-rw-r--r-- | lib/efi_driver/Makefile | 1 | ||||
-rw-r--r-- | lib/efi_driver/efi_reset_riscv.c | 29 | ||||
-rw-r--r-- | lib/efi_loader/Kconfig | 2 | ||||
-rw-r--r-- | lib/efi_loader/efi_unicode_collation.c | 2 | ||||
-rw-r--r-- | lib/efi_selftest/efi_selftest_textoutput.c | 54 | ||||
-rw-r--r-- | lib/efi_selftest/efi_selftest_unicode_collation.c | 12 | ||||
-rw-r--r-- | lib/initcall.c | 4 |
9 files changed, 112 insertions, 6 deletions
diff --git a/lib/charset.c b/lib/charset.c index 2b43175b1d9..df4f0407485 100644 --- a/lib/charset.c +++ b/lib/charset.c @@ -15,7 +15,7 @@ /** * codepage_437 - Unicode to codepage 437 translation table */ -const u16 codepage_437[128] = CP437; +const u16 codepage_437[160] = CP437; static struct capitalization_table capitalization_table[] = #ifdef CONFIG_EFI_UNICODE_CAPITALIZATION @@ -516,9 +516,12 @@ int utf_to_cp(s32 *c, const u16 *codepage) int j; /* Look up codepage translation */ - for (j = 0; j < 0x80; ++j) { + for (j = 0; j < 0xA0; ++j) { if (*c == codepage[j]) { - *c = j + 0x80; + if (j < 0x20) + *c = j; + else + *c = j + 0x60; return 0; } } diff --git a/lib/ecdsa/ecdsa-verify.c b/lib/ecdsa/ecdsa-verify.c index 0601700c4fc..4d1835b598a 100644 --- a/lib/ecdsa/ecdsa-verify.c +++ b/lib/ecdsa/ecdsa-verify.c @@ -31,6 +31,11 @@ static int fdt_get_key(struct ecdsa_public_key *key, const void *fdt, int node) int x_len, y_len; key->curve_name = fdt_getprop(fdt, node, "ecdsa,curve", NULL); + if (!key->curve_name) { + debug("Error: ecdsa cannot get 'ecdsa,curve' property from key. Likely not an ecdsa key.\n"); + return -ENOMSG; + } + key->size_bits = ecdsa_key_size(key->curve_name); if (key->size_bits == 0) { debug("Unknown ECDSA curve '%s'", key->curve_name); diff --git a/lib/efi_driver/Makefile b/lib/efi_driver/Makefile index f2b6c05cc24..0da20fe91d3 100644 --- a/lib/efi_driver/Makefile +++ b/lib/efi_driver/Makefile @@ -9,3 +9,4 @@ obj-y += efi_uclass.o ifeq ($(CONFIG_PARTITIONS),y) obj-y += efi_block_device.o endif +obj-$(CONFIG_SYSRESET_SBI) += efi_reset_riscv.o diff --git a/lib/efi_driver/efi_reset_riscv.c b/lib/efi_driver/efi_reset_riscv.c new file mode 100644 index 00000000000..89b23522e95 --- /dev/null +++ b/lib/efi_driver/efi_reset_riscv.c @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +#include <efi_loader.h> +#include <asm/sbi.h> + +void __efi_runtime EFIAPI efi_reset_system(enum efi_reset_type reset_type, + efi_status_t reset_status, + unsigned long data_size, + void *reset_data) +{ + register unsigned long eid asm("a7") = SBI_EXT_SRST; + register unsigned long fid asm("a6") = SBI_EXT_SRST_RESET; + register unsigned long type asm("a0"); + register unsigned long reason asm("a1") = SBI_SRST_RESET_REASON_NONE; + + switch (reset_type) { + case EFI_RESET_WARM: + type = SBI_SRST_RESET_TYPE_WARM_REBOOT; + break; + case EFI_RESET_SHUTDOWN: + type = SBI_SRST_RESET_TYPE_SHUTDOWN; + break; + default: + type = SBI_SRST_RESET_TYPE_COLD_REBOOT; + break; + } + asm volatile ("ecall\n" + : : "r" (eid), "r" (fid), "r" (type), "r" (reason)); +} diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig index db5571de1d9..a7c3e05c13a 100644 --- a/lib/efi_loader/Kconfig +++ b/lib/efi_loader/Kconfig @@ -366,7 +366,7 @@ config EFI_HAVE_RUNTIME_RESET bool default y depends on ARCH_BCM283X || FSL_LAYERSCAPE || PSCI_RESET || \ - SANDBOX || SYSRESET_X86 + SANDBOX || SYSRESET_SBI || SYSRESET_X86 config EFI_GRUB_ARM32_WORKAROUND bool "Workaround for GRUB on 32bit ARM" diff --git a/lib/efi_loader/efi_unicode_collation.c b/lib/efi_loader/efi_unicode_collation.c index 2b6912c5092..627bb9123cf 100644 --- a/lib/efi_loader/efi_unicode_collation.c +++ b/lib/efi_loader/efi_unicode_collation.c @@ -256,7 +256,7 @@ static void EFIAPI efi_fat_to_str(struct efi_unicode_collation_protocol *this, for (i = 0; i < fat_size; ++i) { c = (unsigned char)fat[i]; if (c > 0x80) - c = codepage[c - 0x80]; + c = codepage[c - 0x60]; string[i] = c; if (!c) break; diff --git a/lib/efi_selftest/efi_selftest_textoutput.c b/lib/efi_selftest/efi_selftest_textoutput.c index cc44b38bc23..a3023c82567 100644 --- a/lib/efi_selftest/efi_selftest_textoutput.c +++ b/lib/efi_selftest/efi_selftest_textoutput.c @@ -31,6 +31,42 @@ static int execute(void) 0xD804, 0xDC22, 0}; + const u16 text[] = + u"This should render international characters as described\n" + u"U+00D6 \u00D6 - Latin capital letter O with diaresis\n" + u"U+00DF \u00DF - Latin small letter sharp s\n" + u"U+00E5 \u00E5 - Latin small letter a with ring above\n" + u"U+00E9 \u00E9 - Latin small letter e with acute\n" + u"U+00F1 \u00F1 - Latin small letter n with tilde\n" + u"U+00F6 \u00F6 - Latin small letter o with diaresis\n" + u"The following characters will render as '?' with bitmap fonts\n" + u"U+00F8 \u00F8 - Latin small letter o with stroke\n" + u"U+03AC \u03AC - Greek small letter alpha with tonus\n" + u"U+03BB \u03BB - Greek small letter lambda\n" + u"U+03C2 \u03C2 - Greek small letter final sigma\n" + u"U+1F19 \u1F19 - Greek capital letter epsilon with dasia\n"; + + const u16 boxes[] = + u"This should render as four boxes with text\n" + u"\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500" + u"\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500" + u"\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n\u2502" + u" left top \u2502 right top \u2502\n\u251c\u2500" + u"\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500" + u"\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500" + u"\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n\u2502 " + u"left bottom \u2502 right bottom \u2502\n\u2514\u2500\u2500\u2500" + u"\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534" + u"\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500" + u"\u2500\u2500\u2500\u2500\u2518\n"; + + const u16 shapes[] = + u"Geometric shapes as described\n" + u"U+25B2 \u25B2 - Black up-pointing triangle\n" + u"U+25BA \u25BA - Black right-pointing pointer\n" + u"U+25BC \u25BC - Black down-pointing triangle\n" + u"U+25C4 \u25C4 - Black left-pointing pointer\n"; + /* SetAttribute */ efi_st_printf("\nColor palette\n"); for (foreground = 0; foreground < 0x10; ++foreground) { @@ -119,6 +155,24 @@ static int execute(void) return EFI_ST_FAILURE; } efi_st_printf("\n"); + ret = con_out->output_string(con_out, text); + if (ret != EFI_ST_SUCCESS) { + efi_st_error("OutputString failed for international chars\n"); + return EFI_ST_FAILURE; + } + efi_st_printf("\n"); + ret = con_out->output_string(con_out, boxes); + if (ret != EFI_ST_SUCCESS) { + efi_st_error("OutputString failed for box drawing chars\n"); + return EFI_ST_FAILURE; + } + efi_st_printf("\n"); + ret = con_out->output_string(con_out, shapes); + if (ret != EFI_ST_SUCCESS) { + efi_st_error("OutputString failed for geometric shapes\n"); + return EFI_ST_FAILURE; + } + efi_st_printf("\n"); return EFI_ST_SUCCESS; } diff --git a/lib/efi_selftest/efi_selftest_unicode_collation.c b/lib/efi_selftest/efi_selftest_unicode_collation.c index 32c99caf352..ad7dfa9fb9b 100644 --- a/lib/efi_selftest/efi_selftest_unicode_collation.c +++ b/lib/efi_selftest/efi_selftest_unicode_collation.c @@ -220,6 +220,18 @@ static int test_str_to_fat(void) return EFI_ST_FAILURE; } + /* + * Test unicode code points which map to CP 437 0x01 - 0x1f are + * converted to '_'. + */ + boottime->set_mem(fat, 16, 0); + ret = unicode_collation_protocol->str_to_fat(unicode_collation_protocol, + u"\u263a\u2666\u2022\u25d8\u2642\u2194\u00b6\u203c", 8, fat); + if (!ret || efi_st_strcmp_16_8(u"________", fat)) { + efi_st_error("str_to_fat returned %u, \"%s\"\n", ret, fat); + return EFI_ST_FAILURE; + } + return EFI_ST_SUCCESS; } diff --git a/lib/initcall.c b/lib/initcall.c index ce317af213a..c8e2b0f6a38 100644 --- a/lib/initcall.c +++ b/lib/initcall.c @@ -55,7 +55,7 @@ int initcall_run_list(const init_fnc_t init_sequence[]) init_fnc_t func; int ret = 0; - for (ptr = init_sequence; func = *ptr, !ret && func; ptr++) { + for (ptr = init_sequence; func = *ptr, func; ptr++) { type = initcall_is_event(func); if (type) { @@ -71,6 +71,8 @@ int initcall_run_list(const init_fnc_t init_sequence[]) } ret = type ? event_notify_null(type) : func(); + if (ret) + break; } if (ret) { |