[U-Boot] [PATCH v2 2/5] efi_loader: bootmgr: allow for running a given load option

AKASHI Takahiro takahiro.akashi at linaro.org
Tue Jan 15 02:54:34 UTC 2019


With an extra argument, efi_bootmgr_load() can now load an efi binary
based on a "BootXXXX" variable specified.

Signed-off-by: AKASHI Takahiro <takahiro.akashi at linaro.org>
---
 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",
-- 
2.19.1



More information about the U-Boot mailing list