summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Kconfig9
-rw-r--r--lib/Makefile2
-rw-r--r--lib/efi_loader/Kconfig50
-rw-r--r--lib/fw_loader.c63
-rw-r--r--lib/lwip/u-boot/lwipopts.h1
5 files changed, 100 insertions, 25 deletions
diff --git a/lib/Kconfig b/lib/Kconfig
index fbc9de90669..f5c1731f456 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -71,6 +71,14 @@ config DYNAMIC_CRC_TABLE
Enable this option to calculate entries for CRC tables at runtime.
This can be helpful when reducing the size of the build image
+config FW_LOADER
+ bool "Enable firmware loader using environment script"
+ depends on CMDLINE
+ depends on ENV_SUPPORT
+ help
+ Enable this option to make firmware loading using user-provided
+ U-Boot environment script functionality accessible to U-Boot code.
+
config HAVE_ARCH_IOMAP
bool
help
@@ -1244,6 +1252,7 @@ config SPL_LMB
config LMB_ARCH_MEM_MAP
bool "Add an architecture specific memory map"
depends on LMB
+ depends on !COMPILE_TEST
default y if FSL_LAYERSCAPE || X86
help
Some architectures have special or unique aspects which need
diff --git a/lib/Makefile b/lib/Makefile
index 2643bfc867c..a2e60668864 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -22,6 +22,8 @@ obj-$(CONFIG_AES) += aes.o
obj-$(CONFIG_AES) += aes/
obj-$(CONFIG_$(PHASE_)BINMAN_FDT) += binman.o
+obj-$(CONFIG_FW_LOADER) += fw_loader.o
+
ifndef API_BUILD
ifneq ($(CONFIG_CHARSET),)
obj-y += charset.o
diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
index 900113ca3e9..13e44be1d06 100644
--- a/lib/efi_loader/Kconfig
+++ b/lib/efi_loader/Kconfig
@@ -123,22 +123,6 @@ config EFI_VARIABLE_FILE_STORE
Select this option if you want non-volatile UEFI variables to be
stored as file /ubootefi.var on the EFI system partition.
-config EFI_RT_VOLATILE_STORE
- bool "Allow variable runtime services in volatile storage (e.g RAM)"
- depends on EFI_VARIABLE_FILE_STORE
- help
- When EFI variables are stored on file we don't allow SetVariableRT,
- since the OS doesn't know how to write that file. At the same time
- we copy runtime variables in DRAM and support GetVariableRT
-
- Enable this option to allow SetVariableRT on the RAM backend of
- the EFI variable storage. The OS will be responsible for syncing
- the RAM contents to the file, otherwise any changes made during
- runtime won't persist reboots.
- Authenticated variables are not supported. Note that this will
- violate the EFI spec since writing auth variables will return
- EFI_INVALID_PARAMETER
-
config EFI_MM_COMM_TEE
bool "UEFI variables storage service via the trusted world"
depends on OPTEE
@@ -157,6 +141,31 @@ config EFI_MM_COMM_TEE
MM buffer. The data is copied by u-boot to the shared buffer before issuing
the door bell event.
+config EFI_VARIABLE_NO_STORE
+ bool "Don't persist non-volatile UEFI variables"
+ help
+ If you choose this option, non-volatile variables cannot be persisted.
+ You could still provide non-volatile variables via
+ EFI_VARIABLES_PRESEED.
+
+endchoice
+
+config EFI_RT_VOLATILE_STORE
+ bool "Allow variable runtime services in volatile storage (e.g RAM)"
+ depends on EFI_VARIABLE_FILE_STORE
+ help
+ When EFI variables are stored on file we don't allow SetVariableRT,
+ since the OS doesn't know how to write that file. At the same time
+ we copy runtime variables in DRAM and support GetVariableRT
+
+ Enable this option to allow SetVariableRT on the RAM backend of
+ the EFI variable storage. The OS will be responsible for syncing
+ the RAM contents to the file, otherwise any changes made during
+ runtime won't persist reboots.
+ Authenticated variables are not supported. Note that this will
+ violate the EFI spec since writing auth variables will return
+ EFI_INVALID_PARAMETER
+
config FFA_SHARED_MM_BUF_SIZE
int "Memory size of the shared MM communication buffer"
depends on EFI_MM_COMM_TEE && ARM_FFA_TRANSPORT
@@ -184,15 +193,6 @@ config FFA_SHARED_MM_BUF_ADDR
the MM SP in secure world.
It is assumed that the MM SP knows the address of the shared MM communication buffer.
-config EFI_VARIABLE_NO_STORE
- bool "Don't persist non-volatile UEFI variables"
- help
- If you choose this option, non-volatile variables cannot be persisted.
- You could still provide non-volatile variables via
- EFI_VARIABLES_PRESEED.
-
-endchoice
-
config EFI_VARIABLES_PRESEED
bool "Initial values for UEFI variables"
depends on !COMPILE_TEST
diff --git a/lib/fw_loader.c b/lib/fw_loader.c
new file mode 100644
index 00000000000..f776e09523a
--- /dev/null
+++ b/lib/fw_loader.c
@@ -0,0 +1,63 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2025 Lucien Jheng <lucienzx159@gmail.com>
+ */
+
+#include <command.h>
+#include <env.h>
+#include <errno.h>
+#include <linux/types.h>
+#include <log.h>
+
+int request_firmware_into_buf_via_script(void *buf, size_t max_size,
+ const char *script_name,
+ size_t *retsize)
+{
+ char env_addr[CONFIG_SYS_CBSIZE] = { 0 };
+ char env_size[CONFIG_SYS_CBSIZE] = { 0 };
+ char *args[2] = { "run", (char *)script_name };
+ int ret, repeatable;
+ ulong addr, size;
+
+ if (!buf || !script_name || !max_size)
+ return -EINVAL;
+
+ /* Run the firmware loading script */
+ ret = cmd_process(0, 2, args, &repeatable, NULL);
+ if (ret) {
+ log_err("Firmware loading script '%s' not defined or failed.\n",
+ script_name);
+ return -EINVAL;
+ }
+
+ /* Prefix the FW loader variables with the script prefix */
+ snprintf(env_addr, sizeof(env_addr), "%s_addr", script_name);
+ snprintf(env_size, sizeof(env_size), "%s_size", script_name);
+
+ /* Find out where the firmware got loaded and how long it is */
+ addr = env_get_hex(env_addr, 0);
+ size = env_get_hex(env_size, 0);
+
+ /* Clear the variables set by the firmware loading script */
+ env_set(env_addr, NULL);
+ env_set(env_size, NULL);
+
+ if (!addr || !size) {
+ log_err("Firmware address (0x%lx) or size (0x%lx) are invalid.\n",
+ addr, size);
+ return -EINVAL;
+ }
+
+ if (size > max_size) {
+ log_err("Loaded firmware size 0x%lx exceeded maximum allowed size 0x%zx.\n",
+ size, max_size);
+ return -E2BIG;
+ }
+
+ if (retsize)
+ *retsize = size;
+
+ memcpy(buf, (void *)addr, size);
+
+ return 0;
+}
diff --git a/lib/lwip/u-boot/lwipopts.h b/lib/lwip/u-boot/lwipopts.h
index 80b93ea172d..e8a2c9d7a0a 100644
--- a/lib/lwip/u-boot/lwipopts.h
+++ b/lib/lwip/u-boot/lwipopts.h
@@ -44,6 +44,7 @@
#define DNS_DEBUG LWIP_DBG_ON
#define IP6_DEBUG LWIP_DBG_OFF
#define DHCP6_DEBUG LWIP_DBG_OFF
+#define SNTP_DEBUG LWIP_DBG_ON
#endif
#define LWIP_TESTMODE 0