print out PCI tables
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
33
kernel/src/acpi.h
Normal file
33
kernel/src/acpi.h
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
namespace ACPI {
|
||||||
|
struct RSDP2 {
|
||||||
|
unsigned char Signature[8];
|
||||||
|
uint8_t Checksum;
|
||||||
|
uint8_t OEMID[6];
|
||||||
|
uint8_t Revision;
|
||||||
|
uint32_t RSDTAddress;
|
||||||
|
uint32_t Length;
|
||||||
|
uint64_t XSDTAddress;
|
||||||
|
uint8_t ExtendedChecksum;
|
||||||
|
uint8_t Reserved[3];
|
||||||
|
}__attribute__((packed));
|
||||||
|
|
||||||
|
struct SDTHeader {
|
||||||
|
unsigned char Signature[4];
|
||||||
|
uint32_t Length;
|
||||||
|
uint8_t Revision;
|
||||||
|
uint8_t Checksum;
|
||||||
|
uint8_t OEMID[6];
|
||||||
|
uint8_t OEMTableID[8];
|
||||||
|
uint32_t OEMRevision;
|
||||||
|
uint32_t CreatorID;
|
||||||
|
uint32_t CreatorRevision;
|
||||||
|
}__attribute__((packed));
|
||||||
|
|
||||||
|
struct MCFGHeader {
|
||||||
|
SDTHeader Header;
|
||||||
|
uint64_t Reserved;
|
||||||
|
}__attribute__((packed));
|
||||||
|
};
|
||||||
@@ -6,14 +6,6 @@ extern "C" void _start(BootInfo* bootInfo) {
|
|||||||
|
|
||||||
GlobalRenderer->Print(to_hstring((uint64_t)bootInfo->rsdp));
|
GlobalRenderer->Print(to_hstring((uint64_t)bootInfo->rsdp));
|
||||||
GlobalRenderer->Next();
|
GlobalRenderer->Next();
|
||||||
GlobalRenderer->PutChar(*(uint8_t*)bootInfo->rsdp);
|
|
||||||
GlobalRenderer->PutChar(*((uint8_t*)bootInfo->rsdp + 1));
|
|
||||||
GlobalRenderer->PutChar(*((uint8_t*)bootInfo->rsdp + 2));
|
|
||||||
GlobalRenderer->PutChar(*((uint8_t*)bootInfo->rsdp + 3));
|
|
||||||
GlobalRenderer->PutChar(*((uint8_t*)bootInfo->rsdp + 4));
|
|
||||||
GlobalRenderer->PutChar(*((uint8_t*)bootInfo->rsdp + 5));
|
|
||||||
GlobalRenderer->PutChar(*((uint8_t*)bootInfo->rsdp + 6));
|
|
||||||
GlobalRenderer->PutChar(*((uint8_t*)bootInfo->rsdp + 7));
|
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
ProcessMousePacket();
|
ProcessMousePacket();
|
||||||
|
|||||||
@@ -13,6 +13,9 @@ extern "C" void __stack_chk_fail(void) {
|
|||||||
KernelInfo kernelInfo;
|
KernelInfo kernelInfo;
|
||||||
PageTableManager pageTableManager = NULL;
|
PageTableManager pageTableManager = NULL;
|
||||||
void PrepareMemory(BootInfo* bootInfo){
|
void PrepareMemory(BootInfo* bootInfo){
|
||||||
|
GlobalRenderer->Print(" - Locking kernel pages...");
|
||||||
|
GlobalRenderer->Next();
|
||||||
|
|
||||||
uint64_t mMapEntries = bootInfo->mMapSize / bootInfo->mMapDescriptorSize;
|
uint64_t mMapEntries = bootInfo->mMapSize / bootInfo->mMapDescriptorSize;
|
||||||
|
|
||||||
GlobalAllocator = PageFrameAllocator();
|
GlobalAllocator = PageFrameAllocator();
|
||||||
@@ -23,6 +26,9 @@ void PrepareMemory(BootInfo* bootInfo){
|
|||||||
|
|
||||||
GlobalAllocator.LockPages(&_KernelStart, kernelPages);
|
GlobalAllocator.LockPages(&_KernelStart, kernelPages);
|
||||||
|
|
||||||
|
GlobalRenderer->Print(" - Setting up page table manager...");
|
||||||
|
GlobalRenderer->Next();
|
||||||
|
|
||||||
PageTable* PML4 = (PageTable*)GlobalAllocator.RequestPage();
|
PageTable* PML4 = (PageTable*)GlobalAllocator.RequestPage();
|
||||||
memset(PML4, 0, 0x1000);
|
memset(PML4, 0, 0x1000);
|
||||||
|
|
||||||
@@ -53,6 +59,21 @@ void SetIDTGate(void* handler, uint8_t entryOffset, uint8_t type_attr, uint8_t s
|
|||||||
interrupt->selector = selector;
|
interrupt->selector = selector;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PrepareACPI(BootInfo* bootInfo) {
|
||||||
|
ACPI::SDTHeader* xsdt = (ACPI::SDTHeader*)(bootInfo->rsdp->XSDTAddress);
|
||||||
|
|
||||||
|
int entries = (xsdt->Length - sizeof(ACPI::SDTHeader)) / 8;
|
||||||
|
for (int t = 0; t < entries; t++) {
|
||||||
|
ACPI::SDTHeader* newSDTHeader = (ACPI::SDTHeader*)*(uint64_t*)((uint64_t)xsdt + sizeof(ACPI::SDTHeader) + (t * 8));
|
||||||
|
for (int i = 0; i < 4; i++) {
|
||||||
|
GlobalRenderer->PutChar(newSDTHeader->Signature[i]);
|
||||||
|
}
|
||||||
|
GlobalRenderer->PutChar(' ');
|
||||||
|
}
|
||||||
|
|
||||||
|
GlobalRenderer->Next();
|
||||||
|
}
|
||||||
|
|
||||||
void PrepareInterrupts() {
|
void PrepareInterrupts() {
|
||||||
idtr.Limit = 0x0FFF;
|
idtr.Limit = 0x0FFF;
|
||||||
idtr.Offset = (uint64_t)GlobalAllocator.RequestPage();
|
idtr.Offset = (uint64_t)GlobalAllocator.RequestPage();
|
||||||
@@ -88,13 +109,11 @@ KernelInfo InitializeKernel(BootInfo* bootInfo){
|
|||||||
gdtDescriptor.Offset = (uint64_t)&DefaultGDT;
|
gdtDescriptor.Offset = (uint64_t)&DefaultGDT;
|
||||||
LoadGDT(&gdtDescriptor);
|
LoadGDT(&gdtDescriptor);
|
||||||
|
|
||||||
GlobalRenderer->Print("Preparing memory... (this doesn't always work, you may need to restart. sorry.)");
|
GlobalRenderer->Print("Preparing memory...");
|
||||||
GlobalRenderer->Next();
|
GlobalRenderer->Next();
|
||||||
|
|
||||||
PrepareMemory(bootInfo);
|
PrepareMemory(bootInfo);
|
||||||
|
|
||||||
//memset(bootInfo->framebuffer->BaseAddress, 0, bootInfo->framebuffer->BufferSize);
|
|
||||||
|
|
||||||
GlobalRenderer->Print("Setting up interrupts...");
|
GlobalRenderer->Print("Setting up interrupts...");
|
||||||
GlobalRenderer->Next();
|
GlobalRenderer->Next();
|
||||||
|
|
||||||
@@ -104,6 +123,10 @@ KernelInfo InitializeKernel(BootInfo* bootInfo){
|
|||||||
GlobalRenderer->Next();
|
GlobalRenderer->Next();
|
||||||
InitPS2Mouse();
|
InitPS2Mouse();
|
||||||
|
|
||||||
|
GlobalRenderer->Print("Setting up ACPI...");
|
||||||
|
GlobalRenderer->Next();
|
||||||
|
PrepareACPI(bootInfo);
|
||||||
|
|
||||||
outb(PIC1_DATA, 0b11111001); // unmask 2nd interrupt
|
outb(PIC1_DATA, 0b11111001); // unmask 2nd interrupt
|
||||||
outb(PIC2_DATA, 0b11101111);
|
outb(PIC2_DATA, 0b11101111);
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
#include "paging/paging.h"
|
#include "paging/paging.h"
|
||||||
#include "paging/PageTableManager.h"
|
#include "paging/PageTableManager.h"
|
||||||
#include "userinput/mouse.h"
|
#include "userinput/mouse.h"
|
||||||
|
#include "acpi.h"
|
||||||
|
|
||||||
struct BootInfo {
|
struct BootInfo {
|
||||||
Framebuffer* framebuffer;
|
Framebuffer* framebuffer;
|
||||||
@@ -19,7 +20,7 @@ struct BootInfo {
|
|||||||
EFI_MEMORY_DESCRIPTOR* mMap;
|
EFI_MEMORY_DESCRIPTOR* mMap;
|
||||||
uint64_t mMapSize;
|
uint64_t mMapSize;
|
||||||
uint64_t mMapDescriptorSize;
|
uint64_t mMapDescriptorSize;
|
||||||
void* rsdp;
|
ACPI::RSDP2* rsdp;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern uint64_t _KernelStart;
|
extern uint64_t _KernelStart;
|
||||||
|
|||||||
Reference in New Issue
Block a user