All of lore.kernel.org
 help / color / mirror / Atom feed
From: AKASHI Takahiro <takahiro.akashi@linaro.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3 7/8] cmd: efishell: export uefi variable helper functions
Date: Tue, 18 Dec 2018 14:05:09 +0900	[thread overview]
Message-ID: <20181218050510.20308-8-takahiro.akashi@linaro.org> (raw)
In-Reply-To: <20181218050510.20308-1-takahiro.akashi@linaro.org>

Those function will be used for integration with 'env' command
so as to handle uefi variables.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
---
 cmd/efishell.c    | 38 ++++++++++++++++++++++++++++++++++----
 include/command.h |  4 ++++
 2 files changed, 38 insertions(+), 4 deletions(-)

diff --git a/cmd/efishell.c b/cmd/efishell.c
index 47ad77606062..42a29de7617c 100644
--- a/cmd/efishell.c
+++ b/cmd/efishell.c
@@ -65,7 +65,7 @@ static void dump_var_data(char *data, unsigned long len)
  *
  *   efi_$guid_$varname = {attributes}(type)value
  */
-static int do_efi_dump_var(int argc, char * const argv[])
+static int _do_efi_dump_var(int argc, char * const argv[])
 {
 	char regex[256];
 	char * const regexlist[] = {regex};
@@ -128,6 +128,21 @@ static int do_efi_dump_var(int argc, char * const argv[])
 	return CMD_RET_SUCCESS;
 }
 
+int do_efi_dump_var(int argc, char * const argv[])
+{
+	efi_status_t r;
+
+	/* Initialize EFI drivers */
+	r = efi_init_obj_list();
+	if (r != EFI_SUCCESS) {
+		printf("Error: Cannot set up EFI drivers, r = %lu\n",
+		       r & ~EFI_ERROR_MASK);
+		return CMD_RET_FAILURE;
+	}
+
+	return _do_efi_dump_var(argc, argv);
+}
+
 static int append_value(char **bufp, unsigned long *sizep, char *data)
 {
 	char *tmp_buf = NULL, *new_buf = NULL, *value;
@@ -225,7 +240,7 @@ out:
 	return 0;
 }
 
-static int do_efi_set_var(int argc, char * const argv[])
+static int _do_efi_set_var(int argc, char * const argv[])
 {
 	char *var_name, *value = NULL;
 	unsigned long size = 0;
@@ -265,6 +280,21 @@ out:
 	return ret;
 }
 
+int do_efi_set_var(int argc, char * const argv[])
+{
+	efi_status_t r;
+
+	/* Initialize EFI drivers */
+	r = efi_init_obj_list();
+	if (r != EFI_SUCCESS) {
+		printf("Error: Cannot set up EFI drivers, r = %lu\n",
+		       r & ~EFI_ERROR_MASK);
+		return CMD_RET_FAILURE;
+	}
+
+	return _do_efi_set_var(argc, argv);
+}
+
 static efi_handle_t *efi_get_handles_by_proto(efi_guid_t *guid)
 {
 	efi_handle_t *handles = NULL;
@@ -916,9 +946,9 @@ static int do_efishell(cmd_tbl_t *cmdtp, int flag,
 	if (!strcmp(command, "boot"))
 		return do_efi_boot_opt(argc, argv);
 	else if (!strcmp(command, "dumpvar") || !strcmp(command, "dmpstore"))
-		return do_efi_dump_var(argc, argv);
+		return _do_efi_dump_var(argc, argv);
 	else if (!strcmp(command, "setvar"))
-		return do_efi_set_var(argc, argv);
+		return _do_efi_set_var(argc, argv);
 	else if (!strcmp(command, "devices"))
 		return do_efi_show_devices(argc, argv);
 	else if (!strcmp(command, "drivers"))
diff --git a/include/command.h b/include/command.h
index 9b7b876585d9..5b081ae94cf3 100644
--- a/include/command.h
+++ b/include/command.h
@@ -51,6 +51,10 @@ extern int do_run(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
 #if defined(CONFIG_CMD_BOOTEFI)
 int do_bootefi_bootmgr_exec(int boot_id);
 #endif
+#if defined(CONFIG_CMD_EFISHELL)
+int do_efi_dump_var(int argc, char * const argv[]);
+int do_efi_set_var(int argc, char * const argv[]);
+#endif
 
 /* common/command.c */
 int _do_help (cmd_tbl_t *cmd_start, int cmd_items, cmd_tbl_t * cmdtp, int
-- 
2.19.1

  parent reply	other threads:[~2018-12-18  5:05 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-18  5:05 [U-Boot] [PATCH v3 0/8] cmd: add efishell for efi environment AKASHI Takahiro
2018-12-18  5:05 ` [U-Boot] [PATCH v3 1/8] cmd: add efishell command AKASHI Takahiro
2018-12-30 15:44   ` Heinrich Schuchardt
2018-12-30 17:10     ` Heinrich Schuchardt
2019-01-07  5:08       ` AKASHI Takahiro
2019-01-08  9:57         ` Alexander Graf
2019-01-07  5:06     ` AKASHI Takahiro
2018-12-30 23:47   ` Heinrich Schuchardt
2019-01-07  5:13     ` AKASHI Takahiro
2018-12-18  5:05 ` [U-Boot] [PATCH v3 2/8] cmd: efishell: add devices command AKASHI Takahiro
2018-12-18  5:05 ` [U-Boot] [PATCH v3 3/8] cmd: efishell: add drivers command AKASHI Takahiro
2018-12-20  7:51   ` Heinrich Schuchardt
2018-12-25  7:22     ` AKASHI Takahiro
2018-12-25 12:07       ` Heinrich Schuchardt
2018-12-18  5:05 ` [U-Boot] [PATCH v3 4/8] cmd: efishell: add images command AKASHI Takahiro
2018-12-18  5:05 ` [U-Boot] [PATCH v3 5/8] cmd: efishell: add memmap command AKASHI Takahiro
2018-12-18  5:05 ` [U-Boot] [PATCH v3 6/8] cmd: efishell: add dh command AKASHI Takahiro
2018-12-20  7:49   ` Heinrich Schuchardt
2018-12-25  5:32     ` AKASHI Takahiro
2018-12-18  5:05 ` AKASHI Takahiro [this message]
2018-12-18  5:05 ` [U-Boot] [PATCH v3 8/8] cmd: env: add "-e" option for handling UEFI variables AKASHI Takahiro
2018-12-18  6:07   ` Heinrich Schuchardt
2018-12-19  1:49     ` AKASHI Takahiro
2018-12-19 12:23       ` Heinrich Schuchardt
2018-12-23  1:56         ` Alexander Graf
2018-12-25  8:44           ` AKASHI Takahiro
2018-12-26 21:20             ` Alexander Graf
2019-01-07  7:47               ` AKASHI Takahiro
2019-01-08  7:29                 ` AKASHI Takahiro
2019-01-08  8:58                   ` Alexander Graf

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=20181218050510.20308-8-takahiro.akashi@linaro.org \
    --to=takahiro.akashi@linaro.org \
    --cc=u-boot@lists.denx.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.