From patchwork Wed Nov 28 06:00:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 152195 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp700013ljp; Tue, 27 Nov 2018 21:59:44 -0800 (PST) X-Google-Smtp-Source: AFSGD/XwpZ0LaPDhv6De0Djx4mzLeigsCnC9M/yVmiPdRXGvbi4BQQwINy3UVMkE/tR+RWfc2L3Z X-Received: by 2002:a50:9e43:: with SMTP id z61mr29395508ede.90.1543384784327; Tue, 27 Nov 2018 21:59:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543384784; cv=none; d=google.com; s=arc-20160816; b=Y9xB80He13Hj2FgcVI6XmQ+ED/v6r2K9H12nEPFkC6jcC7dlDSwSdYLxvNLqRCbcBS 9uT9rR7SqR+aYZu5KToflYklwtLks5y4fmAdpcypTeaqenGwErzNVofkUvp86ykytWa3 7Nmtx1sdAB7BnCKzeipI5IRhCp0tRjpzECimlTwWLoZjXW7lkH9Sd4KYV6wnwblfnMd5 OR0WQLuOBmFOUm3t/H2onolOlVbfNc8namD4DuaPgovDA+38A3lYA89O8w5L5deP5i7D O9/8QKjvHIWJ5BX/HZnC4Bt71JLaK0ninqy/rRE5iNS1Va2xQgNREX4pYjOC4KuAw8ij lOew== 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=jKVgLLMcy0T6m864CUG3pPQEhW9ZwUjfUikbk6xQxmI=; b=FjmC10ZY6rE7HNrgYog3szWEbLEYekJNs1UM+as5hu9rZqm5/aF38GZCZ3wum180VK 3SzdlbHZjKFH+yUHa7kv7B3NXpvr9MY/yXkRSY5ABp6o6jsBl0lAUmF1Fjwib3rdBUym kdYjQ0sEwDG5LDNmMkUg3UJUQzYl43yZM4SVM8hX4z+gf+36GiANPQGbAHnpb9a2mIS8 wGRsQAd7Kbq6m3tfrB2Jm4uf/gT2d69lX9FstPdyR8smNYOOeTeMgoH7p1fK2Yh7sH4z RtAc7ZDMqj5THm6IK7A14Z2t8OmJxgKgFUFhXw8jYyrVVbSQ2eBZkkRjCI3rnJ0+Grt8 d4Bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=ZFfmgXfd; 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 v27si2535734edb.444.2018.11.27.21.59.44; Tue, 27 Nov 2018 21:59:44 -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=ZFfmgXfd; 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 DF1EAC22171; Wed, 28 Nov 2018 05:59:23 +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_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 92DD2C2218B; Wed, 28 Nov 2018 05:59:15 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 7EC6BC2212E; Wed, 28 Nov 2018 05:58:55 +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 5C3C7C221BA for ; Wed, 28 Nov 2018 05:58:52 +0000 (UTC) Received: by mail-yw1-f65.google.com with SMTP id h32so10250274ywk.2 for ; Tue, 27 Nov 2018 21:58:52 -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=h1iqcyR857W+HIPftMlJWYkQKCC3Iw5j6ZMjLpKqJbA=; b=ZFfmgXfdzg3gVSsaBvWuvs5Z3ZFfzXWkrU9aQ6H5UskCvKsTIlcO9tJbr9ZRS8g2JX UrrFLrS8UX/1TfUgbcpLxFRhVTYTHRcE3Bk34PZNBhoLSWJlXNKLStWf7ReJS4a7j/gX 4Jc7RFI0hc6UwewIGvhNcbMw36jTCFKG0QdmE= 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=h1iqcyR857W+HIPftMlJWYkQKCC3Iw5j6ZMjLpKqJbA=; b=X38PQy9N7VVgzxkbV3PNSLtI0/CG0d5DO6YfE5fBJsz22HvhBmoyP/k/93Dg1Zjpag ugam6OBX/NpBWv7u1v/Z08ckftDFbfsaSfx016cnssQzqKjXcoL2Ea2G17U5i3CFPtz7 ttsvrCexQsIY/SVLYrJtj2S1zAGptzS/srSLOjEY1Xs143kwpqhV5DEw49wIhjmb35zb ERiMCvOHRM12Ief06SdijcPh3r98sVc/qGCDrLDC+EYdVAs6JUwy3u/Tp0j+/qiNWyqg aZx8cjZZez4+HBRn8X1cbeymAH43jIFnmk6C6EvHHqP5jENDSn43Rb8NC36SuzHsDXZB aqCg== X-Gm-Message-State: AA+aEWaJ/iYUiUyI07rlvC3VGB5dFpSC/y4naZ3bq9mNE1kEVCiYenEL SpHcqd0JArTRKbGkPyPiK/lBsQ== X-Received: by 2002:a81:51c7:: with SMTP id f190mr33772970ywb.162.1543384731178; Tue, 27 Nov 2018 21:58:51 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id u84sm1549893ywb.12.2018.11.27.21.58.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Nov 2018 21:58:50 -0800 (PST) From: AKASHI Takahiro To: trini@konsulko.com, agraf@suse.de, xypron.glpk@gmx.de Date: Wed, 28 Nov 2018 15:00:57 +0900 Message-Id: <20181128060059.5508-3-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181128060059.5508-1-takahiro.akashi@linaro.org> References: <20181128060059.5508-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH 2/4] cmd: efishell: support -nv option to setvar sub-command 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" With -nv specified, a variable to be created will have NON_VOLATILE attribute. Signed-off-by: AKASHI Takahiro --- cmd/efishell.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/cmd/efishell.c b/cmd/efishell.c index 7cd3ca489559..7cdff757b06c 100644 --- a/cmd/efishell.c +++ b/cmd/efishell.c @@ -249,11 +249,22 @@ static int _do_efi_set_var(int argc, char * const argv[]) unsigned long size = 0; u16 *var_name16, *p; efi_guid_t guid; + u32 attributes; efi_status_t ret; if (argc == 1) return CMD_RET_SUCCESS; + attributes = EFI_VARIABLE_BOOTSERVICE_ACCESS | + EFI_VARIABLE_RUNTIME_ACCESS; + if (!strcmp(argv[1], "-nv")) { + attributes |= EFI_VARIABLE_NON_VOLATILE; + argc--; + argv++; + if (argc == 1) + return CMD_RET_SUCCESS; + } + var_name = argv[1]; if (argc == 2) { /* remove */ @@ -275,9 +286,7 @@ static int _do_efi_set_var(int argc, char * const argv[]) utf8_utf16_strncpy(&p, var_name, strlen(var_name) + 1); guid = efi_global_variable_guid; - ret = efi_set_variable(var_name16, &guid, - EFI_VARIABLE_BOOTSERVICE_ACCESS | - EFI_VARIABLE_RUNTIME_ACCESS, size, value); + ret = efi_set_variable(var_name16, &guid, attributes, size, value); ret = (ret == EFI_SUCCESS ? CMD_RET_SUCCESS : CMD_RET_FAILURE); out: return ret; @@ -978,7 +987,7 @@ static char efishell_help_text[] = "\n" "efishell dumpvar []\n" " - get uefi variable's value\n" - "efishell setvar []\n" + "efishell setvar [-nv] []\n" " - set/delete uefi variable's value\n" " may be \"=\"...\"\", \"=0x...\" (set) or \"=\" (delete)\n" "efishell devices\n"