From: AKASHI Takahiro <takahiro.akashi@linaro.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v5 7/7] cmd: env: add "-e" option for handling UEFI variables
Date: Tue, 22 Jan 2019 12:06:28 +0900 [thread overview]
Message-ID: <20190122030626.GC20286@linaro.org> (raw)
In-Reply-To: <e28180ba-cf9e-5963-ec66-07e3cf907acd@suse.de>
On Mon, Jan 21, 2019 at 02:41:07PM +0100, Alexander Graf wrote:
> On 01/21/2019 08:49 AM, AKASHI Takahiro wrote:
> >"env [print|set] -e" allows for handling uefi variables without
> >knowing details about mapping to corresponding u-boot variables.
> >
> >Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
> >---
> > cmd/nvedit.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++-
> > 1 file changed, 58 insertions(+), 1 deletion(-)
> >
> >diff --git a/cmd/nvedit.c b/cmd/nvedit.c
> >index ce746bbf1b3e..1b971d7233bc 100644
> >--- a/cmd/nvedit.c
> >+++ b/cmd/nvedit.c
> >@@ -27,6 +27,8 @@
> > #include <cli.h>
> > #include <command.h>
> > #include <console.h>
> >+#include <efi.h>
> >+#include <efi_loader.h>
> > #include <environment.h>
> > #include <search.h>
> > #include <errno.h>
> >@@ -119,6 +121,25 @@ static int do_env_print(cmd_tbl_t *cmdtp, int flag, int argc,
> > int rcode = 0;
> > int env_flag = H_HIDE_DOT;
> >+#if defined(CONFIG_EFI_LOADER)
> >+ if (argc > 1 && argv[1][0] == '-' && argv[1][1] == 'e') {
> >+ efi_status_t r;
> >+
> >+ argc--;
> >+ argv++;
> >+
> >+ /* 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;
> >+ }
>
> No need for efi_init_obj_list() here, as it's already done by
> do_efi_dump_var_ext(), no?
Ah, right. (That's why do_efi_dump_var_ext() was introduced.)
Thanks,
-Takahiro Akashi
> >+
> >+ return do_efi_dump_var_ext(cmdtp, flag, argc, argv);
> >+ }
> >+#endif
> >+
> > if (argc > 1 && argv[1][0] == '-' && argv[1][1] == 'a') {
> > argc--;
> > argv++;
> >@@ -216,6 +237,26 @@ static int _do_env_set(int flag, int argc, char * const argv[], int env_flag)
> > ENTRY e, *ep;
> > debug("Initial value for argc=%d\n", argc);
> >+
> >+#if defined(CONFIG_EFI_LOADER)
> >+ if (argc > 1 && argv[1][0] == '-' && argv[1][1] == 'e') {
> >+ efi_status_t r;
> >+
> >+ argc--;
> >+ argv++;
> >+
> >+ /* 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;
> >+ }
>
> Same here.
>
>
> Alex
>
> >+
> >+ return do_efi_set_var_ext(NULL, flag, argc, argv);
> >+ }
> >+#endif
> >+
> > while (argc > 1 && **(argv + 1) == '-') {
> > char *arg = *++argv;
> >@@ -1262,15 +1303,23 @@ static char env_help_text[] =
> > #if defined(CONFIG_CMD_IMPORTENV)
> > "env import [-d] [-t [-r] | -b | -c] addr [size] [var ...] - import environment\n"
> > #endif
> >+#if defined(CONFIG_EFI_LOADER)
> >+ "env print [-a | -e [name] | name ...] - print environment\n"
> >+#else
> > "env print [-a | name ...] - print environment\n"
> >+#endif
> > #if defined(CONFIG_CMD_RUN)
> > "env run var [...] - run commands in an environment variable\n"
> > #endif
> > #if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_ENV_IS_NOWHERE)
> > "env save - save environment\n"
> > #endif
> >+#if defined(CONFIG_EFI_LOADER)
> >+ "env set [-e | -f] name [arg ...]\n";
> >+#else
> > "env set [-f] name [arg ...]\n";
> > #endif
> >+#endif
> > U_BOOT_CMD(
> > env, CONFIG_SYS_MAXARGS, 1, do_env,
> >@@ -1295,6 +1344,10 @@ U_BOOT_CMD_COMPLETE(
> > printenv, CONFIG_SYS_MAXARGS, 1, do_env_print,
> > "print environment variables",
> > "[-a]\n - print [all] values of all environment variables\n"
> >+#if defined(CONFIG_EFI_LOADER)
> >+ "printenv -e [<name>]\n"
> >+ " - print UEFI variable 'name' or all the variables\n"
> >+#endif
> > "printenv name ...\n"
> > " - print value of environment variable 'name'",
> > var_complete
> >@@ -1322,7 +1375,11 @@ U_BOOT_CMD_COMPLETE(
> > U_BOOT_CMD_COMPLETE(
> > setenv, CONFIG_SYS_MAXARGS, 0, do_env_set,
> > "set environment variables",
> >- "[-f] name value ...\n"
> >+#if defined(CONFIG_EFI_LOADER)
> >+ "-e <name> [<value>]\n"
> >+ " - set UEFI variable 'name' to 'value' ...'\n"
> >+#endif
> >+ "setenv [-f] name value ...\n"
> > " - [forcibly] set environment variable 'name' to 'value ...'\n"
> > "setenv [-f] name\n"
> > " - [forcibly] delete environment variable 'name'",
>
>
prev parent reply other threads:[~2019-01-22 3:06 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-21 7:49 [U-Boot] [PATCH v5 0/7] cmd: add efidebug for efi environment AKASHI Takahiro
2019-01-21 7:49 ` [U-Boot] [PATCH v5 1/7] cmd: add efidebug command AKASHI Takahiro
2019-01-21 13:07 ` Alexander Graf
2019-01-22 1:02 ` AKASHI Takahiro
2019-01-22 9:18 ` Alexander Graf
2019-01-23 4:47 ` AKASHI Takahiro
2019-01-23 9:52 ` Alexander Graf
2019-01-24 1:02 ` AKASHI Takahiro
2019-01-21 7:49 ` [U-Boot] [PATCH v5 2/7] cmd: efidebug: add devices command AKASHI Takahiro
2019-01-21 13:34 ` Alexander Graf
2019-01-22 1:38 ` AKASHI Takahiro
2019-01-22 9:19 ` Alexander Graf
2019-01-23 4:56 ` AKASHI Takahiro
2019-01-21 7:49 ` [U-Boot] [PATCH v5 3/7] cmd: efidebug: add drivers command AKASHI Takahiro
2019-01-21 7:49 ` [U-Boot] [PATCH v5 4/7] cmd: efidebug: add dh command AKASHI Takahiro
2019-01-21 7:49 ` [U-Boot] [PATCH v5 5/7] cmd: efidebug: add images command AKASHI Takahiro
2019-01-21 7:49 ` [U-Boot] [PATCH v5 6/7] cmd: efidebug: add memmap command AKASHI Takahiro
2019-01-21 13:39 ` Alexander Graf
2019-01-22 1:42 ` AKASHI Takahiro
2019-01-21 7:49 ` [U-Boot] [PATCH v5 7/7] cmd: env: add "-e" option for handling UEFI variables AKASHI Takahiro
2019-01-21 13:41 ` Alexander Graf
2019-01-22 3:06 ` AKASHI Takahiro [this message]
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=20190122030626.GC20286@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox