diff --git a/sdk/xtdk/hltypes.h b/sdk/xtdk/hltypes.h index b38033e..27e823d 100644 --- a/sdk/xtdk/hltypes.h +++ b/sdk/xtdk/hltypes.h @@ -101,6 +101,12 @@ #define ACPI_MADT_PLACE_ENABLED 0 /* Processor Local APIC CPU Enabled */ #define ACPI_MADT_PLAOC_ENABLED 1 /* Processor Local APIC Online Capable */ +/* ACPI address space definitions */ +#define ACPI_ADDRESS_SPACE_MEMORY 0x00 + +/* Maximum number of cached ACPI tables */ +#define ACPI_MAX_CACHED_TABLES 32 + /* Default serial port settings */ #define COMPORT_CLOCK_RATE 0x1C200 #define COMPORT_WAIT_TIMEOUT 204800 @@ -222,7 +228,7 @@ typedef struct _ACPI_SUBTABLE_HEADER typedef struct _ACPI_CACHE_LIST { LIST_ENTRY ListEntry; - ACPI_DESCRIPTION_HEADER Header; + PACPI_DESCRIPTION_HEADER Table; } ACPI_CACHE_LIST, *PACPI_CACHE_LIST; /* ACPI Root System Description Table Pointer (RSDP) structure */ diff --git a/xtoskrnl/hl/acpi.cc b/xtoskrnl/hl/acpi.cc index e8145cd..938ea20 100644 --- a/xtoskrnl/hl/acpi.cc +++ b/xtoskrnl/hl/acpi.cc @@ -26,8 +26,21 @@ HL::Acpi::CacheAcpiTable(IN PACPI_DESCRIPTION_HEADER AcpiTable) { PACPI_CACHE_LIST AcpiCache; - /* Create new ACPI table cache entry */ - AcpiCache = CONTAIN_RECORD(AcpiTable, ACPI_CACHE_LIST, Header); + /* Check if there are free slots in static early-boot cache array */ + if(CacheCount >= ACPI_MAX_CACHED_TABLES) + { + /* Cache is full, the table is mapped but not cached */ + return; + } + + /* Get the next available static cache entry */ + AcpiCache = &CacheEntries[CacheCount]; + CacheCount++; + + /* Store the pointer to the mapped ACPI table */ + AcpiCache->Table = AcpiTable; + + /* Insert entry into the global ACPI cache list */ RTL::LinkedList::InsertTailList(&CacheList, &AcpiCache->ListEntry); } @@ -539,10 +552,10 @@ HL::Acpi::QueryAcpiCache(IN ULONG Signature, AcpiCache = CONTAIN_RECORD(ListEntry, ACPI_CACHE_LIST, ListEntry); /* Check if ACPI table signature matches */ - if(AcpiCache->Header.Signature == Signature) + if(AcpiCache->Table->Signature == Signature) { /* ACPI table found in cache, return it */ - TableHeader = &AcpiCache->Header; + TableHeader = AcpiCache->Table; break; } diff --git a/xtoskrnl/hl/data.cc b/xtoskrnl/hl/data.cc index 574f8c3..48099ee 100644 --- a/xtoskrnl/hl/data.cc +++ b/xtoskrnl/hl/data.cc @@ -9,6 +9,12 @@ #include +/* ACPI tables cache count */ +ULONG HL::Acpi::CacheCount = 0; + +/* ACPI tables cache entries */ +ACPI_CACHE_LIST HL::Acpi::CacheEntries[ACPI_MAX_CACHED_TABLES]; + /* ACPI tables cache list */ LIST_ENTRY HL::Acpi::CacheList; diff --git a/xtoskrnl/includes/hl/acpi.hh b/xtoskrnl/includes/hl/acpi.hh index 227cf0f..cb188eb 100644 --- a/xtoskrnl/includes/hl/acpi.hh +++ b/xtoskrnl/includes/hl/acpi.hh @@ -18,6 +18,8 @@ namespace HL class Acpi { private: + STATIC ULONG CacheCount; + STATIC ACPI_CACHE_LIST CacheEntries[ACPI_MAX_CACHED_TABLES]; STATIC LIST_ENTRY CacheList; STATIC PACPI_RSDP RsdpStructure; STATIC ACPI_SYSTEM_INFO SystemInfo;