Started fleshing out the storage API
This commit is contained in:
35
kernel/acpi/acpi.cpp
Normal file
35
kernel/acpi/acpi.cpp
Normal file
@ -0,0 +1,35 @@
|
||||
#include "acpi.h"
|
||||
RSDPDescriptor* ACPI::rsd_ptr;
|
||||
RSDT* ACPI::rsd_table;
|
||||
|
||||
|
||||
|
||||
void ACPI::initialize(){
|
||||
|
||||
// Find the Root System Description Pointer
|
||||
ACPI::rsd_ptr = FindRSD();
|
||||
|
||||
// is it valid
|
||||
int sum = 0;
|
||||
for (int i =0; i < 20 ; i++) {
|
||||
sum += ((char*)rsd_ptr)[i];
|
||||
}
|
||||
|
||||
printf(" 0x%x sum\n", sum);
|
||||
return;
|
||||
|
||||
// Get the Root System Description Table
|
||||
RSDT* rootSystemDescriptionTable = getRSDT((RSDPDescriptor *) rsd_ptr);
|
||||
|
||||
auto tableHeader = &rootSystemDescriptionTable->h;
|
||||
|
||||
// do checksum
|
||||
sum = 0;
|
||||
|
||||
for(int i = 0; i < tableHeader->Length; i ++) {
|
||||
sum += ((char*) tableHeader)[i];
|
||||
}
|
||||
|
||||
if( sum != 0)
|
||||
printf("Table invalid!");
|
||||
}
|
13
kernel/acpi/acpi.h
Normal file
13
kernel/acpi/acpi.h
Normal file
@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
#include "rsdp.h"
|
||||
class ACPI {
|
||||
public:
|
||||
static void initialize();
|
||||
|
||||
// In the future ACPI might start
|
||||
// doing more systems initialization
|
||||
|
||||
private:
|
||||
static RSDPDescriptor* rsd_ptr;
|
||||
static RSDT* rsd_table;
|
||||
};
|
40
kernel/acpi/rsdp.cpp
Normal file
40
kernel/acpi/rsdp.cpp
Normal file
@ -0,0 +1,40 @@
|
||||
#include "rsdp.h"
|
||||
#include "../memory/VirtualMemoryManager.h"
|
||||
|
||||
|
||||
void printRSD(RSDPDescriptor* rsd){
|
||||
printf("Signature: ");
|
||||
for(int i = 0; i < 8; i++){
|
||||
kterm_put(rsd->signature[i]);
|
||||
}
|
||||
kterm_put('\n');
|
||||
|
||||
printf("OEMID: ");
|
||||
for(int i =0; i < 6 ; i++){
|
||||
kterm_put (rsd->OEMID[i]);
|
||||
}
|
||||
kterm_put('\n');
|
||||
|
||||
printf("Revision: %d\n", rsd->Revision);
|
||||
printf("RSDT Address: 0x%x\n", rsd->RsdtAddress );
|
||||
}
|
||||
|
||||
RSDPDescriptor* FindRSD(){
|
||||
char* memory_byte = (char*) 0x000f2e14;
|
||||
const void* string = "RSD PTR ";
|
||||
|
||||
for( ; (uint32_t) memory_byte < 0x00100000; memory_byte+=10){
|
||||
if( memcmp(memory_byte , string , 8 ) == 0 ) {
|
||||
printf("RSD PTR found at 0x%x !\n", memory_byte);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return (RSDPDescriptor*) memory_byte;
|
||||
}
|
||||
|
||||
|
||||
RSDT* getRSDT(RSDPDescriptor* rsd){
|
||||
printf("rsdt Address: 0x%x\n", rsd->RsdtAddress);
|
||||
return (RSDT*)rsd->RsdtAddress ;
|
||||
|
||||
}
|
35
kernel/acpi/rsdp.h
Normal file
35
kernel/acpi/rsdp.h
Normal file
@ -0,0 +1,35 @@
|
||||
#pragma once
|
||||
#include "../terminal/kterm.h"
|
||||
#include <CoreLib/Memory.h>
|
||||
#include <stdint-gcc.h>
|
||||
|
||||
struct RSDPDescriptor {
|
||||
char signature[8];
|
||||
uint8_t Checksum ;
|
||||
char OEMID [6];
|
||||
uint8_t Revision;
|
||||
uint32_t RsdtAddress;
|
||||
}__attribute__((packed));
|
||||
|
||||
struct ACPISDTHeader{
|
||||
char Signature[4];
|
||||
uint32_t Length;
|
||||
uint8_t Revision;
|
||||
uint8_t CheckSum;
|
||||
char OEMID[6];
|
||||
char OEMTableID[8];
|
||||
uint32_t OEMRevision;
|
||||
uint32_t CreatorID;
|
||||
uint32_t CreatorRevision;
|
||||
};
|
||||
|
||||
|
||||
struct RSDT{
|
||||
struct ACPISDTHeader h;
|
||||
uint32_t PointerToSDT[]; // Length of array : (header.Length - sizeof(header))/ 4
|
||||
}__attribute__((packed));
|
||||
RSDPDescriptor* FindRSD();
|
||||
|
||||
void printRSD(RSDPDescriptor* rsd);
|
||||
|
||||
RSDT* getRSDT(RSDPDescriptor* rsd);
|
Reference in New Issue
Block a user