From patchwork Mon Jan 21 07:49:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 156171 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp6089318jaa; Sun, 20 Jan 2019 23:53:47 -0800 (PST) X-Google-Smtp-Source: ALg8bN5KWvZhpBBfZbgJY2Jmw6RRppqgmhdjhkdvfmUlkWAE6LS2uW5pmsKhzf89DcEgy1nEchAP X-Received: by 2002:a17:906:340a:: with SMTP id c10-v6mr14349294ejb.130.1548057227101; Sun, 20 Jan 2019 23:53:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548057227; cv=none; d=google.com; s=arc-20160816; b=u9fUbqMEXb5PaW4YCCytLlKtM5mJxwIoSyIKC5gu8kTByIo3cFKmqXP3lkEkIJxjO2 L8sXbT1oFv6OXoDKIdvueoPkCkcrc/AkzUNtNfb7OItua65rsgss0e9YIO9cX0kMrc0r c7ysb5PZAwuJypPp0iPEhEEAMrB0S/djaUe2nLxG7IQVCTSkFIHlcyX/UDQPL0puL+bJ g1sHu1tfTCOMuisI4YhwKt1l6ixEusq+VD36GF6Pr5FwYU25vcBTaxurUOJU4YU5/xJu X0fTxWwymX/iyKYyz6Qa1tclvQWORyp+91siqCYhIHPVvidtY7iz/ERnsYzJWuthJXsX f+Uw== 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=HFbGAxqjJ2CFuF9kqoVGCRwQ9e81kEeNoBi/pGovWJg=; b=fM3vuvKTkaXs6EHsyEwnX+vw1RYJau4BM/ScleIDicEESHIYjvqcThl2uICnQkrkIO wrRsFukY4Pk4ba8Tx4rf4wdczL162HPSASEjujrkNCEZIvrm/rIK3RhjFpuQ4Q/VCjKd Z/uRFpmp/JiDTovZ3lle1+BcYLD+vCy6Vbxrwi8dzUJYqGPceAdYWpaRJApSTwendnCP DjNWObSdL8SPHyY8tKO4p7Xphj3eD/OExtYeAvtQ3P75+TTPSrue3Fu6EPnhaIuq8wwe hzyJ6tl5Czk1GNelvNxAuBwGyuVi7Aw0/V+kk9kIk8ECTD52Efipa0A72/ZJ5amHZL74 hWyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=S73HT8aU; 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 c1-v6si3541149ejf.257.2019.01.20.23.53.46; Sun, 20 Jan 2019 23:53:47 -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=S73HT8aU; 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 BA06BC21EAE; Mon, 21 Jan 2019 07:51:47 +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_NONE, 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 4C947C21E76; Mon, 21 Jan 2019 07:50:11 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 2C41DC21E7F; Mon, 21 Jan 2019 07:49:44 +0000 (UTC) Received: from mail-yb1-f195.google.com (mail-yb1-f195.google.com [209.85.219.195]) by lists.denx.de (Postfix) with ESMTPS id BD864C21E52 for ; Mon, 21 Jan 2019 07:49:40 +0000 (UTC) Received: by mail-yb1-f195.google.com with SMTP id x9so6819631ybj.5 for ; Sun, 20 Jan 2019 23:49:40 -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=QhPJZH1CMHI8lwIOz0ido2RD0nOiZ7uW+Y3a44VkMtM=; b=S73HT8aUTDqZ0HsB/ZwdBGjiPSYm1jJbfIp/q/mqlkIQEBBDh0x3G0avun3VbCi2d7 Z7iTaxTrpxoVes3NV1jWXABZppx8y1PMMOqB5CvUKQ4/8AL4olUXou05mJLLP9O5wyq2 MxKswqCsRYHDk5eBNZ0n49Mp7y0Jypvn6qR/Y= 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=QhPJZH1CMHI8lwIOz0ido2RD0nOiZ7uW+Y3a44VkMtM=; b=ozdn78VaRVcQdxaBwP0WE5F6wksRlxmb+B0OF+/R0wwtXgqrFhab3uOQ/vm4e0QFEz x+I7U+9wg46iCbbgw9i+371ce3gK79bfTsMtaM/AMsprD5SoUmaoJ4e5yqQFdMEigUoY JOpxStWT7eSZA0jgZzIp0mAABheCRVc9QeqZyheeOpeYHyAzYyYihHn60l57zhlABYNW UUp7N7BOinxJ/0gr2tLSI0Wisf7ByhW+FsPw4m5XMe4KYyZdwceiYkGNEnK36FKee3dZ Y9EcOli0o6NyVUgSXpp8wLNNieBBcDwbam91rlpD6+9Wa8uvw7Jac43m9b8buTOdKLb6 WoyQ== X-Gm-Message-State: AJcUukc8UURCE6bK6UPaSDKTSUnMpVlgUK0q97hkakRylEeseLs6YyDq YoZAfz5z+sOKZSMArGyXzTfDWg== X-Received: by 2002:a5b:388:: with SMTP id k8mr11209064ybp.122.1548056979751; Sun, 20 Jan 2019 23:49:39 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id c140sm8130029ywa.74.2019.01.20.23.49.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 20 Jan 2019 23:49:39 -0800 (PST) From: AKASHI Takahiro To: trini@konsulko.com, agraf@suse.de, xypron.glpk@gmx.de Date: Mon, 21 Jan 2019 16:49:23 +0900 Message-Id: <20190121074923.29959-8-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190121074923.29959-1-takahiro.akashi@linaro.org> References: <20190121074923.29959-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH v5 7/7] 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 | 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 #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_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; + } + + 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; + } + + 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 []\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 []\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'",