summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Kconfig3
-rw-r--r--lib/Makefile6
-rw-r--r--lib/acpi/acpi_table.c1
-rw-r--r--lib/crc32.c9
-rw-r--r--lib/display_options.c2
-rw-r--r--lib/efi_loader/Kconfig10
-rw-r--r--lib/efi_loader/efi_tcg2.c7
-rw-r--r--lib/fdtdec.c44
-rw-r--r--lib/hang.c2
-rw-r--r--lib/lmb.c35
-rw-r--r--lib/md5.c6
-rw-r--r--lib/optee/Kconfig1
-rw-r--r--lib/rsa/rsa-sign.c78
-rw-r--r--lib/tiny-printf.c6
14 files changed, 63 insertions, 147 deletions
diff --git a/lib/Kconfig b/lib/Kconfig
index 130fa0630ac..034af724b5d 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -92,7 +92,6 @@ config TPL_SPRINTF
config SSCANF
bool
- default n
config STRTO
bool
@@ -348,7 +347,6 @@ menu "Android Verified Boot"
config LIBAVB
bool "Android Verified Boot 2.0 support"
depends on ANDROID_BOOT_IMAGE
- default n
help
This enables support of Android Verified Boot 2.0 which can be used
to assure the end user of the integrity of the software running on a
@@ -769,7 +767,6 @@ endmenu
config PHANDLE_CHECK_SEQ
bool "Enable phandle check while getting sequence number"
- default n
help
When there are multiple device tree nodes with same name,
enable this config option to distinguish them using
diff --git a/lib/Makefile b/lib/Makefile
index 93be86c34a0..09e380eb66c 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -80,14 +80,12 @@ obj-$(CONFIG_$(SPL_)LIB_RATIONAL) += rational.o
obj-$(CONFIG_LIBAVB) += libavb/
obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += libfdt/
-ifneq ($(CONFIG_$(SPL_TPL_)BUILD)$(CONFIG_$(SPL_TPL_)OF_PLATDATA),yy)
-obj-$(CONFIG_$(SPL_TPL_)OF_CONTROL) += fdtdec_common.o
-obj-$(CONFIG_$(SPL_TPL_)OF_CONTROL) += fdtdec.o
-endif
+obj-$(CONFIG_$(SPL_TPL_)OF_REAL) += fdtdec_common.o fdtdec.o
ifdef CONFIG_SPL_BUILD
obj-$(CONFIG_SPL_YMODEM_SUPPORT) += crc16.o
obj-$(CONFIG_$(SPL_TPL_)HASH) += crc16.o
+obj-$(CONFIG_MMC_SPI_CRC_ON) += crc16.o
obj-y += net_utils.o
endif
obj-$(CONFIG_ADDR_MAP) += addr_map.o
diff --git a/lib/acpi/acpi_table.c b/lib/acpi/acpi_table.c
index 2f077417841..7ea4b2e87ee 100644
--- a/lib/acpi/acpi_table.c
+++ b/lib/acpi/acpi_table.c
@@ -11,6 +11,7 @@
#include <log.h>
#include <mapmem.h>
#include <tables_csum.h>
+#include <timestamp.h>
#include <version.h>
#include <acpi/acpi_table.h>
#include <asm/global_data.h>
diff --git a/lib/crc32.c b/lib/crc32.c
index f2acc107fe4..5a3127e03ad 100644
--- a/lib/crc32.c
+++ b/lib/crc32.c
@@ -84,7 +84,7 @@ static void __efi_runtime make_crc_table(void)
}
crc_table_empty = 0;
}
-#else
+#elif !defined(CONFIG_ARM64_CRC32)
/* ========================================================================
* Table of CRC-32's of all single-byte values (made by make_crc_table)
*/
@@ -184,6 +184,12 @@ const uint32_t * ZEXPORT get_crc_table()
*/
uint32_t __efi_runtime crc32_no_comp(uint32_t crc, const Bytef *buf, uInt len)
{
+#ifdef CONFIG_ARM64_CRC32
+ crc = cpu_to_le32(crc);
+ while (len--)
+ crc = __builtin_aarch64_crc32b(crc, *buf++);
+ return le32_to_cpu(crc);
+#else
const uint32_t *tab = crc_table;
const uint32_t *b =(const uint32_t *)buf;
size_t rem_len;
@@ -221,6 +227,7 @@ uint32_t __efi_runtime crc32_no_comp(uint32_t crc, const Bytef *buf, uInt len)
}
return le32_to_cpu(crc);
+#endif
}
#undef DO_CRC
diff --git a/lib/display_options.c b/lib/display_options.c
index 4da1f5244f3..360b01bcf5f 100644
--- a/lib/display_options.c
+++ b/lib/display_options.c
@@ -8,7 +8,7 @@
#include <compiler.h>
#include <console.h>
#include <div64.h>
-#include <version.h>
+#include <version_string.h>
#include <linux/ctype.h>
#include <asm/io.h>
diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
index f48d9e8b513..3d5a5cd189e 100644
--- a/lib/efi_loader/Kconfig
+++ b/lib/efi_loader/Kconfig
@@ -39,7 +39,6 @@ config CMD_BOOTEFI_BOOTMGR
config EFI_SETUP_EARLY
bool
- default n
choice
prompt "Store for non-volatile UEFI variables"
@@ -113,7 +112,6 @@ config EFI_SET_TIME
bool "SetTime() runtime service"
depends on EFI_GET_TIME
default y if ARCH_QEMU || SANDBOX
- default n
help
Provide the SetTime() runtime service at boottime. This service
can be used by an EFI application to adjust the real time clock.
@@ -123,7 +121,6 @@ config EFI_HAVE_CAPSULE_SUPPORT
config EFI_RUNTIME_UPDATE_CAPSULE
bool "UpdateCapsule() runtime service"
- default n
select EFI_HAVE_CAPSULE_SUPPORT
help
Select this option if you want to use UpdateCapsule and
@@ -132,7 +129,6 @@ config EFI_RUNTIME_UPDATE_CAPSULE
config EFI_CAPSULE_ON_DISK
bool "Enable capsule-on-disk support"
select EFI_HAVE_CAPSULE_SUPPORT
- default n
help
Select this option if you want to use capsule-on-disk feature,
that is, capsules can be fetched and executed from files
@@ -142,7 +138,6 @@ config EFI_CAPSULE_ON_DISK
config EFI_IGNORE_OSINDICATIONS
bool "Ignore OsIndications for CapsuleUpdate on-disk"
depends on EFI_CAPSULE_ON_DISK
- default n
help
There are boards where U-Boot does not support SetVariable at runtime.
Select this option if you want to use the capsule-on-disk feature
@@ -152,7 +147,6 @@ config EFI_IGNORE_OSINDICATIONS
config EFI_CAPSULE_ON_DISK_EARLY
bool "Initiate capsule-on-disk at U-Boot boottime"
depends on EFI_CAPSULE_ON_DISK
- default n
select EFI_SETUP_EARLY
help
Normally, without this option enabled, capsules will be
@@ -163,7 +157,6 @@ config EFI_CAPSULE_ON_DISK_EARLY
config EFI_CAPSULE_FIRMWARE
bool
- default n
config EFI_CAPSULE_FIRMWARE_MANAGEMENT
bool "Capsule: Firmware Management Protocol"
@@ -210,7 +203,6 @@ config EFI_CAPSULE_AUTHENTICATE
select PKCS7_VERIFY
select IMAGE_SIGN_INFO
select EFI_SIGNATURE_SUPPORT
- default n
help
Select this option if you want to enable capsule
authentication
@@ -271,7 +263,6 @@ endif
config EFI_LOADER_BOUNCE_BUFFER
bool "EFI Applications use bounce buffers for DMA operations"
depends on ARM64
- default n
help
Some hardware does not support DMA to full 64bit addresses. For this
hardware we can create a bounce buffer so that payloads don't have to
@@ -357,7 +348,6 @@ config EFI_SECURE_BOOT
select PKCS7_MESSAGE_PARSER
select PKCS7_VERIFY
select EFI_SIGNATURE_SUPPORT
- default n
help
Select this option to enable EFI secure boot support.
Once SecureBoot mode is enforced, any EFI binary can run only if
diff --git a/lib/efi_loader/efi_tcg2.c b/lib/efi_loader/efi_tcg2.c
index d3b8f93f148..74f0bef2396 100644
--- a/lib/efi_loader/efi_tcg2.c
+++ b/lib/efi_loader/efi_tcg2.c
@@ -14,7 +14,7 @@
#include <efi_tcg2.h>
#include <log.h>
#include <malloc.h>
-#include <version.h>
+#include <version_string.h>
#include <tpm-v2.h>
#include <u-boot/hash-checksum.h>
#include <u-boot/sha1.h>
@@ -1343,10 +1343,11 @@ out:
*/
static efi_status_t efi_append_scrtm_version(struct udevice *dev)
{
- u8 ver[] = U_BOOT_VERSION_STRING;
efi_status_t ret;
- ret = tcg2_measure_event(dev, 0, EV_S_CRTM_VERSION, sizeof(ver), ver);
+ ret = tcg2_measure_event(dev, 0, EV_S_CRTM_VERSION,
+ strlen(version_string) + 1,
+ (u8 *)version_string);
return ret;
}
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index 7358cb6dd16..af92e65bde6 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -870,50 +870,6 @@ const u8 *fdtdec_locate_byte_array(const void *blob, int node,
return cell;
}
-int fdtdec_get_config_int(const void *blob, const char *prop_name,
- int default_val)
-{
- int config_node;
-
- debug("%s: %s\n", __func__, prop_name);
- config_node = fdt_path_offset(blob, "/config");
- if (config_node < 0)
- return default_val;
- return fdtdec_get_int(blob, config_node, prop_name, default_val);
-}
-
-int fdtdec_get_config_bool(const void *blob, const char *prop_name)
-{
- int config_node;
- const void *prop;
-
- debug("%s: %s\n", __func__, prop_name);
- config_node = fdt_path_offset(blob, "/config");
- if (config_node < 0)
- return 0;
- prop = fdt_get_property(blob, config_node, prop_name, NULL);
-
- return prop != NULL;
-}
-
-char *fdtdec_get_config_string(const void *blob, const char *prop_name)
-{
- const char *nodep;
- int nodeoffset;
- int len;
-
- debug("%s: %s\n", __func__, prop_name);
- nodeoffset = fdt_path_offset(blob, "/config");
- if (nodeoffset < 0)
- return NULL;
-
- nodep = fdt_getprop(blob, nodeoffset, prop_name, &len);
- if (!nodep)
- return NULL;
-
- return (char *)nodep;
-}
-
u64 fdtdec_get_number(const fdt32_t *ptr, unsigned int cells)
{
u64 number = 0;
diff --git a/lib/hang.c b/lib/hang.c
index 578ac78d453..2735774f9a4 100644
--- a/lib/hang.c
+++ b/lib/hang.c
@@ -24,7 +24,7 @@ void hang(void)
{
#if !defined(CONFIG_SPL_BUILD) || \
(CONFIG_IS_ENABLED(LIBCOMMON_SUPPORT) && \
- CONFIG_IS_ENABLED(SERIAL_SUPPORT))
+ CONFIG_IS_ENABLED(SERIAL))
puts("### ERROR ### Please RESET the board ###\n");
#endif
bootstage_error(BOOTSTAGE_ID_NEED_RESET);
diff --git a/lib/lmb.c b/lib/lmb.c
index 7bd1255f7a4..793647724c3 100644
--- a/lib/lmb.c
+++ b/lib/lmb.c
@@ -12,6 +12,10 @@
#include <log.h>
#include <malloc.h>
+#include <asm/global_data.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
#define LMB_ALLOC_ANYWHERE 0
static void lmb_dump_region(struct lmb_region *rgn, char *name)
@@ -113,6 +117,37 @@ void lmb_init(struct lmb *lmb)
lmb->reserved.cnt = 0;
}
+void arch_lmb_reserve_generic(struct lmb *lmb, ulong sp, ulong end, ulong align)
+{
+ ulong bank_end;
+ int bank;
+
+ /*
+ * Reserve memory from aligned address below the bottom of U-Boot stack
+ * until end of U-Boot area using LMB to prevent U-Boot from overwriting
+ * that memory.
+ */
+ debug("## Current stack ends at 0x%08lx ", sp);
+
+ /* adjust sp by 4K to be safe */
+ sp -= align;
+ for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) {
+ if (!gd->bd->bi_dram[bank].size ||
+ sp < gd->bd->bi_dram[bank].start)
+ continue;
+ /* Watch out for RAM at end of address space! */
+ bank_end = gd->bd->bi_dram[bank].start +
+ gd->bd->bi_dram[bank].size - 1;
+ if (sp > bank_end)
+ continue;
+ if (bank_end > end)
+ bank_end = end - 1;
+
+ lmb_reserve(lmb, sp, bank_end - sp + 1);
+ break;
+ }
+}
+
static void lmb_reserve_common(struct lmb *lmb, void *fdt_blob)
{
arch_lmb_reserve(lmb);
diff --git a/lib/md5.c b/lib/md5.c
index e2ba622ea4e..9d34465564e 100644
--- a/lib/md5.c
+++ b/lib/md5.c
@@ -55,7 +55,7 @@ byteReverse(unsigned char *buf, unsigned longs)
* Start MD5 accumulation. Set bit count to 0 and buffer to mysterious
* initialization constants.
*/
-static void
+void
MD5Init(struct MD5Context *ctx)
{
ctx->buf[0] = 0x67452301;
@@ -71,7 +71,7 @@ MD5Init(struct MD5Context *ctx)
* Update context to reflect the concatenation of another buffer full
* of bytes.
*/
-static void
+void
MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len)
{
register __u32 t;
@@ -120,7 +120,7 @@ MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len)
* Final wrapup - pad to 64-byte boundary with the bit pattern
* 1 0* (64-bit count of bits processed, MSB-first)
*/
-static void
+void
MD5Final(unsigned char digest[16], struct MD5Context *ctx)
{
unsigned int count;
diff --git a/lib/optee/Kconfig b/lib/optee/Kconfig
index c398f9b9535..3290b6656d9 100644
--- a/lib/optee/Kconfig
+++ b/lib/optee/Kconfig
@@ -34,7 +34,6 @@ config BOOTM_OPTEE
bool "Support OPTEE bootm command"
select BOOTM_LINUX
depends on OPTEE
- default n
help
Select this command to enable chain-loading of a Linux kernel
via an OPTEE firmware.
diff --git a/lib/rsa/rsa-sign.c b/lib/rsa/rsa-sign.c
index 0e0a890fd15..c27a784c429 100644
--- a/lib/rsa/rsa-sign.c
+++ b/lib/rsa/rsa-sign.c
@@ -19,24 +19,6 @@
#include <openssl/evp.h>
#include <openssl/engine.h>
-#if OPENSSL_VERSION_NUMBER >= 0x10000000L
-#define HAVE_ERR_REMOVE_THREAD_STATE
-#endif
-
-#if OPENSSL_VERSION_NUMBER < 0x10100000L || \
- (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x02070000fL)
-static void RSA_get0_key(const RSA *r,
- const BIGNUM **n, const BIGNUM **e, const BIGNUM **d)
-{
- if (n != NULL)
- *n = r->n;
- if (e != NULL)
- *e = r->e;
- if (d != NULL)
- *d = r->d;
-}
-#endif
-
static int rsa_err(const char *msg)
{
unsigned long sslErr = ERR_get_error();
@@ -272,7 +254,7 @@ static int rsa_engine_get_priv_key(const char *keydir, const char *name,
else if (name)
snprintf(key_id, sizeof(key_id),
"%s",
- name);
+ name ? name : "");
else if (keyfile)
snprintf(key_id, sizeof(key_id), "%s", keyfile);
else
@@ -314,24 +296,11 @@ static int rsa_init(void)
{
int ret;
-#if OPENSSL_VERSION_NUMBER < 0x10100000L || \
- (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x02070000fL)
- ret = SSL_library_init();
-#else
ret = OPENSSL_init_ssl(0, NULL);
-#endif
if (!ret) {
fprintf(stderr, "Failure to init SSL library\n");
return -1;
}
-#if OPENSSL_VERSION_NUMBER < 0x10100000L || \
- (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x02070000fL)
- SSL_load_error_strings();
-
- OpenSSL_add_all_algorithms();
- OpenSSL_add_all_digests();
- OpenSSL_add_all_ciphers();
-#endif
return 0;
}
@@ -347,8 +316,7 @@ 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");
- ret = -1;
- goto err_engine_by_id;
+ return -1;
}
if (!ENGINE_init(e)) {
@@ -381,29 +349,9 @@ err_set_rsa:
ENGINE_finish(e);
err_engine_init:
ENGINE_free(e);
-err_engine_by_id:
-#if OPENSSL_VERSION_NUMBER < 0x10100000L || \
- (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x02070000fL)
- ENGINE_cleanup();
-#endif
return ret;
}
-static void rsa_remove(void)
-{
-#if OPENSSL_VERSION_NUMBER < 0x10100000L || \
- (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x02070000fL)
- CRYPTO_cleanup_all_ex_data();
- ERR_free_strings();
-#ifdef HAVE_ERR_REMOVE_THREAD_STATE
- ERR_remove_thread_state(NULL);
-#else
- ERR_remove_state(0);
-#endif
- EVP_cleanup();
-#endif
-}
-
static void rsa_engine_remove(ENGINE *e)
{
if (e) {
@@ -476,12 +424,7 @@ static int rsa_sign_with_key(EVP_PKEY *pkey, struct padding_algo *padding_algo,
goto err_sign;
}
- #if OPENSSL_VERSION_NUMBER < 0x10100000L || \
- (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x02070000fL)
- EVP_MD_CTX_cleanup(context);
- #else
- EVP_MD_CTX_reset(context);
- #endif
+ EVP_MD_CTX_reset(context);
EVP_MD_CTX_destroy(context);
debug("Got signature: %zu bytes, expected %d\n", size, EVP_PKEY_size(pkey));
@@ -513,7 +456,7 @@ int rsa_sign(struct image_sign_info *info,
if (info->engine_id) {
ret = rsa_engine_init(info->engine_id, &e);
if (ret)
- goto err_engine;
+ return ret;
}
ret = rsa_get_priv_key(info->keydir, info->keyname, info->keyfile,
@@ -528,7 +471,6 @@ int rsa_sign(struct image_sign_info *info,
EVP_PKEY_free(pkey);
if (info->engine_id)
rsa_engine_remove(e);
- rsa_remove();
return ret;
@@ -537,8 +479,6 @@ err_sign:
err_priv:
if (info->engine_id)
rsa_engine_remove(e);
-err_engine:
- rsa_remove();
return ret;
}
@@ -686,12 +626,8 @@ int rsa_add_verify_data(struct image_sign_info *info, void *keydest)
ret = rsa_get_pub_key(info->keydir, info->keyname, e, &pkey);
if (ret)
goto err_get_pub_key;
-#if OPENSSL_VERSION_NUMBER < 0x10100000L || \
- (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x02070000fL)
- rsa = EVP_PKEY_get1_RSA(pkey);
-#else
+
rsa = EVP_PKEY_get0_RSA(pkey);
-#endif
ret = rsa_get_params(rsa, &exponent, &n0_inv, &modulus, &r_squared);
if (ret)
goto err_get_params;
@@ -761,10 +697,6 @@ done:
if (ret)
ret = ret == -FDT_ERR_NOSPACE ? -ENOSPC : -EIO;
err_get_params:
-#if OPENSSL_VERSION_NUMBER < 0x10100000L || \
- (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x02070000fL)
- RSA_free(rsa);
-#endif
EVP_PKEY_free(pkey);
err_get_pub_key:
if (info->engine_id)
diff --git a/lib/tiny-printf.c b/lib/tiny-printf.c
index 89aaa854771..f661fc65054 100644
--- a/lib/tiny-printf.c
+++ b/lib/tiny-printf.c
@@ -48,7 +48,7 @@ static void div_out(struct printf_info *info, unsigned long *num,
out_dgt(info, dgt);
}
-#ifdef CONFIG_SPL_NET_SUPPORT
+#ifdef CONFIG_SPL_NET
static void string(struct printf_info *info, char *s)
{
char ch;
@@ -178,7 +178,7 @@ static void __maybe_unused pointer(struct printf_info *info, const char *fmt,
}
break;
#endif
-#ifdef CONFIG_SPL_NET_SUPPORT
+#ifdef CONFIG_SPL_NET
case 'm':
return mac_address_string(info, ptr, false);
case 'M':
@@ -270,7 +270,7 @@ static int _vprintf(struct printf_info *info, const char *fmt, va_list va)
}
break;
case 'p':
- if (CONFIG_IS_ENABLED(NET_SUPPORT) || _DEBUG) {
+ if (CONFIG_IS_ENABLED(NET) || _DEBUG) {
pointer(info, fmt, va_arg(va, void *));
/*
* Skip this because it pulls in _ctype which is