efi: Add a flag to enable ulib

When running as an EFI app we should set the ulib flag early so as to
avoid printing unwanted output on start. Add a parameter to
efi_startup() to control whether ulib is used.

Drop the starting message in this case.

Signed-off-by: Simon Glass <simon.glass@canonical.com>
This commit is contained in:
Simon Glass
2025-11-06 13:54:06 +01:00
parent dc475d0c11
commit 5ea9e69b82
4 changed files with 17 additions and 8 deletions

View File

@@ -963,9 +963,11 @@ int efi_decode_key_ex(struct efi_key_data *key_data);
*
* @image: Image handle for the app
* @systab: EFI system table to use with the app
* @is_ulib: True if using U-Boot library
* Return: Error code
*/
efi_status_t efi_startup(efi_handle_t image, struct efi_system_table *systab);
efi_status_t EFIAPI efi_startup(efi_handle_t image, struct efi_system_table *systab,
bool is_ulib);
/**
* efi_shutdown() - Shut down the app

View File

@@ -427,15 +427,17 @@ static int efi_reserve_priv(void *ctx, struct event *event)
}
EVENT_SPY_FULL(EVT_RESERVE_BOARD, efi_reserve_priv);
efi_status_t efi_startup(efi_handle_t image, struct efi_system_table *systab)
efi_status_t EFIAPI efi_startup(efi_handle_t image,
struct efi_system_table *systab, bool is_ulib)
{
struct efi_priv local_priv, *priv = &local_priv;
efi_status_t ret;
bool verbose = !is_ulib;
/* Set up access to EFI data structures */
ret = efi_init(priv, "App", image, systab, true);
ret = efi_init(priv, "App", image, systab, verbose);
if (ret) {
printf("Failed to set up U-Boot: err=%lx\n", ret);
printf("Failed to set up ulib: err=%lx\n", ret);
return ret;
}
efi_set_priv(priv);
@@ -447,7 +449,8 @@ efi_status_t efi_startup(efi_handle_t image, struct efi_system_table *systab)
*/
debug_uart_init();
ret = setup_memory(priv, true);
/* allocate some memory and set gd */
ret = setup_memory(priv, verbose);
if (ret) {
printf("Failed to set up memory: ret=%lx\n", ret);
return ret;
@@ -465,9 +468,11 @@ efi_status_t efi_startup(efi_handle_t image, struct efi_system_table *systab)
* return ret;
*/
printf("starting\n");
if (!is_ulib)
printf("starting\n");
board_init_f(GD_FLG_SKIP_RELOC |
(is_ulib ? GD_FLG_ULIB : 0) |
(detect_emulator() ? GD_FLG_EMUL : 0));
gd = gd->new_gd;
board_init_r(NULL, 0);

View File

@@ -204,7 +204,9 @@ static int setup_block(void)
log_debug("%2d: %-12s %ls\n", i,
dev ? dev->name : "<partition>", name);
}
log_info("EFI: disks %d, partitions %d\n", num_disks, num_parts);
if (!gd_ulib())
log_info("EFI: disks %d, partitions %d\n", num_disks,
num_parts);
boot->free_pool(handle);
return 0;

View File

@@ -14,7 +14,7 @@ efi_status_t EFIAPI efi_main(efi_handle_t image,
{
efi_status_t ret;
ret = efi_startup(image, sys_table);
ret = efi_startup(image, sys_table, false);
if (ret)
return ret;