From patchwork Mon Nov 5 09:06:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 150158 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2357082ljp; Mon, 5 Nov 2018 01:09:58 -0800 (PST) X-Google-Smtp-Source: AJdET5cYlkQlLiM2OQUJYfzKW5Ez5lllRl/ug28oteb1uq4d6p2vZbrVhwEIFHT2VBCwNjUBqDHn X-Received: by 2002:aa7:d410:: with SMTP id z16-v6mr17670887edq.26.1541408998581; Mon, 05 Nov 2018 01:09:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541408998; cv=none; d=google.com; s=arc-20160816; b=WmiwAAsEwL+nR5UHdJv5NF0YvPmsIyaj61Ha3apEeBkzfOI8piU4uv0mYb2yuiZZs0 a9baIRXaKHf3xEg1tLtVa8IqZlzBfCbTsaY2R7BBgqzCbrBYQU3xdEWOCZAmxXWe29ez U/p47Tzqpk4VsF6dRtjJLgX0OztcIFyRu8Um81Y2qaAY/bCWhPhC/ln4rgToxyYrbPQi dOvEB7i8ruxD2cnZDALUvgkJRsKEvLiDoahjjJElV2d5oeR0nHaZrRZ3clT4wMcYfH+Q /G/Wpkjmv3vg+NlcJ5+VYt9sIJtqxYrosam+hHm1z+pb7jBSHh/Yfuebfj9H1BbvLpzU asrQ== 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=YYaeTUwAjDK+LuwJ0nxf6RXLy9kJkMHjv8mj9xHXq+Y=; b=DTr7UxEksHnxYKDcIu3FjP2Cc4ndiRFbPJwxlq8dUhpfDwX5bKIXwlWplc5o9Hc0nx 9C0UDHzcU+8dQYqS3L3ejfKoiGLotb9KV5I1Q54hpZO5imG4ZK9QjGgGbsAz57u4ywyN oYqybHiskrGtVizyGNLhDf8XO7pNY3KeUQBKKXXhWtNGNzxysHYjKch/DuGLd0hYK2XD LcIXsdy/PwEs+FIJFZAZpYadigYbnYr3ZuT6w7opztb8AunuMVlbmqKNwut9JoOewrQ/ bhuOoI7wtKdr+NbQCp9xsbRTRdnSqfMTaMu1pHrWVPVz16df1oWySMhWyJqGe7vS+VFx Iq+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=GUUBGhDu; 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 x16-v6si580763eda.5.2018.11.05.01.09.58; Mon, 05 Nov 2018 01:09:58 -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=GUUBGhDu; 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 340F6C2220A; Mon, 5 Nov 2018 09:08:56 +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=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 6ADE0C2220F; Mon, 5 Nov 2018 09:08:20 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 98D35C221F9; Mon, 5 Nov 2018 09:05:31 +0000 (UTC) Received: from mail-yw1-f65.google.com (mail-yw1-f65.google.com [209.85.161.65]) by lists.denx.de (Postfix) with ESMTPS id 261A6C22226 for ; Mon, 5 Nov 2018 09:05:27 +0000 (UTC) Received: by mail-yw1-f65.google.com with SMTP id d126-v6so3346511ywa.5 for ; Mon, 05 Nov 2018 01:05:27 -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=Eh31lHUC4bPAWZC9r5mbRnrIhPgsTAjSpo02e4Aqna4=; b=GUUBGhDuGp55Irkoit4D4s1bWVdoq+ZAGEP2ZOpgyQtRI/k2VOtS8Ksr2crCW38qea nnulEMFJjnhP1DeM1lxfMY1YUU2T9VZPMXe0OehcIimJv6xt26HamdCfkUJFS8JizJ9R j3gfinYIYVbDLFB/+QQLAm+uFLlYVWLV116Ms= 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=Eh31lHUC4bPAWZC9r5mbRnrIhPgsTAjSpo02e4Aqna4=; b=IYNw0qqgUfwsd7rqwhHUw4td/Xpy8nM5nczLI81diew/7LamZJsbK+8otxpdZpki3P YdL+NRSRx+/pO7/fpc0PHd3sKSrew5BnwugaIunqiBTNcCstCfV9t2nb6MbvjGJTd2Op laito6PSJftpXZnU1IXIsC3tpa/nDkOWZ3IDjyr1Sj9MvN45qOtDyY3DnSSHDhL5vETf fu6+yk3rzuee6OYKECF5AvjhuExH/1jh54ugqpg777VJp3ro0DoTuKU+geqhrgulClqh 1Jo5rLnX82KufTlmkgFhRZTLh8Ryq41kBh1WVMqSIqmzoeitNFMdPrYTbwJMle5Jm+Ud yOVg== X-Gm-Message-State: AGRZ1gJb1F6DSfoXW4ispR12b/yaA5wV+uv53R75QrMF7mmWYK+kZvZa 7cwrqdkivSPbvvPTOpENsIZZnQ== X-Received: by 2002:a81:cb0d:: with SMTP id q13-v6mr20093974ywi.298.1541408725996; Mon, 05 Nov 2018 01:05:25 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id x10-v6sm995332ywa.94.2018.11.05.01.05.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Nov 2018 01:05:25 -0800 (PST) From: AKASHI Takahiro To: trini@konsulko.com, agraf@suse.de Date: Mon, 5 Nov 2018 18:06:53 +0900 Message-Id: <20181105090653.7409-15-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181105090653.7409-1-takahiro.akashi@linaro.org> References: <20181105090653.7409-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 Cc: xypron.glpk@gmx.de, u-boot@lists.denx.de Subject: [U-Boot] [PATCH v2 14/14] 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 | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/cmd/nvedit.c b/cmd/nvedit.c index c0facabfc4fe..1925483c0285 100644 --- a/cmd/nvedit.c +++ b/cmd/nvedit.c @@ -36,6 +36,7 @@ #include #include #include +#include "efishell.h" DECLARE_GLOBAL_DATA_PTR; @@ -119,6 +120,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_BOOTEFI) + 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 +236,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_BOOTEFI) + 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 +1302,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_BOOTEFI) + "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_BOOTEFI) + "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 +1343,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_BOOTEFI) + "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 +1374,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_BOOTEFI) + "-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'",