Megacommit to move some memory code into kernel crate

This commit is contained in:
2025-02-28 02:13:50 +00:00
parent 192100be7a
commit 92fe618a99
16 changed files with 106 additions and 323 deletions
+12 -13
View File
@@ -13,16 +13,14 @@
extern crate alloc;
use arch::x86_64::apic::enable_apic;
// use arch::x86_64::apic::enable_apic;
use core::arch::asm;
use libk::drivers::memory;
// use libk::drivers::mem::pmm;
use limine::BaseRevision;
use libk::drivers::kalloc::allocator::init_heap;
// use libk::drivers::alloc::allocator::init_heap;
use libk::prelude::*;
use x86_64::VirtAddr;
mod arch;
/// Sets the base revision to the latest revision supported by the crate.
@@ -58,9 +56,9 @@ pub fn boot() -> Result<(), &'static str> {
return Err("base revision not supported");
}
use arch::x86_64::{gdt, interrupts, memmap};
use arch::x86_64::{gdt, interrupts, mem::memmap};
let memory_map = memmap::get_memory_map();
let _memory_map = memmap::get_memory_map();
print_log!(" Initialising Serial... ");
if libk::drivers::io::serial::init().is_err() {
@@ -78,18 +76,19 @@ pub fn boot() -> Result<(), &'static str> {
println_log!("[Success]");
print_log!(" Initialising Memory Subsystem... ");
let physical_memory_offset = VirtAddr::new(*memmap::PHYSICAL_MEMORY_OFFSET);
let mut l4_table = memory::init_page_table(physical_memory_offset);
// let physical_memory_offset = VirtAddr::new(*memmap::PHYSICAL_MEMORY_OFFSET);
// pmm::init_page_table(physical_memory_offset);
println_log!("[Success]");
print_log!(" Setting Up Page Table... ");
memory::init_frame_allocator(memory_map);
// pmm::init_frame_allocator(memory_map);
println_log!("[Success]");
print_log!(" Initialising Heap... ");
if init_heap().is_err() {
return Err("Failed to initialise heap: error");
}
// TODO: Reenable the heap.
// if init_heap().is_err() {
// return Err("Failed to initialise heap: error");
// }
println_log!("[Success]");
print_log!(" Enabling PICs... ");