U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Garrett <mjg59@srcf.ucam.org>
To: u-boot@lists.denx.de
Cc: Matthew Garrett <mgarrett@aurora.tech>,
	AKASHI Takahiro <akashi.tkhro@gmail.com>,
	Caleb Connolly <caleb.connolly@linaro.org>,
	Dmitry Rokosov <ddrokosov@salutedevices.com>,
	Heinrich Schuchardt <xypron.glpk@gmx.de>,
	Ilias Apalodimas <ilias.apalodimas@linaro.org>,
	Jerome Forissier <jerome.forissier@linaro.org>,
	Mattijs Korpershoek <mkorpershoek@baylibre.com>,
	Simon Glass <sjg@chromium.org>, Tom Rini <trini@konsulko.com>
Subject: [PATCH 04/10] Hook up EFI env variable support in the EFI app
Date: Sat, 23 Nov 2024 11:55:03 -0800	[thread overview]
Message-ID: <20241123195616.305687-5-mjg59@srcf.ucam.org> (raw)
In-Reply-To: <20241123195616.305687-1-mjg59@srcf.ucam.org>

From: Matthew Garrett <mgarrett@aurora.tech>

Add simple support for accessing EFI variables when in EFI app mode

Signed-off-by: Matthew Garrett <mgarrett@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


  parent reply	other threads:[~2024-11-23 21:49 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-23 19:54 [PATCH 00/10] Improve UEFI app support Matthew Garrett
2024-11-23 19:55 ` [PATCH 01/10] Add EFI handover support to bootm Matthew Garrett
2024-11-24 14:43   ` Heinrich Schuchardt
2024-11-24 19:29     ` Matthew Garrett
2024-11-24 19:51       ` Heinrich Schuchardt
2024-12-08 23:06         ` Simon Glass
2024-11-25 13:46       ` Ilias Apalodimas
2024-12-01 16:12   ` Simon Glass
2024-12-08 15:29     ` Simon Glass
2024-11-23 19:55 ` [PATCH 02/10] Add part_find command Matthew Garrett
2024-12-01 16:12   ` Simon Glass
2024-12-08 15:29     ` Simon Glass
2024-12-10  8:21   ` Heinrich Schuchardt
2024-12-10 16:16     ` Simon Glass
2024-11-23 19:55 ` [PATCH 03/10] Add a command to find a load address Matthew Garrett
2024-11-24 15:56   ` Tom Rini
2024-12-01 16:12   ` Simon Glass
2024-12-08 15:29     ` Simon Glass
2024-11-23 19:55 ` Matthew Garrett [this message]
2024-12-01 16:12   ` [PATCH 04/10] Hook up EFI env variable support in the EFI app Simon Glass
2024-12-08 15:29     ` Simon Glass
2024-11-23 19:55 ` [PATCH 05/10] Add EFI network driver Matthew Garrett
2024-12-01 16:12   ` Simon Glass
2024-12-08 15:29     ` Simon Glass
2024-11-23 19:55 ` [PATCH 06/10] Add UEFI TPM2 driver Matthew Garrett
2024-12-01 16:12   ` Simon Glass
2024-12-08 15:29     ` Simon Glass
2024-11-23 19:55 ` [PATCH 07/10] Support separate DTB files with the UEFI app Matthew Garrett
2024-11-25 13:55   ` Ilias Apalodimas
2024-12-01 16:14   ` Simon Glass
2024-12-08 15:29     ` Simon Glass
2024-11-23 19:55 ` [PATCH 08/10] Use the correct ramdisk address Matthew Garrett
2024-12-01 16:14   ` Simon Glass
2024-12-08 15:29     ` Simon Glass
2024-11-23 19:55 ` [PATCH 09/10] Fix efi_bind_block Matthew Garrett
2024-11-25 13:40   ` Ilias Apalodimas
2024-12-09  2:28     ` Simon Glass
2024-12-01 16:14   ` Simon Glass
2024-12-08 15:29     ` Simon Glass
2024-12-10  8:45   ` Heinrich Schuchardt
2024-12-10 16:17     ` Simon Glass
2024-12-10 17:11       ` Tom Rini
2024-12-11 17:50         ` Janis Danisevskis
2024-12-11 17:59           ` Ilias Apalodimas
2024-12-11 20:23           ` Simon Glass
2024-12-11 22:28             ` Janis Danisevskis
2024-11-23 19:55 ` [PATCH 10/10] Add command to set an environment variable to an EFI variable Matthew Garrett
2024-11-24 14:58   ` Heinrich Schuchardt
2024-12-01 16:14     ` Simon Glass
2024-12-08 15:29       ` Simon Glass
2024-12-09  2:28     ` Simon Glass
2024-11-24 14:40 ` [PATCH 00/10] Improve UEFI app support Heinrich Schuchardt
2024-12-01 16:15 ` Simon Glass
2024-12-08 15:28   ` Simon Glass
2024-12-08 15:51     ` Tom Rini
2024-12-08 18:50       ` Tom Rini
2024-12-08 23:07       ` Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241123195616.305687-5-mjg59@srcf.ucam.org \
    --to=mjg59@srcf.ucam.org \
    --cc=akashi.tkhro@gmail.com \
    --cc=caleb.connolly@linaro.org \
    --cc=ddrokosov@salutedevices.com \
    --cc=ilias.apalodimas@linaro.org \
    --cc=jerome.forissier@linaro.org \
    --cc=mgarrett@aurora.tech \
    --cc=mkorpershoek@baylibre.com \
    --cc=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=xypron.glpk@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox