mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-18 13:11:31 +00:00
Pull request for UEFI sub-system for efi-2020-01-rc3
The following changes for the UEFI subsystem are provided: * allow building UEFI binaries on the sandbox * enable access to file systems without partition tables * correctly check the return value of efi_dp_from_file() -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEbcT5xx8ppvoGt20zxIHbvCwFGsQFAl3MwpkACgkQxIHbvCwF GsTX5w/+J468shJXKYU4JseGmCdfMdkuX/0foEm4nXcMx/Mi1RjpJRrlMtvG8Nzm EtPt60GeV/xj2+poVsc4tBbrHQOamDCOH//TFj/SwNIYoU4MGccS4gZVVOnM1M7e IOebSk0V7TLcnu0LlfIn+fjGszTdh7n73McONIgaH/JPydG3Gsp53PsrxLF6u1uS tflVEy3Bjy+NsnpYwOjIGZ9iqY2BZFn3r+VprenoJRYh1Ohc7AmcoCGgxEyl2INk X2nXrspgZ1ROHlRCgETP2fQ3+ArLBR4qNp4sTtXBX0PtP03ZIDf6AZqtvxBhDRVI vyMxu/VZbdhN4Kyn/tkTssULBjn2Z8e5FLpZ/Gt+Evkns02Pt+ga0xE0Yos1DwEe H2I3l1wlL9dxRBKDpjlj2xw4+27sA/6ahajb7wyk9SMKGhoVp3N+Lgmvp/U6Hmvc rLS9kynv5zEh3lpvRrn9P+OMVxxtUKZJwS5h31/pwlQG2FjGPsyOhfNhJ08uIGHW NOQiXZVnBZu7qwn8DVunEnJn8fnyZJiaTxaH61UaVGt6XljJXO35RRUjrYN1WvlM YixcAVbsALrUC0FMOrY0d1pxxoEP4xutNlMnK4rsTlaa39R4UhFuCOEGJmJoPR6o D2bYfIspDe7vFP7KZrM+fsQMHQZC3gn1clVHf9TzSyviotiKIVc= =KBnO -----END PGP SIGNATURE----- Merge tag 'efi-2020-01-rc3' of https://gitlab.denx.de/u-boot/custodians/u-boot-efi Pull request for UEFI sub-system for efi-2020-01-rc3 The following changes for the UEFI subsystem are provided: * allow building UEFI binaries on the sandbox * enable access to file systems without partition tables * correctly check the return value of efi_dp_from_file()
This commit is contained in:
commit
14b254b5f5
11 changed files with 164 additions and 11 deletions
19
Makefile
19
Makefile
|
@ -17,6 +17,25 @@ NAME =
|
|||
# o Look for make include files relative to root of kernel src
|
||||
MAKEFLAGS += -rR --include-dir=$(CURDIR)
|
||||
|
||||
# Determine host architecture
|
||||
include include/host_arch.h
|
||||
MK_ARCH="${shell uname -m}"
|
||||
unexport HOST_ARCH
|
||||
ifeq ("x86_64", $(MK_ARCH))
|
||||
export HOST_ARCH=$(HOST_ARCH_X86_64)
|
||||
else ifneq (,$(findstring $(MK_ARCH), "i386" "i486" "i586" "i686"))
|
||||
export HOST_ARCH=$(HOST_ARCH_X86)
|
||||
else ifneq (,$(findstring $(MK_ARCH), "aarch64" "armv8l"))
|
||||
export HOST_ARCH=$(HOST_ARCH_AARCH64)
|
||||
else ifeq ("armv7l", $(MK_ARCH))
|
||||
export HOST_ARCH=$(HOST_ARCH_ARM)
|
||||
else ifeq ("riscv32", $(MK_ARCH))
|
||||
export HOST_ARCH=$(HOST_ARCH_RISCV32)
|
||||
else ifeq ("riscv64", $(MK_ARCH))
|
||||
export HOST_ARCH=$(HOST_ARCH_RISCV64)
|
||||
endif
|
||||
undefine MK_ARCH
|
||||
|
||||
# Avoid funny character set dependencies
|
||||
unexport LC_ALL
|
||||
LC_COLLATE=C
|
||||
|
|
|
@ -27,3 +27,31 @@ cmd_u-boot-spl = (cd $(obj) && $(CC) -o $(SPL_BIN) -Wl,-T u-boot-spl.lds \
|
|||
$(PLATFORM_LIBS) -Wl,-Map -Wl,u-boot-spl.map -Wl,--gc-sections)
|
||||
|
||||
CONFIG_ARCH_DEVICE_TREE := sandbox
|
||||
|
||||
ifeq ($(HOST_ARCH),$(HOST_ARCH_X86_64))
|
||||
EFI_LDS := ${SRCDIR}/../../../arch/x86/lib/elf_x86_64_efi.lds
|
||||
EFI_TARGET := --target=efi-app-x86_64
|
||||
else ifeq ($(HOST_ARCH),$(HOST_ARCH_X86))
|
||||
EFI_LDS := ${SRCDIR}/../../../arch/x86/lib/elf_ia32_efi.lds
|
||||
EFI_TARGET := --target=efi-app-ia32
|
||||
else ifeq ($(HOST_ARCH),$(HOST_ARCH_AARCH64))
|
||||
EFI_LDS := ${SRCDIR}/../../../arch/arm/lib/elf_aarch64_efi.lds
|
||||
OBJCOPYFLAGS += -j .text -j .secure_text -j .secure_data -j .rodata -j .data \
|
||||
-j .u_boot_list -j .rela.dyn -j .got -j .got.plt \
|
||||
-j .binman_sym_table -j .text_rest \
|
||||
-j .efi_runtime -j .efi_runtime_rel
|
||||
else ifeq ($(HOST_ARCH),$(HOST_ARCH_ARM))
|
||||
EFI_LDS := ${SRCDIR}/../../../arch/arm/lib/elf_arm_efi.lds
|
||||
OBJCOPYFLAGS += -j .text -j .secure_text -j .secure_data -j .rodata -j .hash \
|
||||
-j .data -j .got -j .got.plt -j .u_boot_list -j .rel.dyn \
|
||||
-j .binman_sym_table -j .text_rest \
|
||||
-j .efi_runtime -j .efi_runtime_rel
|
||||
else ifeq ($(HOST_ARCH),$(HOST_ARCH_RISCV32))
|
||||
EFI_LDS := ${SRCDIR}/../../../arch/riscv/lib/elf_riscv32_efi.lds
|
||||
else ifeq ($(HOST_ARCH),$(HOST_ARCH_RISCV64))
|
||||
EFI_LDS := ${SRCDIR}/../../../arch/riscv/lib/elf_riscv64_efi.lds
|
||||
endif
|
||||
EFI_CRT0 := crt0_sandbox_efi.o
|
||||
EFI_RELOC := reloc_sandbox_efi.o
|
||||
AFLAGS_crt0_sandbox_efi.o += -DHOST_ARCH="$(HOST_ARCH)"
|
||||
CFLAGS_reloc_sandbox_efi.o += -DHOST_ARCH="$(HOST_ARCH)"
|
||||
|
|
32
arch/sandbox/lib/crt0_sandbox_efi.S
Normal file
32
arch/sandbox/lib/crt0_sandbox_efi.S
Normal file
|
@ -0,0 +1,32 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||
/*
|
||||
* PE/COFF header for EFI applications
|
||||
*
|
||||
* Copyright (c) 2019 Heinrich Schuchardt
|
||||
*/
|
||||
|
||||
#include <host_arch.h>
|
||||
|
||||
#if HOST_ARCH == HOST_ARCH_X86_64
|
||||
#include "../../../arch/x86/lib/crt0_x86_64_efi.S"
|
||||
#endif
|
||||
|
||||
#if HOST_ARCH == HOST_ARCH_X86
|
||||
#include "../../../arch/x86/lib/crt0_ia32_efi.S"
|
||||
#endif
|
||||
|
||||
#if HOST_ARCH == HOST_ARCH_AARCH64
|
||||
#include "../../../arch/arm/lib/crt0_aarch64_efi.S"
|
||||
#endif
|
||||
|
||||
#if HOST_ARCH == HOST_ARCH_ARM
|
||||
#include "../../../arch/arm/lib/crt0_arm_efi.S"
|
||||
#endif
|
||||
|
||||
#if HOST_ARCH == HOST_ARCH_RISCV32
|
||||
#include "../../../arch/riscv/lib/crt0_riscv_efi.S"
|
||||
#endif
|
||||
|
||||
#if HOST_ARCH == HOST_ARCH_RISCV64
|
||||
#include "../../../arch/riscv/lib/crt0_riscv_efi.S"
|
||||
#endif
|
32
arch/sandbox/lib/reloc_sandbox_efi.c
Normal file
32
arch/sandbox/lib/reloc_sandbox_efi.c
Normal file
|
@ -0,0 +1,32 @@
|
|||
// SPDX-License-Identifier: GPL-2.0+
|
||||
/*
|
||||
* position independent shared object relocator
|
||||
*
|
||||
* Copyright (c) 2019 Heinrich Schuchardt
|
||||
*/
|
||||
|
||||
#include <host_arch.h>
|
||||
|
||||
#if HOST_ARCH == HOST_ARCH_X86_64
|
||||
#include "../../../arch/x86/lib/reloc_x86_64_efi.c"
|
||||
#endif
|
||||
|
||||
#if HOST_ARCH == HOST_ARCH_X86
|
||||
#include "../../../arch/x86/lib/reloc_ia32_efi.c"
|
||||
#endif
|
||||
|
||||
#if HOST_ARCH == HOST_ARCH_AARCH64
|
||||
#include "../../../arch/arm/lib/reloc_aarch64_efi.c"
|
||||
#endif
|
||||
|
||||
#if HOST_ARCH == HOST_ARCH_ARM
|
||||
#include "../../../arch/arm/lib/reloc_arm_efi.c"
|
||||
#endif
|
||||
|
||||
#if HOST_ARCH == HOST_ARCH_RISCV32
|
||||
#include "../../../arch/riscv/lib/reloc_riscv_efi.c"
|
||||
#endif
|
||||
|
||||
#if HOST_ARCH == HOST_ARCH_RISCV64
|
||||
#include "../../../arch/riscv/lib/reloc_riscv_efi.c"
|
||||
#endif
|
|
@ -320,7 +320,7 @@ config CMD_BOOTEFI
|
|||
|
||||
config CMD_BOOTEFI_HELLO_COMPILE
|
||||
bool "Compile a standard EFI hello world binary for testing"
|
||||
depends on CMD_BOOTEFI && !CPU_V7M && !SANDBOX
|
||||
depends on CMD_BOOTEFI && !CPU_V7M
|
||||
default y
|
||||
help
|
||||
This compiles a standard EFI hello world application with U-Boot so
|
||||
|
|
24
include/host_arch.h
Normal file
24
include/host_arch.h
Normal file
|
@ -0,0 +1,24 @@
|
|||
#if 0
|
||||
# SPDX SPDX-License-Identifier: GPL-2.0+
|
||||
#
|
||||
# Constants defining the host architecture in assembler, C, and make files.
|
||||
# The values are arbitrary.
|
||||
#
|
||||
# Copyright 2019 Heinrich Schuchardt <xypron.glpk@gmx.de>
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
export HOST_ARCH_AARCH64=0xaa64
|
||||
export HOST_ARCH_ARM=0x00a7
|
||||
export HOST_ARCH_RISCV32=0x5032
|
||||
export HOST_ARCH_RISCV64=0x5064
|
||||
export HOST_ARCH_X86=0x0386
|
||||
export HOST_ARCH_X86_64=0x8664
|
||||
#endif
|
||||
|
||||
#define HOST_ARCH_AARCH64 0xaa64
|
||||
#define HOST_ARCH_ARM 0x00a7
|
||||
#define HOST_ARCH_RISCV32 0x5032
|
||||
#define HOST_ARCH_RISCV64 0x5064
|
||||
#define HOST_ARCH_X86 0x0386
|
||||
#define HOST_ARCH_X86_64 0x8664
|
|
@ -6,6 +6,9 @@
|
|||
# This file only gets included with CONFIG_EFI_LOADER set, so all
|
||||
# object inclusion implicitly depends on it
|
||||
|
||||
asflags-y += -DHOST_ARCH="$(HOST_ARCH)"
|
||||
ccflags-y += -DHOST_ARCH="$(HOST_ARCH)"
|
||||
|
||||
CFLAGS_efi_boottime.o += \
|
||||
-DFW_VERSION="0x$(VERSION)" \
|
||||
-DFW_PATCHLEVEL="0x$(PATCHLEVEL)"
|
||||
|
|
|
@ -1032,6 +1032,16 @@ out:
|
|||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* efi_dp_from_name() - convert U-Boot device and file path to device path
|
||||
*
|
||||
* @dev: U-Boot device, e.g. 'mmc'
|
||||
* @devnr: U-Boot device number, e.g. 1 for 'mmc:1'
|
||||
* @path: file path relative to U-Boot device, may be NULL
|
||||
* @device: pointer to receive device path of the device
|
||||
* @file: pointer to receive device path for the file
|
||||
* Return: status code
|
||||
*/
|
||||
efi_status_t efi_dp_from_name(const char *dev, const char *devnr,
|
||||
const char *path,
|
||||
struct efi_device_path **device,
|
||||
|
@ -1071,10 +1081,9 @@ efi_status_t efi_dp_from_name(const char *dev, const char *devnr,
|
|||
s = filename;
|
||||
while ((s = strchr(s, '/')))
|
||||
*s++ = '\\';
|
||||
*file = efi_dp_from_file(((!is_net && device) ? desc : NULL),
|
||||
part, filename);
|
||||
*file = efi_dp_from_file(is_net ? NULL : desc, part, filename);
|
||||
|
||||
if (!file)
|
||||
if (!*file)
|
||||
return EFI_INVALID_PARAMETER;
|
||||
|
||||
return EFI_SUCCESS;
|
||||
|
|
|
@ -337,7 +337,9 @@ static efi_status_t efi_disk_add_dev(
|
|||
diskobj->dp);
|
||||
if (ret != EFI_SUCCESS)
|
||||
return ret;
|
||||
if (part >= 1 && efi_fs_exists(desc, part)) {
|
||||
/* partitions or whole disk without partitions */
|
||||
if ((part || desc->part_type == PART_TYPE_UNKNOWN) &&
|
||||
efi_fs_exists(desc, part)) {
|
||||
diskobj->volume = efi_simple_file_system(desc, part,
|
||||
diskobj->dp);
|
||||
ret = efi_add_protocol(&diskobj->header,
|
||||
|
|
|
@ -738,8 +738,10 @@ static void add_u_boot_and_runtime(void)
|
|||
unsigned long uboot_stack_size = 16 * 1024 * 1024;
|
||||
|
||||
/* Add U-Boot */
|
||||
uboot_start = (gd->start_addr_sp - uboot_stack_size) & ~EFI_PAGE_MASK;
|
||||
uboot_pages = (gd->ram_top - uboot_start) >> EFI_PAGE_SHIFT;
|
||||
uboot_start = ((uintptr_t)map_sysmem(gd->start_addr_sp, 0) -
|
||||
uboot_stack_size) & ~EFI_PAGE_MASK;
|
||||
uboot_pages = ((uintptr_t)map_sysmem(gd->ram_top - 1, 0) -
|
||||
uboot_start + EFI_PAGE_MASK) >> EFI_PAGE_SHIFT;
|
||||
efi_add_memory_map(uboot_start, uboot_pages, EFI_LOADER_DATA, false);
|
||||
|
||||
#if defined(__aarch64__)
|
||||
|
@ -767,8 +769,7 @@ int efi_memory_init(void)
|
|||
{
|
||||
efi_add_known_memory();
|
||||
|
||||
if (!IS_ENABLED(CONFIG_SANDBOX))
|
||||
add_u_boot_and_runtime();
|
||||
add_u_boot_and_runtime();
|
||||
|
||||
#ifdef CONFIG_EFI_LOADER_BOUNCE_BUFFER
|
||||
/* Request a 32bit 64MB bounce buffer region */
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
# This file only gets included with CONFIG_EFI_LOADER set, so all
|
||||
# object inclusion implicitly depends on it
|
||||
|
||||
asflags-y += -DHOST_ARCH="$(HOST_ARCH)"
|
||||
ccflags-y += -DHOST_ARCH="$(HOST_ARCH)"
|
||||
|
||||
CFLAGS_efi_selftest_miniapp_exit.o := $(CFLAGS_EFI) -Os -ffreestanding
|
||||
CFLAGS_REMOVE_efi_selftest_miniapp_exit.o := $(CFLAGS_NON_EFI)
|
||||
CFLAGS_efi_selftest_miniapp_return.o := $(CFLAGS_EFI) -Os -ffreestanding
|
||||
|
@ -55,8 +58,8 @@ obj-y += efi_selftest_block_device.o
|
|||
endif
|
||||
|
||||
# TODO: As of v2019.10 the relocation code for the EFI application cannot
|
||||
# be built on ARMv7-M and Sandbox.
|
||||
ifeq ($(CONFIG_SANDBOX)$(CONFIG_CPU_V7M),)
|
||||
# be built on ARMv7-M.
|
||||
ifeq ($(CONFIG_CPU_V7M),)
|
||||
|
||||
obj-y += \
|
||||
efi_selftest_exception.o \
|
||||
|
|
Loading…
Add table
Reference in a new issue