aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTom Rini2023-04-03 16:45:41 -0400
committerTom Rini2023-04-03 16:45:41 -0400
commit288fe30a2367b8d0e3f416493150a38ebaa88459 (patch)
tree1f841eb95d9ceeda4aa3255fb1132a0342f9b19a /lib
parentfd4ed6b7e83ec3aea9a2ce21baea8ca9676f40dd (diff)
parent9876c8c147144db2c120fcc9ffa6de27f6894441 (diff)
Merge branch 'next'
Signed-off-by: Tom Rini <trini@konsulko.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/Kconfig32
-rw-r--r--lib/Makefile2
-rw-r--r--lib/efi_loader/efi_device_path.c40
-rw-r--r--lib/efi_loader/efi_device_path_to_text.c5
-rw-r--r--lib/efi_loader/efi_memory.c46
-rw-r--r--lib/efi_loader/efi_tcg2.c2
-rw-r--r--lib/libavb/avb_cmdline.c2
-rw-r--r--lib/tpm-v1.c14
-rw-r--r--lib/tpm-v2.c17
-rw-r--r--lib/tpm_api.c21
-rw-r--r--lib/uuid.c10
-rw-r--r--lib/zlib/trees.c2
12 files changed, 136 insertions, 57 deletions
diff --git a/lib/Kconfig b/lib/Kconfig
index 83e5edd73b0..202a34ab413 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -16,7 +16,7 @@ config SYS_NUM_ADDR_MAP
Sets the number of entries in the virtual-physical mapping table.
config SYS_TIMER_COUNTS_DOWN
- bool "System timer counts down rathe than up"
+ bool "System timer counts down rather than up"
config PHYSMEM
bool "Access to physical memory region (> 4G)"
@@ -74,6 +74,10 @@ config HAVE_PRIVATE_LIBGCC
config LIB_UUID
bool
+config SPL_LIB_UUID
+ depends on SPL
+ bool
+
config SEMIHOSTING
bool "Support semihosting"
depends on ARM || RISCV
@@ -579,6 +583,26 @@ config SPL_SHA_PROG_HW_ACCEL
endif
+config VPL_SHA1
+ bool "Enable SHA1 support in VPL"
+ depends on VPL
+ default y if SHA1
+ help
+ This option enables support of hashing using SHA1 algorithm.
+ The hash is calculated in software.
+ The SHA1 algorithm produces a 160-bit (20-byte) hash value
+ (digest).
+
+config VPL_SHA256
+ bool "Enable SHA256 support in VPL"
+ depends on VPL
+ default y if SHA256
+ help
+ This option enables support of hashing using SHA256 algorithm.
+ The hash is calculated in software.
+ The SHA256 algorithm produces a 256-bit (32-byte) hash value
+ (digest).
+
if SHA_HW_ACCEL
config SHA512_HW_ACCEL
@@ -727,6 +751,12 @@ config ZSTD_LIB_MINIFY
endif
+config SPL_BZIP2
+ bool "Enable bzip2 decompression support for SPL build"
+ depends on SPL
+ help
+ This enables support for bzip2 compression algorithm for SPL boot.
+
config SPL_LZ4
bool "Enable LZ4 decompression support in SPL"
depends on SPL
diff --git a/lib/Makefile b/lib/Makefile
index a282e40258c..10aa7ac0298 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -127,7 +127,7 @@ obj-$(CONFIG_LIB_UUID) += uuid.o
obj-$(CONFIG_LIB_RAND) += rand.o
obj-y += panic.o
-ifeq ($(CONFIG_$(SPL_TPL_)BUILD),y)
+ifeq ($(CONFIG_SPL_BUILD),y)
# SPL U-Boot may use full-printf, tiny-printf or none at all
ifdef CONFIG_$(SPL_TPL_)USE_TINY_PRINTF
obj-$(CONFIG_$(SPL_TPL_)SPRINTF) += tiny-printf.o
diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c
index 8a65dda8838..ea097839dbe 100644
--- a/lib/efi_loader/efi_device_path.c
+++ b/lib/efi_loader/efi_device_path.c
@@ -63,20 +63,6 @@ static bool is_sd(struct blk_desc *desc)
}
#endif
-static void *dp_alloc(size_t sz)
-{
- void *buf;
-
- if (efi_allocate_pool(EFI_BOOT_SERVICES_DATA, sz, &buf) !=
- EFI_SUCCESS) {
- debug("EFI: ERROR: out of memory in %s\n", __func__);
- return NULL;
- }
-
- memset(buf, 0, sz);
- return buf;
-}
-
/*
* Iterate to next block in device-path, terminating (returning NULL)
* at /End* node.
@@ -293,7 +279,7 @@ struct efi_device_path *efi_dp_dup(const struct efi_device_path *dp)
if (!dp)
return NULL;
- ndp = dp_alloc(sz);
+ ndp = efi_alloc(sz);
if (!ndp)
return NULL;
memcpy(ndp, dp, sz);
@@ -337,7 +323,7 @@ efi_device_path *efi_dp_append_or_concatenate(const struct efi_device_path *dp1,
/* both dp1 and dp2 are non-null */
unsigned sz1 = efi_dp_size(dp1);
unsigned sz2 = efi_dp_size(dp2);
- void *p = dp_alloc(sz1 + sz2 + end_size);
+ void *p = efi_alloc(sz1 + sz2 + end_size);
if (!p)
return NULL;
ret = p;
@@ -400,7 +386,7 @@ struct efi_device_path *efi_dp_append_node(const struct efi_device_path *dp,
ret = efi_dp_dup(dp);
} else if (!dp) {
size_t sz = node->length;
- void *p = dp_alloc(sz + sizeof(END));
+ void *p = efi_alloc(sz + sizeof(END));
if (!p)
return NULL;
memcpy(p, node, sz);
@@ -409,7 +395,7 @@ struct efi_device_path *efi_dp_append_node(const struct efi_device_path *dp,
} else {
/* both dp and node are non-null */
size_t sz = efi_dp_size(dp);
- void *p = dp_alloc(sz + node->length + sizeof(END));
+ void *p = efi_alloc(sz + node->length + sizeof(END));
if (!p)
return NULL;
memcpy(p, dp, sz);
@@ -430,7 +416,7 @@ struct efi_device_path *efi_dp_create_device_node(const u8 type,
if (length < sizeof(struct efi_device_path))
return NULL;
- ret = dp_alloc(length);
+ ret = efi_alloc(length);
if (!ret)
return ret;
ret->type = type;
@@ -452,7 +438,7 @@ struct efi_device_path *efi_dp_append_instance(
return efi_dp_dup(dpi);
sz = efi_dp_size(dp);
szi = efi_dp_instance_size(dpi);
- p = dp_alloc(sz + szi + 2 * sizeof(END));
+ p = efi_alloc(sz + szi + 2 * sizeof(END));
if (!p)
return NULL;
ret = p;
@@ -477,7 +463,7 @@ struct efi_device_path *efi_dp_get_next_instance(struct efi_device_path **dp,
if (!dp || !*dp)
return NULL;
sz = efi_dp_instance_size(*dp);
- p = dp_alloc(sz + sizeof(END));
+ p = efi_alloc(sz + sizeof(END));
if (!p)
return NULL;
memcpy(p, *dp, sz + sizeof(END));
@@ -918,7 +904,7 @@ struct efi_device_path *efi_dp_from_part(struct blk_desc *desc, int part)
{
void *buf, *start;
- start = buf = dp_alloc(dp_part_size(desc, part) + sizeof(END));
+ start = buf = efi_alloc(dp_part_size(desc, part) + sizeof(END));
if (!buf)
return NULL;
@@ -945,7 +931,7 @@ struct efi_device_path *efi_dp_part_node(struct blk_desc *desc, int part)
dpsize = sizeof(struct efi_device_path_cdrom_path);
else
dpsize = sizeof(struct efi_device_path_hard_drive_path);
- buf = dp_alloc(dpsize);
+ buf = efi_alloc(dpsize);
if (buf)
dp_part_node(buf, desc, part);
@@ -1019,7 +1005,7 @@ struct efi_device_path *efi_dp_from_file(struct blk_desc *desc, int part,
dpsize += fpsize;
- start = buf = dp_alloc(dpsize + sizeof(END));
+ start = buf = efi_alloc(dpsize + sizeof(END));
if (!buf)
return NULL;
@@ -1047,7 +1033,7 @@ struct efi_device_path *efi_dp_from_uart(void)
struct efi_device_path_uart *uart;
size_t dpsize = sizeof(ROOT) + sizeof(*uart) + sizeof(END);
- buf = dp_alloc(dpsize);
+ buf = efi_alloc(dpsize);
if (!buf)
return NULL;
pos = buf;
@@ -1073,7 +1059,7 @@ struct efi_device_path *efi_dp_from_eth(void)
dpsize += dp_size(eth_get_dev());
- start = buf = dp_alloc(dpsize + sizeof(END));
+ start = buf = efi_alloc(dpsize + sizeof(END));
if (!buf)
return NULL;
@@ -1093,7 +1079,7 @@ struct efi_device_path *efi_dp_from_mem(uint32_t memory_type,
struct efi_device_path_memory *mdp;
void *buf, *start;
- start = buf = dp_alloc(sizeof(*mdp) + sizeof(END));
+ start = buf = efi_alloc(sizeof(*mdp) + sizeof(END));
if (!buf)
return NULL;
diff --git a/lib/efi_loader/efi_device_path_to_text.c b/lib/efi_loader/efi_device_path_to_text.c
index 4b2ade3803f..8c76d8be605 100644
--- a/lib/efi_loader/efi_device_path_to_text.c
+++ b/lib/efi_loader/efi_device_path_to_text.c
@@ -32,11 +32,10 @@ static u16 *efi_str_to_u16(char *str)
{
efi_uintn_t len;
u16 *out, *dst;
- efi_status_t ret;
len = sizeof(u16) * (utf8_utf16_strlen(str) + 1);
- ret = efi_allocate_pool(EFI_BOOT_SERVICES_DATA, len, (void **)&out);
- if (ret != EFI_SUCCESS)
+ out = efi_alloc(len);
+ if (!out)
return NULL;
dst = out;
utf8_utf16_strcpy(&dst, str);
diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
index b7bee98f79c..8f82496740f 100644
--- a/lib/efi_loader/efi_memory.c
+++ b/lib/efi_loader/efi_memory.c
@@ -5,9 +5,12 @@
* Copyright (c) 2016 Alexander Graf
*/
+#define LOG_CATEGORY LOGC_EFI
+
#include <common.h>
#include <efi_loader.h>
#include <init.h>
+#include <log.h>
#include <malloc.h>
#include <mapmem.h>
#include <watchdog.h>
@@ -534,27 +537,6 @@ efi_status_t efi_allocate_pages(enum efi_allocate_type type,
}
/**
- * efi_alloc() - allocate memory pages
- *
- * @len: size of the memory to be allocated
- * @memory_type: usage type of the allocated memory
- * Return: pointer to the allocated memory area or NULL
- */
-void *efi_alloc(uint64_t len, int memory_type)
-{
- uint64_t ret = 0;
- uint64_t pages = efi_size_in_pages(len);
- efi_status_t r;
-
- r = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES, memory_type, pages,
- &ret);
- if (r == EFI_SUCCESS)
- return (void*)(uintptr_t)ret;
-
- return NULL;
-}
-
-/**
* efi_free_pages() - free memory pages
*
* @memory: start of the memory area to be freed
@@ -673,6 +655,28 @@ efi_status_t efi_allocate_pool(enum efi_memory_type pool_type, efi_uintn_t size,
}
/**
+ * efi_alloc() - allocate boot services data pool memory
+ *
+ * Allocate memory from pool and zero it out.
+ *
+ * @size: number of bytes to allocate
+ * Return: pointer to allocated memory or NULL
+ */
+void *efi_alloc(size_t size)
+{
+ void *buf;
+
+ if (efi_allocate_pool(EFI_BOOT_SERVICES_DATA, size, &buf) !=
+ EFI_SUCCESS) {
+ log_err("out of memory");
+ return NULL;
+ }
+ memset(buf, 0, size);
+
+ return buf;
+}
+
+/**
* efi_free_pool() - free memory from pool
*
* @buffer: start of memory to be freed
diff --git a/lib/efi_loader/efi_tcg2.c b/lib/efi_loader/efi_tcg2.c
index 2dcc3171576..a83ae7a46cf 100644
--- a/lib/efi_loader/efi_tcg2.c
+++ b/lib/efi_loader/efi_tcg2.c
@@ -2495,7 +2495,7 @@ efi_status_t efi_tcg2_register(void)
}
/* initialize the TPM as early as possible. */
- err = tpm_startup(dev, TPM_ST_CLEAR);
+ err = tpm_auto_start(dev);
if (err) {
log_err("TPM startup failed\n");
goto fail;
diff --git a/lib/libavb/avb_cmdline.c b/lib/libavb/avb_cmdline.c
index cb54e658c48..a58ce6c48c0 100644
--- a/lib/libavb/avb_cmdline.c
+++ b/lib/libavb/avb_cmdline.c
@@ -394,7 +394,7 @@ out:
return ret;
}
-AvbCmdlineSubstList* avb_new_cmdline_subst_list() {
+AvbCmdlineSubstList* avb_new_cmdline_subst_list(void) {
return (AvbCmdlineSubstList*)avb_calloc(sizeof(AvbCmdlineSubstList));
}
diff --git a/lib/tpm-v1.c b/lib/tpm-v1.c
index d0e3ab1b21d..60a18ca5040 100644
--- a/lib/tpm-v1.c
+++ b/lib/tpm-v1.c
@@ -69,6 +69,20 @@ u32 tpm1_continue_self_test(struct udevice *dev)
return tpm_sendrecv_command(dev, command, NULL, NULL);
}
+u32 tpm1_auto_start(struct udevice *dev)
+{
+ u32 rc;
+
+ rc = tpm1_startup(dev, TPM_ST_CLEAR);
+ /* continue on if the TPM is already inited */
+ if (rc && rc != TPM_INVALID_POSTINIT)
+ return rc;
+
+ rc = tpm1_self_test_full(dev);
+
+ return rc;
+}
+
u32 tpm1_clear_and_reenable(struct udevice *dev)
{
u32 ret;
diff --git a/lib/tpm-v2.c b/lib/tpm-v2.c
index 697b982e079..9ab5b46df17 100644
--- a/lib/tpm-v2.c
+++ b/lib/tpm-v2.c
@@ -44,6 +44,23 @@ u32 tpm2_self_test(struct udevice *dev, enum tpm2_yes_no full_test)
return tpm_sendrecv_command(dev, command_v2, NULL, NULL);
}
+u32 tpm2_auto_start(struct udevice *dev)
+{
+ u32 rc;
+
+ rc = tpm2_self_test(dev, TPMI_YES);
+
+ if (rc == TPM2_RC_INITIALIZE) {
+ rc = tpm2_startup(dev, TPM2_SU_CLEAR);
+ if (rc)
+ return rc;
+
+ rc = tpm2_self_test(dev, TPMI_YES);
+ }
+
+ return rc;
+}
+
u32 tpm2_clear(struct udevice *dev, u32 handle, const char *pw,
const ssize_t pw_sz)
{
diff --git a/lib/tpm_api.c b/lib/tpm_api.c
index 7e8df8795ef..3ef5e811794 100644
--- a/lib/tpm_api.c
+++ b/lib/tpm_api.c
@@ -35,6 +35,27 @@ u32 tpm_startup(struct udevice *dev, enum tpm_startup_type mode)
}
}
+u32 tpm_auto_start(struct udevice *dev)
+{
+ u32 rc;
+
+ /*
+ * the tpm_init() will return -EBUSY if the init has already happened
+ * The selftest and startup code can run multiple times with no side
+ * effects
+ */
+ rc = tpm_init(dev);
+ if (rc && rc != -EBUSY)
+ return rc;
+
+ if (tpm_is_v1(dev))
+ return tpm1_auto_start(dev);
+ else if (tpm_is_v2(dev))
+ return tpm2_auto_start(dev);
+ else
+ return -ENOSYS;
+}
+
u32 tpm_resume(struct udevice *dev)
{
if (tpm_is_v1(dev))
diff --git a/lib/uuid.c b/lib/uuid.c
index 465e1ac38f5..96e1af3c8b0 100644
--- a/lib/uuid.c
+++ b/lib/uuid.c
@@ -102,7 +102,7 @@ static const struct {
{"lvm", PARTITION_LINUX_LVM_GUID},
{"u-boot-env", PARTITION_U_BOOT_ENVIRONMENT},
#endif
-#ifdef CONFIG_CMD_EFIDEBUG
+#if defined(CONFIG_CMD_EFIDEBUG) || defined(CONFIG_EFI)
{
"Device Path",
EFI_DEVICE_PATH_PROTOCOL_GUID,
@@ -255,6 +255,14 @@ static const struct {
EFI_CERT_TYPE_PKCS7_GUID,
},
#endif
+#ifdef CONFIG_EFI
+ { "EFI_LZMA_COMPRESSED", EFI_LZMA_COMPRESSED },
+ { "EFI_DXE_SERVICES", EFI_DXE_SERVICES },
+ { "EFI_HOB_LIST", EFI_HOB_LIST },
+ { "EFI_MEMORY_TYPE", EFI_MEMORY_TYPE },
+ { "EFI_MEM_STATUS_CODE_REC", EFI_MEM_STATUS_CODE_REC },
+ { "EFI_GUID_EFI_ACPI1", EFI_GUID_EFI_ACPI1 },
+#endif
};
/*
diff --git a/lib/zlib/trees.c b/lib/zlib/trees.c
index 970bc5dbc64..e040617686a 100644
--- a/lib/zlib/trees.c
+++ b/lib/zlib/trees.c
@@ -237,7 +237,7 @@ local void send_bits(s, value, length)
/* ===========================================================================
* Initialize the various 'constant' tables.
*/
-local void tr_static_init()
+local void tr_static_init(void)
{
#if defined(GEN_TREES_H) || !defined(STDC)
static int static_init_done = 0;