Working on ACPI exploration
This commit is contained in:
parent
51292364ce
commit
b28740606a
|
@ -69,6 +69,7 @@ struct SDTHeader {
|
|||
uint OEMRevision;
|
||||
uint creatorID;
|
||||
uint creatorRevision;
|
||||
uint sdtTablePtr;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <io/vga.h>
|
||||
#include <io/acpi.h>
|
||||
#include <mm/paging.h>
|
||||
#include <mm/map.h>
|
||||
|
||||
SDTHeader *AcpiSDT = NULL;
|
||||
SDTHeader *AcpiFADT = NULL;
|
||||
|
@ -33,10 +34,12 @@ SDTHeader *AcpiFADT = NULL;
|
|||
char IoACPIVersion = 1;
|
||||
int tableCount = 1;
|
||||
|
||||
extern MemoryMap_t memoryMap;
|
||||
|
||||
//
|
||||
// Returns the checksum of the given structure
|
||||
//
|
||||
static inline char DoChecksum(void *ptr, size_t size,
|
||||
static char DoChecksum(const void *ptr, const size_t size,
|
||||
size_t intermediateSize, ulong reason)
|
||||
{
|
||||
char checksum = 0;
|
||||
|
@ -140,14 +143,7 @@ static inline void IoInitRXSDT(void)
|
|||
|
||||
SDTHeader *rxsdt = AcpiSDT;
|
||||
|
||||
// Map the Table Header
|
||||
for (ulong i = 0; i < (sizeof(SDTHeader)/KPAGESIZE) + 1; i++) {
|
||||
MmMapPage((void*)((ulong)(rxsdt) + i*KPAGESIZE),
|
||||
(void*)((ulong)(rxsdt) + i*KPAGESIZE),
|
||||
PRESENT);
|
||||
}
|
||||
|
||||
// Checksum calculation
|
||||
/* // Checksum calculation */
|
||||
checksum = DoChecksum(rxsdt, (size_t)rxsdt->length,
|
||||
0,
|
||||
0
|
||||
|
@ -178,7 +174,31 @@ static inline void IoInitRXSDT(void)
|
|||
//
|
||||
static inline void IoSearchAcpiTables(void)
|
||||
{
|
||||
return;
|
||||
SDTHeader *xrsdt = AcpiSDT;
|
||||
SDTHeader *cur = NULL;
|
||||
SDTHeader *table = NULL;
|
||||
register char checksum;
|
||||
int entries;
|
||||
|
||||
if (IoACPIVersion == 1)
|
||||
entries = (xrsdt->length - sizeof(xrsdt)) / 4;
|
||||
else
|
||||
entries = (xrsdt->length - sizeof(xrsdt)) / 8;
|
||||
|
||||
KernLog("\tACPI detected %d entries\n", entries);
|
||||
|
||||
for (int i = 0; i < entries; i++) {
|
||||
|
||||
cur = (SDTHeader *)((ulong)&(xrsdt->sdtTablePtr));
|
||||
table = &cur[i];
|
||||
|
||||
// Checksum calculation
|
||||
//checksum = DoChecksum(table, (size_t)table->length, 0, 0);
|
||||
|
||||
//KernLog("Checksum : %d\n", (int)checksum);
|
||||
|
||||
KernLog("\tACPI System Table id %s [%p]\n", table->signature, table);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -195,9 +215,34 @@ void IoInitAcpi(void)
|
|||
if (BtFirmwareInfo.apmValid)
|
||||
KernLog("\tApm Table is valid at %p\n", BtFirmwareInfo.apmTable);
|
||||
|
||||
// FIND RSDP
|
||||
// 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
|
||||
for (uint j = 0;
|
||||
j < (memoryMap.entry[i].length
|
||||
+ ((ulong)memoryMap.entry[i].addr)
|
||||
- ((ulong)memoryMap.entry[i].addr
|
||||
& 0xFFFFFFFFFFFFF000))
|
||||
/ KPAGESIZE;
|
||||
j++) {
|
||||
MmMapPage(memoryMap.entry[i].addr + KPAGESIZE*j,
|
||||
memoryMap.entry[i].addr + KPAGESIZE*j,
|
||||
PRESENT);
|
||||
//KernLog("ACPI %d ID MAP %p\n", i,
|
||||
// memoryMap.entry[i].addr + KPAGESIZE*j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// FIND RSDP
|
||||
IoInitRSDP();
|
||||
|
||||
IoInitRXSDT();
|
||||
|
||||
IoSearchAcpiTables();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue