From patchwork Tue Dec 18 05:02:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 154054 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3276824ljp; Mon, 17 Dec 2018 21:00:36 -0800 (PST) X-Google-Smtp-Source: AFSGD/W7BmuShwjPSf7bFhy67O4cyh1EqtfAh6kt8ZqD9M6XFSY29kDT1PAhS5e/COC5cV4cgpaA X-Received: by 2002:a50:d94a:: with SMTP id u10mr15021265edj.214.1545109236139; Mon, 17 Dec 2018 21:00:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545109236; cv=none; d=google.com; s=arc-20160816; b=S46hxU7qVyet632rixGw1SI8OWwuFYlW6Z+WU9c/umQG/MJDHGZIVBresQh14bh21+ 9qQNQbWKfaIhgz1rox5szBMZ8QL3S5fM3fVkUprwZWfwSZ4nbPLFRpgkkrjpRHqClAem gOpU/aXFJfWJFUL3F3zTghbQobzMjXMtU40Aa3+pngXMc2tcZ3CgWvXxMPEBdBAUbVpY 6wRldtUaO5RubkQ6TQAUB0A+FSPAI3zziH9olEmMnJ8Li3PVTvKX0f6Zs/yf/nXhsg+z ADskdk4egMAnxmQ69i0hc91PS5DSPRegNMGFseD3noSz5s6YC8A1HUDQfGZ2DTcgKUHv uy5g== 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=NtCZ1iKleF216GC1DP28viTiRV7Xh6a9u7HQtH9a0k4=; b=ur9jcAt//aO9uM4fVqyDmQjnpFZc5mhy6lgXhS/ABJ1uKM30SkUap8WAPPxviY1/RR zOrXS5jFyx/FYOr8RCBM1hIGagiM8zPKmyzqpGSfJWZKX/ymJimniNAbfYXCxtUKJ2Nn jNZROb8J8jr4ok/CWttAhnX7VX9jYhZ/H+jVsmPpeDTN0siwBcsok5GIci0dXpTIjAQf D/nb630uPqSMB52E0tW2ojB7finIt8P3oJKrPCqF5KGW8eebIYNeTR3EWk4gtAlx4TK7 Hy1iLWrAZ1ZQJR04H85VFvEIpeqqFXgXtefGyhXWvyFssai7QrvT8l+xvUUfEMXQjqNi o6Ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=FQk5tCl0; 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 x28si92391edm.388.2018.12.17.21.00.35; Mon, 17 Dec 2018 21:00:36 -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=FQk5tCl0; 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 B13B2C21F69; Tue, 18 Dec 2018 05:00:16 +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_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 EFB61C2207C; Tue, 18 Dec 2018 05:00:03 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 3B1A3C21F79; Tue, 18 Dec 2018 04:59:46 +0000 (UTC) Received: from mail-yw1-f67.google.com (mail-yw1-f67.google.com [209.85.161.67]) by lists.denx.de (Postfix) with ESMTPS id B65F3C22018 for ; Tue, 18 Dec 2018 04:59:45 +0000 (UTC) Received: by mail-yw1-f67.google.com with SMTP id n21so5132385ywd.10 for ; Mon, 17 Dec 2018 20:59:45 -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=ii6PV6GSsUlkcoQ/gUiPoKvRBPgajnWaDVaVvqpiorQ=; b=FQk5tCl07FkeAMmQ2nzNE9tBAGawtJUEyQZ4/5XHT1GDQg/6jDwbnL8P0BhUCthCOr ZK4fWufICzcFlpBhQW3YtRaH9qqoL2THSxX+dMe1DNlckGkSDBiF/HRwttjBJq1f3+Ws 86tDOIZml16oWc1HEFId/868rALFYcrTn5weg= 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=ii6PV6GSsUlkcoQ/gUiPoKvRBPgajnWaDVaVvqpiorQ=; b=GHqosFeNyiTcVuEVRenbQoYeNlTU4FpTYFPWtovuytfjjtJBr8dAlScliWMgXTAXtY R0NMexBMAhf8/m7mm+9bZ+yQB9UO2Yv5SCYFVZj99/AonN2D226T1PKHI/JPLMVDLBaq xLyhO9wWVG2YiutouAVZGf1bFeJ/qOfilYz+O7UaCvff9wWEtrGzUFJQg/S0yoEsKSLa hu0456c2XLhXEDNw0mTWWwc7k4OgOeEMo2UcOEBOeHzebvUug1K8E+NuUTMwLCVOG3SV /glWuqyMXI/Z3UIguELkDKV/rh7yxeb0Pw9J0wUKm6Qubffm5VLo755Wvx64JCHcSMFr YReg== X-Gm-Message-State: AA+aEWYgVWkf75o9NELfvDfzn4xswUc0knM0uA1QPGKjzTf3+mF3VL4w 8GnuVxwCZlE0kWbfdDAf7qxJ2g== X-Received: by 2002:a81:5191:: with SMTP id f139mr16169200ywb.132.1545109184689; Mon, 17 Dec 2018 20:59:44 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id z2sm3728183ywe.32.2018.12.17.20.59.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Dec 2018 20:59:44 -0800 (PST) From: AKASHI Takahiro To: trini@konsulko.com, agraf@suse.de, xypron.glpk@gmx.de Date: Tue, 18 Dec 2018 14:02:56 +0900 Message-Id: <20181218050257.20142-5-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 4/5] cmd: bootefi: run an EFI application of a specific load option 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 this patch applied, we will be able to selectively execute an EFI application by specifying a load option, say "1" for Boot0001, "2" for Boot0002 and so on. => bootefi bootmgr 1, or bootefi bootmgr - 1 Please note that BootXXXX need not be included in "BootOrder". Signed-off-by: AKASHI Takahiro --- cmd/bootefi.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 796ca6ee69ec..2fc52e3056d2 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -471,13 +471,13 @@ static efi_status_t bootefi_test_prepare #endif /* CONFIG_CMD_BOOTEFI_SELFTEST */ -static int do_bootefi_bootmgr_exec(void) +static int do_bootefi_bootmgr_exec(int boot_id) { struct efi_device_path *device_path, *file_path; void *addr; efi_status_t r; - addr = efi_bootmgr_load(-1, &device_path, &file_path); + addr = efi_bootmgr_load(boot_id, &device_path, &file_path); if (!addr) return 1; @@ -545,10 +545,22 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } else #endif if (!strcmp(argv[1], "bootmgr")) { - if (efi_handle_fdt(argc > 2 ? argv[2] : NULL)) - return CMD_RET_FAILURE; + char *endp; + int boot_id = -1; + + if (argc > 2) + if (efi_handle_fdt((argv[2][0] == '-') ? + NULL : argv[2])) + return CMD_RET_FAILURE; + + if (argc > 3) { + boot_id = (int)simple_strtoul(argv[3], &endp, 0); + if ((argv[3] + strlen(argv[3]) != endp) || + boot_id > 0xffff) + return CMD_RET_USAGE; + } - return do_bootefi_bootmgr_exec(); + return do_bootefi_bootmgr_exec(boot_id); } else { saddr = argv[1]; @@ -589,7 +601,7 @@ static char bootefi_help_text[] = " Use environment variable efi_selftest to select a single test.\n" " Use 'setenv efi_selftest list' to enumerate all tests.\n" #endif - "bootefi bootmgr [fdt addr]\n" + "bootefi bootmgr [|'-' []]\n" " - load and boot EFI payload based on BootOrder/BootXXXX variables.\n" "\n" " If specified, the device tree located at gets\n" @@ -597,7 +609,7 @@ static char bootefi_help_text[] = #endif U_BOOT_CMD( - bootefi, 3, 0, do_bootefi, + bootefi, 5, 0, do_bootefi, "Boots an EFI payload from memory", bootefi_help_text );