arrfab / rpms / shim

Forked from rpms/shim 5 years ago
Clone

Blame SOURCES/0028-fallback-Try-to-boot-the-first-boot-option-anyway.patch

e97c83
From 0ba09477afac58ef2eadc7311440e695e6250029 Mon Sep 17 00:00:00 2001
e97c83
From: Gary Ching-Pang Lin <glin@suse.com>
e97c83
Date: Wed, 5 Mar 2014 18:14:09 +0800
e97c83
Subject: [PATCH 28/74] [fallback] Try to boot the first boot option anyway
e97c83
e97c83
Some UEFI implementations never care the boot options, so the
e97c83
restored boot options could be just ignored and this results in
e97c83
endless reboot. To avoid this situation, this commit makes
e97c83
fallback.efi to load the first matched boot option even if there
e97c83
is no boot option to be restored. It may not be perfect, but at
e97c83
least the bootloader is loaded...
e97c83
e97c83
Signed-off-by: Gary Ching-Pang Lin <glin@suse.com>
e97c83
---
e97c83
 fallback.c | 13 ++++++++++---
e97c83
 1 file changed, 10 insertions(+), 3 deletions(-)
e97c83
e97c83
diff --git a/fallback.c b/fallback.c
e97c83
index 7f242e1..d10fb62 100644
e97c83
--- a/fallback.c
e97c83
+++ b/fallback.c
e97c83
@@ -226,8 +226,9 @@ add_boot_option(EFI_DEVICE_PATH *hddp, EFI_DEVICE_PATH *fulldp,
e97c83
 }
e97c83
 
e97c83
 EFI_STATUS
e97c83
-find_boot_option(EFI_DEVICE_PATH *dp, CHAR16 *filename, CHAR16 *label,
e97c83
-		CHAR16 *arguments, UINT16 *optnum)
e97c83
+find_boot_option(EFI_DEVICE_PATH *dp, EFI_DEVICE_PATH *fulldp,
e97c83
+                 CHAR16 *filename, CHAR16 *label, CHAR16 *arguments,
e97c83
+                 UINT16 *optnum)
e97c83
 {
e97c83
 	unsigned int size = sizeof(UINT32) + sizeof (UINT16) +
e97c83
 		StrLen(label)*2 + 2 + DevicePathSize(dp) +
e97c83
@@ -278,6 +279,12 @@ find_boot_option(EFI_DEVICE_PATH *dp, CHAR16 *filename, CHAR16 *label,
e97c83
 			continue;
e97c83
 
e97c83
 		/* at this point, we have duplicate data. */
e97c83
+		if (!first_new_option) {
e97c83
+			first_new_option = DuplicateDevicePath(fulldp);
e97c83
+			first_new_option_args = arguments;
e97c83
+			first_new_option_size = StrLen(arguments) * sizeof (CHAR16);
e97c83
+		}
e97c83
+
e97c83
 		*optnum = i;
e97c83
 		FreePool(candidate);
e97c83
 		FreePool(data);
e97c83
@@ -403,7 +410,7 @@ add_to_boot_list(EFI_FILE_HANDLE fh, CHAR16 *dirname, CHAR16 *filename, CHAR16 *
e97c83
 #endif
e97c83
 
e97c83
 	UINT16 option;
e97c83
-	rc = find_boot_option(dp, fullpath, label, arguments, &option);
e97c83
+	rc = find_boot_option(dp, full_device_path, fullpath, label, arguments, &option);
e97c83
 	if (EFI_ERROR(rc)) {
e97c83
 		add_boot_option(dp, full_device_path, fullpath, label, arguments);
e97c83
 	} else if (option != 0) {
e97c83
-- 
e97c83
1.9.3
e97c83