diff --git a/include/io/acpi.h b/include/io/acpi.h index 1c4bb30..654266d 100644 --- a/include/io/acpi.h +++ b/include/io/acpi.h @@ -72,10 +72,45 @@ struct SDTHeader { uint sdtTablePtr; }; +// +// ACPI table types id +// +enum { + SDT_MADT, + SDT_BERT, + SDT_CPEP, + SDT_DSDT, + SDT_ECDT, + SDT_EINJ, + SDT_ERST, + SDT_FADT, + SDT_FACS, + SDT_HEST, + SDT_MSCT, + SDT_MPST, + SDT_OEMx, + SDT_PMTT, + SDT_PSDT, + SDT_RASF, + SDT_RSDT, + SDT_SBST, + SDT_SLIT, + SDT_SRAT, + SDT_SSDT, + SDT_XSDT, + SDT_HEPT +}; + +#define N_SDT_TYPES 23 + + + //----------------------------------------------------------------------------// void IoInitAcpi(void); +SDTHeader *IoGetAcpiTable(ulong id); + //----------------------------------------------------------------------------// #endif diff --git a/kaleid/kernel/io/acpi.c b/kaleid/kernel/io/acpi.c index d939bf1..6846607 100644 --- a/kaleid/kernel/io/acpi.c +++ b/kaleid/kernel/io/acpi.c @@ -36,6 +36,36 @@ int tableCount = 1; extern MemoryMap_t memoryMap; +// ACPI reverse strings +static char *SDTChar[N_SDT_TYPES] = { + "APIC", + "BERT", + "CPEP", + "DSDT", + "ECDT", + "EINJ", + "ERST", + "FACP", + "FACS", + "HEST", + "MSCT", + "MPST", + "OEMx", + "PMTT", + "PSDT", + "RASF", + "RSDT", + "SBST", + "SLIT", + "SRAT", + "SSDT", + "XSDT", + "HPET" +}; + +// ACPI Tables Directory +static SDTHeader *SDTDirectory[N_SDT_TYPES] = {0}; + // // Returns the checksum of the given structure // @@ -189,25 +219,31 @@ static inline void IoSearchAcpiTables(void) DebugLog("ACPI detected %d entries\n", entries); - curInt = &(xrsdt->sdtTablePtr); - curLong = &(xrsdt->sdtTablePtr); + curInt = (uint*)&(xrsdt->sdtTablePtr); + curLong = (ulong*)&(xrsdt->sdtTablePtr); for (int i = 0; i < entries; i++) { if (IoACPIVersion == 1) - table = (SDTHeader *)curInt[i]; + table = (SDTHeader *)(ulong)curInt[i]; else - table = (SDTHeader *)curLong[i]; + table = (SDTHeader *)(ulong)curLong[i]; //KernLog("\tACPI RSDT[%d] %p\n", i, table); if (MmIsBusyZone(table)) { checksum = DoChecksum(table, (size_t)table->length, 0, 0); if (!checksum) { - DebugLog("ACPI System Table %s (OEM %s) length %d [%p]\n", - table->signature, - table->OEMID, - table->length, - table); + for (ulong i=0; i < N_SDT_TYPES; i++) { + if (!strncmp(table->signature, SDTChar[i], 3)) { + DebugLog("ACPI System Table %s (OEM %s) length %d [%p]\n", + SDTChar[i], + table->OEMID, + table->length, + table + ); + SDTDirectory[i] = table; + } + } } } } @@ -252,3 +288,14 @@ void IoInitAcpi(void) IoSearchAcpiTables(); } + + +// +// Returns the addr of the submitted SDT +// +// Arg must be a member of the enum in acpi.h +// +SDTHeader *IoGetAcpiTable(ulong id) +{ + return SDTDirectory[id]; +} diff --git a/kaleid/kernel/mm/gdt.c b/kaleid/kernel/mm/gdt.c index e99ef94..b1fdc1c 100644 --- a/kaleid/kernel/mm/gdt.c +++ b/kaleid/kernel/mm/gdt.c @@ -58,9 +58,9 @@ void MmInitGdt(void) tssDesc.veryHighBase = ((ulong)&tss >> 32) & 0xFFFFFFFF; tssDesc.lowLimit = sizeof(tss); - tss.ist1 = (ulong)memalign(4*KB, 4*KB) + 4*KB; // ISR RESCUE STACK - tss.ist2 = (ulong)memalign(4*KB, 4*KB) + 4*KB; // ISR STACK - tss.ist3 = (ulong)memalign(4*KB, 4*KB) + 4*KB; // ISR STACK + tss.ist1 = (ulong)memalign(4*MB, 4*KB) + 4*MB; // ISR RESCUE STACK + tss.ist2 = (ulong)memalign(4*MB, 4*KB) + 4*MB; // ISR STACK + tss.ist3 = (ulong)memalign(4*MB, 4*KB) + 4*MB; // ISR STACK tss.iomap_base = sizeof(tss); DebugLog("ISR Stacks initialized : Rescue %p, Normal %p, %p\n",