diff --git a/include/io/acpi.h b/include/io/acpi.h index ec7b644..917a682 100644 --- a/include/io/acpi.h +++ b/include/io/acpi.h @@ -110,10 +110,11 @@ enum { SDT_SRAT, SDT_SSDT, SDT_XSDT, - SDT_HEPT + SDT_HEPT, + SDT_MCFG }; -#define N_SDT_TYPES 23 +#define N_SDT_TYPES 24 //----------------------------------------------------------------------------// // FADT related diff --git a/kaleid/kernel/io/acpi.c b/kaleid/kernel/io/acpi.c index b16b603..2435e63 100644 --- a/kaleid/kernel/io/acpi.c +++ b/kaleid/kernel/io/acpi.c @@ -57,7 +57,8 @@ static char *SDTChar[N_SDT_TYPES] = { "SRAT", "SSDT", "XSDT", - "HPET" + "HPET", + "MCFG" }; // ACPI Tables Directory @@ -184,6 +185,31 @@ static inline void IoInitRXSDT(void) } } +// +// Returns the address of the MCFG +// +static inline SDTHeader_t *IoFindMCFG() +{ + char *mcfg = NULL; + + for (uint i = 0; i < memoryMap.length; i++) { + if (memoryMap.entry[i].type == RESERVED_ZONE) { + + for (mcfg = (char *)memoryMap.entry[i].addr; + (ulong)mcfg < (ulong)(memoryMap.entry[i].addr + + memoryMap.entry[i].length); + mcfg++) { + + if (!strncmp(mcfg, "MCFG", 3)) { + return (SDTHeader_t *)mcfg; + } + } + } + } + + return NULL; +} + // // Explore all ACPI Tables // @@ -257,6 +283,25 @@ static inline void IoSearchAcpiTables(void) SDTDirectory[SDT_DSDT] = dsdt; } } + + // Finding MCFG + SDTHeader_t *mcfg = IoFindMCFG(); + + if (mcfg) { + //DebugLog("MCFG found at %p\n"); + checksum = 0; //DoChecksum(mcfg, (size_t)mcfg->length, 0, 0); + if (!checksum) { + if (!strncmp(mcfg->signature, SDTChar[SDT_MCFG], 3)) { + DebugLog("ACPI System Table %s (OEM %s) length %lu [%p]\n", + SDTChar[SDT_MCFG], + mcfg->OEMID, + mcfg->length, + mcfg + ); + SDTDirectory[SDT_MCFG] = mcfg; + } + } + } } // -------------------------------------------------------------------------- // @@ -268,9 +313,7 @@ void IoInitAcpi(void) { // MAP ACPI PAGES - // Search the zone where the start address is for (uint i = 0; i < memoryMap.length; i++) { - // if the address is in an available zone, we can return the length if (memoryMap.entry[i].type != AVAILABLE_ZONE) { // Map each page that is in the busy zone