From patchwork Tue Dec 18 05:05:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 154063 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3281940ljp; Mon, 17 Dec 2018 21:07:18 -0800 (PST) X-Google-Smtp-Source: AFSGD/VHU7lLEH+yvGrw2+LBczdKmQBGlfxWksibcPULgTCpue4kSCcbLJdn98ZdLfFhEMP8tp9r X-Received: by 2002:a50:95b4:: with SMTP id w49mr14954434eda.186.1545109638085; Mon, 17 Dec 2018 21:07:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545109638; cv=none; d=google.com; s=arc-20160816; b=awkpIOic5wFvFfK3sBdtgyIKWAbPbqdXlHHYxEHFXeewv/o4S2zzu9SEE3zIqqWIyq L+vJD3kARBLdEbpFs14pkyvnODIeKmqqKvdPfjiqNR7bV6KRpN9pxhuX9urRjjY6k4I2 uxRhpYu1hnKOpEyHW24k1e/hkfniVT056XJQhSHA9U478P25m1D+EEzzTpzXlAs92DBH cvsJZDKyD1eY8U8mDBerG8BgrmIEUYQymc7K7B+523J/lag39sM+3E0s2RioKORTE+Wk POrh2wxqSUZezmVqUOMWPa3vBSViPwfCCqFrWugU0c3jMwkUsWtIOPj/dBr3o57fnaN+ 9Xow== 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=yQ15i/nL9Lb+1mAlxvoQqtlHPBBEcLEGZRTtLqk7vFU=; b=xpBThaJ60g/188IeTG6Ccldlcmg10yZvKbauC4HWTJSlCI7O6HNLKzcbi8Jql1cPEE ks4Y3LRmsNJbBewuhT7nyJcisyp671IsiScqB5turDL4bCYXH6XDh101SlrqjbMq4CD3 wWDTUKmLUk8xKUHSKfe/qKXh5YOTgbHi9XmSpV4MsgwMixjI2sQT85IBL0NmCZ9nO3o+ wHCNubV8ITXToYOKLErGRNjfu2S8+a6605OxkzWSAAtyewWJRDe4KIOMV4JOzFYNF7SR ID0GsLnwQkNowzdQ67GkT26Pe+LVeA7RQHnVaRk9X8LCVebNe1PEDjo8c1DG/OTSk95Z rKzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=jGQ4Z7+I; 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 g16-v6si4661167ejf.225.2018.12.17.21.07.17; Mon, 17 Dec 2018 21:07:18 -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=jGQ4Z7+I; 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 B430DC22141; Tue, 18 Dec 2018 05:05:40 +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 4B8E8C2204E; Tue, 18 Dec 2018 05:05:38 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 1462DC2206B; Tue, 18 Dec 2018 05:02:08 +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 141FAC2206B for ; Tue, 18 Dec 2018 05:02:08 +0000 (UTC) Received: by mail-yw1-f65.google.com with SMTP id d190so6162092ywd.12 for ; Mon, 17 Dec 2018 21:02:08 -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=uRv0fQ/OweX5FHd033YY1iGKLWtsO9/vRIDG85pmcg8=; b=jGQ4Z7+IqQlqu3T0zJZcLkHRDG/NhqkLY4Z1SpXT4QyvFJ8a5TAorJiF658Gbfl4ME FMnqOlCEs42xp1/qGgERDdkDYOrmIxeMzYKihS/qIsQ36dnDKKTAPB+EoXOhVBbE3Tmk 96JEhx7IrTMS1cfjGIdql1ZBywLSPgsMQ+QTI= 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=uRv0fQ/OweX5FHd033YY1iGKLWtsO9/vRIDG85pmcg8=; b=k0Lmj8pMFblLrT5H4z+h6a7rnG89ron90suPA6F9XXrUy/Z4TYwB2+bfV+06I2GQiV zOznNLqUkyFowzys0K3n8lcyvASXBTARyB1ay57zV+53atZRg8EWLkzDSg2EFh+NhQfG G7q+HdTAJ9737BGRDb3LQJLbwYBJPsOBp4OD/NnqLD6vlnPScwnIVm2Ed7I2RtfMe/9T 44yovtF4JEW0S5lYRH3qMRg6PRhiCNiaui/1WPe04XonmDa1U7c6zPT9/oDnfrVPIhZv u8Gj3pvxS65KQFOgvqXreyzUdd7AdL9Ot1E67B8rhHcPGgXMV0edb1bvFgc1qOJfnqYU oeIA== X-Gm-Message-State: AA+aEWYkUrkW6/ousVs7QZ1/zReRMQPPUSqqInNwtFV13g2bnZcob+AP iAom09vconGGwCuJTY137lPhJw== X-Received: by 2002:a81:ec0d:: with SMTP id j13mr16094838ywm.5.1545109327074; Mon, 17 Dec 2018 21:02:07 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id l16sm4717589ywa.25.2018.12.17.21.02.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Dec 2018 21:02:06 -0800 (PST) From: AKASHI Takahiro To: trini@konsulko.com, agraf@suse.de, xypron.glpk@gmx.de Date: Tue, 18 Dec 2018 14:05:09 +0900 Message-Id: <20181218050510.20308-8-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 7/8] cmd: efishell: export uefi variable helper functions 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" Those function will be used for integration with 'env' command so as to handle uefi variables. Signed-off-by: AKASHI Takahiro --- cmd/efishell.c | 38 ++++++++++++++++++++++++++++++++++---- include/command.h | 4 ++++ 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/cmd/efishell.c b/cmd/efishell.c index 47ad77606062..42a29de7617c 100644 --- a/cmd/efishell.c +++ b/cmd/efishell.c @@ -65,7 +65,7 @@ static void dump_var_data(char *data, unsigned long len) * * efi_$guid_$varname = {attributes}(type)value */ -static int do_efi_dump_var(int argc, char * const argv[]) +static int _do_efi_dump_var(int argc, char * const argv[]) { char regex[256]; char * const regexlist[] = {regex}; @@ -128,6 +128,21 @@ static int do_efi_dump_var(int argc, char * const argv[]) return CMD_RET_SUCCESS; } +int do_efi_dump_var(int argc, char * const argv[]) +{ + efi_status_t r; + + /* 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); +} + static int append_value(char **bufp, unsigned long *sizep, char *data) { char *tmp_buf = NULL, *new_buf = NULL, *value; @@ -225,7 +240,7 @@ out: return 0; } -static int do_efi_set_var(int argc, char * const argv[]) +static int _do_efi_set_var(int argc, char * const argv[]) { char *var_name, *value = NULL; unsigned long size = 0; @@ -265,6 +280,21 @@ out: return ret; } +int do_efi_set_var(int argc, char * const argv[]) +{ + efi_status_t r; + + /* 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); +} + static efi_handle_t *efi_get_handles_by_proto(efi_guid_t *guid) { efi_handle_t *handles = NULL; @@ -916,9 +946,9 @@ static int do_efishell(cmd_tbl_t *cmdtp, int flag, if (!strcmp(command, "boot")) return do_efi_boot_opt(argc, argv); else if (!strcmp(command, "dumpvar") || !strcmp(command, "dmpstore")) - return do_efi_dump_var(argc, argv); + return _do_efi_dump_var(argc, argv); else if (!strcmp(command, "setvar")) - return do_efi_set_var(argc, argv); + return _do_efi_set_var(argc, argv); else if (!strcmp(command, "devices")) return do_efi_show_devices(argc, argv); else if (!strcmp(command, "drivers")) diff --git a/include/command.h b/include/command.h index 9b7b876585d9..5b081ae94cf3 100644 --- a/include/command.h +++ b/include/command.h @@ -51,6 +51,10 @@ extern int do_run(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); #if defined(CONFIG_CMD_BOOTEFI) int do_bootefi_bootmgr_exec(int boot_id); #endif +#if defined(CONFIG_CMD_EFISHELL) +int do_efi_dump_var(int argc, char * const argv[]); +int do_efi_set_var(int argc, char * const argv[]); +#endif /* common/command.c */ int _do_help (cmd_tbl_t *cmd_start, int cmd_items, cmd_tbl_t * cmdtp, int