Merge into main the new state of the operating system/kernel #1
@ -1,20 +1,22 @@
|
|||||||
#include "acpi.h"
|
#include "acpi.h"
|
||||||
|
#include "../../CoreLib/Memory.h"
|
||||||
|
#include "../memory/VirtualMemoryManager.h"
|
||||||
|
|
||||||
RSDPDescriptor* ACPI::rsd_ptr;
|
RSDPDescriptor* ACPI::rsd_ptr;
|
||||||
RSCPDescriptor20* ACPI::rsd2_ptr;
|
RSCPDescriptor20* ACPI::rsd2_ptr;
|
||||||
RSDT* ACPI::rsd_table;
|
RSDT* ACPI::rsd_table;
|
||||||
|
|
||||||
|
const int KERNEL_OFFSET = 0xC0000000;
|
||||||
|
|
||||||
void ACPI::initialize(){
|
void ACPI::initialize(){
|
||||||
|
|
||||||
// Find the Root System Description Pointer
|
// Find the Root System Description Pointer
|
||||||
ACPI::rsd_ptr = FindRSD();
|
ACPI::rsd_ptr = FindRSD();
|
||||||
printf("RSD address: 0x%x\n", ACPI::rsd_ptr);
|
printf("RSD address: 0x%x\n", ACPI::rsd_ptr);
|
||||||
//printRSD(rsd_ptr);
|
printRSD(rsd_ptr);
|
||||||
|
|
||||||
|
|
||||||
if( rsd_ptr->Revision == 0 ){
|
if( rsd_ptr->Revision == 0 ){
|
||||||
// Using veriosn 1.0 of the ACPI specifiction
|
// Using version 1.0 of the ACPI specification
|
||||||
int sum = rsd_ptr->Checksum;
|
int sum = rsd_ptr->Checksum;
|
||||||
for (int i =0; i < sizeof(RSDPDescriptor) ; i++) {
|
for (int i =0; i < sizeof(RSDPDescriptor) ; i++) {
|
||||||
sum += ((char*)rsd_ptr)[i];
|
sum += ((char*)rsd_ptr)[i];
|
||||||
@ -26,11 +28,34 @@ void ACPI::initialize(){
|
|||||||
else
|
else
|
||||||
printf("invalid rsd\n");
|
printf("invalid rsd\n");
|
||||||
|
|
||||||
|
printf("rsdp: 0x%x\n", rsd_ptr);
|
||||||
|
|
||||||
|
printf("0x%x address\n", (rsd_ptr->RsdtAddress));
|
||||||
|
Immediate_Map(rsd_ptr->RsdtAddress + KERNEL_OFFSET, rsd_ptr->RsdtAddress);
|
||||||
|
|
||||||
|
RSDT* rootSystemDescriptionTable = (RSDT*)(rsd_ptr->RsdtAddress + KERNEL_OFFSET);
|
||||||
|
//printf("0x%x Root System Descriptor address\n", rootSystemDescriptionTable);
|
||||||
|
// checksum it, but we'll ignore it for now
|
||||||
|
printf("signature ");
|
||||||
|
for (int i = 0; i < 4; i++) {
|
||||||
|
kterm_put( rootSystemDescriptionTable->h.Signature[i]);
|
||||||
|
}
|
||||||
|
kterm_put('\n');
|
||||||
|
|
||||||
|
|
||||||
|
int entries = (rootSystemDescriptionTable->h.Length - sizeof (rootSystemDescriptionTable->h)) /4;
|
||||||
|
printf("%d num entries\n", entries);
|
||||||
|
for( int i = 0; i < entries; i++){
|
||||||
|
ACPISDTHeader* h = (ACPISDTHeader*) rootSystemDescriptionTable->PointerToSDT + i ;
|
||||||
|
if(strncmp(h->Signature, "FACP", 4)){
|
||||||
|
printf("Found FACP Entry!\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Get the Root System Description Table NOTE: might need memory mapping
|
|
||||||
//RSDT* rootSystemDescriptionTable = (RSDT*) (rsd_ptr->RsdtAddress + 0xC0000000);
|
|
||||||
} else{
|
} else{
|
||||||
// parse it as of version2.0
|
// parse it as of version2.0
|
||||||
|
printf("rsd2_ptr\n");
|
||||||
ACPI::rsd2_ptr = (RSCPDescriptor20*)rsd_ptr;
|
ACPI::rsd2_ptr = (RSCPDescriptor20*)rsd_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,11 +23,22 @@ RSDPDescriptor* FindRSD(){
|
|||||||
char* memory_byte = (char*) 0x000f2e14;
|
char* memory_byte = (char*) 0x000f2e14;
|
||||||
const void* string = "RSD PTR ";
|
const void* string = "RSD PTR ";
|
||||||
|
|
||||||
for( ; (uint32_t) memory_byte < 0x00100000; memory_byte+=10){
|
|
||||||
|
for( ; (uint32_t) memory_byte < 0x0100000; memory_byte+=10){
|
||||||
if( memcmp(memory_byte , string , 8 ) == 0 ) {
|
if( memcmp(memory_byte , string , 8 ) == 0 ) {
|
||||||
printf("RSD PTR found at 0x%x !\n", memory_byte);
|
printf("RSD PTR found at 0x%x !\n", memory_byte);
|
||||||
|
return (RSDPDescriptor*) memory_byte;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (RSDPDescriptor*) memory_byte;
|
|
||||||
|
memory_byte = (char*) 0x000E0000;
|
||||||
|
for ( ;(uint32_t) memory_byte < 0x000FFFFF; memory_byte += 1)
|
||||||
|
{
|
||||||
|
if( memcmp(memory_byte , string , 8 ) == 0 ) {
|
||||||
|
printf("RSD PTR found at 0x%x !\n", memory_byte);
|
||||||
|
return (RSDPDescriptor*) memory_byte;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,10 +16,9 @@ struct ACPISDTHeader{
|
|||||||
uint32_t CreatorRevision;
|
uint32_t CreatorRevision;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct RSDT{
|
struct RSDT{
|
||||||
struct ACPISDTHeader h;
|
struct ACPISDTHeader h;
|
||||||
uint32_t PointerToSDT[]; // Length of array : (header.Length - sizeof(header))/ 4
|
uint32_t *PointerToSDT; // Length of array : (header.Length - sizeof(header))/ 4
|
||||||
}__attribute__((packed));
|
}__attribute__((packed));
|
||||||
|
|
||||||
|
|
||||||
@ -28,7 +27,7 @@ struct RSDPDescriptor {
|
|||||||
uint8_t Checksum ;
|
uint8_t Checksum ;
|
||||||
char OEMID [6];
|
char OEMID [6];
|
||||||
uint8_t Revision;
|
uint8_t Revision;
|
||||||
RSDT* RsdtAddress;
|
uint32_t RsdtAddress;
|
||||||
}__attribute__((packed));
|
}__attribute__((packed));
|
||||||
|
|
||||||
struct RSCPDescriptor20{
|
struct RSCPDescriptor20{
|
||||||
|
Loading…
Reference in New Issue
Block a user