efi: Move x86 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 c0c2b1237e
commit cf92622d07
4 changed files with 23 additions and 75 deletions

View File

@@ -156,7 +156,7 @@ efi_status_t EFIAPI efi_main_common(efi_handle_t image,
}
efi_set_priv(priv);
#if 0 /* to be enabled */
#ifdef CONFIG_X86
ret = arch_efi_main_init(priv, boot);
if (ret)
return ret;
@@ -207,7 +207,7 @@ efi_status_t EFIAPI efi_main_common(efi_handle_t image,
printhex8(priv->info->total_size);
putc('\n');
#endif
#if 0 /* to be enabled */
#ifdef CONFIG_X86
arch_efi_jump_to_payload(priv);
#endif

View File

@@ -201,85 +201,28 @@ static int get_codeseg32(void)
return cs32;
}
/**
* 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;
int cs32;
ret = efi_init(priv, "Payload", image, sys_table);
if (ret) {
printhex2(ret);
puts(" efi_init() failed\n");
return ret;
}
efi_set_priv(priv);
cs32 = get_codeseg32();
if (cs32 < 0)
return EFI_UNSUPPORTED;
priv->x86_cs32 = cs32;
ret = efi_store_memory_map(priv);
if (ret)
return ret;
priv->jump_addr = CONFIG_TEXT_BASE;
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 UART won't work now, switch to a debug one */
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 *)CONFIG_TEXT_BASE, _binary_u_boot_bin_start,
(ulong)_binary_u_boot_bin_end -
(ulong)_binary_u_boot_bin_start);
#ifdef DEBUG
puts("EFI table at ");
printhex8((ulong)priv->info);
puts(" size ");
printhex8(priv->info->total_size);
#endif
putc('\n');
jump_to_uboot(cs32, CONFIG_TEXT_BASE, (ulong)priv->info);
return EFI_LOAD_ERROR;
return 0;
}
void arch_efi_jump_to_payload(struct efi_priv *priv)
{
jump_to_uboot(priv->x86_cs32, priv->jump_addr, (ulong)priv->info);
}
efi_status_t EFIAPI efi_main(efi_handle_t image,
struct efi_system_table *sys_table)
{
return efi_main_common(image, sys_table);
}