Skip to content

Commit b7abd70

Browse files
committed
efi_loader: prefer EFI system partition
When booting from a block io device, prefer the EFI system partition over other partitions. Signed-off-by: Mark Kettenis <[email protected]>
1 parent 1115e79 commit b7abd70

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

lib/efi_loader/efi_bootmgr.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <log.h>
1717
#include <malloc.h>
1818
#include <net.h>
19+
#include <part.h>
1920
#include <efi_loader.h>
2021
#include <efi_variable.h>
2122
#include <asm/unaligned.h>
@@ -313,6 +314,7 @@ static efi_status_t search_default_file(struct udevice *dev,
313314
static efi_status_t fill_default_file_path(struct udevice *blk,
314315
struct efi_device_path **dp)
315316
{
317+
struct blk_desc *desc = dev_get_uclass_plat(blk);
316318
efi_status_t ret;
317319
struct udevice *partition;
318320

@@ -321,6 +323,26 @@ static efi_status_t fill_default_file_path(struct udevice *blk,
321323
if (ret == EFI_SUCCESS)
322324
return ret;
323325

326+
/* try EFI system partition */
327+
if (desc->uclass_id == efi_system_partition.uclass_id &&
328+
desc->devnum == efi_system_partition.devnum) {
329+
device_foreach_child(partition, blk) {
330+
struct disk_part *part;
331+
enum uclass_id id;
332+
333+
id = device_get_uclass_id(partition);
334+
if (id != UCLASS_PARTITION)
335+
continue;
336+
337+
part = dev_get_uclass_plat(partition);
338+
if (part->partnum == efi_system_partition.part) {
339+
ret = search_default_file(partition, dp);
340+
if (ret == EFI_SUCCESS)
341+
return ret;
342+
}
343+
}
344+
}
345+
324346
/* try the partitions */
325347
device_foreach_child(partition, blk) {
326348
enum uclass_id id;

0 commit comments

Comments
 (0)