efi: Move ARM over to use the common efi_main() function

Fill in the required helper functions and call efi_main_common() to
do everything else.

Delete the old efi_main() function.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass
2025-06-12 07:59:55 -06:00
parent cf92622d07
commit c3c7d368a0
2 changed files with 17 additions and 82 deletions

View File

@@ -156,11 +156,10 @@ efi_status_t EFIAPI efi_main_common(efi_handle_t image,
}
efi_set_priv(priv);
#ifdef CONFIG_X86
ret = arch_efi_main_init(priv, boot);
if (ret)
return ret;
#endif
ret = efi_store_memory_map(priv);
if (ret)
return ret;
@@ -207,9 +206,7 @@ efi_status_t EFIAPI efi_main_common(efi_handle_t image,
printhex8(priv->info->total_size);
putc('\n');
#endif
#ifdef CONFIG_X86
arch_efi_jump_to_payload(priv);
#endif
return EFI_LOAD_ERROR;
}

View File

@@ -48,35 +48,12 @@ void puts(const char *str)
putc(*str++);
}
/**
* efi_main() - Start an EFI image
*
* This function is called by our EFI start-up code. It handles running
* U-Boot. If it returns, EFI will continue.
*/
efi_status_t EFIAPI efi_main(efi_handle_t image,
struct efi_system_table *sys_table)
efi_status_t arch_efi_main_init(struct efi_priv *priv,
struct efi_boot_services *boot)
{
struct efi_priv local_priv, *priv = &local_priv;
struct efi_boot_services *boot = sys_table->boottime;
struct efi_entry_memmap map;
struct efi_gop *gop;
struct efi_entry_gopmode mode;
struct efi_entry_systable table;
efi_guid_t efi_gop_guid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID;
efi_status_t ret;
use_hw_uart = false;
ret = efi_init(priv, "Payload", image, sys_table);
if (ret) {
printhex2(ret);
puts(" efi_init() failed\n");
return ret;
}
efi_set_priv(priv);
phys_addr_t reloc_addr = ULONG_MAX;
int ret;
ret = boot->allocate_pages(EFI_ALLOCATE_MAX_ADDRESS, EFI_LOADER_CODE,
(phys_addr_t)_binary_u_boot_bin_size / EFI_PAGE_SIZE,
&reloc_addr);
@@ -86,59 +63,20 @@ efi_status_t EFIAPI efi_main(efi_handle_t image,
putc('\n');
return ret;
}
priv->jump_addr = reloc_addr;
ret = efi_store_memory_map(priv);
if (ret)
return ret;
return 0;
}
ret = setup_info_table(priv, priv->memmap_size + 128);
if (ret)
return ret;
ret = boot->locate_protocol(&efi_gop_guid, NULL, (void **)&gop);
if (ret) {
puts(" GOP unavailable\n");
} else {
mode.fb_base = gop->mode->fb_base;
mode.fb_size = gop->mode->fb_size;
mode.info_size = gop->mode->info_size;
add_entry_addr(priv, EFIET_GOP_MODE, &mode, sizeof(mode),
gop->mode->info,
sizeof(struct efi_gop_mode_info));
}
table.sys_table = (ulong)sys_table;
add_entry_addr(priv, EFIET_SYS_TABLE, &table, sizeof(table), NULL, 0);
ret = efi_stub_exit_boot_services();
if (ret)
return ret;
/* The EFI console won't work now :( */
use_hw_uart = true;
map.version = priv->memmap_version;
map.desc_size = priv->memmap_desc_size;
add_entry_addr(priv, EFIET_MEMORY_MAP, &map, sizeof(map),
priv->memmap_desc, priv->memmap_size);
add_entry_addr(priv, EFIET_END, NULL, 0, 0, 0);
memcpy((void *)reloc_addr, _binary_u_boot_bin_start,
(ulong)_binary_u_boot_bin_end -
(ulong)_binary_u_boot_bin_start);
/* This will only work if you patched your own debug uart into this file. */
#ifdef DEBUG
puts("EFI table at ");
printhex8((ulong)priv->info);
puts(" size ");
printhex8(priv->info->total_size);
putc('\n');
#endif
void arch_efi_jump_to_payload(struct efi_priv *priv)
{
typedef void (*func_t)(u64 x0, u64 x1, u64 x2, u64 x3);
puts("Jumping to U-Boot\n");
((func_t)reloc_addr)((phys_addr_t)priv->info, 0, 0, 0);
return EFI_LOAD_ERROR;
((func_t)priv->jump_addr)((phys_addr_t)priv->info, 0, 0, 0);
}
efi_status_t EFIAPI efi_main(efi_handle_t image,
struct efi_system_table *sys_table)
{
return efi_main_common(image, sys_table);
}