refactor mega-commit.
- reorganised the entire project so that the entire kernel is a single codebase rather than a kernel and a libk.
This commit is contained in:
+23
-19
@@ -12,18 +12,26 @@
|
||||
)]
|
||||
|
||||
extern crate alloc;
|
||||
|
||||
use arch::x86_64::apic::enable_apic;
|
||||
use crate::prelude::*;
|
||||
use crate::arch::x86_64::memory::memory::{init_frame_allocator, init_page_table};
|
||||
use arch::x86_64::memory::allocation::allocator::init_heap;
|
||||
use arch::x86_64::memory::memory_map;
|
||||
use core::arch::asm;
|
||||
use libk::drivers::memory;
|
||||
use limine::BaseRevision;
|
||||
|
||||
use libk::drivers::kalloc::allocator::init_heap;
|
||||
use libk::prelude::*;
|
||||
|
||||
use x86_64::VirtAddr;
|
||||
|
||||
mod arch;
|
||||
pub mod arch;
|
||||
pub mod resources;
|
||||
#[allow(unused)] // We aren't using much of this right now.
|
||||
pub mod std;
|
||||
pub mod util;
|
||||
|
||||
pub mod prelude {
|
||||
pub use crate::std::io::{
|
||||
_print, _print_log, _serial_write
|
||||
};
|
||||
pub use crate::{print, println, print_log, println_log, printerr, printlnerr, serial_print, serial_println};
|
||||
}
|
||||
|
||||
/// Sets the base revision to the latest revision supported by the crate.
|
||||
/// See specification for further info.
|
||||
@@ -45,10 +53,6 @@ pub fn hcf() -> ! {
|
||||
unsafe {
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
asm!("hlt");
|
||||
#[cfg(any(target_arch = "aarch64", target_arch = "riscv64"))]
|
||||
asm!("wfi");
|
||||
#[cfg(target_arch = "loongarch64")]
|
||||
asm!("idle 0");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -58,12 +62,12 @@ 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};
|
||||
|
||||
let memory_map = memmap::get_memory_map();
|
||||
let memory_map = memory_map::get_memory_map();
|
||||
|
||||
print_log!(" Initialising Serial... ");
|
||||
if libk::drivers::io::serial::init().is_err() {
|
||||
if arch::x86_64::drivers::serial::init().is_err() {
|
||||
println_log!("[Not Detected]")
|
||||
} else {
|
||||
println_log!("[Success]");
|
||||
@@ -78,16 +82,16 @@ pub fn boot() -> Result<(), &'static str> {
|
||||
println_log!("[Success]");
|
||||
|
||||
print_log!(" Initialising Memory Subsystem... ");
|
||||
let physical_memory_offset = VirtAddr::new(*memmap::PHYSICAL_MEMORY_OFFSET);
|
||||
memory::init_page_table(physical_memory_offset);
|
||||
let physical_memory_offset = VirtAddr::new(*memory_map::PHYSICAL_MEMORY_OFFSET);
|
||||
init_page_table(physical_memory_offset);
|
||||
println_log!("[Success]");
|
||||
|
||||
print_log!(" Setting Up Page Table... ");
|
||||
memory::init_frame_allocator(memory_map);
|
||||
init_frame_allocator(memory_map);
|
||||
println_log!("[Success]");
|
||||
|
||||
print_log!(" Initialising Heap... ");
|
||||
if init_heap().is_err() {
|
||||
if unsafe { init_heap() }.is_err() {
|
||||
return Err("Failed to initialise heap: error");
|
||||
}
|
||||
println_log!("[Success]");
|
||||
|
||||
Reference in New Issue
Block a user