aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Kconfig11
-rw-r--r--lib/abuf.c1
-rw-r--r--lib/acpi/acpi.c21
-rw-r--r--lib/acpi/acpi_device.c1
-rw-r--r--lib/acpi/acpi_dp.c1
-rw-r--r--lib/acpi/acpi_table.c1
-rw-r--r--lib/acpi/acpi_writer.c2
-rw-r--r--lib/acpi/acpigen.c1
-rw-r--r--lib/acpi/base.c26
-rw-r--r--lib/acpi/csrt.c2
-rw-r--r--lib/acpi/dsdt.c2
-rw-r--r--lib/acpi/facs.c2
-rw-r--r--lib/acpi/mcfg.c4
-rw-r--r--lib/acpi/ssdt.c6
-rw-r--r--lib/addr_map.c1
-rw-r--r--lib/aes.c2
-rw-r--r--lib/aes/aes-decrypt.c1
-rw-r--r--lib/asm-offsets.c2
-rw-r--r--lib/at91/at91.c1
-rw-r--r--lib/bch.c1
-rw-r--r--lib/binman.c1
-rw-r--r--lib/bzip2/bzlib.c3
-rw-r--r--lib/bzip2/bzlib_decompress.c1
-rw-r--r--lib/charset.c1
-rw-r--r--lib/circbuf.c1
-rw-r--r--lib/crc16-ccitt.c2
-rw-r--r--lib/crc32.c1
-rw-r--r--lib/crc32c.c1
-rw-r--r--lib/crc8.c2
-rw-r--r--lib/crypt/crypt-port.h3
-rw-r--r--lib/crypt/crypt.c1
-rw-r--r--lib/crypto/x509_public_key.c1
-rw-r--r--lib/date.c1
-rw-r--r--lib/dhry/cmd_dhry.c3
-rw-r--r--lib/dhry/dhry_1.c2
-rw-r--r--lib/dhry/dhry_2.c2
-rw-r--r--lib/display_options.c3
-rw-r--r--lib/efi/efi.c1
-rw-r--r--lib/efi/efi_app.c1
-rw-r--r--lib/efi/efi_info.c1
-rw-r--r--lib/efi/efi_stub.c1
-rw-r--r--lib/efi_driver/efi_block_device.c1
-rw-r--r--lib/efi_driver/efi_uclass.c1
-rw-r--r--lib/efi_loader/Kconfig15
-rw-r--r--lib/efi_loader/Makefile2
-rw-r--r--lib/efi_loader/dtbdump.c1
-rw-r--r--lib/efi_loader/efi_acpi.c1
-rw-r--r--lib/efi_loader/efi_bootmgr.c912
-rw-r--r--lib/efi_loader/efi_boottime.c8
-rw-r--r--lib/efi_loader/efi_capsule.c1
-rw-r--r--lib/efi_loader/efi_conformance.c1
-rw-r--r--lib/efi_loader/efi_console.c1
-rw-r--r--lib/efi_loader/efi_device_path.c1
-rw-r--r--lib/efi_loader/efi_device_path_to_text.c1
-rw-r--r--lib/efi_loader/efi_device_path_utilities.c1
-rw-r--r--lib/efi_loader/efi_disk.c19
-rw-r--r--lib/efi_loader/efi_dt_fixup.c3
-rw-r--r--lib/efi_loader/efi_esrt.c1
-rw-r--r--lib/efi_loader/efi_file.c1
-rw-r--r--lib/efi_loader/efi_firmware.c1
-rw-r--r--lib/efi_loader/efi_freestanding.c2
-rw-r--r--lib/efi_loader/efi_gop.c1
-rw-r--r--lib/efi_loader/efi_helper.c1
-rw-r--r--lib/efi_loader/efi_hii.c1
-rw-r--r--lib/efi_loader/efi_hii_config.c1
-rw-r--r--lib/efi_loader/efi_image_loader.c1
-rw-r--r--lib/efi_loader/efi_load_initrd.c1
-rw-r--r--lib/efi_loader/efi_load_options.c1
-rw-r--r--lib/efi_loader/efi_memory.c1
-rw-r--r--lib/efi_loader/efi_net.c1
-rw-r--r--lib/efi_loader/efi_riscv.c1
-rw-r--r--lib/efi_loader/efi_rng.c1
-rw-r--r--lib/efi_loader/efi_root_node.c1
-rw-r--r--lib/efi_loader/efi_runtime.c1
-rw-r--r--lib/efi_loader/efi_setup.c8
-rw-r--r--lib/efi_loader/efi_signature.c1
-rw-r--r--lib/efi_loader/efi_smbios.c1
-rw-r--r--lib/efi_loader/efi_string.c1
-rw-r--r--lib/efi_loader/efi_tcg2.c1
-rw-r--r--lib/efi_loader/efi_unicode_collation.c1
-rw-r--r--lib/efi_loader/efi_var_common.c1
-rw-r--r--lib/efi_loader/efi_var_file.c1
-rw-r--r--lib/efi_loader/efi_var_mem.c1
-rw-r--r--lib/efi_loader/efi_variable.c1
-rw-r--r--lib/efi_loader/efi_variable_tee.c1
-rw-r--r--lib/efi_loader/efi_watchdog.c1
-rw-r--r--lib/efi_loader/initrddump.c1
-rw-r--r--lib/efi_selftest/efi_selftest_esrt.c1
-rw-r--r--lib/efi_selftest/efi_selftest_miniapp_exception.c1
-rw-r--r--lib/efi_selftest/efi_selftest_miniapp_exit.c1
-rw-r--r--lib/efi_selftest/efi_selftest_miniapp_return.c1
-rw-r--r--lib/elf.c1
-rw-r--r--lib/errno_str.c2
-rw-r--r--lib/fdtdec.c1
-rw-r--r--lib/fdtdec_common.c1
-rw-r--r--lib/fdtdec_test.c1
-rw-r--r--lib/getopt.c2
-rw-r--r--lib/gunzip.c1
-rw-r--r--lib/gzip.c1
-rw-r--r--lib/hang.c2
-rw-r--r--lib/hash-checksum.c1
-rw-r--r--lib/hashtable.c1
-rw-r--r--lib/hexdump.c2
-rw-r--r--lib/image-sparse.c1
-rw-r--r--lib/initcall.c1
-rw-r--r--lib/libavb/avb_sysdeps.h4
-rw-r--r--lib/linux_compat.c1
-rw-r--r--lib/list_sort.c1
-rw-r--r--lib/lmb.c1
-rw-r--r--lib/lz4.c1
-rw-r--r--lib/lz4_wrapper.c1
-rw-r--r--lib/lzma/LzmaDec.c1
-rw-r--r--lib/lzma/LzmaTools.c1
-rw-r--r--lib/lzo/lzo1x_decompress.c3
-rw-r--r--lib/md5.c1
-rw-r--r--lib/membuff.c1
-rw-r--r--lib/net_utils.c2
-rw-r--r--lib/of_live.c1
-rw-r--r--lib/optee/optee.c1
-rw-r--r--lib/panic.c1
-rw-r--r--lib/physmem.c2
-rw-r--r--lib/qsort.c1
-rw-r--r--lib/rand.c1
-rw-r--r--lib/rc4.c3
-rw-r--r--lib/rsa/rsa-keyprop.c1
-rw-r--r--lib/rsa/rsa-mod-exp.c1
-rw-r--r--lib/rsa/rsa-sign.c15
-rw-r--r--lib/rsa/rsa-verify.c3
-rw-r--r--lib/rtc-lib.c1
-rw-r--r--lib/semihosting.c3
-rw-r--r--lib/sha1.c7
-rw-r--r--lib/sha256.c7
-rw-r--r--lib/sha512.c6
-rw-r--r--lib/slre.c3
-rw-r--r--lib/smbios-parser.c1
-rw-r--r--lib/smbios.c164
-rw-r--r--lib/strto.c2
-rw-r--r--lib/tables_csum.c3
-rw-r--r--lib/time.c1
-rw-r--r--lib/tiny-printf.c1
-rw-r--r--lib/tpm-common.c1
-rw-r--r--lib/tpm-v1.c1
-rw-r--r--lib/tpm-v2.c1
-rw-r--r--lib/tpm_api.c1
-rw-r--r--lib/trace.c2
-rw-r--r--lib/uuid.c2
-rw-r--r--lib/vsprintf.c1
-rw-r--r--lib/zlib/zlib.h1
-rw-r--r--lib/zstd/zstd.c2
149 files changed, 1176 insertions, 234 deletions
diff --git a/lib/Kconfig b/lib/Kconfig
index d47df6b..37ac14f 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
diff --git a/lib/abuf.c b/lib/abuf.c
index ce2cff5..937c3df 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/acpi.c b/lib/acpi/acpi.c
index 14b1575..939a638 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,18 +15,30 @@ 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 = map_sysmem(rsdp->xsdt_address, 0);
+ len = xsdt->header.length - sizeof(xsdt->header);
+ count = len / sizeof(u64);
+ } else {
+ if (!rsdp->rsdt_address)
+ return NULL;
+ rsdt = map_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 = map_sysmem(xsdt->entry[i], 0);
+ else
+ hdr = map_sysmem(rsdt->entry[i], 0);
if (!memcmp(hdr->signature, sig, ACPI_NAME_LEN))
return hdr;
if (!memcmp(hdr->signature, "FACP", ACPI_NAME_LEN)) {
diff --git a/lib/acpi/acpi_device.c b/lib/acpi/acpi_device.c
index 1b838fd..ed94194 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 7e3e325..6733809 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 a8d4b47..e74522e 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>
diff --git a/lib/acpi/acpi_writer.c b/lib/acpi/acpi_writer.c
index 946f90e..a8dc207 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;
diff --git a/lib/acpi/acpigen.c b/lib/acpi/acpigen.c
index e395226..b95cabb 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 2057bd2..07b53e0 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 = map_to_sysmem(rsdt);
+
+ if (xsdt)
+ rsdp->xsdt_address = map_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 2ba86f2..00927e5 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 db98cc2..206e1e2 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 e89f43c..86c2812 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 7404ae58..8b8a5bf 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 659c1aa..b0a96f8 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 86e932e..f85fb0c 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>
diff --git a/lib/aes.c b/lib/aes.c
index 4fca85e..39ad4a9 100644
--- a/lib/aes.c
+++ b/lib/aes.c
@@ -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 345029f..741102a 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 216d971..4e2dbda 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 0485976..bd31e9e 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"
diff --git a/lib/bch.c b/lib/bch.c
index 72b4fdc..a309a8d 100644
--- a/lib/bch.c
+++ b/lib/bch.c
@@ -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 cfe1e5f..9047f52 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 bd589aa..f7318b7 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 3b417d5..e56ab66 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 5e4c4f9..89057ef 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 fa79c14..2e161ae 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 6cadbc1..6fa4e93 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 f6fad8c..f36f176 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 016b34a..7026ac4 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 87b87b6..20d46d1 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 6b9542d..50dde68 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 247c34b..8f5fadb 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 3007123..a10145a 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 e3d2245..0deac8a 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 77b52a2..e52beae 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 dcc224f..252cd14 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 1ba8796..a74197d 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 80def52..d6b9355 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 aa42f18..bcb34d6 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 c5eb816..119db66 100644
--- a/lib/efi/efi_app.c
+++ b/lib/efi/efi_app.c
@@ -8,7 +8,6 @@
* This file implements U-Boot running as an EFI application.
*/
-#include <common.h>
#include <cpu_func.h>
#include <debug_uart.h>
#include <dm.h>
diff --git a/lib/efi/efi_info.c b/lib/efi/efi_info.c
index 4d78923..5b564c5 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 c9eb32e..40fc29d 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 e3abd90..34a0365 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 66a45e1..e1e28df 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 2e39354..ea80734 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 d476df1..24d33d5 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
diff --git a/lib/efi_loader/dtbdump.c b/lib/efi_loader/dtbdump.c
index 3ce2a07..5f39cf2 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 f755af7..67bbd2a 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 a40762c..a032d3a 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 fad0476..c579d89 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;
diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c
index af8a2ee..de0d49e 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 0ca26f5..167067e 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 a2d137d..03dece5 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 ed7214f..8dbd810 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 8c76d8b..0c7b30a 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 a07d9ba..844d8ac 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 f0d7611..ed99700 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 838023c..9886e68 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 7f46d65..dafd447 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 3c56ceb..222001d 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 9abb29f..1fde188 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 4b65fc6..b278609 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 a09db31..41e12fa 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 cdfd16e..17f27ca 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 3b54ecb1..74e402d 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 31b0c97..ae0f3ec 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 9754757..6042436 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 1934337..2b467b5 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 5f62184..0198423 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 f752703..edfad2d 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 96a5bcc..7cd5367 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 0641727..4d398c5 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 bb11d8d..9bad7ed 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 108c14b..4d7fb74 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 bf54d6a..18da689 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 e6de685..a610e03 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 742d891..f338e73 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 0fbf51b..bbb8421 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>
diff --git a/lib/efi_loader/efi_string.c b/lib/efi_loader/efi_string.c
index e21e09c..413e329 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 463ea4c..8db35d0 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 c4c7572..2b6912c 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 ad50bff..d528747 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 d7dba05..532b6b4 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 5fa7dcb..6c21cec 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 be95ed4..40f7a0f 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 09d03c0..dde135f 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 d741076..f5fb911 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 5b470f4..0004b6b 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 922ff25..b7688de 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 a9ad381..f668cda 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 1c42d6d..8b2e60c 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 45366aa..8792d78 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>
/*
diff --git a/lib/elf.c b/lib/elf.c
index 0476b26..9a794f9 100644
--- a/lib/elf.c
+++ b/lib/elf.c
@@ -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 2e5f4a8..752d4eb 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 7a69167..4016bf3 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -7,7 +7,6 @@
*/
#ifndef USE_HOSTCC
-#include <common.h>
#include <boot_fit.h>
#include <display_options.h>
#include <dm.h>
diff --git a/lib/fdtdec_common.c b/lib/fdtdec_common.c
index ddaca00..ca36ff1 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 85351c7..1e4d5fc 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 8b4515d..e9175e2 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 932e3e8..e71d8d0 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 2595b2d..5d9c195 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 2735774..3cfb06e 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 68c290d..1970a74 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 f2d36bd..a0060f6 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 149c93e..33e3e6e 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 323aad9..f828906 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 33b7d76..ce317af 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 f52428c..aece8e0 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 c83426f..985e88e 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 1c9e061..a6e54d5 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
diff --git a/lib/lmb.c b/lib/lmb.c
index da924c6..44f9820 100644
--- a/lib/lmb.c
+++ b/lib/lmb.c
@@ -6,7 +6,6 @@
* Copyright (C) 2001 Peter Bergner.
*/
-#include <common.h>
#include <efi_loader.h>
#include <image.h>
#include <mapmem.h>
diff --git a/lib/lz4.c b/lib/lz4.c
index 5337842..d365dc7 100644
--- a/lib/lz4.c
+++ b/lib/lz4.c
@@ -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 67dea2f..4d48e7b 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 a90b35c..1da3f0a 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 55f64cd..400d606 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 65fef0b..5d70fa4 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"
diff --git a/lib/md5.c b/lib/md5.c
index 1636ab9..faf3f78 100644
--- a/lib/md5.c
+++ b/lib/md5.c
@@ -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 36dc43a..3c6c0ae 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 4283c13..c70fef0 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 812c488..90b9459 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 b036224..393f271 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 66ae17f..0f578b5 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 fc90ce4..562c74d 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 2f18588..a2562c4 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 d256baf..d6f2977 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;
diff --git a/lib/rc4.c b/lib/rc4.c
index 720112d..3839924 100644
--- a/lib/rc4.c
+++ b/lib/rc4.c
@@ -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 98855f6..80d0594 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 d259b2a..5b3ea02 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 d20bdb5..858ad92 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 2f3b344..1007b69 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 1f7bdad..46dcfba 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 831774e..9be5bff 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 8d07407..7ef536f 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 4d26aea..665ba6f 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 fbe8d5f..ffe2c5c 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 e82a9e7..277a59a 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 2b93929..b578c30 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 d7f4999..45480b0 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,
diff --git a/lib/strto.c b/lib/strto.c
index 1549211..5157332 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 e2630d5..636aa59 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 00f4a1a..872f73d 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 f661fc6..9a70c60 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 82ffdc5..b592c22 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 60a18ca..e66023d 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 bd0fb07..68eaaa6 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 3ef5e81..39a5121 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 4874bef..cabbe47 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 afb40bf..0be22bc 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 e14c6ca..27ea9c9 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 af3703e..560e7be 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 3a2abc8..14bde36 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)