Files
u-boot/lib/efi_client/stub_arm64.c
Simon Glass 5209eaf9e5 efi: Switch x86 and ARM to use the unified stub
Now that the stub code is unified, switch over to it, dropping the
individual efi_main() functions.

Series-to: concept
Cover-letter:
efi: Unify the scripts and start-up code
We have two scripts which run QEMU, one for EFI and one for bare metal.
They have similar options so it seems reasonable to try to unify them a
bit. This series creates a common file and adjusts arguments so they are
consistent across both scripts.

The EFI app for ARM and x86 have different start-up code but in fact
the code is quiet similar. This series creates a new common main
program, called efi_main_common() which is used for both architectures.
The small number of differences are handled in arch-specific code.
END
2025-06-30 14:28:08 -06:00

77 lines
1.6 KiB
C

// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright (c) 2015 Google, Inc
* Copyright (c) 2024 Linaro, Ltd.
*
* EFI information obtained here:
* http://wiki.phoenix.com/wiki/index.php/EFI_BOOT_SERVICES
*
* Call ExitBootServices() and launch U-Boot from an EFI environment.
*/
#include <debug_uart.h>
#include <efi.h>
#include <efi_api.h>
#include <efi_stub.h>
#include <malloc.h>
#include <asm/io.h>
#include <linux/err.h>
#include <linux/types.h>
void _debug_uart_putc(int ch)
{
struct efi_priv *priv = efi_get_priv();
if (ch == '\n')
_debug_uart_putc('\r');
/*
* After calling EBS we can't log anywhere.
* NOTE: for development it is possible to re-implement
* your boards debug uart here like in efi_stub.c for x86.
*/
if (!use_hw_uart)
efi_putc(priv, ch);
}
void _debug_uart_init(void) {}
DEBUG_UART_FUNCS;
void putc(const char ch)
{
_debug_uart_putc(ch);
}
void puts(const char *str)
{
while (*str)
putc(*str++);
}
efi_status_t arch_efi_main_init(struct efi_priv *priv,
struct efi_boot_services *boot)
{
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);
if (ret != EFI_SUCCESS) {
puts("Failed to allocate memory for U-Boot: ");
printhex2(ret);
putc('\n');
return ret;
}
priv->jump_addr = reloc_addr;
return 0;
}
void arch_efi_jump_to_payload(struct efi_priv *priv)
{
typedef void (*func_t)(u64 x0, u64 x1, u64 x2, u64 x3);
((func_t)priv->jump_addr)((phys_addr_t)priv->info, 0, 0, 0);
}