diff options
Diffstat (limited to 'lib')
150 files changed, 1304 insertions, 327 deletions
diff --git a/lib/Kconfig b/lib/Kconfig index 19649517a3..37ac14f7ba 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -74,6 +74,13 @@ config HAVE_PRIVATE_LIBGCC config LIB_UUID bool +config RANDOM_UUID + bool "GPT Random UUID generation" + select LIB_UUID + help + Enable the generation of partitions with random UUIDs if none + are provided. + config SPL_LIB_UUID depends on SPL bool @@ -93,7 +100,7 @@ config SEMIHOSTING config SEMIHOSTING_FALLBACK bool "Recover gracefully when semihosting fails" - depends on SEMIHOSTING && (ARM64 || RISCV) + depends on SEMIHOSTING default y help Normally, if U-Boot makes a semihosting call and no debugger is @@ -116,7 +123,7 @@ config SPL_SEMIHOSTING config SPL_SEMIHOSTING_FALLBACK bool "Recover gracefully when semihosting fails in SPL" - depends on SPL_SEMIHOSTING && (ARM64 || RISCV) + depends on SPL_SEMIHOSTING select ARMV8_SPL_EXCEPTION_VECTORS if ARM64 default y help @@ -995,7 +1002,7 @@ config GENERATE_SMBIOS_TABLE Check http://www.dmtf.org/standards/smbios for details. - See also SMBIOS_SYSINFO which allows SMBIOS values to be provided in + See also SYSINFO_SMBIOS which allows SMBIOS values to be provided in the devicetree. endmenu diff --git a/lib/abuf.c b/lib/abuf.c index ce2cff53dc..937c3df351 100644 --- a/lib/abuf.c +++ b/lib/abuf.c @@ -7,7 +7,6 @@ */ #ifndef USE_HOSTCC -#include <common.h> #include <malloc.h> #include <mapmem.h> #include <string.h> diff --git a/lib/acpi/Makefile b/lib/acpi/Makefile index c1c9675b5d..cc2868488a 100644 --- a/lib/acpi/Makefile +++ b/lib/acpi/Makefile @@ -12,7 +12,7 @@ obj-$(CONFIG_$(SPL_)ACPIGEN) += acpi_table.o obj-y += acpi_writer.o # With QEMU the ACPI tables come from there, not from U-Boot -ifndef CONFIG_QEMU +ifndef CONFIG_QFW_ACPI obj-y += base.o obj-y += csrt.o obj-y += mcfg.o diff --git a/lib/acpi/acpi.c b/lib/acpi/acpi.c index 14b15754f4..f4d5c1e25d 100644 --- a/lib/acpi/acpi.c +++ b/lib/acpi/acpi.c @@ -5,7 +5,6 @@ * Copyright 2023 Google LLC */ -#include <common.h> #include <mapmem.h> #include <acpi/acpi_table.h> #include <asm/global_data.h> @@ -16,28 +15,59 @@ struct acpi_table_header *acpi_find_table(const char *sig) { struct acpi_rsdp *rsdp; struct acpi_rsdt *rsdt; + struct acpi_xsdt *xsdt; int len, i, count; rsdp = map_sysmem(gd_acpi_start(), 0); if (!rsdp) return NULL; - rsdt = map_sysmem(rsdp->rsdt_address, 0); - len = rsdt->header.length - sizeof(rsdt->header); - count = len / sizeof(u32); + if (rsdp->xsdt_address) { + xsdt = nomap_sysmem(rsdp->xsdt_address, 0); + len = xsdt->header.length - sizeof(xsdt->header); + count = len / sizeof(u64); + } else { + if (!rsdp->rsdt_address) + return NULL; + rsdt = nomap_sysmem(rsdp->rsdt_address, 0); + len = rsdt->header.length - sizeof(rsdt->header); + count = len / sizeof(u32); + } for (i = 0; i < count; i++) { struct acpi_table_header *hdr; - hdr = map_sysmem(rsdt->entry[i], 0); + if (rsdp->xsdt_address) + hdr = nomap_sysmem(xsdt->entry[i], 0); + else + hdr = nomap_sysmem(rsdt->entry[i], 0); if (!memcmp(hdr->signature, sig, ACPI_NAME_LEN)) return hdr; if (!memcmp(hdr->signature, "FACP", ACPI_NAME_LEN)) { struct acpi_fadt *fadt = (struct acpi_fadt *)hdr; - if (!memcmp(sig, "DSDT", ACPI_NAME_LEN) && fadt->dsdt) - return map_sysmem(fadt->dsdt, 0); - if (!memcmp(sig, "FACS", ACPI_NAME_LEN) && - fadt->firmware_ctrl) - return map_sysmem(fadt->firmware_ctrl, 0); + if (!memcmp(sig, "DSDT", ACPI_NAME_LEN)) { + void *dsdt; + + if (fadt->header.revision >= 3 && fadt->x_dsdt) + dsdt = nomap_sysmem(fadt->x_dsdt, 0); + else if (fadt->dsdt) + dsdt = nomap_sysmem(fadt->dsdt, 0); + else + dsdt = NULL; + return dsdt; + } + + if (!memcmp(sig, "FACS", ACPI_NAME_LEN)) { + void *facs; + + if (fadt->header.revision >= 3 && + fadt->x_firmware_ctrl) + facs = nomap_sysmem(fadt->x_firmware_ctrl, 0); + else if (fadt->firmware_ctrl) + facs = nomap_sysmem(fadt->firmware_ctrl, 0); + else + facs = NULL; + return facs; + } } } diff --git a/lib/acpi/acpi_device.c b/lib/acpi/acpi_device.c index 1b838fdbd6..ed94194346 100644 --- a/lib/acpi/acpi_device.c +++ b/lib/acpi/acpi_device.c @@ -6,7 +6,6 @@ * Mostly taken from coreboot file of the same name */ -#include <common.h> #include <dm.h> #include <irq.h> #include <log.h> diff --git a/lib/acpi/acpi_dp.c b/lib/acpi/acpi_dp.c index 7e3e3259d8..6733809986 100644 --- a/lib/acpi/acpi_dp.c +++ b/lib/acpi/acpi_dp.c @@ -6,7 +6,6 @@ * Mostly taken from coreboot file acpi_device.c */ -#include <common.h> #include <dm.h> #include <log.h> #include <malloc.h> diff --git a/lib/acpi/acpi_table.c b/lib/acpi/acpi_table.c index a8d4b47000..39dd53ec40 100644 --- a/lib/acpi/acpi_table.c +++ b/lib/acpi/acpi_table.c @@ -5,7 +5,6 @@ * Copyright 2019 Google LLC */ -#include <common.h> #include <dm.h> #include <cpu.h> #include <log.h> @@ -168,7 +167,7 @@ int acpi_add_table(struct acpi_ctx *ctx, void *table) } /* Add table to the RSDT */ - rsdt->entry[i] = map_to_sysmem(table); + rsdt->entry[i] = nomap_to_sysmem(table); /* Fix RSDT length or the kernel will assume invalid entries */ rsdt->header.length = sizeof(struct acpi_table_header) + @@ -186,7 +185,7 @@ int acpi_add_table(struct acpi_ctx *ctx, void *table) xsdt = ctx->xsdt; /* Add table to the XSDT */ - xsdt->entry[i] = map_to_sysmem(table); + xsdt->entry[i] = nomap_to_sysmem(table); /* Fix XSDT length */ xsdt->header.length = sizeof(struct acpi_table_header) + diff --git a/lib/acpi/acpi_writer.c b/lib/acpi/acpi_writer.c index 946f90e8e7..bbb9b54786 100644 --- a/lib/acpi/acpi_writer.c +++ b/lib/acpi/acpi_writer.c @@ -7,13 +7,13 @@ #define LOG_CATEGORY LOGC_ACPI -#include <common.h> #include <log.h> #include <malloc.h> #include <mapmem.h> #include <acpi/acpi_table.h> #include <asm/global_data.h> #include <dm/acpi.h> +#include <linux/errno.h> DECLARE_GLOBAL_DATA_PTR; @@ -48,7 +48,7 @@ int acpi_write_one(struct acpi_ctx *ctx, const struct acpi_writer *entry) return 0; } -#ifndef CONFIG_QEMU +#ifndef CONFIG_QFW_ACPI static int acpi_write_all(struct acpi_ctx *ctx) { const struct acpi_writer *writer = @@ -115,7 +115,7 @@ ulong acpi_get_rsdp_addr(void) return map_to_sysmem(gd->acpi_ctx->rsdp); } -#endif /* QEMU */ +#endif /* QFW_ACPI */ void acpi_setup_ctx(struct acpi_ctx *ctx, ulong start) { diff --git a/lib/acpi/acpigen.c b/lib/acpi/acpigen.c index e395226e3d..b95cabb914 100644 --- a/lib/acpi/acpigen.c +++ b/lib/acpi/acpigen.c @@ -8,7 +8,6 @@ #define LOG_CATEGORY LOGC_ACPI -#include <common.h> #include <dm.h> #include <log.h> #include <uuid.h> diff --git a/lib/acpi/base.c b/lib/acpi/base.c index 2057bd2bef..8b6af2bc43 100644 --- a/lib/acpi/base.c +++ b/lib/acpi/base.c @@ -7,11 +7,13 @@ #define LOG_CATEGORY LOGC_ACPI -#include <common.h> #include <acpi/acpi_table.h> #include <dm/acpi.h> #include <mapmem.h> #include <tables_csum.h> +#include <linux/sizes.h> +#include <linux/errno.h> +#include <linux/string.h> void acpi_write_rsdp(struct acpi_rsdp *rsdp, struct acpi_rsdt *rsdt, struct acpi_xsdt *xsdt) @@ -21,10 +23,13 @@ void acpi_write_rsdp(struct acpi_rsdp *rsdp, struct acpi_rsdt *rsdt, memcpy(rsdp->signature, RSDP_SIG, 8); memcpy(rsdp->oem_id, OEM_ID, 6); - rsdp->length = sizeof(struct acpi_rsdp); - rsdp->rsdt_address = map_to_sysmem(rsdt); + if (rsdt) + rsdp->rsdt_address = nomap_to_sysmem(rsdt); + + if (xsdt) + rsdp->xsdt_address = nomap_to_sysmem(xsdt); - rsdp->xsdt_address = map_to_sysmem(xsdt); + rsdp->length = sizeof(struct acpi_rsdp); rsdp->revision = ACPI_RSDP_REV_ACPI_2_0; /* Calculate checksums */ @@ -68,11 +73,15 @@ static void acpi_write_xsdt(struct acpi_xsdt *xsdt) static int acpi_write_base(struct acpi_ctx *ctx, const struct acpi_writer *entry) { - /* We need at least an RSDP and an RSDT Table */ + /* We need at least an RSDP and an XSDT Table */ ctx->rsdp = ctx->current; acpi_inc_align(ctx, sizeof(struct acpi_rsdp)); - ctx->rsdt = ctx->current; - acpi_inc_align(ctx, sizeof(struct acpi_rsdt)); + if (map_to_sysmem(ctx->current) < SZ_4G - SZ_64K) { + ctx->rsdt = ctx->current; + acpi_inc_align(ctx, sizeof(struct acpi_rsdt)); + } else { + ctx->rsdt = 0; + } ctx->xsdt = ctx->current; acpi_inc_align(ctx, sizeof(struct acpi_xsdt)); @@ -80,7 +89,8 @@ static int acpi_write_base(struct acpi_ctx *ctx, memset(ctx->base, '\0', ctx->current - ctx->base); acpi_write_rsdp(ctx->rsdp, ctx->rsdt, ctx->xsdt); - acpi_write_rsdt(ctx->rsdt); + if (ctx->rsdt) + acpi_write_rsdt(ctx->rsdt); acpi_write_xsdt(ctx->xsdt); return 0; diff --git a/lib/acpi/csrt.c b/lib/acpi/csrt.c index 2ba86f2295..00927e5340 100644 --- a/lib/acpi/csrt.c +++ b/lib/acpi/csrt.c @@ -7,11 +7,11 @@ #define LOG_CATEGORY LOGC_ACPI -#include <common.h> #include <mapmem.h> #include <tables_csum.h> #include <acpi/acpi_table.h> #include <dm/acpi.h> +#include <linux/string.h> __weak int acpi_fill_csrt(struct acpi_ctx *ctx) { diff --git a/lib/acpi/dsdt.c b/lib/acpi/dsdt.c index db98cc20e1..206e1e2678 100644 --- a/lib/acpi/dsdt.c +++ b/lib/acpi/dsdt.c @@ -7,10 +7,10 @@ #define LOG_CATEGORY LOGC_ACPI -#include <common.h> #include <acpi/acpi_table.h> #include <dm/acpi.h> #include <tables_csum.h> +#include <linux/string.h> /* * IASL compiles the dsdt entries and writes the hex values diff --git a/lib/acpi/facs.c b/lib/acpi/facs.c index e89f43ca5c..86c28120c7 100644 --- a/lib/acpi/facs.c +++ b/lib/acpi/facs.c @@ -7,9 +7,9 @@ #define LOG_CATEGORY LOGC_ACPI -#include <common.h> #include <acpi/acpi_table.h> #include <dm/acpi.h> +#include <linux/string.h> int acpi_write_facs(struct acpi_ctx *ctx, const struct acpi_writer *entry) { diff --git a/lib/acpi/mcfg.c b/lib/acpi/mcfg.c index 7404ae586a..8b8a5bfafa 100644 --- a/lib/acpi/mcfg.c +++ b/lib/acpi/mcfg.c @@ -7,11 +7,13 @@ #define LOG_CATEGORY LOGC_ACPI -#include <common.h> #include <mapmem.h> #include <tables_csum.h> #include <acpi/acpi_table.h> #include <dm/acpi.h> +#include <linux/errno.h> +#include <linux/string.h> +#include <linux/types.h> int acpi_create_mcfg_mmconfig(struct acpi_mcfg_mmconfig *mmconfig, u32 base, u16 seg_nr, u8 start, u8 end) diff --git a/lib/acpi/ssdt.c b/lib/acpi/ssdt.c index 659c1aad40..b0a96f846e 100644 --- a/lib/acpi/ssdt.c +++ b/lib/acpi/ssdt.c @@ -7,10 +7,11 @@ #define LOG_CATEGORY LOGC_ACPI -#include <common.h> #include <acpi/acpi_table.h> #include <dm/acpi.h> #include <tables_csum.h> +#include <linux/errno.h> +#include <linux/string.h> int acpi_write_ssdt(struct acpi_ctx *ctx, const struct acpi_writer *entry) { @@ -18,10 +19,9 @@ int acpi_write_ssdt(struct acpi_ctx *ctx, const struct acpi_writer *entry) int ret; ssdt = ctx->current; - memset((void *)ssdt, '\0', sizeof(struct acpi_table_header)); + memset(ssdt, '\0', sizeof(struct acpi_table_header)); acpi_fill_header(ssdt, "SSDT"); - memcpy(ssdt->oem_table_id, OEM_TABLE_ID, sizeof(ssdt->oem_table_id)); ssdt->revision = acpi_get_table_revision(ACPITAB_SSDT); ssdt->aslc_revision = 1; ssdt->length = sizeof(struct acpi_table_header); diff --git a/lib/addr_map.c b/lib/addr_map.c index 86e932e4b5..f85fb0c7fb 100644 --- a/lib/addr_map.c +++ b/lib/addr_map.c @@ -3,7 +3,6 @@ * Copyright 2008 Freescale Semiconductor, Inc. */ -#include <common.h> #include <addr_map.h> #include <mapmem.h> @@ -22,9 +22,9 @@ */ #ifndef USE_HOSTCC -#include <common.h> #include <display_options.h> #include <log.h> +#include <linux/string.h> #else #include <string.h> #endif diff --git a/lib/aes/aes-decrypt.c b/lib/aes/aes-decrypt.c index 345029fa78..741102a472 100644 --- a/lib/aes/aes-decrypt.c +++ b/lib/aes/aes-decrypt.c @@ -4,7 +4,6 @@ */ #ifndef USE_HOSTCC -#include <common.h> #include <malloc.h> #endif #include <image.h> diff --git a/lib/asm-offsets.c b/lib/asm-offsets.c index 216d9716d0..4e2dbda9a7 100644 --- a/lib/asm-offsets.c +++ b/lib/asm-offsets.c @@ -11,9 +11,9 @@ * #defines from the assembly-language output. */ -#include <common.h> #include <asm-offsets.h> #include <asm/global_data.h> +#include <asm/u-boot.h> #include <linux/kbuild.h> diff --git a/lib/at91/at91.c b/lib/at91/at91.c index 048597690b..bd31e9e41d 100644 --- a/lib/at91/at91.c +++ b/lib/at91/at91.c @@ -4,7 +4,6 @@ * Wenyou.Yang <wenyou.yang@microchip.com> */ -#include <common.h> #include <atmel_lcd.h> #include "atmel_logo_8bpp.h" @@ -54,7 +54,6 @@ */ #ifndef USE_HOSTCC -#include <common.h> #include <log.h> #include <malloc.h> #include <ubi_uboot.h> diff --git a/lib/binman.c b/lib/binman.c index cfe1e5f807..9047f5275f 100644 --- a/lib/binman.c +++ b/lib/binman.c @@ -6,7 +6,6 @@ * Written by Simon Glass <sjg@chromium.org> */ -#include <common.h> #include <binman.h> #include <dm.h> #include <log.h> diff --git a/lib/bzip2/bzlib.c b/lib/bzip2/bzlib.c index bd589aa810..f7318b7886 100644 --- a/lib/bzip2/bzlib.c +++ b/lib/bzip2/bzlib.c @@ -1,7 +1,6 @@ -#include <config.h> -#include <common.h> #include <malloc.h> #include <watchdog.h> +#include <stdio.h> /* * This file is a modified version of bzlib.c from the bzip2-1.0.2 diff --git a/lib/bzip2/bzlib_decompress.c b/lib/bzip2/bzlib_decompress.c index 3b417d57b2..e56ab6674b 100644 --- a/lib/bzip2/bzlib_decompress.c +++ b/lib/bzip2/bzlib_decompress.c @@ -1,5 +1,4 @@ #include <config.h> -#include <common.h> #include <watchdog.h> /*-------------------------------------------------------------*/ diff --git a/lib/charset.c b/lib/charset.c index 5e4c4f948a..89057ef7ce 100644 --- a/lib/charset.c +++ b/lib/charset.c @@ -5,7 +5,6 @@ * Copyright (c) 2017 Rob Clark */ -#include <common.h> #include <charset.h> #include <capitalization.h> #include <cp437.h> diff --git a/lib/circbuf.c b/lib/circbuf.c index fa79c148da..2e161ae8d8 100644 --- a/lib/circbuf.c +++ b/lib/circbuf.c @@ -4,7 +4,6 @@ * Gerry Hamel, geh@ti.com, Texas Instruments */ -#include <common.h> #include <log.h> #include <malloc.h> diff --git a/lib/crc16-ccitt.c b/lib/crc16-ccitt.c index 6cadbc103d..6fa4e93ed1 100644 --- a/lib/crc16-ccitt.c +++ b/lib/crc16-ccitt.c @@ -24,8 +24,6 @@ #ifdef USE_HOSTCC #include <arpa/inet.h> -#else -#include <common.h> #endif #include <u-boot/crc.h> diff --git a/lib/crc32.c b/lib/crc32.c index f6fad8c15d..f36f176306 100644 --- a/lib/crc32.c +++ b/lib/crc32.c @@ -11,7 +11,6 @@ #ifdef USE_HOSTCC #include <arpa/inet.h> #else -#include <common.h> #include <efi_loader.h> #endif #include <compiler.h> diff --git a/lib/crc32c.c b/lib/crc32c.c index 016b34a523..7026ac4c33 100644 --- a/lib/crc32c.c +++ b/lib/crc32c.c @@ -10,7 +10,6 @@ * any later version. */ -#include <common.h> #include <compiler.h> uint32_t crc32c_cal(uint32_t crc, const char *data, int length, diff --git a/lib/crc8.c b/lib/crc8.c index 87b87b675b..20d46d1614 100644 --- a/lib/crc8.c +++ b/lib/crc8.c @@ -5,8 +5,6 @@ #ifdef USE_HOSTCC #include <arpa/inet.h> -#else -#include <common.h> #endif #include <u-boot/crc.h> diff --git a/lib/crypt/crypt-port.h b/lib/crypt/crypt-port.h index 6b9542d75b..50dde68b5c 100644 --- a/lib/crypt/crypt-port.h +++ b/lib/crypt/crypt-port.h @@ -1,6 +1,9 @@ /* SPDX-License-Identifier: GPL-2.0+ */ /* Copyright (C) 2020 Steffen Jaeckel <jaeckel-floss@eyet-services.de> */ +#include <linux/errno.h> +#include <linux/kernel.h> +#include <linux/string.h> #include <linux/types.h> #include <vsprintf.h> diff --git a/lib/crypt/crypt.c b/lib/crypt/crypt.c index 247c34b2a9..8f5fadb582 100644 --- a/lib/crypt/crypt.c +++ b/lib/crypt/crypt.c @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-2.0+ /* Copyright (C) 2020 Steffen Jaeckel <jaeckel-floss@eyet-services.de> */ -#include <common.h> #include <crypt.h> #include "crypt-port.h" diff --git a/lib/crypto/x509_public_key.c b/lib/crypto/x509_public_key.c index 30071233ee..a10145a7cd 100644 --- a/lib/crypto/x509_public_key.c +++ b/lib/crypto/x509_public_key.c @@ -7,7 +7,6 @@ #define pr_fmt(fmt) "X.509: "fmt #ifdef __UBOOT__ -#include <common.h> #include <image.h> #include <dm/devres.h> #include <linux/compat.h> diff --git a/lib/date.c b/lib/date.c index e3d22459cd..0deac8a1be 100644 --- a/lib/date.c +++ b/lib/date.c @@ -4,7 +4,6 @@ * Wolfgang Denk, DENX Software Engineering, wd@denx.de. */ -#include <common.h> #include <command.h> #include <errno.h> #include <rtc.h> diff --git a/lib/dhry/cmd_dhry.c b/lib/dhry/cmd_dhry.c index 77b52a2300..e52beaeaad 100644 --- a/lib/dhry/cmd_dhry.c +++ b/lib/dhry/cmd_dhry.c @@ -3,9 +3,10 @@ * (C) Copyright 2015 Google, Inc */ -#include <common.h> #include <command.h> #include <div64.h> +#include <time.h> +#include <vsprintf.h> #include "dhry.h" static int do_dhry(struct cmd_tbl *cmdtp, int flag, int argc, diff --git a/lib/dhry/dhry_1.c b/lib/dhry/dhry_1.c index dcc224fb38..252cd14a65 100644 --- a/lib/dhry/dhry_1.c +++ b/lib/dhry/dhry_1.c @@ -42,8 +42,8 @@ ***************************************************************************/ char SCCSid[] = "@(#) @(#)dhry_1.c:3.4 -- 5/15/91 19:30:21"; -#include <common.h> #include <malloc.h> +#include <stdio.h> #include "dhry.h" diff --git a/lib/dhry/dhry_2.c b/lib/dhry/dhry_2.c index 1ba879673e..a74197d884 100644 --- a/lib/dhry/dhry_2.c +++ b/lib/dhry/dhry_2.c @@ -39,7 +39,7 @@ ****************************************************************************/ /* SCCSid is defined in dhry_1.c */ -#include <common.h> +#include <linux/string.h> #include "dhry.h" #ifndef REG diff --git a/lib/display_options.c b/lib/display_options.c index 80def5201f..d6b93553dc 100644 --- a/lib/display_options.c +++ b/lib/display_options.c @@ -4,14 +4,15 @@ * Wolfgang Denk, DENX Software Engineering, wd@denx.de. */ -#include <common.h> #include <compiler.h> #include <console.h> #include <display_options.h> #include <div64.h> #include <version_string.h> #include <linux/ctype.h> +#include <linux/kernel.h> #include <asm/io.h> +#include <vsprintf.h> char *display_options_get_banner_priv(bool newlines, const char *build_tag, char *buf, int size) diff --git a/lib/efi/efi.c b/lib/efi/efi.c index aa42f1842f..bcb34d6746 100644 --- a/lib/efi/efi.c +++ b/lib/efi/efi.c @@ -10,7 +10,6 @@ * Common EFI functions */ -#include <common.h> #include <debug_uart.h> #include <errno.h> #include <malloc.h> diff --git a/lib/efi/efi_app.c b/lib/efi/efi_app.c index 2209410f35..119db6602c 100644 --- a/lib/efi/efi_app.c +++ b/lib/efi/efi_app.c @@ -8,22 +8,24 @@ * This file implements U-Boot running as an EFI application. */ -#include <common.h> #include <cpu_func.h> #include <debug_uart.h> #include <dm.h> +#include <efi.h> +#include <efi_api.h> #include <errno.h> #include <init.h> #include <malloc.h> +#include <sysreset.h> +#include <uuid.h> #include <asm/global_data.h> #include <linux/err.h> #include <linux/types.h> -#include <efi.h> -#include <efi_api.h> -#include <sysreset.h> +#include <asm/global_data.h> #include <dm/device-internal.h> #include <dm/lists.h> #include <dm/root.h> +#include <mapmem.h> DECLARE_GLOBAL_DATA_PTR; @@ -320,6 +322,19 @@ int dm_scan_other(bool pre_reloc_only) return 0; } +static void scan_tables(struct efi_system_table *sys_table) +{ + efi_guid_t acpi = EFI_ACPI_TABLE_GUID; + uint i; + + for (i = 0; i < sys_table->nr_tables; i++) { + struct efi_configuration_table *tab = &sys_table->tables[i]; + + if (!memcmp(&tab->guid, &acpi, sizeof(efi_guid_t))) + gd_set_acpi_start(map_to_sysmem(tab->table)); + } +} + /** * efi_main() - Start an EFI image * @@ -354,6 +369,8 @@ efi_status_t EFIAPI efi_main(efi_handle_t image, return ret; } + scan_tables(priv->sys_table); + /* * We could store the EFI memory map here, but it changes all the time, * so this is only useful for debugging. diff --git a/lib/efi/efi_info.c b/lib/efi/efi_info.c index 4d78923c4d..5b564c5651 100644 --- a/lib/efi/efi_info.c +++ b/lib/efi/efi_info.c @@ -5,7 +5,6 @@ * Access to the EFI information table */ -#include <common.h> #include <efi.h> #include <errno.h> #include <mapmem.h> diff --git a/lib/efi/efi_stub.c b/lib/efi/efi_stub.c index c9eb32ec10..40fc29d9ad 100644 --- a/lib/efi/efi_stub.c +++ b/lib/efi/efi_stub.c @@ -9,7 +9,6 @@ * EFI application. It can be built either in 32-bit or 64-bit mode. */ -#include <common.h> #include <debug_uart.h> #include <efi.h> #include <efi_api.h> diff --git a/lib/efi_driver/efi_block_device.c b/lib/efi_driver/efi_block_device.c index e3abd90275..34a0365739 100644 --- a/lib/efi_driver/efi_block_device.c +++ b/lib/efi_driver/efi_block_device.c @@ -28,7 +28,6 @@ * iPXE uses the simple file protocol to load Grub or the Linux Kernel. */ -#include <common.h> #include <blk.h> #include <dm.h> #include <efi_driver.h> diff --git a/lib/efi_driver/efi_uclass.c b/lib/efi_driver/efi_uclass.c index 66a45e156d..e1e28df20b 100644 --- a/lib/efi_driver/efi_uclass.c +++ b/lib/efi_driver/efi_uclass.c @@ -17,7 +17,6 @@ * controllers. */ -#include <common.h> #include <dm.h> #include <efi_driver.h> #include <log.h> diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig index 2e3935467c..ea807342f0 100644 --- a/lib/efi_loader/Kconfig +++ b/lib/efi_loader/Kconfig @@ -32,14 +32,14 @@ config EFI_LOADER if EFI_LOADER -config CMD_BOOTEFI_BOOTMGR +config BOOTEFI_BOOTMGR bool "UEFI Boot Manager" default y select BOOTMETH_GLOBAL if BOOTSTD help Select this option if you want to select the UEFI binary to be booted - via UEFI variables Boot####, BootOrder, and BootNext. This enables the - 'bootefi bootmgr' command. + via UEFI variables Boot####, BootOrder, and BootNext. You should also + normally enable CMD_BOOTEFI_BOOTMGR so that the command is available. choice prompt "Store for non-volatile UEFI variables" @@ -479,4 +479,13 @@ config EFI_RISCV_BOOT_PROTOCOL replace the transfer via the device-tree. The latter is not possible on systems using ACPI. +config EFI_HTTP_BOOT + bool "EFI HTTP Boot support" + select CMD_DNS + select CMD_WGET + select BLKMAP + help + Enabling this option adds EFI HTTP Boot support. It allows to + directly boot from network. + endif diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile index 8d31fc61c6..24d33d5409 100644 --- a/lib/efi_loader/Makefile +++ b/lib/efi_loader/Makefile @@ -42,7 +42,7 @@ targets += initrddump.o endif obj-$(CONFIG_CMD_BOOTEFI_HELLO) += helloworld_efi.o -obj-$(CONFIG_CMD_BOOTEFI_BOOTMGR) += efi_bootmgr.o +obj-$(CONFIG_BOOTEFI_BOOTMGR) += efi_bootmgr.o obj-y += efi_boottime.o obj-y += efi_helper.o obj-$(CONFIG_EFI_HAVE_CAPSULE_SUPPORT) += efi_capsule.o @@ -51,9 +51,7 @@ obj-y += efi_console.o obj-y += efi_device_path.o obj-$(CONFIG_EFI_DEVICE_PATH_TO_TEXT) += efi_device_path_to_text.o obj-$(CONFIG_EFI_DEVICE_PATH_UTIL) += efi_device_path_utilities.o -ifeq ($(CONFIG_GENERATE_ACPI_TABLE),) obj-y += efi_dt_fixup.o -endif obj-y += efi_file.o obj-$(CONFIG_EFI_LOADER_HII) += efi_hii.o obj-y += efi_image_loader.o diff --git a/lib/efi_loader/dtbdump.c b/lib/efi_loader/dtbdump.c index 3ce2a07f9e..5f39cf22da 100644 --- a/lib/efi_loader/dtbdump.c +++ b/lib/efi_loader/dtbdump.c @@ -6,7 +6,6 @@ * to a file. */ -#include <common.h> #include <efi_api.h> #include <efi_dt_fixup.h> #include <part.h> diff --git a/lib/efi_loader/efi_acpi.c b/lib/efi_loader/efi_acpi.c index f755af76f8..67bbd2a01c 100644 --- a/lib/efi_loader/efi_acpi.c +++ b/lib/efi_loader/efi_acpi.c @@ -5,7 +5,6 @@ * Copyright (C) 2018, Bin Meng <bmeng.cn@gmail.com> */ -#include <common.h> #include <efi_loader.h> #include <log.h> #include <mapmem.h> diff --git a/lib/efi_loader/efi_bootmgr.c b/lib/efi_loader/efi_bootmgr.c index a40762c74c..a032d3ae04 100644 --- a/lib/efi_loader/efi_bootmgr.c +++ b/lib/efi_loader/efi_bootmgr.c @@ -3,22 +3,55 @@ * EFI boot manager * * Copyright (c) 2017 Rob Clark + * For the code moved from cmd/bootefi.c + * Copyright (c) 2016 Alexander Graf */ #define LOG_CATEGORY LOGC_EFI -#include <common.h> +#include <blk.h> +#include <blkmap.h> #include <charset.h> +#include <dm.h> #include <log.h> #include <malloc.h> +#include <net.h> #include <efi_default_filename.h> #include <efi_loader.h> #include <efi_variable.h> #include <asm/unaligned.h> +/* TODO: temporarily added here; clean up later */ +#include <bootm.h> +#include <efi_selftest.h> +#include <env.h> +#include <mapmem.h> +#include <asm/global_data.h> +#include <linux/libfdt.h> +#include <linux/libfdt_env.h> + +DECLARE_GLOBAL_DATA_PTR; + static const struct efi_boot_services *bs; static const struct efi_runtime_services *rs; +/** + * struct uridp_context - uri device path resource + * + * @image_size: image size + * @image_addr: image address + * @loaded_dp: pointer to loaded device path + * @ramdisk_blk_dev: pointer to the ramdisk blk device + * @mem_handle: efi_handle to the loaded PE-COFF image + */ +struct uridp_context { + ulong image_size; + ulong image_addr; + struct efi_device_path *loaded_dp; + struct udevice *ramdisk_blk_dev; + efi_handle_t mem_handle; +}; + const efi_guid_t efi_guid_bootmenu_auto_generated = EFICONFIG_AUTO_GENERATED_ENTRY_GUID; @@ -169,6 +202,364 @@ out: } /** + * mount_image() - mount the image with blkmap + * + * @lo_label: u16 label string of load option + * @addr: image address + * @size: image size + * Return: pointer to the UCLASS_BLK udevice, NULL if failed + */ +static struct udevice *mount_image(u16 *lo_label, ulong addr, ulong size) +{ + int err; + struct blkmap *bm; + struct udevice *bm_dev; + char *label = NULL, *p; + + label = efi_alloc(utf16_utf8_strlen(lo_label) + 1); + if (!label) + return NULL; + + p = label; + utf16_utf8_strcpy(&p, lo_label); + err = blkmap_create_ramdisk(label, addr, size, &bm_dev); + if (err) { + efi_free_pool(label); + return NULL; + } + bm = dev_get_plat(bm_dev); + + efi_free_pool(label); + + return bm->blk; +} + +/** + * search_default_file() - search default file + * + * @dev: pointer to the UCLASS_BLK or UCLASS_PARTITION udevice + * @loaded_dp: pointer to default file device path + * Return: status code + */ +static efi_status_t search_default_file(struct udevice *dev, + struct efi_device_path **loaded_dp) +{ + efi_status_t ret; + efi_handle_t handle; + u16 *default_file_name = NULL; + struct efi_file_handle *root, *f; + struct efi_device_path *dp = NULL, *fp = NULL; + struct efi_simple_file_system_protocol *file_system; + struct efi_device_path *device_path, *full_path = NULL; + + if (dev_tag_get_ptr(dev, DM_TAG_EFI, (void **)&handle)) { + log_warning("DM_TAG_EFI not found\n"); + return EFI_INVALID_PARAMETER; + } + + ret = EFI_CALL(bs->open_protocol(handle, &efi_guid_device_path, + (void **)&device_path, efi_root, NULL, + EFI_OPEN_PROTOCOL_GET_PROTOCOL)); + if (ret != EFI_SUCCESS) + return ret; + + ret = EFI_CALL(bs->open_protocol(handle, &efi_simple_file_system_protocol_guid, + (void **)&file_system, efi_root, NULL, + EFI_OPEN_PROTOCOL_GET_PROTOCOL)); + if (ret != EFI_SUCCESS) + return ret; + + ret = EFI_CALL(file_system->open_volume(file_system, &root)); + if (ret != EFI_SUCCESS) + return ret; + + full_path = expand_media_path(device_path); + ret = efi_dp_split_file_path(full_path, &dp, &fp); + if (ret != EFI_SUCCESS) + goto err; + + default_file_name = efi_dp_str(fp); + efi_free_pool(dp); + efi_free_pool(fp); + if (!default_file_name) { + ret = EFI_OUT_OF_RESOURCES; + goto err; + } + + ret = EFI_CALL(root->open(root, &f, default_file_name, + EFI_FILE_MODE_READ, 0)); + efi_free_pool(default_file_name); + if (ret != EFI_SUCCESS) + goto err; + + EFI_CALL(f->close(f)); + EFI_CALL(root->close(root)); + + *loaded_dp = full_path; + + return EFI_SUCCESS; + +err: + EFI_CALL(root->close(root)); + efi_free_pool(full_path); + + return ret; +} + +/** + * check_disk_has_default_file() - load the default file + * + * @blk: pointer to the UCLASS_BLK udevice + * @dp: pointer to default file device path + * Return: status code + */ +static efi_status_t check_disk_has_default_file(struct udevice *blk, + struct efi_device_path **dp) +{ + efi_status_t ret; + struct udevice *partition; + + /* image that has no partition table but a file system */ + ret = search_default_file(blk, dp); + if (ret == EFI_SUCCESS) + return ret; + + /* try the partitions */ + device_foreach_child(partition, blk) { + enum uclass_id id; + + id = device_get_uclass_id(partition); + if (id != UCLASS_PARTITION) + continue; + + ret = search_default_file(partition, dp); + if (ret == EFI_SUCCESS) + return ret; + } + + return EFI_NOT_FOUND; +} + +/** + * prepare_loaded_image() - prepare ramdisk for downloaded image + * + * @label: label of load option + * @addr: image address + * @size: image size + * @dp: pointer to default file device path + * @blk: pointer to created blk udevice + * Return: status code + */ +static efi_status_t prepare_loaded_image(u16 *label, ulong addr, ulong size, + struct efi_device_path **dp, + struct udevice **blk) +{ + efi_status_t ret; + struct udevice *ramdisk_blk; + + ramdisk_blk = mount_image(label, addr, size); + if (!ramdisk_blk) + return EFI_LOAD_ERROR; + + ret = check_disk_has_default_file(ramdisk_blk, dp); + if (ret != EFI_SUCCESS) { + log_info("Cannot boot from downloaded image\n"); + goto err; + } + + /* + * TODO: expose the ramdisk to OS. + * Need to pass the ramdisk information by the architecture-specific + * methods such as 'pmem' device-tree node. + */ + ret = efi_add_memory_map(addr, size, EFI_RESERVED_MEMORY_TYPE); + if (ret != EFI_SUCCESS) { + log_err("Memory reservation failed\n"); + goto err; + } + + *blk = ramdisk_blk; + + return EFI_SUCCESS; + +err: + if (blkmap_destroy(ramdisk_blk->parent)) + log_err("Destroying blkmap failed\n"); + + return ret; +} + +/** + * efi_bootmgr_release_uridp_resource() - cleanup uri device path resource + * + * @ctx: event context + * Return: status code + */ +efi_status_t efi_bootmgr_release_uridp_resource(struct uridp_context *ctx) +{ + efi_status_t ret = EFI_SUCCESS; + + if (!ctx) + return ret; + + /* cleanup for iso or img image */ + if (ctx->ramdisk_blk_dev) { + ret = efi_add_memory_map(ctx->image_addr, ctx->image_size, + EFI_CONVENTIONAL_MEMORY); + if (ret != EFI_SUCCESS) + log_err("Reclaiming memory failed\n"); + + if (blkmap_destroy(ctx->ramdisk_blk_dev->parent)) { + log_err("Destroying blkmap failed\n"); + ret = EFI_DEVICE_ERROR; + } + } + + /* cleanup for PE-COFF image */ + if (ctx->mem_handle) { + ret = efi_uninstall_multiple_protocol_interfaces( + ctx->mem_handle, &efi_guid_device_path, ctx->loaded_dp, + NULL); + if (ret != EFI_SUCCESS) + log_err("Uninstall device_path protocol failed\n"); + } + + efi_free_pool(ctx->loaded_dp); + free(ctx); + + return ret; +} + +/** + * efi_bootmgr_image_return_notify() - return to efibootmgr callback + * + * @event: the event for which this notification function is registered + * @context: event context + */ +static void EFIAPI efi_bootmgr_image_return_notify(struct efi_event *event, + void *context) +{ + efi_status_t ret; + + EFI_ENTRY("%p, %p", event, context); + ret = efi_bootmgr_release_uridp_resource(context); + EFI_EXIT(ret); +} + +/** + * try_load_from_uri_path() - Handle the URI device path + * + * @uridp: uri device path + * @lo_label: label of load option + * @handle: pointer to handle for newly installed image + * Return: status code + */ +static efi_status_t try_load_from_uri_path(struct efi_device_path_uri *uridp, + u16 *lo_label, + efi_handle_t *handle) +{ + char *s; + int err; + int uri_len; + efi_status_t ret; + void *source_buffer; + efi_uintn_t source_size; + struct uridp_context *ctx; + struct udevice *blk = NULL; + struct efi_event *event = NULL; + efi_handle_t mem_handle = NULL; + struct efi_device_path *loaded_dp; + static ulong image_size, image_addr; + + ctx = calloc(1, sizeof(struct uridp_context)); + if (!ctx) + return EFI_OUT_OF_RESOURCES; + + s = env_get("loadaddr"); + if (!s) { + log_err("Error: loadaddr is not set\n"); + ret = EFI_INVALID_PARAMETER; + goto err; + } + + image_addr = hextoul(s, NULL); + err = wget_with_dns(image_addr, uridp->uri); + if (err < 0) { + ret = EFI_INVALID_PARAMETER; + goto err; + } + + image_size = env_get_hex("filesize", 0); + if (!image_size) { + ret = EFI_INVALID_PARAMETER; + goto err; + } + + /* + * If the file extension is ".iso" or ".img", mount it and try to load + * the default file. + * If the file is PE-COFF image, load the downloaded file. + */ + uri_len = strlen(uridp->uri); + if (!strncmp(&uridp->uri[uri_len - 4], ".iso", 4) || + !strncmp(&uridp->uri[uri_len - 4], ".img", 4)) { + ret = prepare_loaded_image(lo_label, image_addr, image_size, + &loaded_dp, &blk); + if (ret != EFI_SUCCESS) + goto err; + + source_buffer = NULL; + source_size = 0; + } else if (efi_check_pe((void *)image_addr, image_size, NULL) == EFI_SUCCESS) { + /* + * loaded_dp must exist until efi application returns, + * will be freed in return_to_efibootmgr event callback. + */ + loaded_dp = efi_dp_from_mem(EFI_RESERVED_MEMORY_TYPE, + (uintptr_t)image_addr, image_size); + ret = efi_install_multiple_protocol_interfaces( + &mem_handle, &efi_guid_device_path, loaded_dp, NULL); + if (ret != EFI_SUCCESS) + goto err; + + source_buffer = (void *)image_addr; + source_size = image_size; + } else { + log_err("Error: file type is not supported\n"); + ret = EFI_UNSUPPORTED; + goto err; + } + + ctx->image_size = image_size; + ctx->image_addr = image_addr; + ctx->loaded_dp = loaded_dp; + ctx->ramdisk_blk_dev = blk; + ctx->mem_handle = mem_handle; + + ret = EFI_CALL(efi_load_image(false, efi_root, loaded_dp, source_buffer, + source_size, handle)); + if (ret != EFI_SUCCESS) + goto err; + + /* create event for cleanup when the image returns or error occurs */ + ret = efi_create_event(EVT_NOTIFY_SIGNAL, TPL_CALLBACK, + efi_bootmgr_image_return_notify, ctx, + &efi_guid_event_group_return_to_efibootmgr, + &event); + if (ret != EFI_SUCCESS) { + log_err("Creating event failed\n"); + goto err; + } + + return ret; + +err: + efi_bootmgr_release_uridp_resource(ctx); + + return ret; +} + +/** * try_load_entry() - try to load image for boot option * * Attempt to load load-option number 'n', returning device_path and file_path @@ -211,6 +602,13 @@ static efi_status_t try_load_entry(u16 n, efi_handle_t *handle, if (EFI_DP_TYPE(lo.file_path, MEDIA_DEVICE, FILE_PATH)) { /* file_path doesn't contain a device path */ ret = try_load_from_short_path(lo.file_path, handle); + } else if (EFI_DP_TYPE(lo.file_path, MESSAGING_DEVICE, MSG_URI)) { + if (IS_ENABLED(CONFIG_EFI_HTTP_BOOT)) + ret = try_load_from_uri_path( + (struct efi_device_path_uri *)lo.file_path, + lo.label, handle); + else + ret = EFI_LOAD_ERROR; } else { file_path = expand_media_path(lo.file_path); ret = EFI_CALL(efi_load_image(true, efi_root, file_path, @@ -729,3 +1127,515 @@ out: return EFI_SUCCESS; return ret; } + +static struct efi_device_path *bootefi_image_path; +static struct efi_device_path *bootefi_device_path; +static void *image_addr; +static size_t image_size; + +/** + * efi_get_image_parameters() - return image parameters + * + * @img_addr: address of loaded image in memory + * @img_size: size of loaded image + */ +void efi_get_image_parameters(void **img_addr, size_t *img_size) +{ + *img_addr = image_addr; + *img_size = image_size; +} + +/** + * efi_clear_bootdev() - clear boot device + */ +void efi_clear_bootdev(void) +{ + efi_free_pool(bootefi_device_path); + efi_free_pool(bootefi_image_path); + bootefi_device_path = NULL; + bootefi_image_path = NULL; + image_addr = NULL; + image_size = 0; +} + +/** + * efi_set_bootdev() - set boot device + * + * This function is called when a file is loaded, e.g. via the 'load' command. + * We use the path to this file to inform the UEFI binary about the boot device. + * + * @dev: device, e.g. "MMC" + * @devnr: number of the device, e.g. "1:2" + * @path: path to file loaded + * @buffer: buffer with file loaded + * @buffer_size: size of file loaded + */ +void efi_set_bootdev(const char *dev, const char *devnr, const char *path, + void *buffer, size_t buffer_size) +{ + struct efi_device_path *device, *image; + efi_status_t ret; + + log_debug("dev=%s, devnr=%s, path=%s, buffer=%p, size=%zx\n", dev, + devnr, path, buffer, buffer_size); + + /* Forget overwritten image */ + if (buffer + buffer_size >= image_addr && + image_addr + image_size >= buffer) + efi_clear_bootdev(); + + /* Remember only PE-COFF and FIT images */ + if (efi_check_pe(buffer, buffer_size, NULL) != EFI_SUCCESS) { + if (IS_ENABLED(CONFIG_FIT) && + !fit_check_format(buffer, IMAGE_SIZE_INVAL)) { + /* + * FIT images of type EFI_OS are started via command + * bootm. We should not use their boot device with the + * bootefi command. + */ + buffer = 0; + buffer_size = 0; + } else { + log_debug("- not remembering image\n"); + return; + } + } + + /* efi_set_bootdev() is typically called repeatedly, recover memory */ + efi_clear_bootdev(); + + image_addr = buffer; + image_size = buffer_size; + + ret = efi_dp_from_name(dev, devnr, path, &device, &image); + if (ret == EFI_SUCCESS) { + bootefi_device_path = device; + if (image) { + /* FIXME: image should not contain device */ + struct efi_device_path *image_tmp = image; + + efi_dp_split_file_path(image, &device, &image); + efi_free_pool(image_tmp); + } + bootefi_image_path = image; + log_debug("- boot device %pD\n", device); + if (image) + log_debug("- image %pD\n", image); + } else { + log_debug("- efi_dp_from_name() failed, err=%lx\n", ret); + efi_clear_bootdev(); + } +} + +/** + * efi_env_set_load_options() - set load options from environment variable + * + * @handle: the image handle + * @env_var: name of the environment variable + * @load_options: pointer to load options (output) + * Return: status code + */ +efi_status_t efi_env_set_load_options(efi_handle_t handle, + const char *env_var, + u16 **load_options) +{ + const char *env = env_get(env_var); + size_t size; + u16 *pos; + efi_status_t ret; + + *load_options = NULL; + if (!env) + return EFI_SUCCESS; + size = sizeof(u16) * (utf8_utf16_strlen(env) + 1); + pos = calloc(size, 1); + if (!pos) + return EFI_OUT_OF_RESOURCES; + *load_options = pos; + utf8_utf16_strcpy(&pos, env); + ret = efi_set_load_options(handle, size, *load_options); + if (ret != EFI_SUCCESS) { + free(*load_options); + *load_options = NULL; + } + return ret; +} + +/** + * copy_fdt() - Copy the device tree to a new location available to EFI + * + * The FDT is copied to a suitable location within the EFI memory map. + * Additional 12 KiB are added to the space in case the device tree needs to be + * expanded later with fdt_open_into(). + * + * @fdtp: On entry a pointer to the flattened device tree. + * On exit a pointer to the copy of the flattened device tree. + * FDT start + * Return: status code + */ +static efi_status_t copy_fdt(void **fdtp) +{ + unsigned long fdt_ram_start = -1L, fdt_pages; + efi_status_t ret = 0; + void *fdt, *new_fdt; + u64 new_fdt_addr; + uint fdt_size; + int i; + + for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) { + u64 ram_start = gd->bd->bi_dram[i].start; + u64 ram_size = gd->bd->bi_dram[i].size; + + if (!ram_size) + continue; + + if (ram_start < fdt_ram_start) + fdt_ram_start = ram_start; + } + + /* + * Give us at least 12 KiB of breathing room in case the device tree + * needs to be expanded later. + */ + fdt = *fdtp; + fdt_pages = efi_size_in_pages(fdt_totalsize(fdt) + 0x3000); + fdt_size = fdt_pages << EFI_PAGE_SHIFT; + + ret = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES, + EFI_ACPI_RECLAIM_MEMORY, fdt_pages, + &new_fdt_addr); + if (ret != EFI_SUCCESS) { + log_err("ERROR: Failed to reserve space for FDT\n"); + goto done; + } + new_fdt = (void *)(uintptr_t)new_fdt_addr; + memcpy(new_fdt, fdt, fdt_totalsize(fdt)); + fdt_set_totalsize(new_fdt, fdt_size); + + *fdtp = (void *)(uintptr_t)new_fdt_addr; +done: + return ret; +} + +/** + * get_config_table() - get configuration table + * + * @guid: GUID of the configuration table + * Return: pointer to configuration table or NULL + */ +static void *get_config_table(const efi_guid_t *guid) +{ + size_t i; + + for (i = 0; i < systab.nr_tables; i++) { + if (!guidcmp(guid, &systab.tables[i].guid)) + return systab.tables[i].table; + } + return NULL; +} + +/** + * efi_install_fdt() - install device tree + * + * If fdt is not EFI_FDT_USE_INTERNAL, the device tree located at that memory + * address will be installed as configuration table, otherwise the device + * tree located at the address indicated by environment variable fdt_addr or as + * fallback fdtcontroladdr will be used. + * + * On architectures using ACPI tables device trees shall not be installed as + * configuration table. + * + * @fdt: address of device tree or EFI_FDT_USE_INTERNAL to use + * the hardware device tree as indicated by environment variable + * fdt_addr or as fallback the internal device tree as indicated by + * the environment variable fdtcontroladdr + * Return: status code + */ +efi_status_t efi_install_fdt(void *fdt) +{ + struct bootm_headers img = { 0 }; + efi_status_t ret; + + /* + * The EBBR spec requires that we have either an FDT or an ACPI table + * but not both. + */ + if (CONFIG_IS_ENABLED(GENERATE_ACPI_TABLE) && fdt) + log_warning("WARNING: Can't have ACPI table and device tree - ignoring DT.\n"); + + if (fdt == EFI_FDT_USE_INTERNAL) { + const char *fdt_opt; + uintptr_t fdt_addr; + + /* Look for device tree that is already installed */ + if (get_config_table(&efi_guid_fdt)) + return EFI_SUCCESS; + /* Check if there is a hardware device tree */ + fdt_opt = env_get("fdt_addr"); + /* Use our own device tree as fallback */ + if (!fdt_opt) { + fdt_opt = env_get("fdtcontroladdr"); + if (!fdt_opt) { + log_err("ERROR: need device tree\n"); + return EFI_NOT_FOUND; + } + } + fdt_addr = hextoul(fdt_opt, NULL); + if (!fdt_addr) { + log_err("ERROR: invalid $fdt_addr or $fdtcontroladdr\n"); + return EFI_LOAD_ERROR; + } + fdt = map_sysmem(fdt_addr, 0); + } + + /* Install device tree */ + if (fdt_check_header(fdt)) { + log_err("ERROR: invalid device tree\n"); + return EFI_LOAD_ERROR; + } + + /* Create memory reservations as indicated by the device tree */ + efi_carve_out_dt_rsv(fdt); + + if (CONFIG_IS_ENABLED(GENERATE_ACPI_TABLE)) + return EFI_SUCCESS; + + /* Prepare device tree for payload */ + ret = copy_fdt(&fdt); + if (ret) { + log_err("ERROR: out of memory\n"); + return EFI_OUT_OF_RESOURCES; + } + + if (image_setup_libfdt(&img, fdt, NULL)) { + log_err("ERROR: failed to process device tree\n"); + return EFI_LOAD_ERROR; + } + + efi_try_purge_kaslr_seed(fdt); + + if (CONFIG_IS_ENABLED(EFI_TCG2_PROTOCOL_MEASURE_DTB)) { + ret = efi_tcg2_measure_dtb(fdt); + if (ret == EFI_SECURITY_VIOLATION) { + log_err("ERROR: failed to measure DTB\n"); + return ret; + } + } + + /* Install device tree as UEFI table */ + ret = efi_install_configuration_table(&efi_guid_fdt, fdt); + if (ret != EFI_SUCCESS) { + log_err("ERROR: failed to install device tree\n"); + return ret; + } + + return EFI_SUCCESS; +} + +/** + * do_bootefi_exec() - execute EFI binary + * + * The image indicated by @handle is started. When it returns the allocated + * memory for the @load_options is freed. + * + * @handle: handle of loaded image + * @load_options: load options + * Return: status code + * + * Load the EFI binary into a newly assigned memory unwinding the relocation + * information, install the loaded image protocol, and call the binary. + */ +static efi_status_t do_bootefi_exec(efi_handle_t handle, void *load_options) +{ + efi_status_t ret; + efi_uintn_t exit_data_size = 0; + u16 *exit_data = NULL; + struct efi_event *evt; + + /* On ARM switch from EL3 or secure mode to EL2 or non-secure mode */ + switch_to_non_secure_mode(); + + /* + * The UEFI standard requires that the watchdog timer is set to five + * minutes when invoking an EFI boot option. + * + * Unified Extensible Firmware Interface (UEFI), version 2.7 Errata A + * 7.5. Miscellaneous Boot Services - EFI_BOOT_SERVICES.SetWatchdogTimer + */ + ret = efi_set_watchdog(300); + if (ret != EFI_SUCCESS) { + log_err("ERROR: Failed to set watchdog timer\n"); + goto out; + } + + /* Call our payload! */ + ret = EFI_CALL(efi_start_image(handle, &exit_data_size, &exit_data)); + if (ret != EFI_SUCCESS) { + log_err("## Application failed, r = %lu\n", + ret & ~EFI_ERROR_MASK); + if (exit_data) { + log_err("## %ls\n", exit_data); + efi_free_pool(exit_data); + } + } + + efi_restore_gd(); + +out: + free(load_options); + + if (IS_ENABLED(CONFIG_EFI_LOAD_FILE2_INITRD)) { + if (efi_initrd_deregister() != EFI_SUCCESS) + log_err("Failed to remove loadfile2 for initrd\n"); + } + + /* Notify EFI_EVENT_GROUP_RETURN_TO_EFIBOOTMGR event group. */ + list_for_each_entry(evt, &efi_events, link) { + if (evt->group && + !guidcmp(evt->group, + &efi_guid_event_group_return_to_efibootmgr)) { + efi_signal_event(evt); + EFI_CALL(systab.boottime->close_event(evt)); + break; + } + } + + /* Control is returned to U-Boot, disable EFI watchdog */ + efi_set_watchdog(0); + + return ret; +} + +/** + * efi_bootmgr_run() - execute EFI boot manager + * @fdt: Flat device tree + * + * Invoke EFI boot manager and execute a binary depending on + * boot options. If @fdt is not NULL, it will be passed to + * the executed binary. + * + * Return: status code + */ +efi_status_t efi_bootmgr_run(void *fdt) +{ + efi_handle_t handle; + void *load_options; + efi_status_t ret; + + /* Initialize EFI drivers */ + ret = efi_init_obj_list(); + if (ret != EFI_SUCCESS) { + log_err("Error: Cannot initialize UEFI sub-system, r = %lu\n", + ret & ~EFI_ERROR_MASK); + return CMD_RET_FAILURE; + } + + ret = efi_install_fdt(fdt); + if (ret != EFI_SUCCESS) + return ret; + + ret = efi_bootmgr_load(&handle, &load_options); + if (ret != EFI_SUCCESS) { + log_notice("EFI boot manager: Cannot load any image\n"); + return ret; + } + + return do_bootefi_exec(handle, load_options); +} + +/** + * efi_run_image() - run loaded UEFI image + * + * @source_buffer: memory address of the UEFI image + * @source_size: size of the UEFI image + * Return: status code + */ +efi_status_t efi_run_image(void *source_buffer, efi_uintn_t source_size) +{ + efi_handle_t mem_handle = NULL, handle; + struct efi_device_path *file_path = NULL; + struct efi_device_path *msg_path; + efi_status_t ret, ret2; + u16 *load_options; + + if (!bootefi_device_path || !bootefi_image_path) { + log_debug("Not loaded from disk\n"); + /* + * Special case for efi payload not loaded from disk, + * such as 'bootefi hello' or for example payload + * loaded directly into memory via JTAG, etc: + */ + file_path = efi_dp_from_mem(EFI_RESERVED_MEMORY_TYPE, + (uintptr_t)source_buffer, + source_size); + /* + * Make sure that device for device_path exist + * in load_image(). Otherwise, shell and grub will fail. + */ + ret = efi_install_multiple_protocol_interfaces(&mem_handle, + &efi_guid_device_path, + file_path, NULL); + if (ret != EFI_SUCCESS) + goto out; + msg_path = file_path; + } else { + file_path = efi_dp_append(bootefi_device_path, + bootefi_image_path); + msg_path = bootefi_image_path; + log_debug("Loaded from disk\n"); + } + + log_info("Booting %pD\n", msg_path); + + ret = EFI_CALL(efi_load_image(false, efi_root, file_path, source_buffer, + source_size, &handle)); + if (ret != EFI_SUCCESS) { + log_err("Loading image failed\n"); + goto out; + } + + /* Transfer environment variable as load options */ + ret = efi_env_set_load_options(handle, "bootargs", &load_options); + if (ret != EFI_SUCCESS) + goto out; + + ret = do_bootefi_exec(handle, load_options); + +out: + ret2 = efi_uninstall_multiple_protocol_interfaces(mem_handle, + &efi_guid_device_path, + file_path, NULL); + efi_free_pool(file_path); + return (ret != EFI_SUCCESS) ? ret : ret2; +} + +/** + * efi_binary_run() - run loaded UEFI image + * + * @image: memory address of the UEFI image + * @size: size of the UEFI image + * @fdt: device-tree + * + * Execute an EFI binary image loaded at @image. + * @size may be zero if the binary is loaded with U-Boot load command. + * + * Return: status code + */ +efi_status_t efi_binary_run(void *image, size_t size, void *fdt) +{ + efi_status_t ret; + + /* Initialize EFI drivers */ + ret = efi_init_obj_list(); + if (ret != EFI_SUCCESS) { + log_err("Error: Cannot initialize UEFI sub-system, r = %lu\n", + ret & ~EFI_ERROR_MASK); + return -1; + } + + ret = efi_install_fdt(fdt); + if (ret != EFI_SUCCESS) + return ret; + + return efi_run_image(image, size); +} diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index 0b7579cb5a..c579d89211 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -5,7 +5,6 @@ * Copyright (c) 2016 Alexander Graf */ -#include <common.h> #include <bootm.h> #include <div64.h> #include <dm/device.h> @@ -90,6 +89,9 @@ const efi_guid_t efi_guid_event_group_ready_to_boot = /* event group ResetSystem() invoked (before ExitBootServices) */ const efi_guid_t efi_guid_event_group_reset_system = EFI_EVENT_GROUP_RESET_SYSTEM; +/* event group return to efibootmgr */ +const efi_guid_t efi_guid_event_group_return_to_efibootmgr = + EFI_EVENT_GROUP_RETURN_TO_EFIBOOTMGR; /* GUIDs of the Load File and Load File2 protocols */ const efi_guid_t efi_guid_load_file_protocol = EFI_LOAD_FILE_PROTOCOL_GUID; const efi_guid_t efi_guid_load_file2_protocol = EFI_LOAD_FILE2_PROTOCOL_GUID; @@ -712,7 +714,7 @@ efi_status_t efi_create_event(uint32_t type, efi_uintn_t notify_tpl, void (EFIAPI *notify_function) ( struct efi_event *event, void *context), - void *notify_context, efi_guid_t *group, + void *notify_context, const efi_guid_t *group, struct efi_event **event) { struct efi_event *evt; @@ -790,7 +792,7 @@ efi_status_t EFIAPI efi_create_event_ex(uint32_t type, efi_uintn_t notify_tpl, struct efi_event *event, void *context), void *notify_context, - efi_guid_t *event_group, + const efi_guid_t *event_group, struct efi_event **event) { efi_status_t ret; @@ -1339,7 +1341,7 @@ static efi_status_t efi_disconnect_all_drivers const efi_guid_t *protocol, efi_handle_t child_handle) { - efi_uintn_t number_of_drivers, tmp; + efi_uintn_t number_of_drivers; efi_handle_t *driver_handle_buffer; efi_status_t r, ret; @@ -1350,27 +1352,13 @@ static efi_status_t efi_disconnect_all_drivers if (!number_of_drivers) return EFI_SUCCESS; - tmp = number_of_drivers; while (number_of_drivers) { - ret = EFI_CALL(efi_disconnect_controller( + r = EFI_CALL(efi_disconnect_controller( handle, driver_handle_buffer[--number_of_drivers], child_handle)); - if (ret != EFI_SUCCESS) - goto reconnect; - } - - free(driver_handle_buffer); - return ret; - -reconnect: - /* Reconnect all disconnected drivers */ - for (; number_of_drivers < tmp; number_of_drivers++) { - r = EFI_CALL(efi_connect_controller(handle, - &driver_handle_buffer[number_of_drivers], - NULL, true)); if (r != EFI_SUCCESS) - EFI_PRINT("Failed to reconnect controller\n"); + ret = r; } free(driver_handle_buffer); @@ -1409,6 +1397,13 @@ static efi_status_t efi_uninstall_protocol r = efi_disconnect_all_drivers(handle, protocol, NULL); if (r != EFI_SUCCESS) { r = EFI_ACCESS_DENIED; + /* + * This will reconnect all controllers of the handle, even ones + * that were not connected before. This can be done better + * but we are following the EDKII implementation on this for + * now + */ + EFI_CALL(efi_connect_controller(handle, NULL, NULL, true)); goto out; } /* Close protocol */ diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c index af8a2ee940..de0d49ebeb 100644 --- a/lib/efi_loader/efi_capsule.c +++ b/lib/efi_loader/efi_capsule.c @@ -8,7 +8,6 @@ #define LOG_CATEGORY LOGC_EFI -#include <common.h> #include <efi_loader.h> #include <efi_variable.h> #include <env.h> diff --git a/lib/efi_loader/efi_conformance.c b/lib/efi_loader/efi_conformance.c index 0ca26f57a7..167067e26c 100644 --- a/lib/efi_loader/efi_conformance.c +++ b/lib/efi_loader/efi_conformance.c @@ -5,7 +5,6 @@ * Copyright (C) 2022 Arm Ltd. */ -#include <common.h> #include <efi_loader.h> #include <log.h> #include <efi_api.h> diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c index a2d137d7a9..03dece51ae 100644 --- a/lib/efi_loader/efi_console.c +++ b/lib/efi_loader/efi_console.c @@ -8,7 +8,6 @@ #define LOG_CATEGORY LOGC_EFI #include <ansi.h> -#include <common.h> #include <charset.h> #include <malloc.h> #include <time.h> diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c index ed7214f3a3..8dbd8105ae 100644 --- a/lib/efi_loader/efi_device_path.c +++ b/lib/efi_loader/efi_device_path.c @@ -7,7 +7,6 @@ #define LOG_CATEGORY LOGC_EFI -#include <common.h> #include <blk.h> #include <dm.h> #include <dm/root.h> diff --git a/lib/efi_loader/efi_device_path_to_text.c b/lib/efi_loader/efi_device_path_to_text.c index 8c76d8be60..0c7b30a26e 100644 --- a/lib/efi_loader/efi_device_path_to_text.c +++ b/lib/efi_loader/efi_device_path_to_text.c @@ -5,7 +5,6 @@ * Copyright (c) 2017 Heinrich Schuchardt */ -#include <common.h> #include <blk.h> #include <efi_loader.h> #include <malloc.h> diff --git a/lib/efi_loader/efi_device_path_utilities.c b/lib/efi_loader/efi_device_path_utilities.c index a07d9bab3a..844d8acd67 100644 --- a/lib/efi_loader/efi_device_path_utilities.c +++ b/lib/efi_loader/efi_device_path_utilities.c @@ -5,7 +5,6 @@ * Copyright (c) 2017 Leif Lindholm */ -#include <common.h> #include <efi_loader.h> const efi_guid_t efi_guid_device_path_utilities_protocol = diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c index f0d76113b0..ed997008c4 100644 --- a/lib/efi_loader/efi_disk.c +++ b/lib/efi_loader/efi_disk.c @@ -7,7 +7,6 @@ #define LOG_CATEGORY LOGC_EFI -#include <common.h> #include <blk.h> #include <dm.h> #include <dm/device-internal.h> @@ -690,6 +689,13 @@ int efi_disk_probe(void *ctx, struct event *event) return -1; } + /* only do the boot option management when UEFI sub-system is initialized */ + if (IS_ENABLED(CONFIG_CMD_BOOTEFI_BOOTMGR) && efi_obj_list_initialized == EFI_SUCCESS) { + ret = efi_bootmgr_update_media_device_boot_option(); + if (ret != EFI_SUCCESS) + return -1; + } + return 0; } @@ -742,6 +748,17 @@ int efi_disk_remove(void *ctx, struct event *event) dev_tag_del(dev, DM_TAG_EFI); return 0; + + /* + * TODO A flag to distinguish below 2 different scenarios of this + * function call is needed: + * a) Unplugging of a removable media under U-Boot + * b) U-Boot exiting and booting an OS + * In case of scenario a), efi_bootmgr_update_media_device_boot_option() + * needs to be invoked here to update the boot options and remove the + * unnecessary ones. + */ + } /** diff --git a/lib/efi_loader/efi_dt_fixup.c b/lib/efi_loader/efi_dt_fixup.c index 838023c78f..9886e6897c 100644 --- a/lib/efi_loader/efi_dt_fixup.c +++ b/lib/efi_loader/efi_dt_fixup.c @@ -5,7 +5,6 @@ * Copyright (c) 2020 Heinrich Schuchardt */ -#include <common.h> #include <efi_dt_fixup.h> #include <efi_loader.h> #include <efi_rng.h> @@ -173,7 +172,7 @@ efi_dt_fixup(struct efi_dt_fixup_protocol *this, void *dtb, } fdt_set_totalsize(dtb, *buffer_size); - if (image_setup_libfdt(&img, dtb, 0, NULL)) { + if (image_setup_libfdt(&img, dtb, NULL)) { log_err("failed to process device tree\n"); ret = EFI_INVALID_PARAMETER; goto out; diff --git a/lib/efi_loader/efi_esrt.c b/lib/efi_loader/efi_esrt.c index 7f46d651e6..dafd447b6d 100644 --- a/lib/efi_loader/efi_esrt.c +++ b/lib/efi_loader/efi_esrt.c @@ -5,7 +5,6 @@ * Copyright (C) 2021 Arm Ltd. */ -#include <common.h> #include <efi_loader.h> #include <log.h> #include <efi_api.h> diff --git a/lib/efi_loader/efi_file.c b/lib/efi_loader/efi_file.c index 3c56cebf96..222001d6a3 100644 --- a/lib/efi_loader/efi_file.c +++ b/lib/efi_loader/efi_file.c @@ -5,7 +5,6 @@ * Copyright (c) 2017 Rob Clark */ -#include <common.h> #include <charset.h> #include <efi_loader.h> #include <log.h> diff --git a/lib/efi_loader/efi_firmware.c b/lib/efi_loader/efi_firmware.c index 9abb29f1df..1fde1885e3 100644 --- a/lib/efi_loader/efi_firmware.c +++ b/lib/efi_loader/efi_firmware.c @@ -6,7 +6,6 @@ * Author: AKASHI Takahiro */ -#include <common.h> #include <charset.h> #include <dfu.h> #include <efi_loader.h> diff --git a/lib/efi_loader/efi_freestanding.c b/lib/efi_loader/efi_freestanding.c index 4b65fc64dd..b2786095c3 100644 --- a/lib/efi_loader/efi_freestanding.c +++ b/lib/efi_loader/efi_freestanding.c @@ -8,7 +8,7 @@ * memset(), and memcmp(). */ -#include <common.h> +#include <linux/types.h> /** * memcmp() - compare memory areas diff --git a/lib/efi_loader/efi_gop.c b/lib/efi_loader/efi_gop.c index a09db31eb4..41e12fa724 100644 --- a/lib/efi_loader/efi_gop.c +++ b/lib/efi_loader/efi_gop.c @@ -5,7 +5,6 @@ * Copyright (c) 2016 Alexander Graf */ -#include <common.h> #include <dm.h> #include <efi_loader.h> #include <log.h> diff --git a/lib/efi_loader/efi_helper.c b/lib/efi_loader/efi_helper.c index cdfd16ea77..17f27ca1a0 100644 --- a/lib/efi_loader/efi_helper.c +++ b/lib/efi_loader/efi_helper.c @@ -4,7 +4,6 @@ */ #define LOG_CATEGORY LOGC_EFI -#include <common.h> #include <env.h> #include <malloc.h> #include <dm.h> diff --git a/lib/efi_loader/efi_hii.c b/lib/efi_loader/efi_hii.c index 3b54ecb11a..74e402df1b 100644 --- a/lib/efi_loader/efi_hii.c +++ b/lib/efi_loader/efi_hii.c @@ -6,7 +6,6 @@ * Copyright (c) 2018 AKASHI Takahiro, Linaro Limited */ -#include <common.h> #include <efi_loader.h> #include <malloc.h> #include <asm/unaligned.h> diff --git a/lib/efi_loader/efi_hii_config.c b/lib/efi_loader/efi_hii_config.c index 31b0c97eb2..ae0f3ecd3b 100644 --- a/lib/efi_loader/efi_hii_config.c +++ b/lib/efi_loader/efi_hii_config.c @@ -10,7 +10,6 @@ * the Makefile. */ -#include <common.h> #include <efi_loader.h> const efi_guid_t efi_guid_hii_config_routing_protocol diff --git a/lib/efi_loader/efi_image_loader.c b/lib/efi_loader/efi_image_loader.c index 97547571ce..6042436032 100644 --- a/lib/efi_loader/efi_image_loader.c +++ b/lib/efi_loader/efi_image_loader.c @@ -9,7 +9,6 @@ #define LOG_CATEGORY LOGC_EFI -#include <common.h> #include <cpu_func.h> #include <efi_loader.h> #include <log.h> diff --git a/lib/efi_loader/efi_load_initrd.c b/lib/efi_loader/efi_load_initrd.c index 193433782c..2b467b5548 100644 --- a/lib/efi_loader/efi_load_initrd.c +++ b/lib/efi_loader/efi_load_initrd.c @@ -4,7 +4,6 @@ */ #define LOG_CATEGORY LOGC_EFI -#include <common.h> #include <efi_loader.h> #include <efi_load_initrd.h> #include <efi_variable.h> diff --git a/lib/efi_loader/efi_load_options.c b/lib/efi_loader/efi_load_options.c index 5f62184da1..01984235e2 100644 --- a/lib/efi_loader/efi_load_options.c +++ b/lib/efi_loader/efi_load_options.c @@ -7,7 +7,6 @@ #define LOG_CATEGORY LOGC_EFI -#include <common.h> #include <charset.h> #include <log.h> #include <malloc.h> diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c index f752703b43..edfad2d95a 100644 --- a/lib/efi_loader/efi_memory.c +++ b/lib/efi_loader/efi_memory.c @@ -7,7 +7,6 @@ #define LOG_CATEGORY LOGC_EFI -#include <common.h> #include <efi_loader.h> #include <init.h> #include <log.h> diff --git a/lib/efi_loader/efi_net.c b/lib/efi_loader/efi_net.c index 96a5bcca27..7cd536705f 100644 --- a/lib/efi_loader/efi_net.c +++ b/lib/efi_loader/efi_net.c @@ -15,7 +15,6 @@ * Reset(): EfiSimpleNetworkInitialized -> EfiSimpleNetworkInitialized */ -#include <common.h> #include <efi_loader.h> #include <malloc.h> #include <net.h> diff --git a/lib/efi_loader/efi_riscv.c b/lib/efi_loader/efi_riscv.c index 064172755b..4d398c5be3 100644 --- a/lib/efi_loader/efi_riscv.c +++ b/lib/efi_loader/efi_riscv.c @@ -7,7 +7,6 @@ */ #define LOG_CATEGORY LOGC_EFI -#include <common.h> #include <efi_loader.h> #include <efi_variable.h> #include <log.h> diff --git a/lib/efi_loader/efi_rng.c b/lib/efi_loader/efi_rng.c index bb11d8d0e0..9bad7ed693 100644 --- a/lib/efi_loader/efi_rng.c +++ b/lib/efi_loader/efi_rng.c @@ -5,7 +5,6 @@ #define LOG_CATEGORY LOGC_EFI -#include <common.h> #include <dm.h> #include <efi_loader.h> #include <efi_rng.h> diff --git a/lib/efi_loader/efi_root_node.c b/lib/efi_loader/efi_root_node.c index 108c14b95b..4d7fb74b5d 100644 --- a/lib/efi_loader/efi_root_node.c +++ b/lib/efi_loader/efi_root_node.c @@ -5,7 +5,6 @@ * Copyright (c) 2018 Heinrich Schuchardt */ -#include <common.h> #include <malloc.h> #include <efi_dt_fixup.h> #include <efi_loader.h> diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c index bf54d6ad87..18da6892e7 100644 --- a/lib/efi_loader/efi_runtime.c +++ b/lib/efi_loader/efi_runtime.c @@ -5,7 +5,6 @@ * Copyright (c) 2016 Alexander Graf */ -#include <common.h> #include <command.h> #include <cpu_func.h> #include <dm.h> diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c index e6de685e87..a610e032d2 100644 --- a/lib/efi_loader/efi_setup.c +++ b/lib/efi_loader/efi_setup.c @@ -7,7 +7,6 @@ #define LOG_CATEGORY LOGC_EFI -#include <common.h> #include <efi_loader.h> #include <efi_variable.h> #include <log.h> @@ -245,6 +244,13 @@ efi_status_t efi_init_obj_list(void) if (ret != EFI_SUCCESS) goto out; + if (IS_ENABLED(CONFIG_CMD_BOOTEFI_BOOTMGR)) { + /* update boot option after variable service initialized */ + ret = efi_bootmgr_update_media_device_boot_option(); + if (ret != EFI_SUCCESS) + goto out; + } + /* Define supported languages */ ret = efi_init_platform_lang(); if (ret != EFI_SUCCESS) diff --git a/lib/efi_loader/efi_signature.c b/lib/efi_loader/efi_signature.c index 742d891940..f338e73275 100644 --- a/lib/efi_loader/efi_signature.c +++ b/lib/efi_loader/efi_signature.c @@ -4,7 +4,6 @@ * Copyright (c) 2019 Linaro Limited, Author: AKASHI Takahiro */ -#include <common.h> #include <charset.h> #include <efi_loader.h> #include <efi_variable.h> diff --git a/lib/efi_loader/efi_smbios.c b/lib/efi_loader/efi_smbios.c index 0fbf51b98d..eb6d2ba43c 100644 --- a/lib/efi_loader/efi_smbios.c +++ b/lib/efi_loader/efi_smbios.c @@ -7,7 +7,6 @@ #define LOG_CATEGORY LOGC_EFI -#include <common.h> #include <efi_loader.h> #include <log.h> #include <malloc.h> @@ -15,6 +14,8 @@ #include <smbios.h> #include <linux/sizes.h> +const efi_guid_t smbios3_guid = SMBIOS3_TABLE_GUID; + enum { TABLE_SIZE = SZ_4K, }; @@ -28,8 +29,9 @@ efi_status_t efi_smbios_register(void) { ulong addr; efi_status_t ret; + void *buf; - addr = gd->arch.smbios_start; + addr = gd_smbios_start(); if (!addr) { log_err("No SMBIOS tables to install\n"); return EFI_NOT_FOUND; @@ -43,33 +45,34 @@ efi_status_t efi_smbios_register(void) log_debug("EFI using SMBIOS tables at %lx\n", addr); /* Install SMBIOS information as configuration table */ - return efi_install_configuration_table(&smbios_guid, - map_sysmem(addr, 0)); + buf = map_sysmem(addr, 0); + ret = efi_install_configuration_table(&smbios3_guid, buf); + unmap_sysmem(buf); + + return ret; } static int install_smbios_table(void) { - u64 addr; - efi_status_t ret; + ulong addr; + void *buf; if (!IS_ENABLED(CONFIG_GENERATE_SMBIOS_TABLE) || IS_ENABLED(CONFIG_X86)) return 0; - addr = SZ_4G; - ret = efi_allocate_pages(EFI_ALLOCATE_MAX_ADDRESS, - EFI_RUNTIME_SERVICES_DATA, - efi_size_in_pages(TABLE_SIZE), &addr); - if (ret != EFI_SUCCESS) + /* Align the table to a 4KB boundary to keep EFI happy */ + buf = memalign(SZ_4K, TABLE_SIZE); + if (!buf) return log_msg_ret("mem", -ENOMEM); - addr = map_to_sysmem((void *)(uintptr_t)addr); + addr = map_to_sysmem(buf); if (!write_smbios_table(addr)) { log_err("Failed to write SMBIOS table\n"); return log_msg_ret("smbios", -EINVAL); } /* Make a note of where we put it */ - log_debug("SMBIOS tables written to %llx\n", addr); + log_debug("SMBIOS tables written to %lx\n", addr); gd->arch.smbios_start = addr; return 0; diff --git a/lib/efi_loader/efi_string.c b/lib/efi_loader/efi_string.c index e21e09c946..413e329b60 100644 --- a/lib/efi_loader/efi_string.c +++ b/lib/efi_loader/efi_string.c @@ -5,7 +5,6 @@ * Copyright (c) 2020 AKASHI Takahiro, Linaro Limited */ -#include <common.h> #include <charset.h> #include <efi_loader.h> #include <malloc.h> diff --git a/lib/efi_loader/efi_tcg2.c b/lib/efi_loader/efi_tcg2.c index 463ea4c154..8db35d0b3c 100644 --- a/lib/efi_loader/efi_tcg2.c +++ b/lib/efi_loader/efi_tcg2.c @@ -8,7 +8,6 @@ */ #define LOG_CATEGORY LOGC_EFI -#include <common.h> #include <dm.h> #include <efi_loader.h> #include <efi_variable.h> diff --git a/lib/efi_loader/efi_unicode_collation.c b/lib/efi_loader/efi_unicode_collation.c index c4c7572063..2b6912c509 100644 --- a/lib/efi_loader/efi_unicode_collation.c +++ b/lib/efi_loader/efi_unicode_collation.c @@ -5,7 +5,6 @@ * Copyright (c) 2018 Heinrich Schuchardt <xypron.glpk@gmx.de> */ -#include <common.h> #include <charset.h> #include <cp1250.h> #include <cp437.h> diff --git a/lib/efi_loader/efi_var_common.c b/lib/efi_loader/efi_var_common.c index ad50bffd2b..d528747f3f 100644 --- a/lib/efi_loader/efi_var_common.c +++ b/lib/efi_loader/efi_var_common.c @@ -6,7 +6,6 @@ * Copyright (c) 2020 Linaro Limited, Author: AKASHI Takahiro */ -#include <common.h> #include <efi_loader.h> #include <efi_variable.h> #include <stdlib.h> diff --git a/lib/efi_loader/efi_var_file.c b/lib/efi_loader/efi_var_file.c index d7dba05071..532b6b40ee 100644 --- a/lib/efi_loader/efi_var_file.c +++ b/lib/efi_loader/efi_var_file.c @@ -7,7 +7,6 @@ #define LOG_CATEGORY LOGC_EFI -#include <common.h> #include <charset.h> #include <fs.h> #include <log.h> diff --git a/lib/efi_loader/efi_var_mem.c b/lib/efi_loader/efi_var_mem.c index 5fa7dcb8d3..6c21cec5d4 100644 --- a/lib/efi_loader/efi_var_mem.c +++ b/lib/efi_loader/efi_var_mem.c @@ -5,7 +5,6 @@ * Copyright (c) 2020, Heinrich Schuchardt */ -#include <common.h> #include <efi_loader.h> #include <efi_variable.h> #include <u-boot/crc.h> diff --git a/lib/efi_loader/efi_variable.c b/lib/efi_loader/efi_variable.c index be95ed44e6..40f7a0fb10 100644 --- a/lib/efi_loader/efi_variable.c +++ b/lib/efi_loader/efi_variable.c @@ -7,7 +7,6 @@ #define LOG_CATEGORY LOGC_EFI -#include <common.h> #include <efi_loader.h> #include <efi_variable.h> #include <env.h> diff --git a/lib/efi_loader/efi_variable_tee.c b/lib/efi_loader/efi_variable_tee.c index 09d03c0eee..dde135fd9f 100644 --- a/lib/efi_loader/efi_variable_tee.c +++ b/lib/efi_loader/efi_variable_tee.c @@ -10,7 +10,6 @@ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> */ -#include <common.h> #if CONFIG_IS_ENABLED(ARM_FFA_TRANSPORT) #include <arm_ffa.h> #endif diff --git a/lib/efi_loader/efi_watchdog.c b/lib/efi_loader/efi_watchdog.c index d741076dcd..f5fb911771 100644 --- a/lib/efi_loader/efi_watchdog.c +++ b/lib/efi_loader/efi_watchdog.c @@ -5,7 +5,6 @@ * Copyright (c) 2017 Heinrich Schuchardt */ -#include <common.h> #include <efi_loader.h> /* Conversion factor from seconds to multiples of 100ns */ diff --git a/lib/efi_loader/initrddump.c b/lib/efi_loader/initrddump.c index 5b470f4819..0004b6b042 100644 --- a/lib/efi_loader/initrddump.c +++ b/lib/efi_loader/initrddump.c @@ -9,7 +9,6 @@ * clearing of the screen. */ -#include <common.h> #include <efi_api.h> #include <efi_load_initrd.h> diff --git a/lib/efi_selftest/efi_selftest_esrt.c b/lib/efi_selftest/efi_selftest_esrt.c index 922ff253c7..b7688deb49 100644 --- a/lib/efi_selftest/efi_selftest_esrt.c +++ b/lib/efi_selftest/efi_selftest_esrt.c @@ -4,7 +4,6 @@ * * Copyright (C) 2021 Arm Ltd. */ -#include <common.h> #include <efi_loader.h> #include <efi_selftest.h> diff --git a/lib/efi_selftest/efi_selftest_miniapp_exception.c b/lib/efi_selftest/efi_selftest_miniapp_exception.c index a9ad381001..f668cdac4a 100644 --- a/lib/efi_selftest/efi_selftest_miniapp_exception.c +++ b/lib/efi_selftest/efi_selftest_miniapp_exception.c @@ -7,7 +7,6 @@ * This EFI application triggers an exception. */ -#include <common.h> #include <efi_api.h> #include <host_arch.h> diff --git a/lib/efi_selftest/efi_selftest_miniapp_exit.c b/lib/efi_selftest/efi_selftest_miniapp_exit.c index 1c42d6dd40..8b2e60cc71 100644 --- a/lib/efi_selftest/efi_selftest_miniapp_exit.c +++ b/lib/efi_selftest/efi_selftest_miniapp_exit.c @@ -8,7 +8,6 @@ * It uses the Exit boot service to return. */ -#include <common.h> #include <efi_selftest.h> static efi_guid_t loaded_image_protocol_guid = EFI_LOADED_IMAGE_PROTOCOL_GUID; diff --git a/lib/efi_selftest/efi_selftest_miniapp_return.c b/lib/efi_selftest/efi_selftest_miniapp_return.c index 45366aa9c6..8792d78ab3 100644 --- a/lib/efi_selftest/efi_selftest_miniapp_return.c +++ b/lib/efi_selftest/efi_selftest_miniapp_return.c @@ -8,7 +8,6 @@ * It returns directly without calling the Exit boot service. */ -#include <common.h> #include <efi_api.h> /* @@ -3,7 +3,6 @@ Copyright (c) 2001 William L. Pitts */ -#include <common.h> #include <command.h> #include <cpu_func.h> #include <elf.h> diff --git a/lib/errno_str.c b/lib/errno_str.c index 2e5f4a887d..752d4eb47a 100644 --- a/lib/errno_str.c +++ b/lib/errno_str.c @@ -4,8 +4,8 @@ * * SDPX-License-Identifier: GPL-2.0+ */ -#include <common.h> #include <errno.h> +#include <linux/kernel.h> #define ERRNO_MSG(errno, msg) msg #define SAME_AS(x) (const char *)&errno_message[x] diff --git a/lib/fdtdec.c b/lib/fdtdec.c index 7a69167648..b2c59ab381 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -7,7 +7,10 @@ */ #ifndef USE_HOSTCC -#include <common.h> + +#define LOG_CATEGORY LOGC_DT + +#include <bloblist.h> #include <boot_fit.h> #include <display_options.h> #include <dm.h> @@ -87,6 +90,7 @@ static const char *const fdt_src_name[] = { [FDTSRC_BOARD] = "board", [FDTSRC_EMBED] = "embed", [FDTSRC_ENV] = "env", + [FDTSRC_BLOBLIST] = "bloblist", }; const char *fdtdec_get_srcname(void) @@ -1663,23 +1667,42 @@ static void setup_multi_dtb_fit(void) int fdtdec_setup(void) { - int ret; + int ret = -ENOENT; + + /* If allowing a bloblist, check that first */ + if (CONFIG_IS_ENABLED(BLOBLIST)) { + ret = bloblist_maybe_init(); + if (!ret) { + gd->fdt_blob = bloblist_find(BLOBLISTT_CONTROL_FDT, 0); + if (gd->fdt_blob) { + gd->fdt_src = FDTSRC_BLOBLIST; + log_debug("Devicetree is in bloblist at %p\n", + gd->fdt_blob); + } else { + log_debug("No FDT found in bloblist\n"); + ret = -ENOENT; + } + } + } - /* The devicetree is typically appended to U-Boot */ - if (IS_ENABLED(CONFIG_OF_SEPARATE)) { - gd->fdt_blob = fdt_find_separate(); - gd->fdt_src = FDTSRC_SEPARATE; - } else { /* embed dtb in ELF file for testing / development */ - gd->fdt_blob = dtb_dt_embedded(); - gd->fdt_src = FDTSRC_EMBED; + /* Otherwise, the devicetree is typically appended to U-Boot */ + if (ret) { + if (IS_ENABLED(CONFIG_OF_SEPARATE)) { + gd->fdt_blob = fdt_find_separate(); + gd->fdt_src = FDTSRC_SEPARATE; + } else { /* embed dtb in ELF file for testing / development */ + gd->fdt_blob = dtb_dt_embedded(); + gd->fdt_src = FDTSRC_EMBED; + } } /* Allow the board to override the fdt address. */ if (IS_ENABLED(CONFIG_OF_BOARD)) { gd->fdt_blob = board_fdt_blob_setup(&ret); - if (ret) + if (!ret) + gd->fdt_src = FDTSRC_BOARD; + else if (ret != -EEXIST) return ret; - gd->fdt_src = FDTSRC_BOARD; } /* Allow the early environment to override the fdt address */ diff --git a/lib/fdtdec_common.c b/lib/fdtdec_common.c index ddaca0087e..ca36ff1595 100644 --- a/lib/fdtdec_common.c +++ b/lib/fdtdec_common.c @@ -8,7 +8,6 @@ */ #ifndef USE_HOSTCC -#include <common.h> #include <log.h> #include <linux/libfdt.h> #include <fdtdec.h> diff --git a/lib/fdtdec_test.c b/lib/fdtdec_test.c index 85351c75ca..1e4d5fc832 100644 --- a/lib/fdtdec_test.c +++ b/lib/fdtdec_test.c @@ -6,7 +6,6 @@ * Copyright (c) 2011 The Chromium OS Authors. */ -#include <common.h> #include <command.h> #include <fdtdec.h> #include <linux/libfdt.h> diff --git a/lib/getopt.c b/lib/getopt.c index 8b4515dc19..e9175e2fff 100644 --- a/lib/getopt.c +++ b/lib/getopt.c @@ -8,9 +8,9 @@ #define LOG_CATEGORY LOGC_CORE -#include <common.h> #include <getopt.h> #include <log.h> +#include <linux/string.h> void getopt_init_state(struct getopt_state *gs) { diff --git a/lib/gunzip.c b/lib/gunzip.c index 932e3e8036..e71d8d00cc 100644 --- a/lib/gunzip.c +++ b/lib/gunzip.c @@ -4,7 +4,6 @@ * Wolfgang Denk, DENX Software Engineering, wd@denx.de. */ -#include <common.h> #include <blk.h> #include <command.h> #include <console.h> diff --git a/lib/gzip.c b/lib/gzip.c index 2595b2d04b..5d9c19598d 100644 --- a/lib/gzip.c +++ b/lib/gzip.c @@ -4,7 +4,6 @@ * Lei Wen <leiwen@marvell.com>, Marvell Inc. */ -#include <common.h> #include <watchdog.h> #include <command.h> #include <gzip.h> diff --git a/lib/hang.c b/lib/hang.c index 2735774f9a..3cfb06e9ca 100644 --- a/lib/hang.c +++ b/lib/hang.c @@ -7,9 +7,9 @@ * u-boot. */ -#include <common.h> #include <bootstage.h> #include <hang.h> +#include <stdio.h> #include <os.h> /** diff --git a/lib/hash-checksum.c b/lib/hash-checksum.c index 68c290d64d..1970a74129 100644 --- a/lib/hash-checksum.c +++ b/lib/hash-checksum.c @@ -4,7 +4,6 @@ */ #ifndef USE_HOSTCC -#include <common.h> #include <fdtdec.h> #include <asm/byteorder.h> #include <linux/errno.h> diff --git a/lib/hashtable.c b/lib/hashtable.c index f2d36bd34b..a0060f6a0d 100644 --- a/lib/hashtable.c +++ b/lib/hashtable.c @@ -30,7 +30,6 @@ # endif # endif #else /* U-Boot build */ -# include <common.h> # include <linux/string.h> # include <linux/ctype.h> #endif diff --git a/lib/hexdump.c b/lib/hexdump.c index 149c93ead8..33e3e6e518 100644 --- a/lib/hexdump.c +++ b/lib/hexdump.c @@ -8,9 +8,9 @@ * more details. */ -#include <common.h> #include <hexdump.h> #include <mapmem.h> +#include <vsprintf.h> #include <linux/ctype.h> #include <linux/compat.h> #include <linux/log2.h> diff --git a/lib/image-sparse.c b/lib/image-sparse.c index 323aad981c..f828906469 100644 --- a/lib/image-sparse.c +++ b/lib/image-sparse.c @@ -35,7 +35,6 @@ */ #include <config.h> -#include <common.h> #include <blk.h> #include <image-sparse.h> #include <div64.h> diff --git a/lib/initcall.c b/lib/initcall.c index 33b7d761dc..ce317af213 100644 --- a/lib/initcall.c +++ b/lib/initcall.c @@ -3,7 +3,6 @@ * Copyright (c) 2013 The Chromium OS Authors. */ -#include <common.h> #include <efi.h> #include <initcall.h> #include <log.h> diff --git a/lib/libavb/avb_sysdeps.h b/lib/libavb/avb_sysdeps.h index f52428cc62..aece8e0a01 100644 --- a/lib/libavb/avb_sysdeps.h +++ b/lib/libavb/avb_sysdeps.h @@ -19,7 +19,9 @@ extern "C" { * like uint8_t, uint64_t, and bool (with |false|, |true| keywords) * must be present. */ -#include <common.h> +#include <stdio.h> +#include <stdbool.h> +#include <linux/types.h> /* If you don't have gcc or clang, these attribute macros may need to * be adjusted. diff --git a/lib/linux_compat.c b/lib/linux_compat.c index c83426f59d..985e88eb39 100644 --- a/lib/linux_compat.c +++ b/lib/linux_compat.c @@ -1,5 +1,4 @@ -#include <common.h> #include <malloc.h> #include <memalign.h> #include <asm/cache.h> diff --git a/lib/list_sort.c b/lib/list_sort.c index 1c9e061732..a6e54d5bc4 100644 --- a/lib/list_sort.c +++ b/lib/list_sort.c @@ -6,7 +6,6 @@ #include <linux/slab.h> #else #include <linux/compat.h> -#include <common.h> #include <malloc.h> #include <linux/printk.h> #endif @@ -6,7 +6,6 @@ * Copyright (C) 2001 Peter Bergner. */ -#include <common.h> #include <efi_loader.h> #include <image.h> #include <mapmem.h> @@ -27,7 +27,6 @@ * - LZ4 homepage : http://www.lz4.org * - LZ4 source repository : https://github.com/lz4/lz4 */ -#include <common.h> #include <compiler.h> #include <linux/kernel.h> #include <linux/types.h> diff --git a/lib/lz4_wrapper.c b/lib/lz4_wrapper.c index 67dea2ff39..4d48e7b0e8 100644 --- a/lib/lz4_wrapper.c +++ b/lib/lz4_wrapper.c @@ -3,7 +3,6 @@ * Copyright 2015 Google Inc. */ -#include <common.h> #include <compiler.h> #include <image.h> #include <linux/kernel.h> diff --git a/lib/lzma/LzmaDec.c b/lib/lzma/LzmaDec.c index a90b35c6a9..1da3f0a14a 100644 --- a/lib/lzma/LzmaDec.c +++ b/lib/lzma/LzmaDec.c @@ -2,7 +2,6 @@ 2009-09-20 : Igor Pavlov : Public domain */ #include <config.h> -#include <common.h> #include <watchdog.h> #include "LzmaDec.h" diff --git a/lib/lzma/LzmaTools.c b/lib/lzma/LzmaTools.c index 55f64cd289..400d606784 100644 --- a/lib/lzma/LzmaTools.c +++ b/lib/lzma/LzmaTools.c @@ -18,7 +18,6 @@ */ #include <config.h> -#include <common.h> #include <log.h> #include <watchdog.h> diff --git a/lib/lzo/lzo1x_decompress.c b/lib/lzo/lzo1x_decompress.c index 65fef0b0eb..5d70fa4133 100644 --- a/lib/lzo/lzo1x_decompress.c +++ b/lib/lzo/lzo1x_decompress.c @@ -11,8 +11,9 @@ * Richard Purdie <rpurdie@openedhand.com> */ -#include <common.h> +#include <linux/kernel.h> #include <linux/lzo.h> +#include <linux/string.h> #include <asm/byteorder.h> #include <asm/unaligned.h> #include "lzodefs.h" @@ -28,7 +28,6 @@ #include "compiler.h" #ifndef USE_HOSTCC -#include <common.h> #include <watchdog.h> #endif /* USE_HOSTCC */ #include <u-boot/md5.h> diff --git a/lib/membuff.c b/lib/membuff.c index 36dc43a523..3c6c0ae125 100644 --- a/lib/membuff.c +++ b/lib/membuff.c @@ -6,7 +6,6 @@ * Copyright (c) 1992 Simon Glass */ -#include <common.h> #include <errno.h> #include <log.h> #include <malloc.h> diff --git a/lib/net_utils.c b/lib/net_utils.c index 4283c13a31..c70fef0d99 100644 --- a/lib/net_utils.c +++ b/lib/net_utils.c @@ -9,9 +9,9 @@ * Copyright 2009 Dirk Behme, dirk.behme@googlemail.com */ -#include <common.h> #include <net.h> #include <net6.h> +#include <vsprintf.h> struct in_addr string_to_ip(const char *s) { diff --git a/lib/of_live.c b/lib/of_live.c index 812c488f60..90b9459ede 100644 --- a/lib/of_live.c +++ b/lib/of_live.c @@ -10,7 +10,6 @@ #define LOG_CATEGORY LOGC_DT -#include <common.h> #include <abuf.h> #include <log.h> #include <linux/libfdt.h> diff --git a/lib/optee/optee.c b/lib/optee/optee.c index b036224044..393f2715a9 100644 --- a/lib/optee/optee.c +++ b/lib/optee/optee.c @@ -4,7 +4,6 @@ * Bryan O'Donoghue <bryan.odonoghue@linaro.org> */ -#include <common.h> #include <fdtdec.h> #include <image.h> #include <log.h> diff --git a/lib/panic.c b/lib/panic.c index 66ae17f3df..0f578b5b51 100644 --- a/lib/panic.c +++ b/lib/panic.c @@ -9,7 +9,6 @@ * Wirzenius wrote this portably, Torvalds fucked it up :-) */ -#include <common.h> #include <hang.h> #if !defined(CONFIG_PANIC_HANG) #include <command.h> diff --git a/lib/physmem.c b/lib/physmem.c index fc90ce4d7c..562c74d37f 100644 --- a/lib/physmem.c +++ b/lib/physmem.c @@ -8,11 +8,11 @@ * Software Foundation. */ -#include <common.h> #include <log.h> #include <mapmem.h> #include <physmem.h> #include <linux/compiler.h> +#include <linux/string.h> phys_addr_t __weak arch_phys_memset(phys_addr_t s, int c, phys_size_t n) { diff --git a/lib/qsort.c b/lib/qsort.c index 2f18588dfc..a2562c4942 100644 --- a/lib/qsort.c +++ b/lib/qsort.c @@ -17,7 +17,6 @@ #include <log.h> #include <linux/types.h> -#include <common.h> #include <exports.h> #include <sort.h> diff --git a/lib/rand.c b/lib/rand.c index d256baf5ce..d6f2977e8d 100644 --- a/lib/rand.c +++ b/lib/rand.c @@ -7,7 +7,6 @@ * Michael Walle <michael@walle.cc> */ -#include <common.h> #include <rand.h> static unsigned int y = 1U; @@ -7,9 +7,6 @@ * Rivest Cipher 4 (RC4) implementation */ -#ifndef USE_HOSTCC -#include <common.h> -#endif #include <rc4.h> void rc4_encode(unsigned char *buf, unsigned int len, const unsigned char key[16]) diff --git a/lib/rsa/rsa-keyprop.c b/lib/rsa/rsa-keyprop.c index 98855f67b8..80d0594a43 100644 --- a/lib/rsa/rsa-keyprop.c +++ b/lib/rsa/rsa-keyprop.c @@ -9,7 +9,6 @@ * Copyright (c) 2016 Thomas Pornin <pornin@bolet.org> */ -#include <common.h> #include <image.h> #include <malloc.h> #include <crypto/internal/rsa.h> diff --git a/lib/rsa/rsa-mod-exp.c b/lib/rsa/rsa-mod-exp.c index d259b2aedf..5b3ea02f82 100644 --- a/lib/rsa/rsa-mod-exp.c +++ b/lib/rsa/rsa-mod-exp.c @@ -4,7 +4,6 @@ */ #ifndef USE_HOSTCC -#include <common.h> #include <fdtdec.h> #include <log.h> #include <asm/types.h> diff --git a/lib/rsa/rsa-sign.c b/lib/rsa/rsa-sign.c index d20bdb58a5..858ad92a6f 100644 --- a/lib/rsa/rsa-sign.c +++ b/lib/rsa/rsa-sign.c @@ -116,15 +116,15 @@ static int rsa_engine_get_pub_key(const char *keydir, const char *name, if (keydir) if (strstr(keydir, "object=")) snprintf(key_id, sizeof(key_id), - "pkcs11:%s;type=public", + "%s;type=public", keydir); else snprintf(key_id, sizeof(key_id), - "pkcs11:%s;object=%s;type=public", + "%s;object=%s;type=public", keydir, name); else snprintf(key_id, sizeof(key_id), - "pkcs11:object=%s;type=public", + "object=%s;type=public", name); } else if (engine_id) { if (keydir) @@ -238,15 +238,15 @@ static int rsa_engine_get_priv_key(const char *keydir, const char *name, if (keydir) if (strstr(keydir, "object=")) snprintf(key_id, sizeof(key_id), - "pkcs11:%s;type=private", + "%s;type=private", keydir); else snprintf(key_id, sizeof(key_id), - "pkcs11:%s;object=%s;type=private", + "%s;object=%s;type=private", keydir, name); else snprintf(key_id, sizeof(key_id), - "pkcs11:object=%s;type=private", + "object=%s;type=private", name); } else if (engine_id) { if (keydir && name) @@ -317,7 +317,8 @@ static int rsa_engine_init(const char *engine_id, ENGINE **pe) e = ENGINE_by_id(engine_id); if (!e) { - fprintf(stderr, "Engine isn't available\n"); + fprintf(stderr, "Engine '%s' isn't available\n", engine_id); + ERR_print_errors_fp(stderr); return -1; } diff --git a/lib/rsa/rsa-verify.c b/lib/rsa/rsa-verify.c index 2f3b344039..1007b6979a 100644 --- a/lib/rsa/rsa-verify.c +++ b/lib/rsa/rsa-verify.c @@ -4,7 +4,6 @@ */ #ifndef USE_HOSTCC -#include <common.h> #include <fdtdec.h> #include <log.h> #include <malloc.h> @@ -17,9 +16,9 @@ #else #include "fdt_host.h" #include "mkimage.h" +#include <linux/kconfig.h> #include <fdt_support.h> #endif -#include <linux/kconfig.h> #include <u-boot/rsa-mod-exp.h> #include <u-boot/rsa.h> diff --git a/lib/rtc-lib.c b/lib/rtc-lib.c index 1f7bdade29..46dcfba271 100644 --- a/lib/rtc-lib.c +++ b/lib/rtc-lib.c @@ -10,7 +10,6 @@ * - January is month 1. */ -#include <common.h> #include <rtc.h> #include <linux/math64.h> diff --git a/lib/semihosting.c b/lib/semihosting.c index 831774e356..9be5bffd30 100644 --- a/lib/semihosting.c +++ b/lib/semihosting.c @@ -4,9 +4,10 @@ * Copyright 2014 Broadcom Corporation */ -#include <common.h> #include <log.h> #include <semihosting.h> +#include <linux/errno.h> +#include <linux/string.h> #define SYSOPEN 0x01 #define SYSCLOSE 0x02 diff --git a/lib/sha1.c b/lib/sha1.c index 8d07407893..7ef536f4b5 100644 --- a/lib/sha1.c +++ b/lib/sha1.c @@ -17,12 +17,9 @@ #endif #ifndef USE_HOSTCC -#include <common.h> -#include <linux/string.h> -#else -#include <string.h> +#include <cyclic.h> #endif /* USE_HOSTCC */ -#include <watchdog.h> +#include <string.h> #include <u-boot/sha1.h> #include <linux/compiler_attributes.h> diff --git a/lib/sha256.c b/lib/sha256.c index 4d26aea1c8..665ba6f152 100644 --- a/lib/sha256.c +++ b/lib/sha256.c @@ -6,12 +6,9 @@ */ #ifndef USE_HOSTCC -#include <common.h> -#include <linux/string.h> -#else -#include <string.h> +#include <cyclic.h> #endif /* USE_HOSTCC */ -#include <watchdog.h> +#include <string.h> #include <u-boot/sha256.h> #include <linux/compiler_attributes.h> diff --git a/lib/sha512.c b/lib/sha512.c index fbe8d5f5bf..ffe2c5cd96 100644 --- a/lib/sha512.c +++ b/lib/sha512.c @@ -11,13 +11,9 @@ */ #ifndef USE_HOSTCC -#include <common.h> -#include <linux/string.h> -#else -#include <string.h> +#include <cyclic.h> #endif /* USE_HOSTCC */ #include <compiler.h> -#include <watchdog.h> #include <u-boot/sha512.h> const uint8_t sha384_der_prefix[SHA384_DER_LEN] = { diff --git a/lib/slre.c b/lib/slre.c index e82a9e7635..277a59a03a 100644 --- a/lib/slre.c +++ b/lib/slre.c @@ -21,8 +21,8 @@ #include <string.h> #else #include <log.h> -#include <common.h> #include <linux/ctype.h> +#include <linux/string.h> #endif /* SLRE_TEST */ #include <errno.h> @@ -686,6 +686,7 @@ int main(int argc, char *argv[]) } if (!slre_compile(&slre, argv[1])) { + (void) fclose(fp); fprintf(stderr, "Error compiling slre: %s\n", slre.err_str); return 1; } diff --git a/lib/smbios-parser.c b/lib/smbios-parser.c index 2b9392936b..b578c30840 100644 --- a/lib/smbios-parser.c +++ b/lib/smbios-parser.c @@ -5,7 +5,6 @@ #define LOG_CATEGORY LOGC_BOOT -#include <common.h> #include <smbios.h> static inline int verify_checksum(const struct smbios_entry *e) diff --git a/lib/smbios.c b/lib/smbios.c index d7f4999e8b..d9d52bd58d 100644 --- a/lib/smbios.c +++ b/lib/smbios.c @@ -5,15 +5,17 @@ * Adapted from coreboot src/arch/x86/smbios.c */ -#include <common.h> #include <dm.h> #include <env.h> #include <linux/stringify.h> +#include <linux/string.h> #include <mapmem.h> #include <smbios.h> #include <sysinfo.h> #include <tables_csum.h> #include <version.h> +#include <malloc.h> +#include <dm/ofnode.h> #ifdef CONFIG_CPU #include <cpu.h> #include <dm/uclass-internal.h> @@ -44,6 +46,25 @@ DECLARE_GLOBAL_DATA_PTR; /** + * struct map_sysinfo - Mapping of sysinfo strings to DT + * + * @sysinfo_str: sysinfo string + * @dt_str: DT string + * @max: Max index of the tokenized string to pick. Counting starts from 0 + * + */ +struct map_sysinfo { + const char *sysinfo_str; + const char *dt_str; + int max; +}; + +static const struct map_sysinfo sysinfo_to_dt[] = { + { .sysinfo_str = "product", .dt_str = "model", 2 }, + { .sysinfo_str = "manufacturer", .dt_str = "compatible", 1 }, +}; + +/** * struct smbios_ctx - context for writing SMBIOS tables * * @node: node containing the information to write (ofnode_null() if none) @@ -87,6 +108,18 @@ struct smbios_write_method { const char *subnode_name; }; +static const struct map_sysinfo *convert_sysinfo_to_dt(const char *sysinfo_str) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(sysinfo_to_dt); i++) { + if (!strcmp(sysinfo_str, sysinfo_to_dt[i].sysinfo_str)) + return &sysinfo_to_dt[i]; + } + + return NULL; +} + /** * smbios_add_string() - add a string to the string area * @@ -102,9 +135,6 @@ static int smbios_add_string(struct smbios_ctx *ctx, const char *str) int i = 1; char *p = ctx->eos; - if (!*str) - str = "Unknown"; - for (;;) { if (!*p) { ctx->last_str = p; @@ -128,31 +158,88 @@ static int smbios_add_string(struct smbios_ctx *ctx, const char *str) } /** + * get_str_from_dt - Get a substring from a DT property. + * After finding the property in the DT, the function + * will parse comma-separated values and return the value. + * If nprop->max exceeds the number of comma-separated + * elements, the last non NULL value will be returned. + * Counting starts from zero. + * + * @nprop: sysinfo property to use + * @str: pointer to fill with data + * @size: str buffer length + */ +static +void get_str_from_dt(const struct map_sysinfo *nprop, char *str, size_t size) +{ + const char *dt_str; + int cnt = 0; + char *token; + + memset(str, 0, size); + if (!nprop || !nprop->max) + return; + + dt_str = ofnode_read_string(ofnode_root(), nprop->dt_str); + if (!dt_str) + return; + + memcpy(str, dt_str, size); + token = strtok(str, ","); + while (token && cnt < nprop->max) { + strlcpy(str, token, strlen(token) + 1); + token = strtok(NULL, ","); + cnt++; + } +} + +/** * smbios_add_prop_si() - Add a property from the devicetree or sysinfo * * Sysinfo is used if available, with a fallback to devicetree * * @ctx: context for writing the tables * @prop: property to write + * @dval: Default value to use if the string is not found or is empty * Return: 0 if not found, else SMBIOS string number (1 or more) */ static int smbios_add_prop_si(struct smbios_ctx *ctx, const char *prop, - int sysinfo_id) + int sysinfo_id, const char *dval) { + int ret; + + if (!dval || !*dval) + dval = "Unknown"; + + if (!prop) + return smbios_add_string(ctx, dval); + if (sysinfo_id && ctx->dev) { char val[SMBIOS_STR_MAX]; - int ret; ret = sysinfo_get_str(ctx->dev, sysinfo_id, sizeof(val), val); if (!ret) return smbios_add_string(ctx, val); } if (IS_ENABLED(CONFIG_OF_CONTROL)) { - const char *str; + const char *str = NULL; + char str_dt[128] = { 0 }; + /* + * If the node is not valid fallback and try the entire DT + * so we can at least fill in manufacturer and board type + */ + if (ofnode_valid(ctx->node)) { + str = ofnode_read_string(ctx->node, prop); + } else { + const struct map_sysinfo *nprop; + + nprop = convert_sysinfo_to_dt(prop); + get_str_from_dt(nprop, str_dt, sizeof(str_dt)); + str = (const char *)str_dt; + } - str = ofnode_read_string(ctx->node, prop); - if (str) - return smbios_add_string(ctx, str); + ret = smbios_add_string(ctx, str && *str ? str : dval); + return ret; } return 0; @@ -161,12 +248,15 @@ static int smbios_add_prop_si(struct smbios_ctx *ctx, const char *prop, /** * smbios_add_prop() - Add a property from the devicetree * - * @prop: property to write + * @prop: property to write. The default string will be written if + * prop is NULL + * @dval: Default value to use if the string is not found or is empty * Return: 0 if not found, else SMBIOS string number (1 or more) */ -static int smbios_add_prop(struct smbios_ctx *ctx, const char *prop) +static int smbios_add_prop(struct smbios_ctx *ctx, const char *prop, + const char *dval) { - return smbios_add_prop_si(ctx, prop, SYSINFO_ID_NONE); + return smbios_add_prop_si(ctx, prop, SYSINFO_ID_NONE, dval); } static void smbios_set_eos(struct smbios_ctx *ctx, char *eos) @@ -228,11 +318,9 @@ static int smbios_write_type0(ulong *current, int handle, memset(t, 0, sizeof(struct smbios_type0)); fill_smbios_header(t, SMBIOS_BIOS_INFORMATION, len, handle); smbios_set_eos(ctx, t->eos); - t->vendor = smbios_add_string(ctx, "U-Boot"); + t->vendor = smbios_add_prop(ctx, NULL, "U-Boot"); - t->bios_ver = smbios_add_prop(ctx, "version"); - if (!t->bios_ver) - t->bios_ver = smbios_add_string(ctx, PLAIN_VERSION); + t->bios_ver = smbios_add_prop(ctx, "version", PLAIN_VERSION); if (t->bios_ver) gd->smbios_version = ctx->last_str; log_debug("smbios_version = %p: '%s'\n", gd->smbios_version, @@ -241,7 +329,7 @@ static int smbios_write_type0(ulong *current, int handle, print_buffer((ulong)gd->smbios_version, gd->smbios_version, 1, strlen(gd->smbios_version) + 1, 0); #endif - t->bios_release_date = smbios_add_string(ctx, U_BOOT_DMI_DATE); + t->bios_release_date = smbios_add_prop(ctx, NULL, U_BOOT_DMI_DATE); #ifdef CONFIG_ROM_SIZE t->bios_rom_size = (CONFIG_ROM_SIZE / 65536) - 1; #endif @@ -280,22 +368,19 @@ static int smbios_write_type1(ulong *current, int handle, memset(t, 0, sizeof(struct smbios_type1)); fill_smbios_header(t, SMBIOS_SYSTEM_INFORMATION, len, handle); smbios_set_eos(ctx, t->eos); - t->manufacturer = smbios_add_prop(ctx, "manufacturer"); - if (!t->manufacturer) - t->manufacturer = smbios_add_string(ctx, "Unknown"); - t->product_name = smbios_add_prop(ctx, "product"); - if (!t->product_name) - t->product_name = smbios_add_string(ctx, "Unknown Product"); + t->manufacturer = smbios_add_prop(ctx, "manufacturer", "Unknown"); + t->product_name = smbios_add_prop(ctx, "product", "Unknown"); t->version = smbios_add_prop_si(ctx, "version", - SYSINFO_ID_SMBIOS_SYSTEM_VERSION); + SYSINFO_ID_SMBIOS_SYSTEM_VERSION, + "Unknown"); if (serial_str) { - t->serial_number = smbios_add_string(ctx, serial_str); + t->serial_number = smbios_add_prop(ctx, NULL, serial_str); strncpy((char *)t->uuid, serial_str, sizeof(t->uuid)); } else { - t->serial_number = smbios_add_prop(ctx, "serial"); + t->serial_number = smbios_add_prop(ctx, "serial", "Unknown"); } - t->sku_number = smbios_add_prop(ctx, "sku"); - t->family = smbios_add_prop(ctx, "family"); + t->sku_number = smbios_add_prop(ctx, "sku", "Unknown"); + t->family = smbios_add_prop(ctx, "family", "Unknown"); len = t->length + smbios_string_table_len(ctx); *current += len; @@ -314,15 +399,12 @@ static int smbios_write_type2(ulong *current, int handle, memset(t, 0, sizeof(struct smbios_type2)); fill_smbios_header(t, SMBIOS_BOARD_INFORMATION, len, handle); smbios_set_eos(ctx, t->eos); - t->manufacturer = smbios_add_prop(ctx, "manufacturer"); - if (!t->manufacturer) - t->manufacturer = smbios_add_string(ctx, "Unknown"); - t->product_name = smbios_add_prop(ctx, "product"); - if (!t->product_name) - t->product_name = smbios_add_string(ctx, "Unknown Product"); + t->manufacturer = smbios_add_prop(ctx, "manufacturer", "Unknown"); + t->product_name = smbios_add_prop(ctx, "product", "Unknown"); t->version = smbios_add_prop_si(ctx, "version", - SYSINFO_ID_SMBIOS_BASEBOARD_VERSION); - t->asset_tag_number = smbios_add_prop(ctx, "asset-tag"); + SYSINFO_ID_SMBIOS_BASEBOARD_VERSION, + "Unknown"); + t->asset_tag_number = smbios_add_prop(ctx, "asset-tag", "Unknown"); t->feature_flags = SMBIOS_BOARD_FEATURE_HOSTING; t->board_type = SMBIOS_BOARD_MOTHERBOARD; @@ -343,9 +425,7 @@ static int smbios_write_type3(ulong *current, int handle, memset(t, 0, sizeof(struct smbios_type3)); fill_smbios_header(t, SMBIOS_SYSTEM_ENCLOSURE, len, handle); smbios_set_eos(ctx, t->eos); - t->manufacturer = smbios_add_prop(ctx, "manufacturer"); - if (!t->manufacturer) - t->manufacturer = smbios_add_string(ctx, "Unknown"); + t->manufacturer = smbios_add_prop(ctx, "manufacturer", "Unknown"); t->chassis_type = SMBIOS_ENCLOSURE_DESKTOP; t->bootup_state = SMBIOS_STATE_SAFE; t->power_supply_state = SMBIOS_STATE_SAFE; @@ -388,8 +468,8 @@ static void smbios_write_type4_dm(struct smbios_type4 *t, #endif t->processor_family = processor_family; - t->processor_manufacturer = smbios_add_string(ctx, vendor); - t->processor_version = smbios_add_string(ctx, name); + t->processor_manufacturer = smbios_add_prop(ctx, NULL, vendor); + t->processor_version = smbios_add_prop(ctx, NULL, name); } static int smbios_write_type4(ulong *current, int handle, @@ -464,15 +544,13 @@ static struct smbios_write_method smbios_write_funcs[] = { ulong write_smbios_table(ulong addr) { ofnode parent_node = ofnode_null(); - struct smbios_entry *se; + ulong table_addr, start_addr; + struct smbios3_entry *se; struct smbios_ctx ctx; - ulong table_addr; ulong tables; int len = 0; int max_struct_size = 0; int handle = 0; - char *istart; - int isize; int i; ctx.node = ofnode_null(); @@ -484,14 +562,10 @@ ulong write_smbios_table(ulong addr) ctx.dev = NULL; } - /* 16 byte align the table address */ - addr = ALIGN(addr, 16); + start_addr = addr; - se = map_sysmem(addr, sizeof(struct smbios_entry)); - memset(se, 0, sizeof(struct smbios_entry)); - - addr += sizeof(struct smbios_entry); - addr = ALIGN(addr, 16); + /* move past the (so-far-unwritten) header to start writing structs */ + addr = ALIGN(addr + sizeof(struct smbios3_entry), 16); tables = addr; /* populate minimum required tables */ @@ -509,40 +583,25 @@ ulong write_smbios_table(ulong addr) len += tmp; } - memcpy(se->anchor, "_SM_", 4); - se->length = sizeof(struct smbios_entry); - se->major_ver = SMBIOS_MAJOR_VER; - se->minor_ver = SMBIOS_MINOR_VER; - se->max_struct_size = max_struct_size; - memcpy(se->intermediate_anchor, "_DMI_", 5); - se->struct_table_length = len; - /* * We must use a pointer here so things work correctly on sandbox. The * user of this table is not aware of the mapping of addresses to * sandbox's DRAM buffer. */ table_addr = (ulong)map_sysmem(tables, 0); - if (sizeof(table_addr) > sizeof(u32) && table_addr > (ulong)UINT_MAX) { - /* - * We need to put this >32-bit pointer into the table but the - * field is only 32 bits wide. - */ - printf("WARNING: SMBIOS table_address overflow %llx\n", - (unsigned long long)table_addr); - addr = 0; - goto out; - } - se->struct_table_address = table_addr; - - se->struct_count = handle; - /* calculate checksums */ - istart = (char *)se + SMBIOS_INTERMEDIATE_OFFSET; - isize = sizeof(struct smbios_entry) - SMBIOS_INTERMEDIATE_OFFSET; - se->intermediate_checksum = table_compute_checksum(istart, isize); - se->checksum = table_compute_checksum(se, sizeof(struct smbios_entry)); -out: + /* now go back and write the SMBIOS3 header */ + se = map_sysmem(start_addr, sizeof(struct smbios_entry)); + memset(se, '\0', sizeof(struct smbios_entry)); + memcpy(se->anchor, "_SM3_", 5); + se->length = sizeof(struct smbios3_entry); + se->major_ver = SMBIOS_MAJOR_VER; + se->minor_ver = SMBIOS_MINOR_VER; + se->doc_rev = 0; + se->entry_point_rev = 1; + se->max_struct_size = len; + se->struct_table_address = table_addr; + se->checksum = table_compute_checksum(se, sizeof(struct smbios3_entry)); unmap_sysmem(se); return addr; diff --git a/lib/strto.c b/lib/strto.c index 154921165c..5157332d6c 100644 --- a/lib/strto.c +++ b/lib/strto.c @@ -9,9 +9,9 @@ * Wirzenius wrote this portably, Torvalds fucked it up :-) */ -#include <common.h> #include <errno.h> #include <malloc.h> +#include <vsprintf.h> #include <linux/ctype.h> /* from lib/kstrtox.c */ diff --git a/lib/tables_csum.c b/lib/tables_csum.c index e2630d57d9..636aa59676 100644 --- a/lib/tables_csum.c +++ b/lib/tables_csum.c @@ -3,8 +3,7 @@ * Copyright (C) 2015, Bin Meng <bmeng.cn@gmail.com> */ -#include <common.h> -#include <linux/ctype.h> +#include <linux/types.h> u8 table_compute_checksum(void *v, int len) { diff --git a/lib/time.c b/lib/time.c index 00f4a1ac8f..872f73d521 100644 --- a/lib/time.c +++ b/lib/time.c @@ -4,7 +4,6 @@ * Wolfgang Denk, DENX Software Engineering, wd@denx.de. */ -#include <common.h> #include <clock_legacy.h> #include <bootstage.h> #include <dm.h> diff --git a/lib/tiny-printf.c b/lib/tiny-printf.c index f661fc6505..9a70c6095b 100644 --- a/lib/tiny-printf.c +++ b/lib/tiny-printf.c @@ -8,7 +8,6 @@ * Copyright (C) 2004,2008 Kustaa Nyholm */ -#include <common.h> #include <log.h> #include <serial.h> #include <stdarg.h> diff --git a/lib/tpm-common.c b/lib/tpm-common.c index 82ffdc5341..b592c22bfc 100644 --- a/lib/tpm-common.c +++ b/lib/tpm-common.c @@ -6,7 +6,6 @@ #define LOG_CATEGORY UCLASS_TPM -#include <common.h> #include <dm.h> #include <log.h> #include <asm/unaligned.h> diff --git a/lib/tpm-v1.c b/lib/tpm-v1.c index 60a18ca504..e66023da5e 100644 --- a/lib/tpm-v1.c +++ b/lib/tpm-v1.c @@ -6,7 +6,6 @@ #define LOG_CATEGORY UCLASS_TPM -#include <common.h> #include <dm.h> #include <log.h> #include <asm/unaligned.h> diff --git a/lib/tpm-v2.c b/lib/tpm-v2.c index bd0fb078dc..68eaaa639f 100644 --- a/lib/tpm-v2.c +++ b/lib/tpm-v2.c @@ -5,7 +5,6 @@ * Author: Miquel Raynal <miquel.raynal@bootlin.com> */ -#include <common.h> #include <dm.h> #include <dm/of_access.h> #include <tpm_api.h> diff --git a/lib/tpm_api.c b/lib/tpm_api.c index 3ef5e81179..39a5121e30 100644 --- a/lib/tpm_api.c +++ b/lib/tpm_api.c @@ -3,7 +3,6 @@ * Copyright 2019 Google LLC */ -#include <common.h> #include <dm.h> #include <log.h> #include <tpm_api.h> diff --git a/lib/trace.c b/lib/trace.c index 4874bef861..cabbe47b58 100644 --- a/lib/trace.c +++ b/lib/trace.c @@ -3,10 +3,10 @@ * Copyright (c) 2012 The Chromium OS Authors. */ -#include <common.h> #include <mapmem.h> #include <time.h> #include <trace.h> +#include <linux/errno.h> #include <asm/global_data.h> #include <asm/io.h> #include <asm/sections.h> diff --git a/lib/uuid.c b/lib/uuid.c index afb40bff50..0be22bc05f 100644 --- a/lib/uuid.c +++ b/lib/uuid.c @@ -9,7 +9,6 @@ #define LOG_CATEGOT LOGC_CORE -#include <common.h> #include <command.h> #include <efi_api.h> #include <env.h> @@ -18,7 +17,6 @@ #include <uuid.h> #include <linux/ctype.h> #include <errno.h> -#include <common.h> #include <asm/io.h> #include <part_efi.h> #include <malloc.h> diff --git a/lib/vsprintf.c b/lib/vsprintf.c index e14c6ca9f9..27ea9c907a 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -13,7 +13,6 @@ * from hush: simple_itoa() was lifted from boa-0.93.15 */ -#include <common.h> #include <charset.h> #include <efi_loader.h> #include <div64.h> diff --git a/lib/zlib/zlib.h b/lib/zlib/zlib.h index af3703e6d7..560e7be97d 100644 --- a/lib/zlib/zlib.h +++ b/lib/zlib/zlib.h @@ -2,7 +2,6 @@ #ifndef __GLUE_ZLIB_H__ #define __GLUE_ZLIB_H__ -#include <common.h> #include <linux/compiler.h> #include <asm/unaligned.h> #include <watchdog.h> diff --git a/lib/zstd/zstd.c b/lib/zstd/zstd.c index 3a2abc8367..14bde36906 100644 --- a/lib/zstd/zstd.c +++ b/lib/zstd/zstd.c @@ -5,10 +5,10 @@ #define LOG_CATEGORY LOGC_BOOT -#include <common.h> #include <abuf.h> #include <log.h> #include <malloc.h> +#include <linux/errno.h> #include <linux/zstd.h> int zstd_decompress(struct abuf *in, struct abuf *out) |