Skip to content

Commit 582f851

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 85c637a commit 582f851

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
@@ -14,6 +14,7 @@
1414
#include <log.h>
1515
#include <malloc.h>
1616
#include <net.h>
17+
#include <part.h>
1718
#include <efi_default_filename.h>
1819
#include <efi_loader.h>
1920
#include <efi_variable.h>
@@ -306,6 +307,7 @@ static efi_status_t search_default_file(struct udevice *dev,
306307
static efi_status_t fill_default_file_path(struct udevice *blk,
307308
struct efi_device_path **dp)
308309
{
310+
struct blk_desc *desc = dev_get_uclass_plat(blk);
309311
efi_status_t ret;
310312
struct udevice *partition;
311313

@@ -314,6 +316,26 @@ static efi_status_t fill_default_file_path(struct udevice *blk,
314316
if (ret == EFI_SUCCESS)
315317
return ret;
316318

319+
/* try EFI system partition */
320+
if (desc->uclass_id == efi_system_partition.uclass_id &&
321+
desc->devnum == efi_system_partition.devnum) {
322+
device_foreach_child(partition, blk) {
323+
struct disk_part *part;
324+
enum uclass_id id;
325+
326+
id = device_get_uclass_id(partition);
327+
if (id != UCLASS_PARTITION)
328+
continue;
329+
330+
part = dev_get_uclass_plat(partition);
331+
if (part->partnum == efi_system_partition.part) {
332+
ret = search_default_file(partition, dp);
333+
if (ret == EFI_SUCCESS)
334+
return ret;
335+
}
336+
}
337+
}
338+
317339
/* try the partitions */
318340
device_foreach_child(partition, blk) {
319341
enum uclass_id id;

0 commit comments

Comments
 (0)