From patchwork Tue Jan 15 02:54:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 155602 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp4384759jaa; Mon, 14 Jan 2019 18:57:08 -0800 (PST) X-Google-Smtp-Source: ALg8bN5mJfsTg0OmZkyWlM6HjzqAfdEt/A3weePsId3vHjARpdHb/tiYgOqutmPTZG/81r1VGKkc X-Received: by 2002:a50:f098:: with SMTP id v24mr1631036edl.78.1547521027919; Mon, 14 Jan 2019 18:57:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547521027; cv=none; d=google.com; s=arc-20160816; b=LtPKetzHnCMsJ6EfPYt8ylEi19gaDJkdKMKJkivrUTsGmVUeghRIojQo9/v77dmeS2 xNtwgvEhqnajOjFSV0tfMWo3Btm8T5LNERnju5QzOHsD14jysR+mmyHE1nwmuAMbQRb5 61shYIcgFnVdvBMNm4tqpYAYu6MEenE7upX2RY+9sjUl3Jwx8MLHVHEtOKECEZE9U6PQ 7KaUq7o/932Uly8n7sRW4Otr2DGzSKnV8asT4NBbfYw7bEpsqu3skb5tDZbmpt/hk2Rm a7ARnphqecPxEZwOSWlEhItgnSck7x4jrpqP0m49I7ua4BOJPNjkVa/EwMzMGBNXvHu+ eiqQ== 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=DH18k20lmo8ZgwNMpXaeN//aY/CTSXckRubaKOvl2Ck=; b=l1cRCE5KgySz5d5onXmVsgCXZEoKxnHnncCKgJhT68y/5CWDpuSAMJJ/+MhMN+G7PC 23Huz6MNAIyq7gnPP2eCnk//obum5tOc2dh5XY7iKLcPOGcr0L0lGR+njmGZhLDjhC9k SU37Yq3T/O0izMFjU8jwK0yxCa74ToqA/OMHga4lJcQORVJSVTiWCQk/Pq+Y3BN7xcbE M+R0z2sAUYy0AW2raV92O9g3SR8p4Z0S6dGFqi/XxEUoBbEli0OjD+qCtADv1behClJ5 SYHHAfEh1h9mtk2ebfynAPRxxD92MGzwhPzZTOVOZZ2sspQ4Ql577lTFxvvyHazjpnRg sMTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=B5CGUK5Z; 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 v3-v6si2979937eji.60.2019.01.14.18.57.07; Mon, 14 Jan 2019 18:57:07 -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=B5CGUK5Z; 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 750A0C21D83; Tue, 15 Jan 2019 02:55:21 +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 0CFDBC2201B; Tue, 15 Jan 2019 02:54:45 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id DAD97C21DFA; Tue, 15 Jan 2019 02:54:41 +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 3286CC21FEC for ; Tue, 15 Jan 2019 02:54:41 +0000 (UTC) Received: by mail-yb1-f196.google.com with SMTP id j10so488964ybj.8 for ; Mon, 14 Jan 2019 18:54:41 -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=5iUS6AFXp88aTCdpbWjC63MtSviEpXMCIXRUWW+FVvw=; b=B5CGUK5ZtYseIWEUCGx83HEd3PVJ65fNY1UBri1D/2OafvB6SUmU4tzfwPPV+iyHRu zQb2DMHvZejFUQsQ4w4Sc8GpjqXZJ4ev2YQg6CkgBn2crwnX7Axufr+w+dej1XxCLne/ z+Uxa0zOPRT/HIFzHBK+w7jmrOyKLZXbeGfU4= 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=5iUS6AFXp88aTCdpbWjC63MtSviEpXMCIXRUWW+FVvw=; b=tSCWZwk4BAhCRc1mPC15SKbTbSuqYUvL4ojQzlxsw5n5wFbIAkGickjT8eLaolpC6J Wq53bB/PixF16DW2z5yxcOlhf57MmD9rPDrZ+Z+M9zlDZU8NpPF/eGlMN4eaMCTPhjFM y93c8qTfIyuOKDIWKHrt5lRYaX7WzQ71tIj7aAdrNO82wyrACzDbkBcuC4pZlJxQryZk 72+mhGrTEPIua3AW4eXoSFGxJIeyuEQTz4wmwPLpCXTvkO8xJAfLsRs/DYAZjhYl+rr/ hFGhop7zodkEKzqFKL4rqfO0Df+arpDxy1HZPD2dlL8HicFMaAAK7zJIUeSxM9XjTXoG mPNA== X-Gm-Message-State: AJcUukdv+DlMd6UTx+sQIpqw1lONLMZAdtHCyByry5rqsQPvADWuOWgH s6EpjsQZBuwk3LjKJtsgr1Uf5A== X-Received: by 2002:a25:9749:: with SMTP id h9mr1211279ybo.219.1547520880157; Mon, 14 Jan 2019 18:54:40 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id q24sm779819ywa.95.2019.01.14.18.54.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Jan 2019 18:54:39 -0800 (PST) From: AKASHI Takahiro To: trini@konsulko.com, agraf@suse.de, xypron.glpk@gmx.de Date: Tue, 15 Jan 2019 11:54:34 +0900 Message-Id: <20190115025437.11966-3-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 2/5] efi_loader: bootmgr: allow for running 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 an extra argument, efi_bootmgr_load() can now load an efi binary based on a "BootXXXX" variable specified. Signed-off-by: AKASHI Takahiro --- cmd/bootefi.c | 3 ++- include/efi_loader.h | 5 ++++- lib/efi_loader/efi_bootmgr.c | 9 ++++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 7012d72ab50d..76171ab679c3 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -452,7 +452,8 @@ static int do_bootefi_bootmgr_exec(void) void *addr; efi_status_t r; - addr = efi_bootmgr_load(&device_path, &file_path); + addr = efi_bootmgr_load(EFI_BOOTMGR_DEFAULT_ORDER, + &device_path, &file_path); if (!addr) return 1; diff --git a/include/efi_loader.h b/include/efi_loader.h index dd68cfce5c65..3077a1e9d58b 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -549,9 +549,12 @@ struct efi_load_option { u8 *optional_data; }; +#define EFI_BOOTMGR_DEFAULT_ORDER (-1) + void efi_deserialize_load_option(struct efi_load_option *lo, u8 *data); unsigned long efi_serialize_load_option(struct efi_load_option *lo, u8 **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 6c5303736dc6..7ce51de4dfb0 100644 --- a/lib/efi_loader/efi_bootmgr.c +++ b/lib/efi_loader/efi_bootmgr.c @@ -180,7 +180,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) { u16 bootnext, *bootorder; @@ -194,6 +195,12 @@ void *efi_bootmgr_load(struct efi_device_path **device_path, bs = systab.boottime; rs = systab.runtime; + /* specified boot option */ + if (boot_id != -1) { + image = try_load_entry(boot_id, device_path, file_path); + goto error; + } + /* get BootNext */ size = sizeof(bootnext); ret = rs->get_variable(L"BootNext",