[PATCH 0/8] efi: A few minor improvements

From: Simon Glass <sjg@chromium.org> This series mostly tidies up the efidebug command, but includes a few other pieces as well. Simon Glass (8): efi_loader: Drop unnecessary efi_dp_str() efidebug: doc: Indent the media output correctly doc: efidebug: Support sorting with efidebug memmap doc: Add documentation for about efidebug boot boot: Move obtaining the label into a common file bootstd: Use the new label finder in bootflow_menu_add() efi: Use the console mux by default with the EFI app efi: Set the log category throughout lib/efi_client/ boot/bootflow.c | 27 +++++ boot/bootflow_menu.c | 7 +- cmd/bootflow.c | 16 +-- cmd/efidebug.c | 57 ++++++++++- doc/usage/cmd/efidebug.rst | 195 +++++++++++++++++++++++++++++++++--- include/bootflow.h | 8 ++ include/efi_loader.h | 2 - lib/efi_client/Kconfig | 1 + lib/efi_client/app_run.c | 2 + lib/efi_client/efi.c | 2 + lib/efi_client/efi_info.c | 2 + lib/efi_client/efi_vars.c | 2 + lib/efi_client/sdram.c | 2 + lib/efi_client/stub.c | 2 + lib/efi_client/stub_arm64.c | 1 + lib/efi_client/stub_x86.c | 2 + lib/efi_client/sync_dt.c | 2 + 17 files changed, 286 insertions(+), 44 deletions(-) -- 2.43.0 base-commit: 1ec67f521cb32e0e423873256fd537aed2a5314a branch: apc

From: Simon Glass <sjg@chromium.org> This declaration already exists in efi.h so drop it from this header. Signed-off-by: Simon Glass <sjg@chromium.org> --- include/efi_loader.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/include/efi_loader.h b/include/efi_loader.h index 52314c33533..57bf508adb9 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -302,8 +302,6 @@ extern const struct efi_hii_config_access_protocol efi_hii_config_access; extern const struct efi_hii_database_protocol efi_hii_database; extern const struct efi_hii_string_protocol efi_hii_string; -uint16_t *efi_dp_str(struct efi_device_path *dp); - /* GUID for the auto generated boot menu entry */ extern const efi_guid_t efi_guid_bootmenu_auto_generated; -- 2.43.0

From: Simon Glass <sjg@chromium.org> The lines after the 'edidebug media' command are only intended three spaces, but it should be four. Fix it. Signed-off-by: Simon Glass <sjg@chromium.org> --- doc/usage/cmd/efidebug.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/usage/cmd/efidebug.rst b/doc/usage/cmd/efidebug.rst index 29167dfa394..5dd68a689a6 100644 --- a/doc/usage/cmd/efidebug.rst +++ b/doc/usage/cmd/efidebug.rst @@ -49,11 +49,11 @@ Example This shows checking the EFI media devices:: - => efidebug media - Device Media type Device Path - ------------------- --------------- ----------- - efi_media_1 ahci PciRoot(0x0)/Pci(0x3,0x0)/Sata(0x0,0xFFFF,0x0) - efi_media_2 pci PciRoot(0x0)/Pci(0x5,0x0) + => efidebug media + Device Media type Device Path + ------------------- --------------- ----------- + efi_media_1 ahci PciRoot(0x0)/Pci(0x3,0x0)/Sata(0x0,0xFFFF,0x0) + efi_media_2 pci PciRoot(0x0)/Pci(0x5,0x0) This shows checking the log, then using 'efidebug tables' to fully set up the -- 2.43.0

From: Simon Glass <sjg@chromium.org> Provide a -s option to sort the memory map in order of address. Add documentation while we are here. Also fix an errant extra line before do_efi_show_media() Co-developed-by: Claude <noreply@anthropic.com> Signed-off-by: Simon Glass <sjg@chromium.org> --- cmd/efidebug.c | 50 +++++++++++++++++++-- doc/usage/cmd/efidebug.rst | 92 +++++++++++++++++++++++++++++++++++++- 2 files changed, 138 insertions(+), 4 deletions(-) diff --git a/cmd/efidebug.c b/cmd/efidebug.c index f88da42c2c4..71b99f9c8d7 100644 --- a/cmd/efidebug.c +++ b/cmd/efidebug.c @@ -25,6 +25,7 @@ #include <net.h> #include <part.h> #include <search.h> +#include <sort.h> #include <linux/ctype.h> #include <linux/err.h> @@ -655,6 +656,25 @@ static void print_memory_attributes(u64 attributes) #define EFI_PHYS_ADDR_WIDTH (int)(sizeof(efi_physical_addr_t) * 2) +/** + * efi_memmap_sort_by_addr() - compare two memory descriptors by address + * + * @a: first memory descriptor + * @b: second memory descriptor + * Return: -1 if a < b, 0 if a == b, 1 if a > b + */ +static int efi_memmap_sort_by_addr(const void *a, const void *b) +{ + const struct efi_mem_desc *desc_a = a; + const struct efi_mem_desc *desc_b = b; + + if (desc_a->physical_start < desc_b->physical_start) + return -1; + else if (desc_a->physical_start > desc_b->physical_start) + return 1; + return 0; +} + /** * do_efi_show_memmap() - show UEFI memory map * @@ -676,6 +696,25 @@ static int do_efi_show_memmap(struct cmd_tbl *cmdtp, int flag, int desc_size, i; efi_status_t eret; int ret; + bool sort_by_addr = false; + int num_entries; + + /* Parse arguments */ + argc--; argv++; /* skip command name */ + while (argc > 0 && argv[0][0] == '-') { + if (!strcmp(argv[0], "-s")) { + sort_by_addr = true; + } else { + printf("Unknown option: %s\n", argv[0]); + return CMD_RET_USAGE; + } + argc--; argv++; + } + + if (argc > 0) { + printf("Too many arguments\n"); + return CMD_RET_USAGE; + } if (IS_ENABLED(CONFIG_EFI_APP)) { uint key, version; @@ -692,6 +731,12 @@ static int do_efi_show_memmap(struct cmd_tbl *cmdtp, int flag, desc_size = sizeof(*map); } + /* Sort entries by address if requested */ + if (sort_by_addr) { + num_entries = map_size / desc_size; + qsort(memmap, num_entries, desc_size, efi_memmap_sort_by_addr); + } + printf("Type Start%.*s End%.*s Attributes\n", EFI_PHYS_ADDR_WIDTH - 5, spc, EFI_PHYS_ADDR_WIDTH - 3, spc); printf("================ %.*s %.*s ==========\n", @@ -1594,7 +1639,6 @@ static int do_efi_test(struct cmd_tbl *cmdtp, int flag, return cp->cmd(cmdtp, flag, argc, argv); } - /** * do_efi_show_media() - show EFI media devices * @@ -1807,8 +1851,8 @@ U_BOOT_LONGHELP(efidebug, " - show UEFI log\n" "efidebug media\n" " - show EFI media devices\n" - "efidebug memmap\n" - " - show UEFI memory map\n" + "efidebug memmap [-s]\n" + " - show UEFI memory map (use -s to sort by address)\n" "efidebug tables\n" " - show UEFI configuration tables\n" #ifdef CONFIG_EFI_BOOTMGR diff --git a/doc/usage/cmd/efidebug.rst b/doc/usage/cmd/efidebug.rst index 5dd68a689a6..8c8a4895197 100644 --- a/doc/usage/cmd/efidebug.rst +++ b/doc/usage/cmd/efidebug.rst @@ -15,6 +15,7 @@ Synopsis efidebug log efidebug media + efidebug memmap [-s] Description ----------- @@ -22,7 +23,7 @@ Description The *efidebug* command provides access to debugging features for the EFI-loader subsystem. -Only two of the subcommands are documented at present. +Only three of the subcommands are documented at present. efidebug log ~~~~~~~~~~~~ @@ -43,6 +44,15 @@ driver subsystem would likely handle the device (e.g., "ahci" for SATA drives, device, which can be useful for debugging boot issues or understanding the system topology. +efidebug memmap +~~~~~~~~~~~~~~~ + +This shows the UEFI memory map, which displays all memory regions and their +types as known to the EFI loader subsystem. This includes information about +memory allocation, reserved regions, and available memory. + +The command supports an optional '-s' flag to sort the memory map entries by +address, making it easier to visualize the memory layout in ascending order. Example ------- @@ -55,6 +65,86 @@ This shows checking the EFI media devices:: efi_media_1 ahci PciRoot(0x0)/Pci(0x3,0x0)/Sata(0x0,0xFFFF,0x0) efi_media_2 pci PciRoot(0x0)/Pci(0x5,0x0) +This shows checking the UEFI memory map, first unsorted and then sorted by +address:: + + => efidebug mem + Type Start End Attributes + ================ ================ ================ ========== + CONVENTIONAL 0000000040000000-0000000044000000 WB + BOOT DATA 0000000044000000-0000000044020000 WB + CONVENTIONAL 0000000044020000-00000000475ee000 WB + BOOT DATA 00000000475ee000-0000000047610000 WB + BOOT CODE 0000000047610000-0000000047647000 WB + BOOT DATA 0000000047647000-0000000047ef2000 WB + BOOT CODE 0000000047ef2000-0000000047ef6000 WB + BOOT DATA 0000000047ef6000-0000000047ff7000 WB + BOOT CODE 0000000047ff7000-0000000047ffa000 WB + BOOT DATA 0000000047ffa000-0000000048000000 WB + CONVENTIONAL 0000000048000000-00000000e0000000 WB + LOADER DATA 00000000e0000000-0000000100000000 WB + CONVENTIONAL 0000000100000000-000000013c278000 WB + LOADER DATA 000000013c278000-000000013c27c000 WB + LOADER CODE 000000013c27c000-000000013c3e0000 WB + ACPI RECLAIM MEM 000000013c3e0000-000000013c3f0000 WB + RUNTIME CODE 000000013c3f0000-000000013c470000 WB|RT + RUNTIME DATA 000000013c470000-000000013c630000 WB|RT + RUNTIME CODE 000000013c630000-000000013c730000 WB|RT + CONVENTIONAL 000000013c730000-000000013dc2a000 WB + BOOT DATA 000000013dc2a000-000000013e9f1000 WB + CONVENTIONAL 000000013e9f1000-000000013e9fe000 WB + BOOT DATA 000000013e9fe000-000000013ea1c000 WB + CONVENTIONAL 000000013ea1c000-000000013ea1e000 WB + BOOT DATA 000000013ea1e000-000000013ea47000 WB + CONVENTIONAL 000000013ea47000-000000013ea48000 WB + BOOT DATA 000000013ea48000-000000013f624000 WB + CONVENTIONAL 000000013f624000-000000013f731000 WB + BOOT CODE 000000013f731000-000000013fc00000 WB + RUNTIME CODE 000000013fc00000-000000013fd90000 WB|RT + RUNTIME DATA 000000013fd90000-000000013ffe0000 WB|RT + CONVENTIONAL 000000013ffe0000-000000013ffff000 WB + BOOT DATA 000000013ffff000-0000000140000000 WB + IO 0000000004000000-0000000008000000 UC|RT + IO 0000000009010000-0000000009011000 UC|RT + => efidebug mem -s + Type Start End Attributes + ================ ================ ================ ========== + IO 0000000004000000-0000000008000000 UC|RT + IO 0000000009010000-0000000009011000 UC|RT + CONVENTIONAL 0000000040000000-0000000044000000 WB + BOOT DATA 0000000044000000-0000000044020000 WB + CONVENTIONAL 0000000044020000-00000000475ee000 WB + BOOT DATA 00000000475ee000-0000000047610000 WB + BOOT CODE 0000000047610000-0000000047647000 WB + BOOT DATA 0000000047647000-0000000047ef2000 WB + BOOT CODE 0000000047ef2000-0000000047ef6000 WB + BOOT DATA 0000000047ef6000-0000000047ff7000 WB + BOOT CODE 0000000047ff7000-0000000047ffa000 WB + BOOT DATA 0000000047ffa000-0000000048000000 WB + CONVENTIONAL 0000000048000000-00000000e0000000 WB + LOADER DATA 00000000e0000000-0000000100000000 WB + CONVENTIONAL 0000000100000000-000000013c278000 WB + LOADER DATA 000000013c278000-000000013c27c000 WB + LOADER CODE 000000013c27c000-000000013c3e0000 WB + ACPI RECLAIM MEM 000000013c3e0000-000000013c3f0000 WB + RUNTIME CODE 000000013c3f0000-000000013c470000 WB|RT + RUNTIME DATA 000000013c470000-000000013c630000 WB|RT + RUNTIME CODE 000000013c630000-000000013c730000 WB|RT + CONVENTIONAL 000000013c730000-000000013dc2a000 WB + BOOT DATA 000000013dc2a000-000000013e9f1000 WB + CONVENTIONAL 000000013e9f1000-000000013e9fe000 WB + BOOT DATA 000000013e9fe000-000000013ea1c000 WB + CONVENTIONAL 000000013ea1c000-000000013ea1e000 WB + BOOT DATA 000000013ea1e000-000000013ea47000 WB + CONVENTIONAL 000000013ea47000-000000013ea48000 WB + BOOT DATA 000000013ea48000-000000013f624000 WB + CONVENTIONAL 000000013f624000-000000013f731000 WB + BOOT CODE 000000013f731000-000000013fc00000 WB + RUNTIME CODE 000000013fc00000-000000013fd90000 WB|RT + RUNTIME DATA 000000013fd90000-000000013ffe0000 WB|RT + CONVENTIONAL 000000013ffe0000-000000013ffff000 WB + BOOT DATA 000000013ffff000-0000000140000000 WB + => This shows checking the log, then using 'efidebug tables' to fully set up the EFI-loader subsystem, then checking the log again:: -- 2.43.0

From: Simon Glass <sjg@chromium.org> So far this subcommand is undocumented. Provide some notes. Also show a better error when 'efidebug boot rm' fails. Co-developed-by: Claude <noreply@anthropic.com> Signed-off-by: Simon Glass <sjg@chromium.org> --- cmd/efidebug.c | 7 ++- doc/usage/cmd/efidebug.rst | 97 +++++++++++++++++++++++++++++++++----- 2 files changed, 90 insertions(+), 14 deletions(-) diff --git a/cmd/efidebug.c b/cmd/efidebug.c index 71b99f9c8d7..3f956fea31a 100644 --- a/cmd/efidebug.c +++ b/cmd/efidebug.c @@ -1166,9 +1166,12 @@ static int do_efi_boot_rm(struct cmd_tbl *cmdtp, int flag, guid = efi_global_variable_guid; for (i = 1; i < argc; i++, argv++) { - id = (int)hextoul(argv[1], &endp); - if (*endp != '\0' || id > 0xffff) + id = (int)hextoul(argv[i], &endp); + if (*endp != '\0' || id > 0xffff) { + printf("Invalid ID '%s', use '0001' for example\n", + argv[i]); return CMD_RET_FAILURE; + } efi_create_indexed_name(var_name16, sizeof(var_name16), "Boot", id); diff --git a/doc/usage/cmd/efidebug.rst b/doc/usage/cmd/efidebug.rst index 8c8a4895197..a739f6b4e06 100644 --- a/doc/usage/cmd/efidebug.rst +++ b/doc/usage/cmd/efidebug.rst @@ -13,6 +13,11 @@ Synopsis :: + efidebug boot add -b <bootid> <label> <interface> <devnum>[:<part>] <file> + efidebug boot rm <bootid> [<bootid> ...] + efidebug boot dump + efidebug boot next <bootid> + efidebug boot order [<bootid> ...] efidebug log efidebug media efidebug memmap [-s] @@ -20,10 +25,44 @@ Synopsis Description ----------- -The *efidebug* command provides access to debugging features for the EFI-loader -subsystem. +The *efidebug* command provides access some EFI-loader features, including boot +management, memory mapping, and system information. -Only three of the subcommands are documented at present. +efidebug boot +~~~~~~~~~~~~~ + +The boot subcommands manage UEFI boot options (BootXXXX variables) and boot +order. + +**efidebug boot add** + Create or modify a UEFI boot option. The basic syntax is: + ``efidebug boot add -b <bootid> <label> <interface> <devnum>[:<part>] <file>`` + + Where: + + - ``<bootid>`` is a hexadecimal boot option ID (e.g., 0001, 000A) + - ``<label>`` is a descriptive name for the boot option + - ``<interface>`` is the storage interface (e.g., mmc, usb, virtio) + - ``<devnum>[:<part>]`` specifies device and optionally partition number + - ``<file>`` is the path to the EFI executable + + Additional options include ``-i`` for initrd, ``-s`` for optional data, + and ``-d`` for device tree files. + +**efidebug boot rm** + Remove one or more UEFI boot options by their boot IDs. + +**efidebug boot dump** + List all defined UEFI boot options with their details including boot ID, + label, and file path. + +**efidebug boot next** + Set the BootNext variable to specify which boot option should be used for + the next boot only. + +**efidebug boot order** + Show the current boot order when called without arguments, or sets a new + boot order when given a list of boot IDs. efidebug log ~~~~~~~~~~~~ @@ -57,12 +96,38 @@ address, making it easier to visualize the memory layout in ascending order. Example ------- +This shows managing UEFI boot options:: + + => efidebug boot add -b 1 "Ubuntu" mmc 0:2 /EFI/ubuntu/grubx64.efi + => efidebug boot add -b 2 "Windows" mmc 0:1 /EFI/Microsoft/Boot/bootmgfw.efi + => efidebug boot dump + Boot0001: + attributes: A-- (0x00000001) + label: Ubuntu + file_path: /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/SD(0)/ + HD(2,GPT,dfae5a37-e8d5-4a2e-aab6-6b6e8c8cb8a3,0x100800, + 0x5dc1800)/\EFI\ubuntu\grubx64.efi + data: + Boot0002: + attributes: A-- (0x00000001) + label: Windows + file_path: /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/SD(0)/ + HD(1,GPT,c8a9e8e7-2d2a-4b8e-9b4f-7b7b3b7b7b7b,0x800, + 0x100000)/\EFI\Microsoft\Boot\bootmgfw.efi + data: + => efidebug boot order 1 2 + => efidebug boot order + BootOrder: 0001 0002 + => efidebug boot next 2 + => efidebug boot rm 1 + This shows checking the EFI media devices:: => efidebug media Device Media type Device Path ------------------- --------------- ----------- - efi_media_1 ahci PciRoot(0x0)/Pci(0x3,0x0)/Sata(0x0,0xFFFF,0x0) + efi_media_1 ahci PciRoot(0x0)/Pci(0x3,0x0)/ + Sata(0x0,0xFFFF,0x0) efi_media_2 pci PciRoot(0x0)/Pci(0x5,0x0) This shows checking the UEFI memory map, first unsorted and then sorted by @@ -160,9 +225,12 @@ EFI-loader subsystem, then checking the log again:: 6 records => efidebug tables efi_var_to_file() Cannot persist EFI variables without system partition - 0000000017bfc010 36122546-f7ef-4c8f-bd9b-eb8525b50c0b EFI Conformance Profiles Table - 0000000017bd4010 b122a263-3661-4f68-9929-78f8b0d62180 EFI System Resource Table - 0000000017bd8010 1e2ed096-30e2-4254-bd89-863bbef82325 TCG2 Final Events Table + 0000000017bfc010 36122546-f7ef-4c8f-bd9b-eb8525b50c0b \ + EFI Conformance Profiles Table + 0000000017bd4010 b122a263-3661-4f68-9929-78f8b0d62180 \ + EFI System Resource Table + 0000000017bd8010 1e2ed096-30e2-4254-bd89-863bbef82325 \ + TCG2 Final Events Table 0000000017bd6010 eb66918a-7eef-402a-842e-931d21c38ae9 Runtime properties 0000000008c49000 8868e871-e4f1-11d3-bc22-0080c73c8881 ACPI table 0000000018c5b000 f2fd1544-9794-4a2c-992e-e5bbcf20e394 SMBIOS3 table @@ -174,7 +242,8 @@ EFI-loader subsystem, then checking the log again:: 3 alloc_pages any-pages bt-data pgs 1 mem 7fffd8448a60 *mem 7c1f000 ret OK 4 alloc_pool bt-data size 60/96 buf 7fffd8448ac0 *buf 7c1e010 ret OK 5 alloc_pages any-pages bt-data pgs 1 mem 7fffd8448a60 *mem 7c1e000 ret OK - 6 alloc_pages any-pages rt-data pgs 20/32 mem 7fffd8448838 *mem 7bfe000 ret OK + 6 alloc_pages any-pages rt-data pgs 20/32 mem 7fffd8448838 \ + *mem 7bfe000 ret OK 7 alloc_pool rt-data size 60/96 buf 7fffd84487e0 *buf 7bfd010 ret OK 8 alloc_pages any-pages rt-data pgs 1 mem 7fffd8448780 *mem 7bfd000 ret OK 9 alloc_pool rt-data size 180/384 buf 56f190ffd890 *buf 7bfc010 ret OK @@ -185,10 +254,14 @@ EFI-loader subsystem, then checking the log again:: 14 alloc_pages any-pages bt-data pgs 1 mem 7fffd84486d0 *mem 7bfa000 ret OK 15 alloc_pool bt-data size 60/96 buf 7fffd84487e0 *buf 7bf9010 ret OK 16 alloc_pages any-pages bt-data pgs 1 mem 7fffd8448780 *mem 7bf9000 ret OK - 17 alloc_pool bt-data size 10000/65536 buf 56f19100fae0 *buf 7be8010 ret OK - 18 alloc_pages any-pages bt-data pgs 11/17 mem 7fffd84487d0 *mem 7be8000 ret OK - 19 alloc_pool acpi-nvs size 10000/65536 buf 56f19100fae8 *buf 7bd7010 ret OK - 20 alloc_pages any-pages acpi-nvs pgs 11/17 mem 7fffd84487d0 *mem 7bd7000 ret OK + 17 alloc_pool bt-data size 10000/65536 buf 56f19100fae0 \ + *buf 7be8010 ret OK + 18 alloc_pages any-pages bt-data pgs 11/17 mem 7fffd84487d0 \ + *mem 7be8000 ret OK + 19 alloc_pool acpi-nvs size 10000/65536 buf 56f19100fae8 \ + *buf 7bd7010 ret OK + 20 alloc_pages any-pages acpi-nvs pgs 11/17 mem 7fffd84487d0 \ + *mem 7bd7000 ret OK 21 alloc_pool bt-data size 60/96 buf 7fffd84487d0 *buf 7bd6010 ret OK 22 alloc_pages any-pages bt-data pgs 1 mem 7fffd8448770 *mem 7bd6000 ret OK 23 alloc_pool rt-data size 8 buf 7fffd8448818 *buf 7bd5010 ret OK -- 2.43.0

From: Simon Glass <sjg@chromium.org> The 'bootflow list' command supports looking at the EFI device-path when available. Move this piece into a common function so it can be used elsewhere. Signed-off-by: Simon Glass <sjg@chromium.org> --- boot/bootflow.c | 27 +++++++++++++++++++++++++++ cmd/bootflow.c | 16 +--------------- include/bootflow.h | 8 ++++++++ 3 files changed, 36 insertions(+), 15 deletions(-) diff --git a/boot/bootflow.c b/boot/bootflow.c index c088300ea96..c8391641001 100644 --- a/boot/bootflow.c +++ b/boot/bootflow.c @@ -11,6 +11,7 @@ #include <bootmeth.h> #include <bootstd.h> #include <dm.h> +#include <efi_device_path.h> #include <env_internal.h> #include <malloc.h> #include <serial.h> @@ -1024,3 +1025,29 @@ int bootflow_get_seq(const struct bootflow *bflow) return alist_calc_index(&std->bootflows, bflow); } + +const char *bootflow_guess_label(const struct bootflow *bflow) +{ + const char *name = NULL; + + if (IS_ENABLED(CONFIG_EFI_APP)) { + struct efi_device_path *dp; + enum uclass_id id; + int ret; + + ret = efi_dp_from_bootflow(bflow, &dp, NULL); + if (!ret) + name = efi_dp_guess_uclass(dp, &id); + } else if (bflow->dev) { + struct udevice *media = dev_get_parent(bflow->dev); + + if (device_get_uclass_id(media) == UCLASS_MASS_STORAGE) + name = "usb"; + else + name = dev_get_uclass_name(media); + } + if (!name) + name = "(none)"; + + return name; +} diff --git a/cmd/bootflow.c b/cmd/bootflow.c index 20fc04bdda3..43335fecb34 100644 --- a/cmd/bootflow.c +++ b/cmd/bootflow.c @@ -70,21 +70,7 @@ static void report_bootflow_err(struct bootflow *bflow, int err) */ static void show_bootflow(int index, struct bootflow *bflow, bool errors) { - const char *name = NULL; - - if (IS_ENABLED(CONFIG_EFI_APP)) { - struct efi_device_path *dp; - enum uclass_id id; - int ret; - - ret = efi_dp_from_bootflow(bflow, &dp, NULL); - if (!ret) - name = efi_dp_guess_uclass(dp, &id); - } else if (bflow->dev) { - name = dev_get_uclass_name(dev_get_parent(bflow->dev)); - } - if (!name) - name = "(none)"; + const char *name = bootflow_guess_label(bflow); printf("%3x %-11s %-6s %-9.9s %4x %-25.25s %s\n", index, bflow->method ? bflow->method->name : "(none)", diff --git a/include/bootflow.h b/include/bootflow.h index ec5baff7e01..422fd32a3ca 100644 --- a/include/bootflow.h +++ b/include/bootflow.h @@ -725,4 +725,12 @@ int bootflow_menu_start(struct bootstd_priv *std, bool text_mode, */ int bootflow_menu_poll(struct expo *exp, int *seqp); +/** + * bootflow_guess_label() - Produce a plausible label for a bootflow + * + * This uses the uclass name or EFI device-path to come up with a useful label + * for display to the user. Ideally it will say "mmc", "usb", nvme", etc. + */ +const char *bootflow_guess_label(const struct bootflow *bflow); + #endif -- 2.43.0

From: Simon Glass <sjg@chromium.org> Make use of bootflow_guess_label() to get the label for a menu, since it provides more information for the EFI app. Signed-off-by: Simon Glass <sjg@chromium.org> --- boot/bootflow_menu.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/boot/bootflow_menu.c b/boot/bootflow_menu.c index 2f08fa54081..5e0e365d12b 100644 --- a/boot/bootflow_menu.c +++ b/boot/bootflow_menu.c @@ -124,7 +124,6 @@ int bootflow_menu_add(struct expo *exp, struct bootflow *bflow, int seq, { struct menu_priv *priv = exp->priv; char str[2], *label, *key; - struct udevice *media; struct scene *scn; const char *name; uint preview_id; @@ -144,11 +143,7 @@ int bootflow_menu_add(struct expo *exp, struct bootflow *bflow, int seq, if (!key) return log_msg_ret("key", -ENOMEM); - media = dev_get_parent(bflow->dev); - if (device_get_uclass_id(media) == UCLASS_MASS_STORAGE) - name = "usb"; - else - name = media->name; + name = bootflow_guess_label(bflow); label = strdup(name); if (!label) { -- 2.43.0

From: Simon Glass <sjg@chromium.org> It is handy to have the pager in the app, since some output can be quite long. Enable the console mux since the pager feature depends on it. Signed-off-by: Simon Glass <sjg@chromium.org> --- lib/efi_client/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/efi_client/Kconfig b/lib/efi_client/Kconfig index 5726e91e814..9361a548c9d 100644 --- a/lib/efi_client/Kconfig +++ b/lib/efi_client/Kconfig @@ -22,6 +22,7 @@ config EFI_APP depends on X86 || ARM select CHARSET select EVENT + imply CONSOLE_MUX imply CONSOLE_PAGER help Build U-Boot as an application which can be started from EFI. This -- 2.43.0

From: Simon Glass <sjg@chromium.org> All files in this directory relate to EFI, so set the log category consistently. Signed-off-by: Simon Glass <sjg@chromium.org> --- lib/efi_client/app_run.c | 2 ++ lib/efi_client/efi.c | 2 ++ lib/efi_client/efi_info.c | 2 ++ lib/efi_client/efi_vars.c | 2 ++ lib/efi_client/sdram.c | 2 ++ lib/efi_client/stub.c | 2 ++ lib/efi_client/stub_arm64.c | 1 + lib/efi_client/stub_x86.c | 2 ++ lib/efi_client/sync_dt.c | 2 ++ 9 files changed, 17 insertions(+) diff --git a/lib/efi_client/app_run.c b/lib/efi_client/app_run.c index 9fc753ceed8..de2c6b8bdd2 100644 --- a/lib/efi_client/app_run.c +++ b/lib/efi_client/app_run.c @@ -6,6 +6,8 @@ * Copyright 2024 Canonical Ltd */ +#define LOG_CATEGORY LOGC_EFI + #include <bootm.h> #include <dm.h> #include <efi.h> diff --git a/lib/efi_client/efi.c b/lib/efi_client/efi.c index 12a646a36b7..083ad1f423c 100644 --- a/lib/efi_client/efi.c +++ b/lib/efi_client/efi.c @@ -10,6 +10,8 @@ * Common EFI functions */ +#define LOG_CATEGORY LOGC_EFI + #include <debug_uart.h> #include <errno.h> #include <malloc.h> diff --git a/lib/efi_client/efi_info.c b/lib/efi_client/efi_info.c index a0d7d3b5d7d..5ff98e8829e 100644 --- a/lib/efi_client/efi_info.c +++ b/lib/efi_client/efi_info.c @@ -5,6 +5,8 @@ * Access to the EFI information table */ +#define LOG_CATEGORY LOGC_EFI + #include <efi.h> #include <efi_loader.h> #include <efi_stub.h> diff --git a/lib/efi_client/efi_vars.c b/lib/efi_client/efi_vars.c index 4fc48b90d6c..9764a9802a4 100644 --- a/lib/efi_client/efi_vars.c +++ b/lib/efi_client/efi_vars.c @@ -4,6 +4,8 @@ * */ +#define LOG_CATEGORY LOGC_EFI + #define __efi_runtime #include <errno.h> diff --git a/lib/efi_client/sdram.c b/lib/efi_client/sdram.c index bd59dfade0f..357ca095f86 100644 --- a/lib/efi_client/sdram.c +++ b/lib/efi_client/sdram.c @@ -3,6 +3,8 @@ * Copyright (c) 2015 Google, Inc */ +#define LOG_CATEGORY LOGC_EFI + #include <efi.h> #include <init.h> #include <asm/global_data.h> diff --git a/lib/efi_client/stub.c b/lib/efi_client/stub.c index 01d62c3e5c9..3e3ea91f915 100644 --- a/lib/efi_client/stub.c +++ b/lib/efi_client/stub.c @@ -8,6 +8,8 @@ * Provides helper functions for use with the stub */ +#define LOG_CATEGORY LOGC_EFI + #include <debug_uart.h> #include <efi.h> #include <efi_api.h> diff --git a/lib/efi_client/stub_arm64.c b/lib/efi_client/stub_arm64.c index 0e579a17a75..3184be64cd0 100644 --- a/lib/efi_client/stub_arm64.c +++ b/lib/efi_client/stub_arm64.c @@ -9,6 +9,7 @@ * Call ExitBootServices() and launch U-Boot from an EFI environment. */ +#define LOG_CATEGORY LOGC_EFI #include <debug_uart.h> #include <efi.h> #include <efi_api.h> diff --git a/lib/efi_client/stub_x86.c b/lib/efi_client/stub_x86.c index fac55fa8f32..b223c36c798 100644 --- a/lib/efi_client/stub_x86.c +++ b/lib/efi_client/stub_x86.c @@ -9,6 +9,8 @@ * EFI application. It can be built either in 32-bit or 64-bit mode. */ +#define LOG_CATEGORY LOGC_EFI + #include <debug_uart.h> #include <efi.h> #include <efi_api.h> diff --git a/lib/efi_client/sync_dt.c b/lib/efi_client/sync_dt.c index f191a31125f..44627451dae 100644 --- a/lib/efi_client/sync_dt.c +++ b/lib/efi_client/sync_dt.c @@ -5,6 +5,8 @@ * Copyright 2025 Simon Glass <sjg@chromium.org> */ +#define LOG_CATEGORY LOGC_EFI + #include <efi.h> #include <efi_api.h> #include <fdt_support.h> -- 2.43.0
participants (1)
-
Simon Glass