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: 1015014 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="FQk5tCl0"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 43Jm7D68xHz9s2P for ; Tue, 18 Dec 2018 16:00:40 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id B4266C22033; Tue, 18 Dec 2018 05:00:17 +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-Google-Smtp-Source: AFSGD/XIHWOgXKN6ev5oRpSpHTcgDU+oDj+KZMBpRnOb3fKzjIaoFRW5FGsvbI+hD5dyxt35bAmw0A== 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 );