hv: Enumerate IOAPIC info from MADT

IOAPIC info, specifically ID, is needed to map the IOAPIC to
corresponding DMAR. DMAR table in ACPI has a field that has IOAPIC
ID, that matches the info provided in MADT. Both (IOAPIC info from
MADT and from DMAR) is needed for remapping IOAPIC interrupts.

Tracked-On: #2426
Signed-off-by: Sainath Grandhi <sainath.grandhi@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
This commit is contained in:
Grandhi, Sainath
2019-01-26 00:04:47 -08:00
committed by Eddie Dong
parent fb6e9267f3
commit 4ff9f5dfb2
8 changed files with 101 additions and 11 deletions

View File

@@ -39,6 +39,7 @@
#define RSDP_CHECKSUM_LENGTH 20
#define ACPI_NAME_SIZE 4U
#define ACPI_MADT_TYPE_LOCAL_APIC 0U
#define ACPI_MADT_TYPE_IOAPIC 1U
#define ACPI_MADT_ENABLED 1U
#define ACPI_OEM_TABLE_ID_SIZE 8
@@ -100,6 +101,14 @@ struct acpi_madt_local_apic {
};
static struct acpi_table_rsdp *acpi_rsdp;
struct acpi_madt_ioapic {
struct acpi_subtable_header header;
/* IOAPIC id */
uint8_t id;
uint8_t rsvd;
uint32_t addr;
uint32_t gsi_base;
};
static struct acpi_table_rsdp*
found_rsdp(char *base, int32_t length)
@@ -245,6 +254,40 @@ local_parse_madt(struct acpi_table_madt *madt, uint32_t lapic_id_array[CONFIG_MA
return pcpu_num;
}
static uint16_t
ioapic_parse_madt(void *madt, struct ioapic_info *ioapic_id_array)
{
struct acpi_madt_ioapic *ioapic;
struct acpi_table_madt *madt_ptr;
void *first, *end, *iterator;
struct acpi_subtable_header *entry;
uint16_t ioapic_idx = 0U;
madt_ptr = (struct acpi_table_madt *)madt;
first = madt_ptr + 1;
end = (void *)madt_ptr + madt_ptr->header.length;
for (iterator = first; (iterator) < (end); iterator += entry->length) {
entry = (struct acpi_subtable_header *)iterator;
if (entry->length < sizeof(struct acpi_subtable_header)) {
break;
}
if (entry->type == ACPI_MADT_TYPE_IOAPIC) {
ioapic = (struct acpi_madt_ioapic *)iterator;
if (ioapic_idx < CONFIG_MAX_IOAPIC_NUM) {
ioapic_id_array[ioapic_idx].id = ioapic->id;
ioapic_id_array[ioapic_idx].addr = ioapic->addr;
ioapic_id_array[ioapic_idx].gsi_base = ioapic->gsi_base;
}
ioapic_idx++;
}
}
return ioapic_idx;
}
/* The lapic_id info gotten from madt will be returned in lapic_id_array */
uint16_t parse_madt(uint32_t lapic_id_array[CONFIG_MAX_PCPU_NUM])
{
@@ -261,6 +304,19 @@ uint16_t parse_madt(uint32_t lapic_id_array[CONFIG_MAX_PCPU_NUM])
return ret;
}
uint16_t parse_madt_ioapic(struct ioapic_info *ioapic_id_array)
{
void *madt;
acpi_rsdp = get_rsdp();
ASSERT(acpi_rsdp != NULL, "fail to get rsdp");
madt = get_acpi_tbl(ACPI_SIG_MADT);
ASSERT(madt != NULL, "fail to get madt");
return ioapic_parse_madt(madt, ioapic_id_array);
}
void *get_dmar_table(void)
{
return get_acpi_tbl(ACPI_SIG_DMAR);

View File

@@ -8,5 +8,6 @@
#define ACPI_H
uint16_t parse_madt(uint32_t lapic_id_array[CONFIG_MAX_PCPU_NUM]);
uint16_t parse_madt_ioapic(struct ioapic_info *ioapic_id_array);
#endif /* !ACPI_H */