summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGary Ching-Pang Lin <glin@suse.com>2014-05-13 13:30:07 -0400
committerPeter Jones <pjones@redhat.com>2014-05-13 13:30:07 -0400
commit8bf83b55dc252cc6b5b83bb0f33cdc8fb68c448b (patch)
tree0b4b566e78de02db9ac4c3083e16d7e7fb5394d0
parent30cead3b403650d320926971b671b4cda3d609e5 (diff)
downloadefi-boot-shim-8bf83b55dc252cc6b5b83bb0f33cdc8fb68c448b.tar.gz
efi-boot-shim-8bf83b55dc252cc6b5b83bb0f33cdc8fb68c448b.zip
[fallback] Try to boot the first boot option anyway
Some UEFI implementations never care the boot options, so the restored boot options could be just ignored and this results in endless reboot. To avoid this situation, this commit makes fallback.efi to load the first matched boot option even if there is no boot option to be restored. It may not be perfect, but at least the bootloader is loaded... Signed-off-by: Gary Ching-Pang Lin <glin@suse.com>
-rw-r--r--fallback.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/fallback.c b/fallback.c
index 7f242e1c..d10fb629 100644
--- a/fallback.c
+++ b/fallback.c
@@ -226,8 +226,9 @@ add_boot_option(EFI_DEVICE_PATH *hddp, EFI_DEVICE_PATH *fulldp,
}
EFI_STATUS
-find_boot_option(EFI_DEVICE_PATH *dp, CHAR16 *filename, CHAR16 *label,
- CHAR16 *arguments, UINT16 *optnum)
+find_boot_option(EFI_DEVICE_PATH *dp, EFI_DEVICE_PATH *fulldp,
+ CHAR16 *filename, CHAR16 *label, CHAR16 *arguments,
+ UINT16 *optnum)
{
unsigned int size = sizeof(UINT32) + sizeof (UINT16) +
StrLen(label)*2 + 2 + DevicePathSize(dp) +
@@ -278,6 +279,12 @@ find_boot_option(EFI_DEVICE_PATH *dp, CHAR16 *filename, CHAR16 *label,
continue;
/* at this point, we have duplicate data. */
+ if (!first_new_option) {
+ first_new_option = DuplicateDevicePath(fulldp);
+ first_new_option_args = arguments;
+ first_new_option_size = StrLen(arguments) * sizeof (CHAR16);
+ }
+
*optnum = i;
FreePool(candidate);
FreePool(data);
@@ -403,7 +410,7 @@ add_to_boot_list(EFI_FILE_HANDLE fh, CHAR16 *dirname, CHAR16 *filename, CHAR16 *
#endif
UINT16 option;
- rc = find_boot_option(dp, fullpath, label, arguments, &option);
+ rc = find_boot_option(dp, full_device_path, fullpath, label, arguments, &option);
if (EFI_ERROR(rc)) {
add_boot_option(dp, full_device_path, fullpath, label, arguments);
} else if (option != 0) {