From patchwork Tue Jan 15 02:54:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 155604 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp4385635jaa; Mon, 14 Jan 2019 18:58:27 -0800 (PST) X-Google-Smtp-Source: ALg8bN68NVzS0RvX1jtAuR77XEcmDbOEROyziktaPUwvlRr5gylWylGpb4YcZVK9qxKknfg0A/3Z X-Received: by 2002:a17:906:6c9:: with SMTP id v9-v6mr1426548ejb.203.1547521107477; Mon, 14 Jan 2019 18:58:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547521107; cv=none; d=google.com; s=arc-20160816; b=ammIvqh99Zz+vegGY8HVhLcULEIBJ9UfJOLrL9hMMsryYfXxfQxFjDAMQAWfWMfJbf f5zobM2U4fX7rg0kEy9v+IWCU/ioSRcfH4BmMuFyb9q9Bx1PZI0nWh5AAlrR6m5cnE4U w5eMgDXYd7jy4FSXTQ2RngNoK+u2fEn0Oeb5Cejz3A8uBgWu9Vs4qIKv+GqU476jVb8s FGnrAm0Px/IOSciwfrOxl1unbw5KcqzynXhRrMCl23SJCN6SvYkRjvwOBBGcv4Luk4cL KVQb9PdnNcNat/CrKT0oFsR6SHOhXEbRxug9WdMuzTj4a60e8ZbbEL0nbXDX2IzT5fKC syyQ== 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=1GBkO8GeNyiLvWqg3I7AUF+ohddQNg75FPoqFz4+0zA=; b=lAov8YWInJR+7uF1A2xLXTVn5IM1ZeE2TV32ztRMDQ/Ad4QWCOoNPE3v/3mBA0Tta1 7H/HYGvpJ0ZU6y34KcEqmyapx+qQSHTMu3nVsGmhOVvwrF84nzrnReBTJfioRJwIq5Wq 1jaqtIkcOC1vRomUFqkj1Of/qe1YrcS8dw/Z9P8jQjOU8uTOo5z1HIfzJIZ+CF1DVmjU Li5Lx7o6Zyd66IrZrErcfKwGhccBguGi3HEdKEKqQ+TWl9/38AQrdAhCrekhjTgvyNLm +gl5bl5h68aKv9OOkjqPbT2e3g+w+K9ja7kuHruDHuNzWhC3Z7RAXHFwLABoHtVnsF7f k9pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b="a2/ZboNu"; 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 h11si655001edw.441.2019.01.14.18.58.27; Mon, 14 Jan 2019 18:58:27 -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="a2/ZboNu"; 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 216BFC21FBF; Tue, 15 Jan 2019 02:56:12 +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 F027EC21F1D; Tue, 15 Jan 2019 02:55:11 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id AFFFCC21FCD; Tue, 15 Jan 2019 02:54:54 +0000 (UTC) Received: from mail-yb1-f196.google.com (mail-yb1-f196.google.com [209.85.219.196]) by lists.denx.de (Postfix) with ESMTPS id D8D4BC21FF8 for ; Tue, 15 Jan 2019 02:54:50 +0000 (UTC) Received: by mail-yb1-f196.google.com with SMTP id t16so482682ybk.10 for ; Mon, 14 Jan 2019 18:54:50 -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=Rhon+GzxhdTNEKSMVmVxmmCG9oYuqPgybpgeh0Kbnk4=; b=a2/ZboNuocFvZB1bkSbq1L9KSpYHGGbIp3W3GqTnHp3Ow5IMvHLkBo+qdfV4WxHVWp 8hiXC4s2ArXOrro2LmS7uuo3BDXYadOyABh2LsOcrnzIrra8kb9O/d2zkAVYEQGYSrtm BVHIvsnXbtr3CUc7/ZNmSmNC25NDXyvsYLgBQ= 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=Rhon+GzxhdTNEKSMVmVxmmCG9oYuqPgybpgeh0Kbnk4=; b=JGLxQ9TFsb5KQCp7xS7233eaLR9DM+lrEBVIpeVDuJGEc1EMzBHPB3kzE8EulP/PAn IGeGtxrdLFllz0v1Y4VFDo9usiMX+AxiR/aYbPfPqlF0Wt5CyqioOxJEoTaPYtjVSwlM 2SM9j7CY4O1Y+MWc3bYBWyrk6xBtTls+7KM9lLiijEv+u7lbcK6mj2rJTQhsc+U597UB 2S+nGhk0l6kY0nEIX4zZqVLLomRxIs9behRXOz+XTgXIfmUfi2DGXxyQRMCKEXtV4hAP ELvackuM3+wKc4hxiYCZhVbehcPfSz5Yc0bCLgE3RfvPW+8TlGdPpOdT5a+jhkQuuB2s a7Xw== X-Gm-Message-State: AJcUukeVbKwK3q8IyWQerWg6FtSljNIzFW+nbv9GVNrFt30ehEqWFqvW JWhEEQztpAVmiHNnJmtUdRbfNqipEik= X-Received: by 2002:a5b:902:: with SMTP id a2mr1196421ybq.445.1547520889845; Mon, 14 Jan 2019 18:54:49 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id e124sm741929ywf.17.2019.01.14.18.54.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Jan 2019 18:54:49 -0800 (PST) From: AKASHI Takahiro To: trini@konsulko.com, agraf@suse.de, xypron.glpk@gmx.de Date: Tue, 15 Jan 2019 11:54:37 +0900 Message-Id: <20190115025437.11966-6-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190115025437.11966-1-takahiro.akashi@linaro.org> References: <20190115025437.11966-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH v2 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 | 31 +++++++++++++++++++++++++++++++ cmd/nvedit.c | 9 ++++++++- common/cli.c | 10 ++++++++++ include/command.h | 3 +++ 4 files changed, 52 insertions(+), 1 deletion(-) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 241fd0f987ab..ebe149dffa1f 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -492,6 +492,37 @@ static int do_bootefi_bootmgr_exec(int boot_id) return CMD_RET_SUCCESS; } +/* Called by "run" command */ +int do_bootefi_run(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +{ + int boot_id = -1; + char *endp; + + if (argc > 2) + return CMD_RET_USAGE; + + if (argc == 2) { + if (!strcmp(argv[1], "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); +} + /* Interpreter command to boot an arbitrary EFI image from memory */ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { diff --git a/cmd/nvedit.c b/cmd/nvedit.c index de16c72c23f2..ce746bbf1b3e 100644 --- a/cmd/nvedit.c +++ b/cmd/nvedit.c @@ -1344,7 +1344,14 @@ U_BOOT_CMD_COMPLETE( run, CONFIG_SYS_MAXARGS, 1, do_run, "run commands in an environment variable", "var [...]\n" - " - run the commands in the environment variable(s) 'var'", + " - run the commands in the environment variable(s) 'var'" +#if defined(CONFIG_CMD_BOOTEFI) + "\n" + "run -e [BootXXXX]\n" + " - load and run UEFI app based on 'BootXXXX' UEFI variable", +#else + , +#endif var_complete ); #endif diff --git a/common/cli.c b/common/cli.c index 51b8d5f85cbb..fbb09d5049a4 100644 --- a/common/cli.c +++ b/common/cli.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -125,6 +126,15 @@ 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")) { + argc--; + argv++; + + return do_bootefi_run(cmdtp, flag, argc, argv); + } +#endif + for (i = 1; i < argc; ++i) { char *arg; diff --git a/include/command.h b/include/command.h index 200c7a5e9f4e..feddef300ccc 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) +extern int do_bootefi_run(cmd_tbl_t *cmdtp, int flag, 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