Abstract out support for locating an EFI config table
We want to grab a pointer to the TPM final events table, so abstract out the existing code for finding an FDT table and make it generic. Signed-off-by: Matthew Garrett <mjg59@google.com> Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> Tested-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
This commit is contained in:
parent
db4d8cb9c9
commit
82d736ac56
@ -926,3 +926,18 @@ free_map:
|
|||||||
fail:
|
fail:
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void *get_efi_config_table(efi_system_table_t *sys_table, efi_guid_t guid)
|
||||||
|
{
|
||||||
|
efi_config_table_t *tables = (efi_config_table_t *)sys_table->tables;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < sys_table->nr_tables; i++) {
|
||||||
|
if (efi_guidcmp(tables[i].guid, guid) != 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
return (void *)tables[i].table;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
@ -65,6 +65,8 @@ efi_status_t check_platform_features(efi_system_table_t *sys_table_arg);
|
|||||||
|
|
||||||
efi_status_t efi_random_get_seed(efi_system_table_t *sys_table_arg);
|
efi_status_t efi_random_get_seed(efi_system_table_t *sys_table_arg);
|
||||||
|
|
||||||
|
void *get_efi_config_table(efi_system_table_t *sys_table, efi_guid_t guid);
|
||||||
|
|
||||||
/* Helper macros for the usual case of using simple C variables: */
|
/* Helper macros for the usual case of using simple C variables: */
|
||||||
#ifndef fdt_setprop_inplace_var
|
#ifndef fdt_setprop_inplace_var
|
||||||
#define fdt_setprop_inplace_var(fdt, node_offset, name, var) \
|
#define fdt_setprop_inplace_var(fdt, node_offset, name, var) \
|
||||||
|
@ -363,26 +363,17 @@ fail:
|
|||||||
|
|
||||||
void *get_fdt(efi_system_table_t *sys_table, unsigned long *fdt_size)
|
void *get_fdt(efi_system_table_t *sys_table, unsigned long *fdt_size)
|
||||||
{
|
{
|
||||||
efi_guid_t fdt_guid = DEVICE_TREE_GUID;
|
void *fdt;
|
||||||
efi_config_table_t *tables;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
tables = (efi_config_table_t *)sys_table->tables;
|
fdt = get_efi_config_table(sys_table, DEVICE_TREE_GUID);
|
||||||
|
|
||||||
for (i = 0; i < sys_table->nr_tables; i++) {
|
if (!fdt)
|
||||||
void *fdt;
|
return NULL;
|
||||||
|
|
||||||
if (efi_guidcmp(tables[i].guid, fdt_guid) != 0)
|
if (fdt_check_header(fdt) != 0) {
|
||||||
continue;
|
pr_efi_err(sys_table, "Invalid header detected on UEFI supplied FDT, ignoring ...\n");
|
||||||
|
return NULL;
|
||||||
fdt = (void *)tables[i].table;
|
|
||||||
if (fdt_check_header(fdt) != 0) {
|
|
||||||
pr_efi_err(sys_table, "Invalid header detected on UEFI supplied FDT, ignoring ...\n");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
*fdt_size = fdt_totalsize(fdt);
|
|
||||||
return fdt;
|
|
||||||
}
|
}
|
||||||
|
*fdt_size = fdt_totalsize(fdt);
|
||||||
return NULL;
|
return fdt;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user