From patchwork Tue Dec 18 05:05:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 154065 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3282402ljp; Mon, 17 Dec 2018 21:08:01 -0800 (PST) X-Google-Smtp-Source: AFSGD/UKAtQ+IuQPbXIL40UKXIuJ1UrCf4cl9BjHI2svFLF6e93+22Q1aau38sZhSxktrd3mCIZk X-Received: by 2002:a50:ee1a:: with SMTP id g26mr14879252eds.266.1545109681907; Mon, 17 Dec 2018 21:08:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545109681; cv=none; d=google.com; s=arc-20160816; b=AgtDa5rICJHOeY5MfD/fatCgBV/ssuiHtnQE7me2Vm21JPDMtAQFVRX7HcUoxSdIf/ 2snq47P8KZ9Ro0QHqo9kd/JwbycRrf/u4zITwxyO7RRrsLv0P+QgKl7tsjxxk2HWNqnz znF3SoxsNOppHrQ6099piCYbbJrpzizvWRFcx1n9dBJ3KSIXRYWncEbZl8X0MhpFZrj3 modRuzSF8BNZ1zfj0+3bGJNvvBjgGbx8TFbxd5kydUraqyujNh/tbV1h3dLMZRp09uNK 31OjnO5u/kuVSC1T379iUDf0OJCCEMe0kwFkgPGMAGxJxjWs0XG3OA+Y2IC2em2NmJQe EfDA== 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=f9eqgLMVXwKpXkc7pJn4FhcC9u3xuDw5L2SFKArSzwk=; b=dBVeU9KbOwC9ZMmyZxi0KBhVdUOA+M5FIYYGj2cRSbkNPAOXP1VNEkQTdkzycq8s5H UBgjSX1rCYYiZaRYrg67Kbs6LSYFCDCrlEUDuSMWGdR/GoC8XFI5TkgTc95mkFccoP/w 93OXEzCxDcnr9Unp+FSu5BoRzu3FVPXcLC9L1wOBfaoDr3TF1DjJZOniNDnG+MKKHH2X kGZOaeMt5GIWJNNtMAFoDc3tHnczYTUuU5jbgnxEmSLlzdzhOr1vgulFLiI0jTDtLoJ/ 6LTOVc5yGRkRdiCk51+EKlGv4/CKGrT6WZwZP03ZIN2G+u5cZ8z9N+uQj63VyU222Ii4 B+Cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=NialhjPM; 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 h16si5753257edj.421.2018.12.17.21.08.01; Mon, 17 Dec 2018 21:08:01 -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=NialhjPM; 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 7D217C220C4; Tue, 18 Dec 2018 05:05:58 +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, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, 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 61C2CC21F7D; Tue, 18 Dec 2018 05:05:43 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 0B351C21F79; Tue, 18 Dec 2018 05:02:11 +0000 (UTC) Received: from mail-yw1-f67.google.com (mail-yw1-f67.google.com [209.85.161.67]) by lists.denx.de (Postfix) with ESMTPS id 1DB37C2205A for ; Tue, 18 Dec 2018 05:02:11 +0000 (UTC) Received: by mail-yw1-f67.google.com with SMTP id h193so6172272ywc.4 for ; Mon, 17 Dec 2018 21:02:11 -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=ZiMHvOy4JcGby7otNLCu2Yzr5rfwR535gGOnw7444CQ=; b=NialhjPMGzTtVKnZKqmbFTtTVUexD1Gw0FJ6u69HZfIuA4AVfDfnjeoPbvlb+cACu2 n5zVviqYV+q1ayhRM5CE7MtXOlJCJuqO1gQwSSNDtFpNfTrRSnRUgIs/VyvHIYGcjilO jz1d6/yclotk2oUWr0p0R5H/uRxsXqAK85xEA= 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=ZiMHvOy4JcGby7otNLCu2Yzr5rfwR535gGOnw7444CQ=; b=QlV01Sx86AX1NQmZUp+mC0669T3Et0eO+leFWeL5Vkv/sl6KBI8dxFmohXhyxQq6oq Nqq5+GUjuU621lMoIQ007zBQWcI6qx+g81DOMXq9CaKYqlo74e+jiZr8MCKDyrHGa4zl FUyWLlsDhkw4oy3rIXLq4nuo2CHt4hCgv/+kY/oHMS7t9Gy4Exu7UNfQhbo7xqD65BOO IcDFByBvZfCP4N96y07tiEjtq7FJuUDqbzutCspJXcmBEPwPPg115D7/MS6Yyot+pZXm UQwJga6tslw+Fh8iQKYfFE3zWUk6SjYB3ovY6SyC/G7Zbu/qrJ2OGum2srhRh1zhw+E/ zO6g== X-Gm-Message-State: AA+aEWbnqX+bVN64U+6eIAzypbhHTh8lp8Ifz7QhtsJ3KoAtLfo8ZjJI ZbFDBgE57EtcgReEa6R8zh42LQ== X-Received: by 2002:a81:650b:: with SMTP id z11mr15696603ywb.441.1545109330097; Mon, 17 Dec 2018 21:02:10 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id 77sm4158809ywb.54.2018.12.17.21.02.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Dec 2018 21:02:09 -0800 (PST) From: AKASHI Takahiro To: trini@konsulko.com, agraf@suse.de, xypron.glpk@gmx.de Date: Tue, 18 Dec 2018 14:05:10 +0900 Message-Id: <20181218050510.20308-9-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181218050510.20308-1-takahiro.akashi@linaro.org> References: <20181218050510.20308-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH v3 8/8] 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 c0facabfc4fe..8168c963ac9d 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_EFISHELL) + 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_EFISHELL) + 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_EFISHELL) + "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_EFISHELL) + "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_EFISHELL) + "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_EFISHELL) + "-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'", @@ -1343,7 +1400,7 @@ U_BOOT_CMD( U_BOOT_CMD_COMPLETE( run, CONFIG_SYS_MAXARGS, 1, do_run, "run commands in an environment variable", -#if defined(CONFIG_CMD_BOOTEFI) +#if defined(CONFIG_CMD_EFISHELL) "var -e [BootXXXX]\n" " - load and run UEFI app based on 'BootXXXX' UEFI variable", #else