[U-Boot] [PATCH 2/4] cmd: efishell: support -nv option to setvar sub-command
Heinrich Schuchardt
xypron.glpk at gmx.de
Tue Dec 11 18:50:40 UTC 2018
On 11/28/18 7:00 AM, AKASHI Takahiro wrote:
> With -nv specified, a variable to be created will have NON_VOLATILE
> attribute.
>
> Signed-off-by: AKASHI Takahiro <takahiro.akashi at linaro.org>
Why would we only make the NON_VOLATILE attribute available and not all
the other attributes like EFI_VARIABLE_BOOTSERVICE_ACCESS?
Where is the patch that ensures that non-volatile variables are not stored?
Currently we do not make EFI variables available to the operating system
so they are not really of much use.
Best regards
Heinrich
> ---
> cmd/efishell.c | 17 +++++++++++++----
> 1 file changed, 13 insertions(+), 4 deletions(-)
>
> diff --git a/cmd/efishell.c b/cmd/efishell.c
> index 7cd3ca489559..7cdff757b06c 100644
> --- a/cmd/efishell.c
> +++ b/cmd/efishell.c
> @@ -249,11 +249,22 @@ static int _do_efi_set_var(int argc, char * const argv[])
> unsigned long size = 0;
> u16 *var_name16, *p;
> efi_guid_t guid;
> + u32 attributes;
> efi_status_t ret;
>
> if (argc == 1)
> return CMD_RET_SUCCESS;
>
> + attributes = EFI_VARIABLE_BOOTSERVICE_ACCESS |
> + EFI_VARIABLE_RUNTIME_ACCESS;
> + if (!strcmp(argv[1], "-nv")) {
> + attributes |= EFI_VARIABLE_NON_VOLATILE;
> + argc--;
> + argv++;
> + if (argc == 1)
> + return CMD_RET_SUCCESS;
> + }
> +
> var_name = argv[1];
> if (argc == 2) {
> /* remove */
> @@ -275,9 +286,7 @@ static int _do_efi_set_var(int argc, char * const argv[])
> utf8_utf16_strncpy(&p, var_name, strlen(var_name) + 1);
>
> guid = efi_global_variable_guid;
> - ret = efi_set_variable(var_name16, &guid,
> - EFI_VARIABLE_BOOTSERVICE_ACCESS |
> - EFI_VARIABLE_RUNTIME_ACCESS, size, value);
> + ret = efi_set_variable(var_name16, &guid, attributes, size, value);
> ret = (ret == EFI_SUCCESS ? CMD_RET_SUCCESS : CMD_RET_FAILURE);
> out:
> return ret;
> @@ -978,7 +987,7 @@ static char efishell_help_text[] =
> "\n"
> "efishell dumpvar [<name>]\n"
> " - get uefi variable's value\n"
> - "efishell setvar <name> [<value>]\n"
> + "efishell setvar [-nv] <name> [<value>]\n"
> " - set/delete uefi variable's value\n"
> " <value> may be \"=\"...\"\", \"=0x...\" (set) or \"=\" (delete)\n"
> "efishell devices\n"
>
More information about the U-Boot
mailing list