stuff
This commit is contained in:
parent
97aef95daa
commit
1820286d8b
10
kernel/include/log/Address.h
Normal file
10
kernel/include/log/Address.h
Normal file
@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
#include "log/Log.h"
|
||||
#include "std/stdio.h"
|
||||
#include <stdint.h>
|
||||
|
||||
// clang-format off
|
||||
|
||||
#define kinfoptr(pointer) char result##pointer[40 + sizeof(#pointer)]; snprintf(result##pointer, sizeof result##pointer, "%s points to 0x%zx\n", #pointer, (uint64_t)pointer); kinfo(result##pointer)
|
||||
|
||||
// clang-format on
|
@ -6,6 +6,9 @@ namespace KernelMemoryManager
|
||||
void* get_mapping(void* physicalAddress);
|
||||
void release_mapping(void* mapping);
|
||||
|
||||
void* get_unaligned_mapping(void* physicalAddress);
|
||||
void release_unaligned_mapping(void* mapping);
|
||||
|
||||
void* get_page();
|
||||
void* get_pages(uint64_t count);
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
#include "acpi/RSDT.h"
|
||||
#include "bootboot.h"
|
||||
#include "log/Address.h"
|
||||
#include "memory/KernelMemoryManager.h"
|
||||
#include "std/stdio.h"
|
||||
#include "std/string.h"
|
||||
|
||||
@ -24,7 +26,9 @@ void* ACPI::FindTable(ACPI::SDTHeader* rootSDT, const char* signature)
|
||||
uint32_t entry = ((RSDT*)rootSDT)->PointerToOtherSDT[i];
|
||||
h = (SDTHeader*)(uint64_t)entry;
|
||||
}
|
||||
SDTHeader* realHeader = (SDTHeader*)KernelMemoryManager::get_unaligned_mapping(h);
|
||||
if (strncmp(h->Signature, signature, 4) == 0) return (void*)h;
|
||||
KernelMemoryManager::release_unaligned_mapping(realHeader);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "interrupts/Interrupts.h"
|
||||
#include "io/PIC.h"
|
||||
#include "io/Serial.h"
|
||||
#include "log/Address.h"
|
||||
#include "log/Log.h"
|
||||
#include "memory/KernelHeap.h"
|
||||
#include "memory/KernelMemoryManager.h"
|
||||
@ -76,7 +77,7 @@ extern "C" void _start()
|
||||
kinfoln("Interrupts enabled");
|
||||
|
||||
Debug::DebugStatus::the()->StartBootStage(Color{0x33, 0x33, 0x00, 0xFF});
|
||||
ACPI::SDTHeader* rootSDT = ACPI::GetRSDTOrXSDT();
|
||||
ACPI::SDTHeader* rootSDT = (ACPI::SDTHeader*)KernelMemoryManager::get_unaligned_mapping(ACPI::GetRSDTOrXSDT());
|
||||
bool isXSDT = false;
|
||||
if (strncmp(rootSDT->Signature, "XSDT", 4) != 0)
|
||||
{
|
||||
@ -130,8 +131,17 @@ extern "C" void _start()
|
||||
}
|
||||
}
|
||||
|
||||
sleep(2500);
|
||||
shutdown();
|
||||
ACPI::SDTHeader* madt = (ACPI::SDTHeader*)ACPI::FindTable(rootSDT, "APIC");
|
||||
if (!madt)
|
||||
{
|
||||
kerrorln("MADT not found");
|
||||
while (1) halt();
|
||||
}
|
||||
|
||||
KernelMemoryManager::release_unaligned_mapping(rootSDT);
|
||||
|
||||
/*sleep(2500);
|
||||
shutdown();*/
|
||||
|
||||
while (1) halt();
|
||||
loop:
|
||||
|
@ -11,6 +11,20 @@ void* KernelMemoryManager::get_mapping(void* physicalAddress)
|
||||
return (void*)virtualAddress;
|
||||
}
|
||||
|
||||
void* KernelMemoryManager::get_unaligned_mapping(void* physicalAddress)
|
||||
{
|
||||
uint64_t offset = (uint64_t)physicalAddress % 4096;
|
||||
uint64_t virtualAddress = KernelHeap::request_virtual_page();
|
||||
kernelVMM.map(virtualAddress, (uint64_t)physicalAddress - offset);
|
||||
return (void*)(virtualAddress + offset);
|
||||
}
|
||||
|
||||
void KernelMemoryManager::release_unaligned_mapping(void* mapping)
|
||||
{
|
||||
uint64_t offset = (uint64_t)mapping % 4096;
|
||||
kernelVMM.unmap((uint64_t)mapping - offset);
|
||||
}
|
||||
|
||||
void KernelMemoryManager::release_mapping(void* mapping)
|
||||
{
|
||||
kernelVMM.unmap((uint64_t)mapping);
|
||||
|
@ -5,4 +5,4 @@ source $(dirname $0)/env.sh
|
||||
|
||||
tools/build-iso.sh
|
||||
|
||||
qemu-system-x86_64 -cdrom Luna.iso -smp 1 -m 256M -serial stdio -d int,cpu_reset -s -no-reboot
|
||||
qemu-system-x86_64 -cdrom Luna.iso -smp 1 -m 256M -serial stdio -d int,cpu_reset -s -no-reboot $@
|
@ -5,4 +5,4 @@ source $(dirname $0)/env.sh
|
||||
|
||||
tools/rebuild-iso.sh
|
||||
|
||||
qemu-system-x86_64 -cdrom Luna.iso -smp 1 -m 256M -serial stdio -enable-kvm
|
||||
qemu-system-x86_64 -cdrom Luna.iso -smp 1 -m 256M -serial stdio -enable-kvm $@
|
@ -5,4 +5,4 @@ source $(dirname $0)/env.sh
|
||||
|
||||
tools/build-iso.sh
|
||||
|
||||
qemu-system-x86_64 -cdrom Luna.iso -smp 1 -m 256M -serial stdio -enable-kvm
|
||||
qemu-system-x86_64 -cdrom Luna.iso -smp 1 -m 256M -serial stdio -enable-kvm $@
|
Loading…
Reference in New Issue
Block a user