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: 992953 X-Patchwork-Delegate: agraf@suse.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="F6vk4wyu"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 42pRmy3B2Wz9sB5 for ; Mon, 5 Nov 2018 20:13:38 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 20F96C225FE; 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-Google-Smtp-Source: AJdET5fuuUFh+hhGoCZP7tC2SNnwcODmJ/9rh/k/W/1dffLGHbL3CGp2X4ipf4Uray2NdbQb+ZnkRw== 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