summaryrefslogtreecommitdiff
path: root/boot/bootmeth_efi.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2023-04-24 04:49:46 +0300
committerTom Rini <trini@konsulko.com>2023-04-26 15:43:04 +0300
commitd80bb4f958b01b6e1a3e904fe8e5e40584113938 (patch)
tree391735767197aeb4b57351a852cf6445fc01364c /boot/bootmeth_efi.c
parent27ff7806c1d7d1e98cc6ec1d295595786e13b4b4 (diff)
downloadu-boot-d80bb4f958b01b6e1a3e904fe8e5e40584113938.tar.xz
bootstd: Support booting EFI where multiple options exist
The current EFI implementation has a strange quirk where it watches loaded files and uses the last-loaded file to determine the device that is being booted from. This is confusing with bootstd, where multiple options may exist. Even loading a device tree will cause it to go wrong. There is no API for passing this information, since the only entry into booting an EFI image is the 'bootefi' command. To work around this, call efi_set_bootdev() for EFI images, if possible, just before booting. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'boot/bootmeth_efi.c')
-rw-r--r--boot/bootmeth_efi.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/boot/bootmeth_efi.c b/boot/bootmeth_efi.c
index d7e042cf01..d8bc7fafd1 100644
--- a/boot/bootmeth_efi.c
+++ b/boot/bootmeth_efi.c
@@ -94,7 +94,7 @@ static int get_efi_pxe_vci(char *str, int max_len)
return 0;
}
-static int efiload_read_file(struct blk_desc *desc, struct bootflow *bflow)
+static void set_efi_bootdev(struct blk_desc *desc, struct bootflow *bflow)
{
const struct udevice *media_dev;
int size = bflow->size;
@@ -102,11 +102,6 @@ static int efiload_read_file(struct blk_desc *desc, struct bootflow *bflow)
char devnum_str[9];
char dirname[200];
char *last_slash;
- int ret;
-
- ret = bootmeth_alloc_file(bflow, 0x2000000, 0x10000);
- if (ret)
- return log_msg_ret("read", ret);
/*
* This is a horrible hack to tell EFI about this boot device. Once we
@@ -117,7 +112,8 @@ static int efiload_read_file(struct blk_desc *desc, struct bootflow *bflow)
* this can go away.
*/
media_dev = dev_get_parent(bflow->dev);
- snprintf(devnum_str, sizeof(devnum_str), "%x", dev_seq(media_dev));
+ snprintf(devnum_str, sizeof(devnum_str), "%x:%x", dev_seq(media_dev),
+ bflow->part);
strlcpy(dirname, bflow->fname, sizeof(dirname));
last_slash = strrchr(dirname, '/');
@@ -130,6 +126,15 @@ static int efiload_read_file(struct blk_desc *desc, struct bootflow *bflow)
dev_name = device_get_uclass_id(media_dev) == UCLASS_MASS_STORAGE ?
"usb" : dev_get_uclass_name(media_dev);
efi_set_bootdev(dev_name, devnum_str, bflow->fname, bflow->buf, size);
+}
+
+static int efiload_read_file(struct blk_desc *desc, struct bootflow *bflow)
+{
+ int ret;
+
+ ret = bootmeth_alloc_file(bflow, 0x2000000, 0x10000);
+ if (ret)
+ return log_msg_ret("read", ret);
return 0;
}
@@ -373,6 +378,13 @@ int distro_efi_boot(struct udevice *dev, struct bootflow *bflow)
/* A non-zero buffer indicates the kernel is there */
if (bflow->buf) {
+ /* Set the EFI bootdev again, since reading an FDT loses it! */
+ if (bflow->blk) {
+ struct blk_desc *desc = dev_get_uclass_plat(bflow->blk);
+
+ set_efi_bootdev(desc, bflow);
+ }
+
kernel = (ulong)map_to_sysmem(bflow->buf);
/*