Merge into main the new state of the operating system/kernel #1
@ -16,16 +16,14 @@ void* memset (void* ptr, int value, size_t num)
|
||||
|
||||
int memcmp( const void* ptr1, const void* ptr2, size_t num)
|
||||
{
|
||||
const unsigned char * cs = (const unsigned char*) ptr1;
|
||||
const unsigned char * ct = (const unsigned char*) ptr2;
|
||||
auto* cs = (const unsigned char*) ptr1;
|
||||
auto* ct = (const unsigned char*) ptr2;
|
||||
|
||||
|
||||
for (int i = 0 ; i < num ; i++, cs++, ct++ ){
|
||||
if( *cs < *ct){
|
||||
return -1;
|
||||
} else if( *cs > *ct){
|
||||
return 1;
|
||||
}
|
||||
if( *cs != *ct)
|
||||
return *cs - *ct;
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "acpi.h"
|
||||
RSDPDescriptor* ACPI::rsd_ptr;
|
||||
RSCPDescriptor20* ACPI::rsd2_ptr;
|
||||
RSDT* ACPI::rsd_table;
|
||||
|
||||
|
||||
@ -8,19 +9,34 @@ void ACPI::initialize(){
|
||||
|
||||
// Find the Root System Description Pointer
|
||||
ACPI::rsd_ptr = FindRSD();
|
||||
printf("RSD address: 0x%x\n", ACPI::rsd_ptr);
|
||||
//printRSD(rsd_ptr);
|
||||
|
||||
// is it valid
|
||||
int sum = 0;
|
||||
for (int i =0; i < 20 ; i++) {
|
||||
|
||||
if( rsd_ptr->Revision == 0 ){
|
||||
// Using veriosn 1.0 of the ACPI specifiction
|
||||
int sum = rsd_ptr->Checksum;
|
||||
for (int i =0; i < sizeof(RSDPDescriptor) ; i++) {
|
||||
sum += ((char*)rsd_ptr)[i];
|
||||
}
|
||||
|
||||
printf(" 0x%x sum\n", sum);
|
||||
return;
|
||||
if(sum & 0xfff0)
|
||||
printf("valid rsd!\n");
|
||||
else
|
||||
printf("invalid rsd\n");
|
||||
|
||||
// Get the Root System Description Table
|
||||
RSDT* rootSystemDescriptionTable = getRSDT((RSDPDescriptor *) rsd_ptr);
|
||||
|
||||
// Get the Root System Description Table NOTE: might need memory mapping
|
||||
//RSDT* rootSystemDescriptionTable = (RSDT*) (rsd_ptr->RsdtAddress + 0xC0000000);
|
||||
} else{
|
||||
// parse it as of version2.0
|
||||
ACPI::rsd2_ptr = (RSCPDescriptor20*)rsd_ptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
auto tableHeader = &rootSystemDescriptionTable->h;
|
||||
|
||||
// do checksum
|
||||
@ -31,5 +47,5 @@ void ACPI::initialize(){
|
||||
}
|
||||
|
||||
if( sum != 0)
|
||||
printf("Table invalid!");
|
||||
printf("Table invalid!");*/
|
||||
}
|
@ -7,7 +7,8 @@ class ACPI {
|
||||
// In the future ACPI might start
|
||||
// doing more systems initialization
|
||||
|
||||
private:
|
||||
static RSDPDescriptor* rsd_ptr;
|
||||
static RSCPDescriptor20* rsd2_ptr;
|
||||
static RSDT* rsd_table;
|
||||
private:
|
||||
};
|
@ -1,5 +1,6 @@
|
||||
#include "rsdp.h"
|
||||
#include "../memory/VirtualMemoryManager.h"
|
||||
#include "../../CoreLib/Memory.h"
|
||||
|
||||
|
||||
void printRSD(RSDPDescriptor* rsd){
|
||||
@ -16,7 +17,6 @@ void printRSD(RSDPDescriptor* rsd){
|
||||
kterm_put('\n');
|
||||
|
||||
printf("Revision: %d\n", rsd->Revision);
|
||||
printf("RSDT Address: 0x%x\n", rsd->RsdtAddress );
|
||||
}
|
||||
|
||||
RSDPDescriptor* FindRSD(){
|
||||
@ -31,10 +31,3 @@ RSDPDescriptor* FindRSD(){
|
||||
}
|
||||
return (RSDPDescriptor*) memory_byte;
|
||||
}
|
||||
|
||||
|
||||
RSDT* getRSDT(RSDPDescriptor* rsd){
|
||||
printf("rsdt Address: 0x%x\n", rsd->RsdtAddress);
|
||||
return (RSDT*)rsd->RsdtAddress ;
|
||||
|
||||
}
|
@ -3,13 +3,6 @@
|
||||
#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];
|
||||
@ -28,6 +21,24 @@ struct RSDT{
|
||||
struct ACPISDTHeader h;
|
||||
uint32_t PointerToSDT[]; // Length of array : (header.Length - sizeof(header))/ 4
|
||||
}__attribute__((packed));
|
||||
|
||||
|
||||
struct RSDPDescriptor {
|
||||
char signature[8];
|
||||
uint8_t Checksum ;
|
||||
char OEMID [6];
|
||||
uint8_t Revision;
|
||||
RSDT* RsdtAddress;
|
||||
}__attribute__((packed));
|
||||
|
||||
struct RSCPDescriptor20{
|
||||
RSDPDescriptor base;
|
||||
uint32_t Length;
|
||||
uint64_t XsdtAddress;
|
||||
uint8_t ExtendedChecksum;
|
||||
uint8_t reserved[3];
|
||||
}__attribute__((packed));
|
||||
|
||||
RSDPDescriptor* FindRSD();
|
||||
|
||||
void printRSD(RSDPDescriptor* rsd);
|
||||
|
Loading…
Reference in New Issue
Block a user