Merge into main the new state of the operating system/kernel #1
							
								
								
									
										46
									
								
								src/kernel/drivers/rsdp/rsdp.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								src/kernel/drivers/rsdp/rsdp.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,46 @@
 | 
			
		||||
#include "rsdp.h"
 | 
			
		||||
 | 
			
		||||
void printRSD(RSDPTR* 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 );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
RSDPTR* FindRSD(){
 | 
			
		||||
    char* memory_byte = (char*) 0x000f2e14;
 | 
			
		||||
    const void* string = "RSD PTR ";
 | 
			
		||||
 | 
			
		||||
    for( ; (uint32_t) memory_byte < 0x0100000; memory_byte+=10){
 | 
			
		||||
        if( memcmp(memory_byte , string , 8 ) ==  0 ) {
 | 
			
		||||
        printf("RSD PTR found at 0x%x !\n", memory_byte);
 | 
			
		||||
        break;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    printRSD((RSDPTR*) memory_byte);
 | 
			
		||||
    return (RSDPTR*) memory_byte;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
RSDT* getRSDT(RSDPTR* rsd){
 | 
			
		||||
 | 
			
		||||
        RSDT* rsdt = (RSDT*) rsd->RsdtAddress;
 | 
			
		||||
 | 
			
		||||
        printf("OEMID: ");
 | 
			
		||||
        for(int i = 0; i < 6; i++){
 | 
			
		||||
            kterm_put(rsdt->header.OEMID[i]);
 | 
			
		||||
        }
 | 
			
		||||
        kterm_put('\n');
 | 
			
		||||
        return rsdt;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										36
									
								
								src/kernel/drivers/rsdp/rsdp.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								src/kernel/drivers/rsdp/rsdp.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,36 @@
 | 
			
		||||
#pragma once
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
#include "./../../tty/kterm.h"
 | 
			
		||||
#include "../../../libc/include/mem.h"
 | 
			
		||||
struct RSDPTR {
 | 
			
		||||
    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 CheckSum;
 | 
			
		||||
    char OEMID[6];
 | 
			
		||||
    char OEMTableID[8];
 | 
			
		||||
    uint32_t OEMRevision;
 | 
			
		||||
    uint32_t CreatorID;
 | 
			
		||||
    uint32_t CreatorRevision;
 | 
			
		||||
}__attribute__((packed));
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
struct RSDT{
 | 
			
		||||
    struct ACPISDTHeader header;
 | 
			
		||||
    uint32_t PointerToSDT[]; // Length of array : (header.Length - sizeof(header))/ 4
 | 
			
		||||
}__attribute__((packed));
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
//NOTE: only scans EBDA enough to find RSD PTR in QEMU
 | 
			
		||||
RSDPTR* FindRSD();
 | 
			
		||||
 | 
			
		||||
void printRSD(RSDPTR* rsd);
 | 
			
		||||
 | 
			
		||||
RSDT* getRSDT(RSDPTR* rsd);
 | 
			
		||||
		Reference in New Issue
	
	Block a user