WIP : MCFG #73

This commit is contained in:
Adrien Bourmault 2020-02-09 20:55:13 +01:00
parent 25b913d140
commit 824420aa9a
2 changed files with 49 additions and 5 deletions

View File

@ -110,10 +110,11 @@ enum {
SDT_SRAT, SDT_SRAT,
SDT_SSDT, SDT_SSDT,
SDT_XSDT, SDT_XSDT,
SDT_HEPT SDT_HEPT,
SDT_MCFG
}; };
#define N_SDT_TYPES 23 #define N_SDT_TYPES 24
//----------------------------------------------------------------------------// //----------------------------------------------------------------------------//
// FADT related // FADT related

View File

@ -57,7 +57,8 @@ static char *SDTChar[N_SDT_TYPES] = {
"SRAT", "SRAT",
"SSDT", "SSDT",
"XSDT", "XSDT",
"HPET" "HPET",
"MCFG"
}; };
// ACPI Tables Directory // 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 // Explore all ACPI Tables
// //
@ -257,6 +283,25 @@ static inline void IoSearchAcpiTables(void)
SDTDirectory[SDT_DSDT] = dsdt; 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 // MAP ACPI PAGES
// Search the zone where the start address is
for (uint i = 0; i < memoryMap.length; i++) { 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) { if (memoryMap.entry[i].type != AVAILABLE_ZONE) {
// Map each page that is in the busy zone // Map each page that is in the busy zone