From patchwork Tue Jan 15 02:54:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 155601 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp4384082jaa; Mon, 14 Jan 2019 18:56:13 -0800 (PST) X-Google-Smtp-Source: ALg8bN77fQggxwBm9AkhDvqgtwnUgyLcsYFiSc+E3oMownvHTJPWHcE8Uo6PgkEvfhp5yTX2m93q X-Received: by 2002:a50:b0a4:: with SMTP id j33mr1484199edd.267.1547520973050; Mon, 14 Jan 2019 18:56:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547520973; cv=none; d=google.com; s=arc-20160816; b=PvkaDPzqv7ZDBDYPlVyoAbOTR8MvLZo/rvQnyiYJ9jw+a05AE1VWJ8opKEHNgUu2e+ m5VF9liPDPQ8O4eJYSCd7t7CEluXFVm2aFczp9c1FHMw0kZIzEqi8xhI6g1GURD6T5kC V4xrY3Z5D9qvHi3szdD3X30mreExduZzqo2dr0bBwXO8uhI1K2lIyR/cAbRHTT+K43hd rovXk5jbW/Usyg4EKKekYfMaMcrdsjJWLNDgc3t9iUEPemME/QIAXcB6ldAl8lGguJ3X okEibUc3NkOGRLR96LDHVGvYXo5Kdzhwde0jM2aE/xBYimB6A0HsIgo6+i7pcW4ghuf1 FjJg== 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=9zYMLxS7Fdcso1zLn2iHKovAn0NbmyecfedMeky1RDg=; b=V7/LKyrZldyVzf+QwlbW8SUZ8mT8CP6MMqNj4pE7j8K5QXFgL6iRy3Vr0U5C3UIBps VTuJ6frcFaN2ywl4Zr6QAIjN4JWae1gr3AGbV1lfHd9In6YI4+/XvzhcEFzVsA+rCpYf SntHpEz9OV6Fw/Ro5dT5fwdcF0TxRViMB4PSxC2XmJnEE5102hwqSBVbsqyr5hRC8heZ a+x5OtVsWt2L9R/SqiMk2tj3LQXhgeR73PTM1+1TnOEZoPUNoya4rruJLfHx8pKdgARY nuXXtsiMNeh3MZWi9Ti480FHtrOfm+jpAhaE8eGSwFIRWNR9SfsEywuzMB7LkGC4V7LF g/Qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=fUygd3xq; 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 u23si5611142edo.113.2019.01.14.18.56.12; Mon, 14 Jan 2019 18:56:13 -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=fUygd3xq; 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 A2FBCC21F17; Tue, 15 Jan 2019 02:55:37 +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 E173EC2204C; Tue, 15 Jan 2019 02:55:02 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id C4F59C21F88; Tue, 15 Jan 2019 02:54:51 +0000 (UTC) Received: from mail-yb1-f193.google.com (mail-yb1-f193.google.com [209.85.219.193]) by lists.denx.de (Postfix) with ESMTPS id 94934C2214B for ; Tue, 15 Jan 2019 02:54:47 +0000 (UTC) Received: by mail-yb1-f193.google.com with SMTP id 2so501649ybw.4 for ; Mon, 14 Jan 2019 18:54:47 -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=BK+n1M5VyKZVxMJg2AvLpZXnr3paTYK4PauaqJk5rGw=; b=fUygd3xq8DjesWpmkTdOG7kOM0F2JCpz1XYM84Al+xVZYhZyUyvSjPsscq1+0ucoaI ZNU8omIVa+dElw2QiIN7AYuWx8G88wv9l4bTgzkmKxf6wMV3m/R7sOof9UlkB2U//OBx 7+y/8c9dHkihe4TTRqj/EbSHr8tLMmyiqvqW8= 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=BK+n1M5VyKZVxMJg2AvLpZXnr3paTYK4PauaqJk5rGw=; b=We1GFbQOIlHHbFvnZHD11RcPlF2N3Dg876Mok6jHBP8EksBtsg5vI0Xk2tzvbdyFfW WZ0OE5bZD4rFahxnKaxnKHXFPCd6ZmYI1Qob6+E/8QxqxTdEQMjlf72HevWwaqxP5COj U13IhE7Oahhm32hn7u/GpcGftWTEc2BzNZB6Vd9vW/4lLMTwIevz33enJYutY3OVMx4Y F0vYT37GEuRZYTWkvtqpsBo3MDAzUH7zArd/xPyShx6/skNEWuNQXw/L3uSyLDjepYGN u38vSiTrOZnJmgjX3miLdl/W05TBUS8jO6oMAJ+w3ar6XVmY5l68VgTumWUdSI/JX8Gt CCug== X-Gm-Message-State: AJcUukejgSBOFU8dF8PI6cCWQ/e1VmwmPz/C4fqUlXt9EQdP/GjaqlNi Grx230MHKuRbwCMC8WYalvLssQ== X-Received: by 2002:a25:57c6:: with SMTP id l189mr1257300ybb.130.1547520886556; Mon, 14 Jan 2019 18:54:46 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id y16sm719166ywg.35.2019.01.14.18.54.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Jan 2019 18:54:46 -0800 (PST) From: AKASHI Takahiro To: trini@konsulko.com, agraf@suse.de, xypron.glpk@gmx.de Date: Tue, 15 Jan 2019 11:54:36 +0900 Message-Id: <20190115025437.11966-5-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 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 | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 3be01b49b589..241fd0f987ab 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -471,16 +471,15 @@ 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(EFI_BOOTMGR_DEFAULT_ORDER, - &device_path, &file_path); + addr = efi_bootmgr_load(boot_id, &device_path, &file_path); if (!addr) - return 1; + return CMD_RET_FAILURE; printf("## Starting EFI application at %p ...\n", addr); r = do_bootefi_exec(addr, device_path, file_path); @@ -488,9 +487,9 @@ static int do_bootefi_bootmgr_exec(void) r & ~EFI_ERROR_MASK); if (r != EFI_SUCCESS) - return 1; + return CMD_RET_FAILURE; - return 0; + return CMD_RET_SUCCESS; } /* Interpreter command to boot an arbitrary EFI image from memory */ @@ -546,10 +545,28 @@ 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 *fdtstr, *endp; + int boot_id = EFI_BOOTMGR_DEFAULT_ORDER; + + if (argc > 2) { + fdtstr = argv[2]; + /* Special address "-" means no device tree */ + if (fdtstr[0] == '-') + fdtstr = NULL; + + r = efi_handle_fdt(fdtstr); + if (r) + 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]; @@ -590,7 +607,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" @@ -598,7 +615,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 );