mirror of
https://github.com/u-boot/u-boot.git
synced 2025-05-09 03:21:51 +00:00
efi_loader: Pass in the required parameters from EFI bootmeth
Rather than setting up the global variables and then making the call, pass them into function directly. This cleans up the code and makes it all a bit easier to understand. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
5f67c8800e
commit
a2338955fc
3 changed files with 83 additions and 47 deletions
|
@ -52,40 +52,6 @@ static bool bootmeth_uses_network(struct bootflow *bflow)
|
|||
device_get_uclass_id(media) == UCLASS_ETH;
|
||||
}
|
||||
|
||||
static void set_efi_bootdev(struct blk_desc *desc, struct bootflow *bflow)
|
||||
{
|
||||
const struct udevice *media_dev;
|
||||
int size = bflow->size;
|
||||
const char *dev_name;
|
||||
char devnum_str[9];
|
||||
char dirname[200];
|
||||
char *last_slash;
|
||||
|
||||
/*
|
||||
* This is a horrible hack to tell EFI about this boot device. Once we
|
||||
* unify EFI with the rest of U-Boot we can clean this up. The same hack
|
||||
* exists in multiple places, e.g. in the fs, tftp and load commands.
|
||||
*
|
||||
* Once we can clean up the EFI code to make proper use of driver model,
|
||||
* this can go away.
|
||||
*/
|
||||
media_dev = dev_get_parent(bflow->dev);
|
||||
snprintf(devnum_str, sizeof(devnum_str), "%x:%x",
|
||||
desc ? desc->devnum : dev_seq(media_dev),
|
||||
bflow->part);
|
||||
|
||||
strlcpy(dirname, bflow->fname, sizeof(dirname));
|
||||
last_slash = strrchr(dirname, '/');
|
||||
if (last_slash)
|
||||
*last_slash = '\0';
|
||||
|
||||
dev_name = device_get_uclass_id(media_dev) == UCLASS_MASS_STORAGE ?
|
||||
"usb" : blk_get_uclass_name(device_get_uclass_id(media_dev));
|
||||
log_debug("setting bootdev %s, %s, %s, %p, %x\n",
|
||||
dev_name, devnum_str, bflow->fname, bflow->buf, size);
|
||||
efi_set_bootdev(dev_name, devnum_str, bflow->fname, bflow->buf, size);
|
||||
}
|
||||
|
||||
static int efiload_read_file(struct bootflow *bflow, ulong addr)
|
||||
{
|
||||
struct blk_desc *desc = NULL;
|
||||
|
@ -102,8 +68,6 @@ static int efiload_read_file(struct bootflow *bflow, ulong addr)
|
|||
return log_msg_ret("rdf", ret);
|
||||
bflow->buf = map_sysmem(addr, bflow->size);
|
||||
|
||||
set_efi_bootdev(desc, bflow);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -344,17 +308,8 @@ static int distro_efi_boot(struct udevice *dev, struct bootflow *bflow)
|
|||
fdt = env_get_hex("fdt_addr_r", 0);
|
||||
}
|
||||
|
||||
if (bflow->flags & BOOTFLOWF_USE_BUILTIN_FDT) {
|
||||
log_debug("Booting with built-in fdt\n");
|
||||
if (efi_binary_run(map_sysmem(kernel, 0), bflow->size,
|
||||
EFI_FDT_USE_INTERNAL))
|
||||
return log_msg_ret("run", -EINVAL);
|
||||
} else {
|
||||
log_debug("Booting with external fdt\n");
|
||||
if (efi_binary_run(map_sysmem(kernel, 0), bflow->size,
|
||||
map_sysmem(fdt, 0)))
|
||||
return log_msg_ret("run", -EINVAL);
|
||||
}
|
||||
if (efi_bootflow_run(bflow))
|
||||
return log_msg_ret("run", -EINVAL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue