From patchwork Tue Dec 18 05:02: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: 154056 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3278529ljp; Mon, 17 Dec 2018 21:02:33 -0800 (PST) X-Google-Smtp-Source: AFSGD/VrVJEJNBUqJ62Z09c13E7m57gj57Q1dnqLotnXV5UvOjvZxVCzi2H7EMAFdQDkJ51xluOY X-Received: by 2002:a17:906:4684:: with SMTP id a4-v6mr12405144ejr.24.1545109353884; Mon, 17 Dec 2018 21:02:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545109353; cv=none; d=google.com; s=arc-20160816; b=X4YdpgRN/VH+UeVb2H2hjNoB1xmeDl0tsp67tymOYZRbz9+1u9GU2WuHzvug4rHQ20 w6FnRXZMi80IkA0XxOv8x749C3DpjBCEvBwtNPPcMBexaeQixNw9/uTJch0407bc1nXy fpv//0c9n+k7aavZR1iqiMcI7MMcIIRq/vreKP/vjN4FYBi4hA+PpHfLoHjAXKHckHmH kHwzeYd/ulNnFE2dKAQsAIXKA+2QV2yHP0mGzwZ41O7lLbEqHB0TFumPyGDT3Y870TEV JDIG4/ok8bqH2It6vYWvL1FvmvRdX1x6mo/40aBtuPhlug1mFs6+7sqkmQOOH8dQ5cxH 2CEw== 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=xRK6U0hJEZ6G8xememW4yzQ+RhrjKcJcni2/6pXUD3k=; b=rYz4PFu8TBj95i6tzH0HI2H20jFnttGwZdTs4bnocDkPiP1VfrkWAiZRLnGaCEmG/d iIJwlBPbSEz8cAMr/4SnkxVkJHNj8u99BfZmj00/yNfHppCEmRVJLkBCfCELOMrtHiNe WUQ4CUxWNFLFeE81fRJWsv7yda95d+x3f77wPQzxaCF4DUI3pYCo5R/cmJdWOU9NBZmB MqWwj7wNjsBZmNA4fO8KPOxXRvjEZbVv1f+a8wliFaMD04qASWnE1mxzBmMEC18LKsRa mQQIlWjvJnWSURBORehOigC8rVRqB4J91RKudNQfP9z5V0+QOVV495yVZGhs+u6mZeYm 1PNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=WZvyuMpr; 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 n7-v6si3112404ejr.283.2018.12.17.21.02.33; Mon, 17 Dec 2018 21:02:33 -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=WZvyuMpr; 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 76773C21ECC; Tue, 18 Dec 2018 05:00:53 +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_H2, 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 576F7C220AF; Tue, 18 Dec 2018 05:00:09 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 94E95C21FA3; Tue, 18 Dec 2018 04:59:49 +0000 (UTC) Received: from mail-yw1-f66.google.com (mail-yw1-f66.google.com [209.85.161.66]) by lists.denx.de (Postfix) with ESMTPS id EF553C21FB9 for ; Tue, 18 Dec 2018 04:59:48 +0000 (UTC) Received: by mail-yw1-f66.google.com with SMTP id g75so6187241ywb.1 for ; Mon, 17 Dec 2018 20:59:48 -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=0CgRnx09H1XwU9KniHuUr0FlCy9bxtQYmCtRCCn+dK0=; b=WZvyuMpryha56mbdQC2bwY2B9b9Axx1/2z7SffaGM8eU+fITRNQmtDmG+nnVgGe+9F 45MRpI5ZrPCFF9Zh1JnAnb+O15zMrfgEzmrLLhv6RAQTpMIcIIGYkhYc1cdlaxjHkfBo 3TGjCIfSxu0bltBEHjtVi8yquG0+TANHupg7w= 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=0CgRnx09H1XwU9KniHuUr0FlCy9bxtQYmCtRCCn+dK0=; b=rtyajQLk+tAgn7RvyQzocBTMu6vXrkoZgFhcy9uJjiWpqv2Wizaz3MWliIx7aqoGFT psuwIFsy3cfvJ+DAqY4S/CZrk/MTkEon9rY+exqqYE8U6tvaniNvf8fQ0RZdsSROMUV1 SNgF0ryBDnx518E/F/Wr2kpmpPy3olBAXiIVtD4QApSdVQS5dYBRcwaikPMWIYvcC9/K xYGkD9f4pGwqnW4EMRnnFFMfitJn53hcdOYVyvtUOACNQiYLLYtp0u3n6f3D85rpQKCm VSeN/RZ8w73c8/BITFsqQk7bawxY09DhSMYLw8V45dAZE+7J1wg+l/W+i2bFnwf9ZKIS O5Yg== X-Gm-Message-State: AA+aEWaMsSk8FHhgpr6JMX157akR4TI5CygFa+gwJWbuMMddDawRZL8M /hZHQbcSY4ZxycnolOxZxCZJPQ== X-Received: by 2002:a81:3009:: with SMTP id w9mr16459225yww.28.1545109187943; Mon, 17 Dec 2018 20:59:47 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id n16sm5082676ywn.31.2018.12.17.20.59.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Dec 2018 20:59:47 -0800 (PST) From: AKASHI Takahiro To: trini@konsulko.com, agraf@suse.de, xypron.glpk@gmx.de Date: Tue, 18 Dec 2018 14:02:57 +0900 Message-Id: <20181218050257.20142-6-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181218050257.20142-1-takahiro.akashi@linaro.org> References: <20181218050257.20142-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH 5/5] cmd: run: add "-e" option to run an EFI application 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" "run -e" allows for executing EFI application with a specific "BootXXXX" variable. If no "BootXXXX" is specified or "BootOrder" is specified, it tries to run an EFI application specified in the order of "bootOrder." Signed-off-by: AKASHI Takahiro --- cmd/bootefi.c | 2 +- cmd/nvedit.c | 5 +++++ common/cli.c | 31 +++++++++++++++++++++++++++++++ include/command.h | 3 +++ 4 files changed, 40 insertions(+), 1 deletion(-) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 2fc52e3056d2..8122793d11c5 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -471,7 +471,7 @@ static efi_status_t bootefi_test_prepare #endif /* CONFIG_CMD_BOOTEFI_SELFTEST */ -static int do_bootefi_bootmgr_exec(int boot_id) +int do_bootefi_bootmgr_exec(int boot_id) { struct efi_device_path *device_path, *file_path; void *addr; diff --git a/cmd/nvedit.c b/cmd/nvedit.c index de16c72c23f2..c0facabfc4fe 100644 --- a/cmd/nvedit.c +++ b/cmd/nvedit.c @@ -1343,8 +1343,13 @@ 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) + "var -e [BootXXXX]\n" + " - load and run UEFI app based on 'BootXXXX' UEFI variable", +#else "var [...]\n" " - run the commands in the environment variable(s) 'var'", +#endif var_complete ); #endif diff --git a/common/cli.c b/common/cli.c index 51b8d5f85cbb..013dd2e51936 100644 --- a/common/cli.c +++ b/common/cli.c @@ -12,8 +12,10 @@ #include #include #include +#include #include #include +#include "../cmd/bootefi.h" DECLARE_GLOBAL_DATA_PTR; @@ -125,6 +127,35 @@ int do_run(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) if (argc < 2) return CMD_RET_USAGE; +#ifdef CONFIG_CMD_BOOTEFI + if (!strcmp(argv[1], "-e")) { + int boot_id = -1; + char *endp; + + if (argc == 3) { + if (!strcmp(argv[2], "BootOrder")) { + boot_id = -1; + } else if (!strncmp(argv[2], "Boot", 4)) { + boot_id = (int)simple_strtoul(&argv[2][4], + &endp, 0); + if ((argv[2] + strlen(argv[2]) != endp) || + boot_id > 0xffff) + return CMD_RET_USAGE; + } else { + return CMD_RET_USAGE; + } + } + + if (efi_init_obj_list()) + return CMD_RET_FAILURE; + + if (efi_handle_fdt(NULL)) + return CMD_RET_FAILURE; + + return do_bootefi_bootmgr_exec(boot_id); + } +#endif + for (i = 1; i < argc; ++i) { char *arg; diff --git a/include/command.h b/include/command.h index 200c7a5e9f4e..9b7b876585d9 100644 --- a/include/command.h +++ b/include/command.h @@ -48,6 +48,9 @@ typedef struct cmd_tbl_s cmd_tbl_t; #if defined(CONFIG_CMD_RUN) extern int do_run(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); #endif +#if defined(CONFIG_CMD_BOOTEFI) +int do_bootefi_bootmgr_exec(int boot_id); +#endif /* common/command.c */ int _do_help (cmd_tbl_t *cmd_start, int cmd_items, cmd_tbl_t * cmdtp, int