
From: Simon Glass <sjg@chromium.org> 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> --- include/efi.h | 2 + include/efi_stub.h | 3 ++ lib/efi_client/stub.c | 4 +- lib/efi_client/stub_x86.c | 85 +++++++-------------------------------- 4 files changed, 21 insertions(+), 73 deletions(-) diff --git a/include/efi.h b/include/efi.h index 7a725343616..302c662a8a7 100644 --- a/include/efi.h +++ b/include/efi.h @@ -474,6 +474,7 @@ static inline struct efi_mem_desc *efi_get_next_mem_desc( * @info_size: Size of the info list @info in bytes * @next_hdr: Pointer to where to put the next header when adding to the list * @jump_addr: Address to jump to to start U-Boot + * @x86_cs32: x86 code-segment to use for U-Boot */ struct efi_priv { efi_handle_t parent_image; @@ -498,6 +499,7 @@ struct efi_priv { unsigned int info_size; void *next_hdr; ulong jump_addr; + int x86_cs32; }; /* diff --git a/include/efi_stub.h b/include/efi_stub.h index 8dcde1b61d1..17637a8845d 100644 --- a/include/efi_stub.h +++ b/include/efi_stub.h @@ -120,6 +120,9 @@ efi_status_t arch_efi_main_init(struct efi_priv *priv, */ void arch_efi_jump_to_payload(struct efi_priv *priv); +efi_status_t EFIAPI efi_main_common(efi_handle_t image, + struct efi_system_table *sys_table); + /* true if we must use the hardware UART directory (EFI not available) */ extern bool use_hw_uart; diff --git a/lib/efi_client/stub.c b/lib/efi_client/stub.c index 2681714d068..0ee6e0135bb 100644 --- a/lib/efi_client/stub.c +++ b/lib/efi_client/stub.c @@ -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 diff --git a/lib/efi_client/stub_x86.c b/lib/efi_client/stub_x86.c index e9276ee825d..66349136e44 100644 --- a/lib/efi_client/stub_x86.c +++ b/lib/efi_client/stub_x86.c @@ -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; - - 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); + priv->jump_addr = CONFIG_TEXT_BASE; - 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); + return 0; +} -#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); +void arch_efi_jump_to_payload(struct efi_priv *priv) +{ + jump_to_uboot(priv->x86_cs32, priv->jump_addr, (ulong)priv->info); +} - return EFI_LOAD_ERROR; +efi_status_t EFIAPI efi_main(efi_handle_t image, + struct efi_system_table *sys_table) +{ + return efi_main_common(image, sys_table); } -- 2.43.0