efi: Deduplicate configuration table search function

We do table search in many places doing exactly the same algorithm.
The only minor variance in users is which table is used if several entries
are present. As specification mandates uniqueness and even if it ever isn't,
first entry is good enough, unify this code and always use the first entry.

Signed-off-by: Vladimir Serbinenko <phcoder@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
Vladimir Serbinenko committed 2023-11-06 22:47:16 +01:00
1 parent c6cf807fc0
commit 7ad30299da
7 files changed
+45 -103

No files matched your search

+6 -14
View File
@@ -23,21 +23,13 @@
void *
grub_efi_get_firmware_fdt (void)
{
grub_efi_configuration_table_t *tables;
static grub_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;
}
void *firmware_fdt = grub_efi_find_configuration_table (&fdt_guid);
if (firmware_fdt) {
grub_dprintf ("linux", "found registered FDT @ %p\n", firmware_fdt);
} else {
grub_dprintf ("linux", "not found registered FDT\n");
}
return firmware_fdt;
}