mirror of
https://git.proxmox.com/git/efi-boot-shim
synced 2025-08-02 20:40:06 +00:00
fallback.c: be more correct with device path code.
Rob Clark noticed while, implementing a UEFI like backend on u-boot, that if a File Handle actually returns a meaningful device path from DevicePathFromHandle(), we wind up with a horribly wrong device path in the boot variable. He's right, normal UEFI doesn't return that, which means FileDevicePath() in our code currently does nothing at all. Instead of all that, pass in the device's handle, and it'll do what we're doing after the fact there. Here's the log from a current run: FS0:\> \efi\BOOT\BOOTX64.EFI System BootOrder not found. Initializing defaults. find_boot_options:778:Found directory named "fedora" try_boot_csv:532:Found file "\EFI\fedora\BOOT.CSV" try_boot_csv:544:File looks like: ?shim.efi,Fedora,,This is the boot entry for Fedora populate_stanza:495:CSV data: "shim.efi,Fedora,,This is the boot entry for Fedora" populate_stanza:501:filename: "shim.efi" populate_stanza:508:label: "Fedora" populate_stanza:514:arguments: "" add_to_boot_list:430:file DP: PciRoot(0)/Pci(0x1F,0x2)/Sata(0x0,0x0,0x0)/HD(Part1,Sig6584272A-D7B9-442A-B8A4-19B5EC4566F4)/\EFI\fedora\shim.efi FindSubDevicePath:78:input device path: "PciRoot(0)/Pci(0x1F,0x2)/Sata(0x0,0x0,0x0)/HD(Part1,Sig6584272A-D7B9-442A-B8A4-19B5EC4566F4)/\EFI\fedora\shim.efi" FindSubDevicePath:86:sub-path (4,1): "HD(Part1,Sig6584272A-D7B9-442A-B8A4-19B5EC4566F4)/\EFI\fedora\shim.efi" add_to_boot_list:452:04 01 2A 00 01 00 00 00 00 08 00 00 00 00 00 00 add_to_boot_list:452:00 40 06 00 00 00 00 00 2A 27 84 65 B9 D7 2A 44 add_to_boot_list:452:B8 A4 19 B5 EC 45 66 F4 02 02 04 04 2E 00 5C 00 add_to_boot_list:452:45 00 46 00 49 00 5C 00 66 00 65 00 64 00 6F 00 add_to_boot_list:452:72 00 61 00 5C 00 73 00 68 00 69 00 6D 00 2E 00 add_to_boot_list:452:65 00 66 00 69 00 00 00 7F FF 04 00 add_to_boot_list:459:device path: "HD(Part1,Sig6584272A-D7B9-442A-B8A4-19B5EC4566F4)/\EFI\fedora\shim.efi" Creating boot entry "Boot0000" with label "Fedora" for file "\EFI\fedora\shim.efi" AddOption - Boot0000, then CurrentCount = 0x00000008 update_boot_order:390:nbootorder: 7 BootOrder: 0000 0002 0001 0003 0005 0006 0004 Signed-off-by: Peter Jones <pjones@redhat.com>
This commit is contained in:
parent
c0f7d13074
commit
a8f3dc82be
26
fallback.c
26
fallback.c
@ -407,7 +407,7 @@ update_boot_order(void)
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
add_to_boot_list(EFI_FILE_HANDLE fh, CHAR16 *dirname, CHAR16 *filename, CHAR16 *label, CHAR16 *arguments)
|
||||
add_to_boot_list(CHAR16 *dirname, CHAR16 *filename, CHAR16 *label, CHAR16 *arguments)
|
||||
{
|
||||
CHAR16 *fullpath = NULL;
|
||||
UINT64 pathlen = 0;
|
||||
@ -417,25 +417,11 @@ add_to_boot_list(EFI_FILE_HANDLE fh, CHAR16 *dirname, CHAR16 *filename, CHAR16 *
|
||||
if (EFI_ERROR(rc))
|
||||
return rc;
|
||||
|
||||
EFI_DEVICE_PATH *dph = NULL;
|
||||
EFI_DEVICE_PATH *file = NULL;
|
||||
EFI_DEVICE_PATH *full_device_path = NULL;
|
||||
EFI_DEVICE_PATH *dp = NULL;
|
||||
CHAR16 *dps;
|
||||
|
||||
dph = DevicePathFromHandle(this_image->DeviceHandle);
|
||||
if (!dph) {
|
||||
rc = EFI_OUT_OF_RESOURCES;
|
||||
goto err;
|
||||
}
|
||||
|
||||
file = FileDevicePath(fh, fullpath);
|
||||
if (!file) {
|
||||
rc = EFI_OUT_OF_RESOURCES;
|
||||
goto err;
|
||||
}
|
||||
|
||||
full_device_path = AppendDevicePath(dph, file);
|
||||
full_device_path = FileDevicePath(this_image->DeviceHandle, fullpath);
|
||||
if (!full_device_path) {
|
||||
rc = EFI_OUT_OF_RESOURCES;
|
||||
goto err;
|
||||
@ -493,8 +479,6 @@ add_to_boot_list(EFI_FILE_HANDLE fh, CHAR16 *dirname, CHAR16 *filename, CHAR16 *
|
||||
}
|
||||
|
||||
err:
|
||||
if (file)
|
||||
FreePool(file);
|
||||
if (full_device_path)
|
||||
FreePool(full_device_path);
|
||||
if (dp)
|
||||
@ -505,7 +489,7 @@ err:
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
populate_stanza(EFI_FILE_HANDLE fh, CHAR16 *dirname, CHAR16 *filename, CHAR16 *csv)
|
||||
populate_stanza(CHAR16 *dirname, CHAR16 *filename, CHAR16 *csv)
|
||||
{
|
||||
CHAR16 *file = csv;
|
||||
VerbosePrint(L"CSV data: \"%s\"\n", csv);
|
||||
@ -529,7 +513,7 @@ populate_stanza(EFI_FILE_HANDLE fh, CHAR16 *dirname, CHAR16 *filename, CHAR16 *c
|
||||
/* This one is optional, so don't check if comma2 is 0 */
|
||||
VerbosePrint(L"arguments: \"%s\"\n", arguments);
|
||||
|
||||
add_to_boot_list(fh, dirname, file, label, arguments);
|
||||
add_to_boot_list(dirname, file, label, arguments);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@ -583,7 +567,7 @@ try_boot_csv(EFI_FILE_HANDLE fh, CHAR16 *dirname, CHAR16 *filename)
|
||||
CHAR16 c = start[l];
|
||||
start[l] = L'\0';
|
||||
|
||||
populate_stanza(fh, dirname, filename, start);
|
||||
populate_stanza(dirname, filename, start);
|
||||
|
||||
start[l] = c;
|
||||
start += l;
|
||||
|
Loading…
Reference in New Issue
Block a user