diff --git a/os/src/drivers/acpi/acpi.cc b/os/src/drivers/acpi/acpi.cc index 57d16a2b07..51d2f83b58 100644 --- a/os/src/drivers/acpi/acpi.cc +++ b/os/src/drivers/acpi/acpi.cc @@ -39,6 +39,17 @@ struct Apic_struct Apic_struct *next() { return reinterpret_cast((uint8_t *)this + length); } } __attribute__((packed)); +struct Mcfg_struct +{ + uint64_t base; + uint16_t pci_seg; + uint8_t pci_bus_start; + uint8_t pci_bus_end; + uint32_t reserved; + + Mcfg_struct *next() { + return reinterpret_cast((uint8_t *)this + sizeof(*this)); } +} __attribute__((packed)); /* ACPI spec 5.2.12.5 */ struct Apic_override : Apic_struct @@ -68,6 +79,10 @@ struct Generic /* MADT acpi structures */ Apic_struct *apic_struct() { return reinterpret_cast(&creator_rev + 3); } Apic_struct *end() { return reinterpret_cast(signature + size); } + + /* MCFG ACPI stucture */ + Mcfg_struct *mcfg_struct() { return reinterpret_cast(&creator_rev + 3); } + Mcfg_struct *mcfg_end() { return reinterpret_cast(signature + size); } } __attribute__((packed)); @@ -186,6 +201,11 @@ class Table_wrapper */ bool is_madt() { return _cmp("APIC"); } + /** + * Is this a MCFG table + */ + bool is_mcfg() { return _cmp("MCFG"); } + /** * Look for DSDT and SSDT tables */ @@ -209,6 +229,15 @@ class Table_wrapper } } + void parse_mcfg() const + { + Mcfg_struct *mcfg = _table->mcfg_struct(); + for (; mcfg < _table->mcfg_end(); mcfg = mcfg->next()) { + PINF("MCFG BASE 0x%llx seg %02x bus %02x-%02x", mcfg->base, + mcfg->pci_seg, mcfg->pci_bus_start, mcfg->pci_bus_end); + } + } + Table_wrapper(addr_t base) : _base(base), _io_mem(0), _table(0) { @@ -927,10 +956,16 @@ class Acpi_table } if (table.is_madt()) { - PDBG("Found MADT"); + PDBG("Found MADT"); table.parse_madt(); } + + if (table.is_mcfg()) { + PDBG("Found MCFG"); + + table.parse_mcfg(); + } } if (dsdt) {