mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-16 18:04:48 +00:00
efi_loader: load distro dtb in bootmgr
If no device-tree is specified, try to load a device-tree from the boot device use the $fdtfile concatenated to either of the paths '/dtb/', '/', '/dtb/current/'. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
This commit is contained in:
parent
8deb5d855b
commit
e91b68fd6b
3 changed files with 57 additions and 2 deletions
|
@ -1205,4 +1205,6 @@ efi_status_t efi_load_option_dp_join(struct efi_device_path **dp,
|
|||
|
||||
int efi_get_distro_fdt_name(char *fname, int size, int seq);
|
||||
|
||||
void efi_load_distro_fdt(void **fdt, efi_uintn_t *fdt_size);
|
||||
|
||||
#endif /* _EFI_LOADER_H */
|
||||
|
|
|
@ -1253,7 +1253,8 @@ efi_status_t efi_bootmgr_run(void *fdt)
|
|||
efi_handle_t handle;
|
||||
void *load_options;
|
||||
efi_status_t ret;
|
||||
void *fdt_lo;
|
||||
void *fdt_lo, *fdt_distro = NULL;
|
||||
efi_uintn_t fdt_size;
|
||||
|
||||
/* Initialize EFI drivers */
|
||||
ret = efi_init_obj_list();
|
||||
|
@ -1275,6 +1276,10 @@ efi_status_t efi_bootmgr_run(void *fdt)
|
|||
return ret;
|
||||
if (fdt_lo)
|
||||
fdt = fdt_lo;
|
||||
if (!fdt) {
|
||||
efi_load_distro_fdt(&fdt_distro, &fdt_size);
|
||||
fdt = fdt_distro;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1283,8 +1288,12 @@ efi_status_t efi_bootmgr_run(void *fdt)
|
|||
*/
|
||||
ret = efi_install_fdt(fdt);
|
||||
|
||||
if (!IS_ENABLED(CONFIG_GENERATE_ACPI_TABLE))
|
||||
if (!IS_ENABLED(CONFIG_GENERATE_ACPI_TABLE)) {
|
||||
free(fdt_lo);
|
||||
if (fdt_distro)
|
||||
efi_free_pages((uintptr_t)fdt_distro,
|
||||
efi_size_in_pages(fdt_size));
|
||||
}
|
||||
|
||||
if (ret != EFI_SUCCESS) {
|
||||
if (EFI_CALL(efi_unload_image(handle)) == EFI_SUCCESS)
|
||||
|
|
|
@ -71,3 +71,47 @@ int efi_get_distro_fdt_name(char *fname, int size, int seq)
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* efi_load_distro_fdt() - load distro device-tree
|
||||
*
|
||||
* @fdt: on return device-tree, must be freed via efi_free_pages()
|
||||
* @fdt_size: buffer size
|
||||
*/
|
||||
void efi_load_distro_fdt(void **fdt, efi_uintn_t *fdt_size)
|
||||
{
|
||||
struct efi_device_path *rem, *dp;
|
||||
efi_status_t ret;
|
||||
efi_handle_t device;
|
||||
|
||||
*fdt = NULL;
|
||||
|
||||
dp = efi_get_dp_from_boot(NULL);
|
||||
if (!dp)
|
||||
return;
|
||||
device = efi_dp_find_obj(dp, NULL, &rem);
|
||||
ret = efi_search_protocol(device, &efi_simple_file_system_protocol_guid,
|
||||
NULL);
|
||||
if (ret != EFI_SUCCESS)
|
||||
goto err;
|
||||
memcpy(rem, &END, sizeof(END));
|
||||
|
||||
/* try the various available names */
|
||||
for (int seq = 0; ; ++seq) {
|
||||
struct efi_device_path *file;
|
||||
char buf[255];
|
||||
|
||||
if (efi_get_distro_fdt_name(buf, sizeof(buf), seq))
|
||||
break;
|
||||
file = efi_dp_from_file(dp, buf);
|
||||
if (!file)
|
||||
break;
|
||||
ret = efi_load_image_from_path(true, file, fdt, fdt_size);
|
||||
efi_free_pool(file);
|
||||
if (ret == EFI_SUCCESS)
|
||||
break;
|
||||
}
|
||||
|
||||
err:
|
||||
efi_free_pool(dp);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue