arm64: Move firmware fdt search into global function

Searching for a device tree that EFI passes to us via configuration tables
is nothing architecture specific. Move it into generic code.

Signed-off-by: Alexander Graf <agraf@suse.de>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
Alexander Graf 2016-02-29 00:22:23 +01:00 committed by Daniel Kiper
parent 5f311e86d2
commit fbca374105
3 changed files with 25 additions and 23 deletions

View file

@ -72,6 +72,28 @@ grub_machine_get_bootlocation (char **device, char **path)
} }
} }
void *
grub_efi_get_firmware_fdt (void)
{
grub_efi_configuration_table_t *tables;
grub_efi_guid_t fdt_guid = GRUB_EFI_DEVICE_TREE_GUID;
void *firmware_fdt = NULL;
unsigned int i;
/* Look for FDT in UEFI config tables. */
tables = grub_efi_system_table->configuration_table;
for (i = 0; i < grub_efi_system_table->num_table_entries; i++)
if (grub_memcmp (&tables[i].vendor_guid, &fdt_guid, sizeof (fdt_guid)) == 0)
{
firmware_fdt = tables[i].vendor_table;
grub_dprintf ("linux", "found registered FDT @ %p\n", firmware_fdt);
break;
}
return firmware_fdt;
}
void void
grub_efi_fini (void) grub_efi_fini (void)
{ {

View file

@ -28,28 +28,6 @@
static void *loaded_fdt; static void *loaded_fdt;
static void *fdt; static void *fdt;
static void *
get_firmware_fdt (void)
{
grub_efi_configuration_table_t *tables;
grub_efi_guid_t fdt_guid = GRUB_EFI_DEVICE_TREE_GUID;
void *firmware_fdt = NULL;
unsigned int i;
/* Look for FDT in UEFI config tables. */
tables = grub_efi_system_table->configuration_table;
for (i = 0; i < grub_efi_system_table->num_table_entries; i++)
if (grub_memcmp (&tables[i].vendor_guid, &fdt_guid, sizeof (fdt_guid)) == 0)
{
firmware_fdt = tables[i].vendor_table;
grub_dprintf ("linux", "found registered FDT @ %p\n", firmware_fdt);
break;
}
return firmware_fdt;
}
void * void *
grub_fdt_load (grub_size_t additional_size) grub_fdt_load (grub_size_t additional_size)
{ {
@ -65,7 +43,7 @@ grub_fdt_load (grub_size_t additional_size)
if (loaded_fdt) if (loaded_fdt)
raw_fdt = loaded_fdt; raw_fdt = loaded_fdt;
else else
raw_fdt = get_firmware_fdt(); raw_fdt = grub_efi_get_firmware_fdt();
size = size =
raw_fdt ? grub_fdt_get_totalsize (raw_fdt) : GRUB_FDT_EMPTY_TREE_SZ; raw_fdt ? grub_fdt_get_totalsize (raw_fdt) : GRUB_FDT_EMPTY_TREE_SZ;

View file

@ -81,6 +81,8 @@ extern void (*EXPORT_VAR(grub_efi_net_config)) (grub_efi_handle_t hnd,
char **device, char **device,
char **path); char **path);
void *EXPORT_FUNC(grub_efi_get_firmware_fdt)(void);
grub_addr_t grub_efi_modules_addr (void); grub_addr_t grub_efi_modules_addr (void);
void grub_efi_mm_init (void); void grub_efi_mm_init (void);