From patchwork Tue Jan 15 02:55:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 155614 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp4390700jaa; Mon, 14 Jan 2019 19:04:35 -0800 (PST) X-Google-Smtp-Source: ALg8bN7AsyYXPMmvzEX+V0702NiDvDZZtEZpDUjHTneaoTgJ4P8E+c03QE56qUyge5s1GqEqTEI1 X-Received: by 2002:a50:9ac4:: with SMTP id p62mr1615656edb.179.1547521474895; Mon, 14 Jan 2019 19:04:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547521474; cv=none; d=google.com; s=arc-20160816; b=o/n6BYA+O2SAHDqNcxGgVjSTWOe0UfsxOzou9aQbKGZj4veYLzvZCc57/JPY/cS5lp 7jDOd/IS903/aGimlpoPuWJ2sEzvplvxOGEuccYWQJt6g9I4Ikp3UFPxEufrxCt2khn7 hRrLctA2vOjX+syI04c+M/SW8pDIJnv79KQThjRcRMdH0RuTmRm+YRk2vE5AcsMBflDp wPaL9Bk2Y/HuliymV52r+6kGnHD4v1FTtWN4xritgpHaE+hyUC1UqzDuBC+cr9pqwnv2 Hv84UEBv/TAzuUZI082hMvpgw2RjHAtTITsshXMTloHvtA/E7d/m6FUs9nKBnDiOyk4J Ej2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :cc:mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature; bh=AKNnbjvvPs/OU5L9L2nlJFNwzLm4fnetGVIvsOK0Gio=; b=JTNeIvUvVopF0UTuOhDALSetbA5fCx14FRetGhFOzqcHOkGDU2ZRmhcFIFxHwT1cSK /XeyKoK7QGFwGAPuxNQ0lBBkMej+wZuSksI3k2RD2CKwD3K3/XUAeZXaYeeSDrQ411eu 5WxGOyQp/F7H8ig3iCPbiYNnknrWAZ62z5QAas5BXn9x06JpTf0IrCiKFjdw8D4uHg2Q Du3N7iZ7VqtiN60YekwSjujT3Zu1rFH3809nAk+QOSUzWqn1rPOBy8ZQ6D9RCFLpq7MK OoE0PTaW2Pa5RhicEq9jkexlZx84o/MxptTwNhT3vWoOaMfu8dvRLuW/ngjZLKBzaKSD uNHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=RB4XtX8c; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id v14-v6si2502377ejw.273.2019.01.14.19.04.34; Mon, 14 Jan 2019 19:04:34 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=RB4XtX8c; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.denx.de (Postfix, from userid 105) id 81C40C21FBF; Tue, 15 Jan 2019 03:01:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_BLOCKED, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 35D29C220A7; Tue, 15 Jan 2019 03:01:39 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id E6F90C21FD0; Tue, 15 Jan 2019 02:56:00 +0000 (UTC) Received: from mail-yw1-f68.google.com (mail-yw1-f68.google.com [209.85.161.68]) by lists.denx.de (Postfix) with ESMTPS id 484DDC21FAB for ; Tue, 15 Jan 2019 02:55:57 +0000 (UTC) Received: by mail-yw1-f68.google.com with SMTP id n21so497969ywd.10 for ; Mon, 14 Jan 2019 18:55:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oAEoUfmG4u2KW2EwIe/N9ylj1iAD0J8Chz4wg/hcMEQ=; b=RB4XtX8cFWKofYcWCn6dLeCAgiC1WLdTExhj5ptqsUldh6FxXLeW8A9hPeh3m2pcO6 Bx2wSQRv3rdyRxt2nxJ6rMAucrBiL2mYMl3/q9YDtf2TnA160TLD+6yibcd/cyuJMK5V EFAzxivvcHOLuGHF8NiC5ahQzDhEYf5Z0Q8ho= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oAEoUfmG4u2KW2EwIe/N9ylj1iAD0J8Chz4wg/hcMEQ=; b=Txrxshjm5gP2pnJzOBS8Hj71RdgeAScD0LhJtKo20oROfQRHvp2Uucz5zRBa0CGbly McYdgQK7GBrpPsbMWJM3YTsGrzFPwhZO4KiKKwVoshPr5Ye1SLDqyfIzcK9pQFPHTE+o e89lgZ+S7Wc94ZcD6NGyLM2x3vVS2QJ8UVN3tgCuKwkmF3X+gFpe2VD3NsysqLVyXvNX 9vWIvg0pcDwrSsBiFQ/PUYgRku2VsmDNwLiEc3CzElzTMyGGSqHgv8FXY8G/02upXTWb jE1ShzNamR8PW1BzoJw/uiXHnPa0OOL95pA+KXj3+Yu/5yZj0GWIBl4qBBx2lJ/1COlw eSKA== X-Gm-Message-State: AJcUukdAoR9T3XpWPpfKXdT8nbDY4ciRuUE2nm1tiV2a7KyuArqYZ1nX OfSKqifqi/SyUnlXvvYIjjLFQg== X-Received: by 2002:a81:ad27:: with SMTP id l39mr1269409ywh.301.1547520956217; Mon, 14 Jan 2019 18:55:56 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id l189sm770349ywl.65.2019.01.14.18.55.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Jan 2019 18:55:55 -0800 (PST) From: AKASHI Takahiro To: trini@konsulko.com, agraf@suse.de, xypron.glpk@gmx.de Date: Tue, 15 Jan 2019 11:55:22 +0900 Message-Id: <20190115025522.12060-10-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190115025522.12060-1-takahiro.akashi@linaro.org> References: <20190115025522.12060-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH v4 9/9] cmd: env: add "-e" option for handling UEFI variables X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" "env [print|set] -e" allows for handling uefi variables without knowing details about mapping to corresponding u-boot variables. Signed-off-by: AKASHI Takahiro --- cmd/nvedit.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 2 deletions(-) diff --git a/cmd/nvedit.c b/cmd/nvedit.c index ce746bbf1b3e..44f6c3759253 100644 --- a/cmd/nvedit.c +++ b/cmd/nvedit.c @@ -27,6 +27,8 @@ #include #include #include +#include +#include #include #include #include @@ -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_CMD_EFITOOL) + 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; + } + + return do_efi_dump_var(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_CMD_EFITOOL) + 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; + } + + return do_efi_set_var(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_CMD_EFITOOL) + "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_CMD_EFITOOL) + "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_CMD_EFITOOL) + "printenv -e []\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_CMD_EFITOOL) + "-e []\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'", @@ -1345,7 +1402,7 @@ U_BOOT_CMD_COMPLETE( "run commands in an environment variable", "var [...]\n" " - run the commands in the environment variable(s) 'var'" -#if defined(CONFIG_CMD_BOOTEFI) +#if defined(CONFIG_CMD_EFITOOL) "\n" "run -e [BootXXXX]\n" " - load and run UEFI app based on 'BootXXXX' UEFI variable",