[PATCH v2 00/22] efi: Improvements for the EFI app on ARM

From: Simon Glass <sjg@chromium.org> This series provides a number of minor improvements for the EFI app when running on ARM machines (on top of Tianocore, for example): - Tidy up various comments - Show the ARM exception level in bdinfo - Tidy up the output of 'meminfo' - Get the addr_find command running - Reduce verbosity when not debugging - Show the model at the top of the diplay when using vidconsole - Allow faking the boot right into the actual OS jump (for debugging) Changes in v2: - Make the messages longer and more explanatory - Use the existing current_el() function - Add a colon so it is clear that 'load_os type' is not a compound term Simon Glass (22): arm: bootm: Add some debugging arm: Fix swtiching typo arm: Show the exception level with bdinfo arm: Drop kernel_entry for arm64 meminfo: Allow for up to 10 hex digits event: Add a dummy function for event_notify() boot: Improve debugging in bootm_load_os() boot: Pass flags to the bootm_final event fdt: Add debugging for fdt_simplefb efi: app: Show only a summary of disks and partitions efi: Fix up the addr_find command efi: app: Tidy up some stale comments in setup_memory() efi: app: Allocate pages in any region efi: app: Pick up the SMBIOS table efi: app: Use EFI_PAGE_SHIFT instead of 12 in free_memory() efi: app: Print the final message before freeing memory efi: app: Use the relocated global_data efi: app: Only show the memory map when debugging efi: app: Add a simplefb node to the devicetree efi: arm: Increase the cyclic timeout again efi: app: Show the model when the vidconsole starts efi: app: Enable the cat command arch/arm/lib/bdinfo.c | 4 ++++ arch/arm/lib/bootm.c | 15 +++++++------ board/efi/efi-arm_app/board.c | 4 ++++ boot/bootm.c | 3 ++- boot/bootm_final.c | 13 ++++++----- boot/fdt_simplefb.c | 4 ++++ cmd/Kconfig | 3 ++- cmd/addr_find.c | 40 +++++++++++---------------------- cmd/meminfo.c | 9 ++++---- configs/efi-arm_app64_defconfig | 5 ++++- include/bootm.h | 13 +---------- include/event.h | 17 +++++++++++++- include/event_decl.h | 27 ++++++++++++++++++++++ lib/Kconfig | 3 ++- lib/efi_client/efi_app.c | 37 +++++++++++++++++++++--------- lib/efi_client/efi_app_init.c | 10 ++++++--- test/cmd/meminfo.c | 2 +- 17 files changed, 135 insertions(+), 74 deletions(-) create mode 100644 include/event_decl.h -- 2.43.0 base-commit: 12f3fc10fd44ee320b79236d7ff0ea3c2d78c12e branch: loadp2

From: Simon Glass <sjg@chromium.org> Provides some debugging info while doing bootm processing. Signed-off-by: Simon Glass <sjg@chromium.org> --- Changes in v2: - Make the messages longer and more explanatory arch/arm/lib/bootm.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c index cb365d95c7b..12383b2c36e 100644 --- a/arch/arm/lib/bootm.c +++ b/arch/arm/lib/bootm.c @@ -11,6 +11,8 @@ * Copyright (C) 2001 Erik Mouw (J.A.K.Mouw@its.tudelft.nl) */ +#define LOG_CATEGORY LOGC_BOOT + #include <bootm.h> #include <bootstage.h> #include <command.h> @@ -349,20 +351,24 @@ int do_bootm_linux(int flag, struct bootm_info *bmi) { struct bootm_headers *images = bmi->images; + log_debug("boot linux flag %x\n", flag); /* No need for those on ARM */ if (flag & BOOTM_STATE_OS_BD_T || flag & BOOTM_STATE_OS_CMDLINE) return -1; if (flag & BOOTM_STATE_OS_PREP) { + log_debug("Preparing to boot Linux\n"); boot_prep_linux(images); return 0; } if (flag & (BOOTM_STATE_OS_GO | BOOTM_STATE_OS_FAKE_GO)) { + log_debug("Jumping to Linux (or faking it)\n"); boot_jump_linux(images, flag); return 0; } + log_debug("No flags set: continuing to prepare and jump to Linux\n"); boot_prep_linux(images); boot_jump_linux(images, flag); return 0; -- 2.43.0

From: Simon Glass <sjg@chromium.org> This should say 'switching', so fix it. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> --- (no changes since v1) arch/arm/lib/bootm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c index 12383b2c36e..f15092fcae4 100644 --- a/arch/arm/lib/bootm.c +++ b/arch/arm/lib/bootm.c @@ -156,7 +156,7 @@ static void do_nonsec_virt_switch(void) { if (ll_boot_init()) { smp_kick_all_cpus(); - dcache_disable(); /* flush cache before swtiching to EL2 */ + dcache_disable(); /* flush cache before switching to EL2 */ } } #endif -- 2.43.0

From: Simon Glass <sjg@chromium.org> Some machines start U-Boot in a different exception level, so provide a way to view it. Signed-off-by: Simon Glass <sjg@chromium.org> --- Changes in v2: - Use the existing current_el() function arch/arm/lib/bdinfo.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/arm/lib/bdinfo.c b/arch/arm/lib/bdinfo.c index 73033310879..d7426efbd7c 100644 --- a/arch/arm/lib/bdinfo.c +++ b/arch/arm/lib/bdinfo.c @@ -11,6 +11,7 @@ #include <init.h> #include <asm/global_data.h> #include <asm/mach-types.h> +#include <asm/system.h> DECLARE_GLOBAL_DATA_PTR; @@ -61,4 +62,7 @@ void arch_print_bdinfo(void) printf("Early malloc usage: %x / %x\n", gd->malloc_ptr, CONFIG_VAL(SYS_MALLOC_F_LEN)); #endif +#ifdef CONFIG_ARM64 + lprint_num_l("CurrentEL", current_el()); +#endif } -- 2.43.0

From: Simon Glass <sjg@chromium.org> This variable is tricky to set up and is only used to show an address. Drop it and use the source variable instead. Signed-off-by: Simon Glass <sjg@chromium.org> --- (no changes since v1) arch/arm/lib/bootm.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c index f15092fcae4..02ff8beaeab 100644 --- a/arch/arm/lib/bootm.c +++ b/arch/arm/lib/bootm.c @@ -260,15 +260,10 @@ static void switch_to_el1(void) static void boot_jump_linux(struct bootm_headers *images, int flag) { #ifdef CONFIG_ARM64 - void (*kernel_entry)(void *fdt_addr, void *res0, void *res1, - void *res2); int fake = (flag & BOOTM_STATE_OS_FAKE_GO); - kernel_entry = (void (*)(void *fdt_addr, void *res0, void *res1, - void *res2))images->ep; - debug("## Transferring control to Linux (at address %lx)...\n", - (ulong) kernel_entry); + (ulong)images->ep); bootstage_mark(BOOTSTAGE_ID_RUN_OS); bootm_final(fake ? BOOTM_FINAL_FAKE : 0); -- 2.43.0

From: Simon Glass <sjg@chromium.org> On platforms where most of the memory is above 4GB, the EFI app may find itself using addresses with 9 or even 10 digits. Expand the width of the columns to cope with this. Add some double bars across digits 9 and 8 so that it is easier to make the value. Signed-off-by: Simon Glass <sjg@chromium.org> --- (no changes since v1) cmd/meminfo.c | 9 +++++---- test/cmd/meminfo.c | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/cmd/meminfo.c b/cmd/meminfo.c index 5e83d61c2dd..2f83ca27537 100644 --- a/cmd/meminfo.c +++ b/cmd/meminfo.c @@ -19,9 +19,9 @@ static void print_region(const char *name, ulong base, ulong size, ulong *uptop) { ulong end = base + size; - printf("%-12s %8lx %8lx %8lx", name, base, size, end); + printf("%-12s %10lx %10lx %10lx", name, base, size, end); if (*uptop) - printf(" %8lx", *uptop - end); + printf(" %10lx", *uptop - end); putc('\n'); *uptop = base; } @@ -58,9 +58,10 @@ static int do_meminfo(struct cmd_tbl *cmdtp, int flag, int argc, if (!IS_ENABLED(CONFIG_CMD_MEMINFO_MAP)) return 0; - printf("\n%-12s %8s %8s %8s %8s\n", "Region", "Base", "Size", "End", + printf("\n%-12s %10s %10s %10s %10s\n", "Region", "|| Base", + "|| Size", "|| End", "Gap"); - printf("------------------------------------------------\n"); + printf("--------------------------------------------------------\n"); upto = 0; if (IS_ENABLED(CONFIG_VIDEO)) print_region("video", gd_video_bottom(), diff --git a/test/cmd/meminfo.c b/test/cmd/meminfo.c index 53b41e3b49e..b2f306d06e2 100644 --- a/test/cmd/meminfo.c +++ b/test/cmd/meminfo.c @@ -17,7 +17,7 @@ static int cmd_test_meminfo(struct unit_test_state *uts) ut_assert_nextline("DRAM: 256 MiB"); ut_assert_nextline_empty(); - ut_assert_nextline("Region Base Size End Gap"); + ut_assert_nextline("Region || Base || Size || End Gap"); ut_assert_nextlinen("-"); /* For now we don't worry about checking the values */ -- 2.43.0

From: Simon Glass <sjg@chromium.org> When CONFIG_EVENT is disabled, we should not try to send an event. This is already handled for events without parameters, so handle it for events that do have parameters, too. Signed-off-by: Simon Glass <sjg@chromium.org> --- (no changes since v1) include/event.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/event.h b/include/event.h index 67b5bdd8a8b..a68be9fc1e8 100644 --- a/include/event.h +++ b/include/event.h @@ -402,6 +402,7 @@ void event_show_spy_list(void); */ const char *event_type_name(enum event_t type); +#if CONFIG_IS_ENABLED(EVENT) /** * event_notify() - notify spies about an event * @@ -416,7 +417,6 @@ const char *event_type_name(enum event_t type); */ int event_notify(enum event_t type, void *data, int size); -#if CONFIG_IS_ENABLED(EVENT) /** * event_notify_null() - notify spies about an event * @@ -431,6 +431,11 @@ static inline int event_notify_null(enum event_t type) { return 0; } + +static inline int event_notify(enum event_t type, void *data, int size) +{ + return 0; +} #endif #if CONFIG_IS_ENABLED(EVENT_DYNAMIC) -- 2.43.0

From: Simon Glass <sjg@chromium.org> This shows an image type as an OS, which is not correct. Fix it up to show both. Signed-off-by: Simon Glass <sjg@chromium.org> --- Changes in v2: - Add a colon so it is clear that 'load_os type' is not a compound term boot/bootm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/boot/bootm.c b/boot/bootm.c index d9bcb748cb1..a536737db09 100644 --- a/boot/bootm.c +++ b/boot/bootm.c @@ -773,7 +773,8 @@ static int bootm_load_os(struct bootm_info *bmi, int boot_progress) ulong decomp_len; int err; - log_debug("load_os type '%s' comp '%s'\n", + log_debug("load_os: type '%s' os '%s' comp '%s'\n", + genimg_get_type_short_name(os.type), genimg_get_os_short_name(os.type), genimg_get_comp_short_name(os.comp)); /* -- 2.43.0

From: Simon Glass <sjg@chromium.org> For a fake go, we should tell the event not to actually do anything irreversable, so pass the flag along. Move the enum into a separate event_decl.h header file since otherwise we must include bootm.h which causes a breakage with qemu-ppce500 We also don't want to pull event.h into the tools build, since it uses types like u8 which are not available outside U-Boot Signed-off-by: Simon Glass <sjg@chromium.org> --- (no changes since v1) boot/bootm_final.c | 13 ++++++++----- include/bootm.h | 13 +------------ include/event.h | 10 ++++++++++ include/event_decl.h | 27 +++++++++++++++++++++++++++ 4 files changed, 46 insertions(+), 17 deletions(-) create mode 100644 include/event_decl.h diff --git a/boot/bootm_final.c b/boot/bootm_final.c index 7594880399e..881d737ce67 100644 --- a/boot/bootm_final.c +++ b/boot/bootm_final.c @@ -17,6 +17,7 @@ __weak void board_quiesce_devices(void) void bootm_final(enum bootm_final_t flags) { + struct event_bootm_final final; int ret; printf("\nStarting kernel ...%s\n\n", flags & BOOTM_FINAL_FAKE ? @@ -43,15 +44,17 @@ void bootm_final(enum bootm_final_t flags) */ dm_remove_devices_active(); - ret = event_notify_null(EVT_BOOTM_FINAL); + final.flags = flags; + ret = event_notify(EVT_BOOTM_FINAL, &final, sizeof(final)); if (ret) { printf("Event handler failed to finalise (err %dE\n", ret); return; } + if (!(flags & BOOTM_FINAL_FAKE)) { + bootm_disable_interrupts(); - bootm_disable_interrupts(); - - if (!(flags & BOOTM_FINAL_NO_CLEANUP)) - cleanup_before_linux(); + if (!(flags & BOOTM_FINAL_NO_CLEANUP)) + cleanup_before_linux(); + } } diff --git a/include/bootm.h b/include/bootm.h index b026e1dd80d..392825841e9 100644 --- a/include/bootm.h +++ b/include/bootm.h @@ -7,6 +7,7 @@ #ifndef _BOOTM_H #define _BOOTM_H +#include <event_decl.h> #include <image.h> struct boot_params; @@ -16,18 +17,6 @@ struct cmd_tbl; #define BOOTM_ERR_OVERLAP (-2) #define BOOTM_ERR_UNIMPLEMENTED (-3) -/** - * enum bootm_final_t - flags to control bootm_final() - * - * @BOOTM_FINAL_FAKE: true to do everything except actually boot; it then - * returns to the caller - * @BOOTM_FINAL_NO_CLEANUP: true to skip calling cleanup_before_linux() - */ -enum bootm_final_t { - BOOTM_FINAL_FAKE = BIT(0), - BOOTM_FINAL_NO_CLEANUP = BIT(1), -}; - /** * struct bootm_info() - information used when processing images to boot * diff --git a/include/event.h b/include/event.h index a68be9fc1e8..5fecaa66e80 100644 --- a/include/event.h +++ b/include/event.h @@ -12,6 +12,7 @@ #include <dm/ofnode_decl.h> #include <linux/types.h> +#include <event_decl.h> /** * enum event_t - Types of events supported by U-Boot @@ -260,6 +261,15 @@ union event_data { struct event_ft_fixup_f { oftree tree; } ft_fixup_f; + + /** + * struct event_bootm_final - State information + * + * @flags: Flags passed to bootm_final() + */ + struct event_bootm_final { + enum bootm_final_t flags; + } bootm_final; }; /** diff --git a/include/event_decl.h b/include/event_decl.h new file mode 100644 index 00000000000..483ae687e5a --- /dev/null +++ b/include/event_decl.h @@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Declarations needed by events + * + * Copyright 2025 Simon Glass <sjg@chromium.org> + */ + +#ifndef __event_decl_h +#define __event_decl_h + +#include <linux/bitops.h> + +/** + * enum bootm_final_t - flags to control bootm_final() + * + * Note that this is defined in event.h since it is used by events + * + * @BOOTM_FINAL_FAKE: true to do everything except actually boot; it then + * returns to the caller + * @BOOTM_FINAL_NO_CLEANUP: true to skip calling cleanup_before_linux() + */ +enum bootm_final_t { + BOOTM_FINAL_FAKE = BIT(0), + BOOTM_FINAL_NO_CLEANUP = BIT(1), +}; + +#endif -- 2.43.0

From: Simon Glass <sjg@chromium.org> Add some simple debug output to see what it is doing. Signed-off-by: Simon Glass <sjg@chromium.org> --- (no changes since v1) board/efi/efi-arm_app/board.c | 4 ++++ boot/fdt_simplefb.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/board/efi/efi-arm_app/board.c b/board/efi/efi-arm_app/board.c index ce6c3e78ebc..662e48a3b74 100644 --- a/board/efi/efi-arm_app/board.c +++ b/board/efi/efi-arm_app/board.c @@ -30,6 +30,10 @@ int board_exit_boot_services(void *ctx, struct event *evt) uint key; int ret; + if (evt->data.bootm_final.flags & BOOTM_FINAL_FAKE) { + printf("Not exiting EFI (fake go)\n"); + return 0; + } printf("Exiting EFI\n"); ret = efi_get_mmap(&desc, &size, &key, &desc_size, &version); if (ret) { diff --git a/boot/fdt_simplefb.c b/boot/fdt_simplefb.c index 5822131767d..6c75a6d5b5f 100644 --- a/boot/fdt_simplefb.c +++ b/boot/fdt_simplefb.c @@ -6,6 +6,8 @@ * Stephen Warren <swarren@wwwdotorg.org> */ +#define LOG_CATEGORY LOGC_BOOT + #include <dm.h> #include <fdt_support.h> #include <asm/global_data.h> @@ -48,6 +50,8 @@ static int fdt_simplefb_configure_node(void *blob, int off) ysize = uc_priv->ysize; bpix = uc_priv->bpix; fb_base = plat->base; + log_debug("simplefb: fb %lx x %d y %d bpix %x\n", fb_base, + xsize, ysize, bpix); } switch (bpix) { -- 2.43.0

From: Simon Glass <sjg@chromium.org> The EFI app shows a list of every disk and partition it can find. On Qualcomm x1e laptops this can fill the screen. The information is not that useful, so just show a summary. Signed-off-by: Simon Glass <sjg@chromium.org> --- (no changes since v1) lib/efi_client/efi_app_init.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/efi_client/efi_app_init.c b/lib/efi_client/efi_app_init.c index 938b16d14ab..7d30e79528f 100644 --- a/lib/efi_client/efi_app_init.c +++ b/lib/efi_client/efi_app_init.c @@ -128,6 +128,7 @@ static int setup_block(void) struct efi_device_path_to_text_protocol *text; struct efi_device_path *path; struct efi_block_io *blkio; + int num_disks, num_parts; efi_uintn_t num_handles; efi_handle_t *handle; int ret, i; @@ -150,7 +151,7 @@ static int setup_block(void) if (ret) return log_msg_ret("text", -ENOTSUPP); - for (i = 0; i < num_handles; i++) { + for (num_disks = 0, num_parts = 0, i = 0; i < num_handles; i++) { struct udevice *dev; const u16 *name; bool is_part; @@ -174,6 +175,7 @@ static int setup_block(void) is_part = devpath_is_partition(path); if (!is_part) { + num_disks++; len = util->get_device_path_size(path); ret = efi_bind_block(handle[i], blkio, path, len, &dev); if (ret) { @@ -183,15 +185,17 @@ static int setup_block(void) } } else { dev = NULL; + num_parts++; } /* * Show the device name if we created one. Otherwise indicate * that it is a partition. */ - printf("%2d: %-12s %ls\n", i, dev ? dev->name : "<partition>", - name); + log_debug("%2d: %-12s %ls\n", i, + dev ? dev->name : "<partition>", name); } + log_info("EFI: disks %d, partitions %d\n", num_disks, num_parts); boot->free_pool(handle); return 0; -- 2.43.0

From: Simon Glass <sjg@chromium.org> This command was written before the lmb unification, so does not currently build. Tidy it up and enable it for the EFI app, by default. Also allow it to search any partition, not just a FAT one, since we may have the kernel on ext4 Signed-off-by: Simon Glass <sjg@chromium.org> --- (no changes since v1) cmd/Kconfig | 3 ++- cmd/addr_find.c | 40 +++++++++++++--------------------------- 2 files changed, 15 insertions(+), 28 deletions(-) diff --git a/cmd/Kconfig b/cmd/Kconfig index 4d564ab5ac6..b7b80cbe59f 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -129,7 +129,8 @@ config CMD_ACPI want to make hardware changes without the OS needing to be adjusted. config CMD_ADDR_FIND - bool "addr_find" + bool "addr_find" + default y if EFI_APP help This command searches for an unused region of address space sufficiently large to hold a file. If successful, it sets the diff --git a/cmd/addr_find.c b/cmd/addr_find.c index 8dcad300ad8..876c58feabd 100644 --- a/cmd/addr_find.c +++ b/cmd/addr_find.c @@ -16,19 +16,17 @@ DECLARE_GLOBAL_DATA_PTR; int do_addr_find(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - struct lmb_region *mem, *reserved; const char *filename; - struct lmb lmb; loff_t size; + ulong addr; int ret; - int i, j; if (!gd->fdt_blob) { log_err("No FDT setup\n"); return CMD_RET_FAILURE; } - if (fs_set_blk_dev(argv[1], argc >= 3 ? argv[2] : NULL, FS_TYPE_FAT)) { + if (fs_set_blk_dev(argv[1], argc >= 3 ? argv[2] : NULL, FS_TYPE_ANY)) { log_err("Can't set block device\n"); return CMD_RET_FAILURE; } @@ -49,32 +47,20 @@ int do_addr_find(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) return CMD_RET_FAILURE; } - lmb_init_and_reserve(&lmb, gd->bd, (void *)gd->fdt_blob); - mem = &lmb.memory; - reserved = &lmb.reserved; - - for (i = 0; i < mem->cnt; i++) { - unsigned long long start, end; + addr = lmb_alloc(size, SZ_1M); + if (!addr) { + log_err("Failed to find enough RAM for 0x%llx bytes\n", size); + return CMD_RET_FAILURE; + } - start = mem->region[i].base; - end = mem->region[i].base + mem->region[i].size - 1; - if ((start + size) > end) - continue; - for (j = 0; j < reserved->cnt; j++) { - if ((reserved->region[j].base + reserved->region[j].size) < start) - continue; - if ((start + size) > reserved->region[j].base) - start = reserved->region[j].base + reserved->region[j].size; - } - if ((start + size) <= end) { - env_set_hex("loadaddr", start); - debug("Set loadaddr to 0x%llx\n", start); - return CMD_RET_SUCCESS; - } + if (env_set_hex("loadaddr", addr)) { + log_err("Could not set loadaddr\n"); + return CMD_RET_FAILURE; } - log_err("Failed to find enough RAM for 0x%llx bytes\n", size); - return CMD_RET_FAILURE; + log_debug("Set loadaddr to %lx\n", addr); + + return CMD_RET_SUCCESS; } U_BOOT_CMD( -- 2.43.0

From: Simon Glass <sjg@chromium.org> A few comments are out of date. Drop the one about global_data_ptr and reword the one about memory above 4GB. Signed-off-by: Simon Glass <sjg@chromium.org> --- (no changes since v1) lib/efi_client/efi_app.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/lib/efi_client/efi_app.c b/lib/efi_client/efi_app.c index 75ebe3a9719..764e562692e 100644 --- a/lib/efi_client/efi_app.c +++ b/lib/efi_client/efi_app.c @@ -92,11 +92,6 @@ static efi_status_t setup_memory(struct efi_priv *priv) efi_status_t ret; int pages; - /* - * Use global_data_ptr instead of gd since it is an assignment. There - * are very few assignments to global_data in U-Boot and this makes - * it easier to find them. - */ ptr = efi_malloc(priv, sizeof(*ptr), &ret); if (!ptr) return ret; @@ -111,8 +106,8 @@ static efi_status_t setup_memory(struct efi_priv *priv) pages = CONFIG_EFI_RAM_SIZE >> 12; /* - * Don't allocate any memory above 4GB. U-Boot is a 32-bit application - * so we want it to load below 4GB. + * Try not to allocate any memory above 4GB, just for ease of looking at + * addresses. */ addr = 1ULL << 32; ret = boot->allocate_pages(EFI_ALLOCATE_MAX_ADDRESS, -- 2.43.0

From: Simon Glass <sjg@chromium.org> Rather than immediately falling back to the pool allocator when we cannot get enough memory below 4GB, try the page allocator first. This provides 4K-aligned memory, which is nicer to look at when debugging. Signed-off-by: Simon Glass <sjg@chromium.org> --- (no changes since v1) lib/efi_client/efi_app.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/efi_client/efi_app.c b/lib/efi_client/efi_app.c index 764e562692e..92aee94a695 100644 --- a/lib/efi_client/efi_app.c +++ b/lib/efi_client/efi_app.c @@ -112,6 +112,11 @@ static efi_status_t setup_memory(struct efi_priv *priv) addr = 1ULL << 32; ret = boot->allocate_pages(EFI_ALLOCATE_MAX_ADDRESS, priv->image_data_type, pages, &addr); + if (ret) { + log_info("(any address) "); + ret = boot->allocate_pages(EFI_ALLOCATE_ANY_PAGES, + priv->image_data_type, pages, &addr); + } if (ret) { log_info("(using pool %lx) ", ret); priv->ram_base = (ulong)efi_malloc(priv, CONFIG_EFI_RAM_SIZE, @@ -123,6 +128,7 @@ static efi_status_t setup_memory(struct efi_priv *priv) log_info("(using allocated RAM address %lx) ", (ulong)addr); priv->ram_base = addr; } + gd->ram_base = addr; gd->ram_size = pages << 12; return 0; -- 2.43.0

From: Simon Glass <sjg@chromium.org> If an SMBIOS table is available, pick it up so that it can be parsed, or examined with the 'smbios' command. Signed-off-by: Simon Glass <sjg@chromium.org> --- (no changes since v1) lib/Kconfig | 3 ++- lib/efi_client/efi_app.c | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/Kconfig b/lib/Kconfig index 0834d46fbb4..ed35c1f0b30 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -1168,7 +1168,7 @@ config SPL_OID_REGISTRY config SMBIOS bool "SMBIOS support" - depends on X86 || EFI_LOADER + depends on X86 || EFI_LOADER || EFI_APP default y select LAST_STAGE_INIT imply CMD_SMBIOS if X86 @@ -1183,6 +1183,7 @@ config SMBIOS config SMBIOS_PARSER bool "SMBIOS parser" + default y if EFI_APP help A simple parser for SMBIOS data. diff --git a/lib/efi_client/efi_app.c b/lib/efi_client/efi_app.c index 92aee94a695..00022b0ab9f 100644 --- a/lib/efi_client/efi_app.c +++ b/lib/efi_client/efi_app.c @@ -159,6 +159,7 @@ static void free_memory(struct efi_priv *priv) static void scan_tables(struct efi_system_table *sys_table) { efi_guid_t acpi = EFI_ACPI_TABLE_GUID; + efi_guid_t smbios = SMBIOS3_TABLE_GUID; uint i; for (i = 0; i < sys_table->nr_tables; i++) { @@ -166,6 +167,8 @@ static void scan_tables(struct efi_system_table *sys_table) if (!memcmp(&tab->guid, &acpi, sizeof(efi_guid_t))) gd_set_acpi_start(map_to_sysmem(tab->table)); + else if (!memcmp(&tab->guid, &smbios, sizeof(efi_guid_t))) + gd->arch.smbios_start = map_to_sysmem(tab->table); } } -- 2.43.0

From: Simon Glass <sjg@chromium.org> Use the constant intended for this purpose, instead of open-coding the value. Signed-off-by: Simon Glass <sjg@chromium.org> --- (no changes since v1) lib/efi_client/efi_app.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/efi_client/efi_app.c b/lib/efi_client/efi_app.c index 00022b0ab9f..19a0032a784 100644 --- a/lib/efi_client/efi_app.c +++ b/lib/efi_client/efi_app.c @@ -149,7 +149,8 @@ static void free_memory(struct efi_priv *priv) if (priv->use_pool_for_malloc) efi_free(priv, (void *)priv->ram_base); else - boot->free_pages(priv->ram_base, gd->ram_size >> 12); + boot->free_pages(priv->ram_base, + gd->ram_size >> EFI_PAGE_SHIFT); efi_free(priv, (void *)gd->malloc_base); efi_free(priv, (void *)gd); -- 2.43.0

From: Simon Glass <sjg@chromium.org> Printing may make use of tables which could go away when freed, so do the free as the last thing before exiting the app. Signed-off-by: Simon Glass <sjg@chromium.org> --- (no changes since v1) lib/efi_client/efi_app.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/efi_client/efi_app.c b/lib/efi_client/efi_app.c index 19a0032a784..3c78165adef 100644 --- a/lib/efi_client/efi_app.c +++ b/lib/efi_client/efi_app.c @@ -231,8 +231,8 @@ static void efi_exit(void) { struct efi_priv *priv = efi_get_priv(); - free_memory(priv); printf("U-Boot EFI exiting\n"); + free_memory(priv); priv->boot->exit(priv->parent_image, EFI_SUCCESS, 0, NULL); } -- 2.43.0

From: Simon Glass <sjg@chromium.org> The new global_data is set up by the app but it never uses it. Switch to the new value after board_init_f(), so that the output of the 'meminfo' command is more contiguous. Signed-off-by: Simon Glass <sjg@chromium.org> --- (no changes since v1) lib/efi_client/efi_app.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/efi_client/efi_app.c b/lib/efi_client/efi_app.c index 3c78165adef..942c7ab5133 100644 --- a/lib/efi_client/efi_app.c +++ b/lib/efi_client/efi_app.c @@ -221,6 +221,7 @@ efi_status_t EFIAPI efi_main(efi_handle_t image, printf("starting\n"); board_init_f(GD_FLG_SKIP_RELOC); + gd = gd->new_gd; board_init_r(NULL, 0); free_memory(priv); -- 2.43.0

From: Simon Glass <sjg@chromium.org> This is quite a long dump and is only useful when debugging. Show it only if LOG_DEBUG is defined in this file. Signed-off-by: Simon Glass <sjg@chromium.org> --- (no changes since v1) lib/efi_client/efi_app.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/efi_client/efi_app.c b/lib/efi_client/efi_app.c index 942c7ab5133..28f6610e0eb 100644 --- a/lib/efi_client/efi_app.c +++ b/lib/efi_client/efi_app.c @@ -8,6 +8,8 @@ * This file implements U-Boot running as an EFI application. */ +#define LOG_CATEGORY LOGC_EFI + #include <cpu_func.h> #include <debug_uart.h> #include <dm.h> @@ -307,7 +309,9 @@ int ft_system_setup(void *fdt, struct bd_info *bd) if (ret) return log_msg_ret("erm", ret); - efi_dump_mem_table(map, size, desc_size, false); + if (_DEBUG) + efi_dump_mem_table(map, size, desc_size, false); + ram_start = -1ULL; ram_end = -1ULL; end = (void *)map + size; -- 2.43.0

From: Simon Glass <sjg@chromium.org> Use simplefb on ARM devices so that we see a console earlier, assuming that 'console=tty0' is passed to Linux. Signed-off-by: Simon Glass <sjg@chromium.org> --- (no changes since v1) configs/efi-arm_app64_defconfig | 1 + lib/efi_client/efi_app.c | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/configs/efi-arm_app64_defconfig b/configs/efi-arm_app64_defconfig index 7e7a033311c..31658c17275 100644 --- a/configs/efi-arm_app64_defconfig +++ b/configs/efi-arm_app64_defconfig @@ -15,6 +15,7 @@ CONFIG_FIT=y CONFIG_BOOTSTD_FULL=y CONFIG_SHOW_BOOT_PROGRESS=y CONFIG_OF_SYSTEM_SETUP=y +CONFIG_FDT_SIMPLEFB=y CONFIG_USE_BOOTARGS=y CONFIG_BOOTCOMMAND="bootflow scan -lbp" CONFIG_SYS_PBSIZE=532 diff --git a/lib/efi_client/efi_app.c b/lib/efi_client/efi_app.c index 28f6610e0eb..81d60f9404a 100644 --- a/lib/efi_client/efi_app.c +++ b/lib/efi_client/efi_app.c @@ -17,6 +17,7 @@ #include <efi_api.h> #include <efi_stub.h> #include <errno.h> +#include <fdt_simplefb.h> #include <image.h> #include <init.h> #include <malloc.h> @@ -339,6 +340,12 @@ int ft_system_setup(void *fdt, struct bd_info *bd) return ret; } + ret = fdt_simplefb_add_node(fdt); + if (ret) { + printf("failed to set up simplefb\n"); + return ret; + } + free(map); return 0; -- 2.43.0

From: Simon Glass <sjg@chromium.org> The video sync sometimes takes 20ms on this board when running under emulation, so increase the limit to 50ms. Signed-off-by: Simon Glass <sjg@chromium.org> --- (no changes since v1) configs/efi-arm_app64_defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configs/efi-arm_app64_defconfig b/configs/efi-arm_app64_defconfig index 31658c17275..4cadaeaedb8 100644 --- a/configs/efi-arm_app64_defconfig +++ b/configs/efi-arm_app64_defconfig @@ -21,7 +21,7 @@ CONFIG_BOOTCOMMAND="bootflow scan -lbp" CONFIG_SYS_PBSIZE=532 CONFIG_SYS_CONSOLE_INFO_QUIET=y CONFIG_LOG=y -CONFIG_CYCLIC_MAX_CPU_TIME_US=15000 +CONFIG_CYCLIC_MAX_CPU_TIME_US=50000 CONFIG_BOARD_EARLY_INIT_R=y CONFIG_CMD_BOOTZ=y CONFIG_CMD_MEMINFO=y -- 2.43.0

From: Simon Glass <sjg@chromium.org> When running with a vidconsole we only see the prompt at the top of the display. Set the option to show the model as well. Signed-off-by: Simon Glass <sjg@chromium.org> --- (no changes since v1) configs/efi-arm_app64_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/efi-arm_app64_defconfig b/configs/efi-arm_app64_defconfig index 4cadaeaedb8..2b686d882e6 100644 --- a/configs/efi-arm_app64_defconfig +++ b/configs/efi-arm_app64_defconfig @@ -21,6 +21,7 @@ CONFIG_BOOTCOMMAND="bootflow scan -lbp" CONFIG_SYS_PBSIZE=532 CONFIG_SYS_CONSOLE_INFO_QUIET=y CONFIG_LOG=y +CONFIG_DISPLAY_BOARDINFO_LATE=y CONFIG_CYCLIC_MAX_CPU_TIME_US=50000 CONFIG_BOARD_EARLY_INIT_R=y CONFIG_CMD_BOOTZ=y -- 2.43.0

From: Simon Glass <sjg@chromium.org> This can be handy for looking at extlinux.conf files, so enable it for the app. Signed-off-by: Simon Glass <sjg@chromium.org> --- (no changes since v1) configs/efi-arm_app64_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/efi-arm_app64_defconfig b/configs/efi-arm_app64_defconfig index 2b686d882e6..2bc7a87506d 100644 --- a/configs/efi-arm_app64_defconfig +++ b/configs/efi-arm_app64_defconfig @@ -29,6 +29,7 @@ CONFIG_CMD_MEMINFO=y CONFIG_CMD_MEMINFO_MAP=y CONFIG_CMD_DM=y CONFIG_CMD_LSBLK=y +CONFIG_CMD_CAT=y CONFIG_CMD_CACHE=y CONFIG_CMD_TIME=y CONFIG_CMD_EXT4_WRITE=y -- 2.43.0
participants (1)
-
Simon Glass