[PATCH 04/10] Hook up EFI env variable support in the EFI app
Matthew Garrett
mjg59 at srcf.ucam.org
Sat Nov 23 20:55:03 CET 2024
From: Matthew Garrett <mgarrett at aurora.tech>
Add simple support for accessing EFI variables when in EFI app mode
Signed-off-by: Matthew Garrett <mgarrett at aurora.tech>
---
cmd/Kconfig | 2 +-
lib/efi/Makefile | 2 +-
lib/efi/efi_app.c | 5 +++++
lib/efi/efi_vars.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 51 insertions(+), 2 deletions(-)
create mode 100644 lib/efi/efi_vars.c
diff --git a/cmd/Kconfig b/cmd/Kconfig
index 5ed6a50121c..33bf3d1ad39 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -717,7 +717,7 @@ config CMD_ENV_FLAGS
config CMD_NVEDIT_EFI
bool "env [set|print] -e - set/print UEFI variables"
- depends on EFI_LOADER
+ depends on EFI_LOADER || EFI_APP
imply HEXDUMP
help
UEFI variables are encoded as some form of U-Boot variables.
diff --git a/lib/efi/Makefile b/lib/efi/Makefile
index 232fa684360..63845287336 100644
--- a/lib/efi/Makefile
+++ b/lib/efi/Makefile
@@ -2,7 +2,7 @@
#
# (C) Copyright 2015 Google, Inc
-obj-$(CONFIG_EFI_APP) += efi_app.o efi.o efi_app_init.o
+obj-$(CONFIG_EFI_APP) += efi_app.o efi.o efi_app_init.o efi_vars.o
obj-$(CONFIG_EFI_STUB) += efi_info.o
CFLAGS_REMOVE_efi_stub.o := -mregparm=3 \
diff --git a/lib/efi/efi_app.c b/lib/efi/efi_app.c
index 7c3ef9a7926..77d5da40a5d 100644
--- a/lib/efi/efi_app.c
+++ b/lib/efi/efi_app.c
@@ -30,6 +30,11 @@
DECLARE_GLOBAL_DATA_PTR;
+int efi_init_obj_list(void)
+{
+ return EFI_SUCCESS;
+}
+
int efi_info_get(enum efi_entry_t type, void **datap, int *sizep)
{
return -ENOSYS;
diff --git a/lib/efi/efi_vars.c b/lib/efi/efi_vars.c
new file mode 100644
index 00000000000..099a59b2a1e
--- /dev/null
+++ b/lib/efi/efi_vars.c
@@ -0,0 +1,44 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Aurora Innovation, Inc. Copyright 2022.
+ *
+ */
+
+#define __efi_runtime
+
+#include <errno.h>
+#include <asm/global_data.h>
+#include <efi.h>
+#include <efi_api.h>
+#include <efi_variable.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+efi_status_t efi_get_variable_int(const u16 *variable_name, const efi_guid_t *vendor,
+ u32 *attributes, efi_uintn_t *data_size,
+ void *data, u64 *timep)
+{
+ struct efi_priv *priv = efi_get_priv();
+ struct efi_runtime_services *run = priv->run;
+
+ return run->get_variable((u16 *)variable_name, vendor, attributes, data_size, data);
+}
+
+efi_status_t efi_set_variable_int(const u16 *variable_name, const efi_guid_t *vendor,
+ u32 attributes, efi_uintn_t data_size, const void *data,
+ bool ro_check)
+{
+ struct efi_priv *priv = efi_get_priv();
+ struct efi_runtime_services *run = priv->run;
+
+ return run->set_variable((u16 *)variable_name, vendor, attributes, data_size, data);
+}
+
+efi_status_t efi_get_next_variable_name_int(efi_uintn_t *variable_name_size,
+ u16 *variable_name, efi_guid_t *vendor)
+{
+ struct efi_priv *priv = efi_get_priv();
+ struct efi_runtime_services *run = priv->run;
+
+ return run->get_next_variable_name(variable_name_size, variable_name, vendor);
+}
--
2.47.0
More information about the U-Boot
mailing list