zefi: Expose EFI configuration lookup function

This will be useful to get various information such as ACPI table
pointer etc...

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This commit is contained in:
Tomasz Bursztyka 2020-09-10 17:07:32 +02:00 committed by Anas Nashif
commit c7090c5ee6
2 changed files with 47 additions and 4 deletions

View file

@ -30,10 +30,20 @@
typedef uintptr_t efi_status_t; typedef uintptr_t efi_status_t;
typedef struct { typedef struct {
uint32_t Data1; union {
uint16_t Data2; struct {
uint16_t Data3; uint32_t Data1;
uint8_t Data4[8]; uint16_t Data2;
uint16_t Data3;
uint8_t Data4[8];
};
/* Easier for comparison */
struct {
uint64_t Part1;
uint64_t Part2;
};
};
} efi_guid_t; } efi_guid_t;
struct efi_input_key { struct efi_input_key {
@ -547,7 +557,9 @@ struct efi_boot_services {
}; };
struct efi_configuration_table { struct efi_configuration_table {
/** Vendor EFI GUID Identifier */
efi_guid_t VendorGuid; efi_guid_t VendorGuid;
/** Vendor table pointer */
void *VendorTable; void *VendorTable;
}; };
@ -563,7 +575,9 @@ struct efi_system_table {
struct efi_simple_text_output *StdErr; struct efi_simple_text_output *StdErr;
struct efi_runtime_services *RuntimeServices; struct efi_runtime_services *RuntimeServices;
struct efi_boot_services *BootServices; struct efi_boot_services *BootServices;
/** The amount of entries to expect in the next attribute */
uint64_t NumberOfTableEntries; uint64_t NumberOfTableEntries;
/** A pointer to the configuration table(s) */
struct efi_configuration_table *ConfigurationTable; struct efi_configuration_table *ConfigurationTable;
}; };

View file

@ -4,6 +4,8 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
#include <stdint.h> #include <stdint.h>
#include <stddef.h>
#include <string.h>
#include "efi.h" #include "efi.h"
#include "printf.h" #include "printf.h"
#include <zefi-segments.h> #include <zefi-segments.h>
@ -42,6 +44,33 @@ static void efi_putchar(int c)
} }
} }
static inline bool efi_guid_compare(efi_guid_t *s1, efi_guid_t *s2)
{
return ((s1->Part1 == s2->Part1) && (s1->Part2 == s2->Part2));
}
static void *efi_config_get_vendor_table_by_guid(efi_guid_t *guid)
{
struct efi_configuration_table *ect_tmp;
int n_ct;
if (efi == NULL) {
return NULL;
}
ect_tmp = efi->ConfigurationTable;
for (n_ct = 0; n_ct < efi->NumberOfTableEntries; n_ct++) {
if (efi_guid_compare(&ect_tmp->VendorGuid, guid)) {
return ect_tmp->VendorTable;
}
ect_tmp++;
}
return NULL;
}
/* Existing x86_64 EFI environments have a bad habit of leaving the /* Existing x86_64 EFI environments have a bad habit of leaving the
* HPET timer running. This then fires later on, once the OS has * HPET timer running. This then fires later on, once the OS has
* started. If the timing isn't right, it can happen before the OS * started. If the timing isn't right, it can happen before the OS