From patchwork Mon Nov 5 09:06:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 150164 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2360437ljp; Mon, 5 Nov 2018 01:13:45 -0800 (PST) X-Google-Smtp-Source: AJdET5ew/HF6TaQNWGmGe3OV5vqGazLpHeQAU0GYo9Z9X2YlEV/Y9wUH81VZX80MkrzRSm5Ky4js X-Received: by 2002:a05:6402:654:: with SMTP id u20mr17282893edx.96.1541409225459; Mon, 05 Nov 2018 01:13:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541409225; cv=none; d=google.com; s=arc-20160816; b=L0OSd5ZXrTjqK8fb6+Ai+xrfYrm7cSjerZfdIR/Fuq3czdgOwo8z0uYBXQ+r+UUKZa PEIvIyJRED7veeLhuNAJ3khylqKDJpCShnrSuPULL0dIMyzpcAFzHQqdVGVaTwbPXNU1 ML+Rb+FkwFng5xY93ljKoOVjE3ra//fTN+UVr+mhhyAktmBIeE6gsvvasBFmNlal4KIK Kzod5pp4lFWXt6uoLEjKMQR/a437FWTT4GoV10vluDJl+os/YIrIaAM60GDHxTW12/3i ++uAZ57fInhPcmoKZA7QrEJV1OP7yaIioh6n9UFqUJLoC17IvG0uYJ3msn6ajfWfetr5 Nu1A== 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=7KYk/rkJs20dSnYZfyIwbe/fWQlRhWKL6vhnYTr3E0A=; b=08LltRy65ew8GwmAUAd2+XW8zGIkSMgxaFcHnYKSHqKEc1fSidNUBpoA+csvX6mcR0 z7NOo6aJH5z5AhpjWJflXA5AhbH7iwZntDaRxhw/q251vw8wjJEs1rIxCAjv7tpVPXag EOwVtCaOoqBmuCnx0wfhD1ircK8AvJLluU9mrB9xdbN3QA1GAHn2Tigk27mmrUMKyBQI T/OO4glH+aE49KfEdJL+vnmjzACWeFYiJj610Gt0SbGVy1q7WJW4vdq5dCQnLChCX8Qy PpBVKmNsNziPWEdJ82caroMlheZmuvhr5F9rlfViUMUAatq8/zniarQowWiCL+qHQ7c/ Gdmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=F6vk4wyu; 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 z1-v6si5020238edr.81.2018.11.05.01.13.45; Mon, 05 Nov 2018 01:13:45 -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=F6vk4wyu; 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 0B674C225FE; Mon, 5 Nov 2018 09:08:02 +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_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 B8684C221F9; Mon, 5 Nov 2018 09:07:10 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 89272C2220A; Mon, 5 Nov 2018 09:05:25 +0000 (UTC) Received: from mail-yb1-f195.google.com (mail-yb1-f195.google.com [209.85.219.195]) by lists.denx.de (Postfix) with ESMTPS id 65278C22417 for ; Mon, 5 Nov 2018 09:05:20 +0000 (UTC) Received: by mail-yb1-f195.google.com with SMTP id t13-v6so3470027ybb.8 for ; Mon, 05 Nov 2018 01:05:20 -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=J57P7EXOo8vfRBYacJbTfY+Ph2m1LFLlDg6V20dtz9Q=; b=F6vk4wyubfBnVK+0jmuTBdrDw9Awo9K96MqVCq6x4BKbIQ0sw/yABBAkzcMZ2iGvqf t+14C7C9IJ5zSpIIQRkLHMCSCGb9R70cwJcBImqItObvmWXDjVbKaIl//Zelmlnxb8g9 Pt4gf9cOgnzrhuoFyXMPoThWXC5hteUjjkb1o= 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=J57P7EXOo8vfRBYacJbTfY+Ph2m1LFLlDg6V20dtz9Q=; b=RU5v/F/p7xbdPypUUGmPN+8/im8Cb95oca2FBE/qm2ufBhJjIEVP8CFb6X/LVH8Hzf n5X8xV8NdSOMPJuD7HArMlxsVZQ9xk3Pu0sgORELG8n0dP99jcUyeP7aD2i9J41DeIXt 078fUkhWy+2I/fdAHcHXkBs0/6UD8z3H+0tPKA9ZVp7vr/GgFTFcjbEW5ekscwqupPaR aYK8XRi+XQ3wRtL5B37YWz8sOglKHmDK67hHpscNCL5a8E4FffmtrvG4ryoXJKb5BFTf RdWscMlKWj5WCRsCjiJAsNIjhurDJFpN5yNHUG5o1M6ZNgzTDFAMN+ANNzaQTRfIt9kW Ik6g== X-Gm-Message-State: AGRZ1gINFg2cK34KYU52HhNJVl9BXxronfg5TEjneXxASAyD0miWuRc/ yxH6agnqP15O/83duqdNchvdGA== X-Received: by 2002:a25:acd3:: with SMTP id x19-v6mr5537919ybd.472.1541408719246; Mon, 05 Nov 2018 01:05:19 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id l69-v6sm10923252ywl.51.2018.11.05.01.05.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Nov 2018 01:05:18 -0800 (PST) From: AKASHI Takahiro To: trini@konsulko.com, agraf@suse.de Date: Mon, 5 Nov 2018 18:06:51 +0900 Message-Id: <20181105090653.7409-13-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 12/14] 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 | 30 ++++++++++++++++++++++++++++++ include/command.h | 3 +++ 4 files changed, 39 insertions(+), 1 deletion(-) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 7580008f691b..3cefb4d0ecaa 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -509,7 +509,7 @@ exit: return ret; } -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..e4ec35b5eb00 100644 --- a/common/cli.c +++ b/common/cli.c @@ -14,6 +14,7 @@ #include #include #include +#include "../cmd/efishell.h" DECLARE_GLOBAL_DATA_PTR; @@ -125,6 +126,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 5b1577f3b477..5bb675122cce 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