From patchwork Wed Oct 17 07:32:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 149026 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp321263lji; Wed, 17 Oct 2018 00:34:08 -0700 (PDT) X-Google-Smtp-Source: ACcGV638KKYRCmGKt+o+RiJDC4aWZOd6tU8voTyMW8retL9Mvo9I0CYA+73ci00ffF/HUVj0vgQM X-Received: by 2002:a50:998a:: with SMTP id m10-v6mr34910229edb.7.1539761648815; Wed, 17 Oct 2018 00:34:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539761648; cv=none; d=google.com; s=arc-20160816; b=llweOmX2lQK8xK2h/JfBI75CKb1Xtd29zCi5axrt1/8IE1TcQ+aO9FNq80j66WCbjN PQBbrBUeDiTZYeim6f733GkWWg0n9yE9Qe8J53qU/2ozSXC9TZUN/PEtC5cwg6f6A0go zseELwv5C/KPI2K22KSPczl3+JS+k+e25lH0R4LDsXcB33geIp/tG4imiwiAqz5skwCs TafuhEJKj4WgvlQvD2Y4okIfJOelcYPJMALiLIGYNbjpmAu02kJzX6rLR1qO0S6UiVma ItDjxAWq40Ii1VA4L08QZvD7uxxw+utWPO7yamBvA9NAoNv957jepFMyQhxjU45Dgp1g zOQw== 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=0V0iGNKeyOu4mWfJIJBtt1LiTq4tYwYiO+a4gflzqEc=; b=mR6kum7D8VaocAxkRo5A0ITXcWPriGZPgpITTUlWo+rK8uUPJW8jKB5iq92Dpi+Tnw zZc7gxrM4tjAqw9DUUUYSz6xi7r4mcFmlZfPec98KqVHyDsbi56nuRay+rAwWdjfhSy2 2y9zQdb44EcXTN5oHbWxERy1Sj+IYUeR64Ep1pLv6gutA+ApnfpEKkSTiPGxX1Fqi/+6 XX1Uk/WkMRQM9016h9m47xezYHvHHhgqBrIJPc7bdTSzm9VGDtSBWh52DTcKuGIamM+1 Yqsp0U7QKLoC0+w/F706MJAXckAfyOVOyPhuuldcAv1FwA4s+QXGQqYIvZc4Jg4qZUzQ sHbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=ggjQYgmD; 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 d10-v6si4877512edh.283.2018.10.17.00.34.08; Wed, 17 Oct 2018 00:34:08 -0700 (PDT) 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=ggjQYgmD; 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 6FEB3C21E12; Wed, 17 Oct 2018 07:32:51 +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 5470FC21D9A; Wed, 17 Oct 2018 07:31:24 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id AE513C21E02; Wed, 17 Oct 2018 07:31:02 +0000 (UTC) Received: from mail-yw1-f68.google.com (mail-yw1-f68.google.com [209.85.161.68]) by lists.denx.de (Postfix) with ESMTPS id 391E5C21C27 for ; Wed, 17 Oct 2018 07:30:58 +0000 (UTC) Received: by mail-yw1-f68.google.com with SMTP id e201-v6so9956275ywa.3 for ; Wed, 17 Oct 2018 00:30:58 -0700 (PDT) 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=yiQgSTH3HjjOpEed+WR5pS0CwTLvCKWA1pE/hssBeN8=; b=ggjQYgmDz031PlbsnZ+kQbHuYYVrCpvOZkA3/7USWtphzEOoTSYIUCvRAzzbKaNtpd AjPD6sEt6HZEj62j0fddLKt8L1ajkIn8Dl5ONpxJYgYH9Vm7JsOfNxFRcCTMuEPWLy3R X7dQoum4yzDNd9+rqrBI2ASFzj6Xt3/oTILac= 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=yiQgSTH3HjjOpEed+WR5pS0CwTLvCKWA1pE/hssBeN8=; b=APSzMb1OoD95egqJETbY2LLKx+AYILoM/hOAqggsseNHEBDL+4DJLHjlHpwKdYJFrT swCSQhmctRO51DIHRWn9xSbGw1vYbmaPl3A94WBjjYd566f4v4adGz4RPuF0H9McWITc or9UUO4epEviY/g3r/qKbyA5pzWLB5oaJL7IS37rQnb4Bs9jEOfmiSvrwBof3Mh0djr+ KOSYAJ0A5atGY5Sl+vDx6SLPdYlwJErmqDpKMcf1TWPfXWEbwoKdPmLQd/v/9T3E5YQ6 kLLyZcpxwPDqGMez0+6dBP2WfC/tX1XFQGA9aPZXZbXxvUtrN952HZFsMZinZibhOP7a we+Q== X-Gm-Message-State: ABuFfojtv29pcvcQF+oCETZw/MeS3vODNdjPJKLSbwJK/Uo/v9WEwZ1w wnPhBFhm4T3fdJ+RVPGdw0GkXg== X-Received: by 2002:a0d:d695:: with SMTP id y143-v6mr13440724ywd.132.1539761457083; Wed, 17 Oct 2018 00:30:57 -0700 (PDT) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id p185-v6sm4891591ywc.14.2018.10.17.00.30.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Oct 2018 00:30:56 -0700 (PDT) From: AKASHI Takahiro To: trini@konsulko.com, agraf@suse.de Date: Wed, 17 Oct 2018 16:32:07 +0900 Message-Id: <20181017073207.13150-7-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181017073207.13150-1-takahiro.akashi@linaro.org> References: <20181017073207.13150-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH 6/6] efi_loader: bootmgr: run an EFI application of a given 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 Please note that BootXXXX need not be included in "BootOrder". Signed-off-by: AKASHI Takahiro --- cmd/bootefi.c | 19 ++++++++++++++++--- include/efi_loader.h | 3 ++- lib/efi_loader/efi_bootmgr.c | 8 +++++++- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 5772f7422e5f..434a6a07c26a 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -508,7 +508,7 @@ exit: return ret; } -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; @@ -520,7 +520,7 @@ static int do_bootefi_bootmgr_exec(void) */ efi_save_gd(); - addr = efi_bootmgr_load(&device_path, &file_path); + addr = efi_bootmgr_load(boot_id, &device_path, &file_path); if (!addr) return 1; @@ -605,6 +605,19 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } else #endif if (!strcmp(argv[1], "bootmgr")) { + char *endp; + int boot_id = -1; + + if ((argc > 2) && (argv[2][0] == '-')) { + boot_id = (int)simple_strtoul(&argv[2][1], &endp, 0); + if ((argv[2] + strlen(argv[2]) != endp) || + (boot_id > 0xffff)) + return CMD_RET_USAGE; + + argc--; + argv++; + } + if (efi_handle_fdt(argc > 2 ? argv[2] : NULL)) return CMD_RET_FAILURE; @@ -649,7 +662,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 [-XXXX] [fdt addr]\n" " - load and boot EFI payload based on BootOrder/BootXXXX variables.\n" "\n" " If specified, the device tree located at gets\n" diff --git a/include/efi_loader.h b/include/efi_loader.h index 1cabb1680d20..5804c2b5015d 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -527,7 +527,8 @@ void efi_parse_load_option(struct load_option *lo, void *ptr); unsigned long efi_marshal_load_option(u32 attr, u16 *label, struct efi_device_path *file_path, char *option, void **data); -void *efi_bootmgr_load(struct efi_device_path **device_path, +void *efi_bootmgr_load(int boot_id, + struct efi_device_path **device_path, struct efi_device_path **file_path); #else /* CONFIG_IS_ENABLED(EFI_LOADER) */ diff --git a/lib/efi_loader/efi_bootmgr.c b/lib/efi_loader/efi_bootmgr.c index c2d29f956065..348f99a9ca25 100644 --- a/lib/efi_loader/efi_bootmgr.c +++ b/lib/efi_loader/efi_bootmgr.c @@ -165,7 +165,8 @@ error: * available load-options, finding and returning the first one that can * be loaded successfully. */ -void *efi_bootmgr_load(struct efi_device_path **device_path, +void *efi_bootmgr_load(int boot_id, + struct efi_device_path **device_path, struct efi_device_path **file_path) { uint16_t *bootorder; @@ -178,6 +179,11 @@ void *efi_bootmgr_load(struct efi_device_path **device_path, bs = systab.boottime; rs = systab.runtime; + if (boot_id != -1) { + image = try_load_entry(boot_id, device_path, file_path); + goto error; + } + bootorder = get_var(L"BootOrder", &efi_global_variable_guid, &size); if (!bootorder) goto error;