Start refactoring code. No rush to merge anything.
I will try to focus on getting things working, as simply as possible
This commit is contained in:
+2
-66
@@ -11,19 +11,12 @@
|
||||
rustdoc::missing_panics_doc
|
||||
)]
|
||||
|
||||
extern crate alloc;
|
||||
|
||||
use arch::x86_64::apic::enable_apic;
|
||||
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;
|
||||
mod graphics;
|
||||
mod io;
|
||||
|
||||
/// Sets the base revision to the latest revision supported by the crate.
|
||||
/// See specification for further info.
|
||||
@@ -35,20 +28,13 @@ static BASE_REVISION: BaseRevision = BaseRevision::new();
|
||||
|
||||
#[panic_handler]
|
||||
fn rust_panic(_info: &core::panic::PanicInfo) -> ! {
|
||||
println!("Kernel panic: {}", _info);
|
||||
serial_println!("Kernel panic: {}", _info);
|
||||
hcf();
|
||||
}
|
||||
|
||||
pub fn hcf() -> ! {
|
||||
loop {
|
||||
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,55 +44,5 @@ pub fn boot() -> Result<(), &'static str> {
|
||||
return Err("base revision not supported");
|
||||
}
|
||||
|
||||
use arch::x86_64::{gdt, interrupts, memmap};
|
||||
|
||||
let memory_map = memmap::get_memory_map();
|
||||
|
||||
print_log!(" Initialising Serial... ");
|
||||
if libk::drivers::io::serial::init().is_err() {
|
||||
println_log!("[Not Detected]")
|
||||
} else {
|
||||
println_log!("[Success]");
|
||||
}
|
||||
|
||||
print_log!(" Setting Up Global Descriptor Table... ");
|
||||
gdt::init();
|
||||
println_log!("[Success]");
|
||||
|
||||
print_log!(" Setting Up Interrupt Descriptor Table... ");
|
||||
interrupts::init_idt();
|
||||
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);
|
||||
println_log!("[Success]");
|
||||
|
||||
print_log!(" Setting Up Page Table... ");
|
||||
memory::init_frame_allocator(memory_map);
|
||||
println_log!("[Success]");
|
||||
|
||||
print_log!(" Initialising Heap... ");
|
||||
if init_heap().is_err() {
|
||||
return Err("Failed to initialise heap: error");
|
||||
}
|
||||
println_log!("[Success]");
|
||||
|
||||
print_log!(" Enabling PICs... ");
|
||||
interrupts::enable_pic();
|
||||
println_log!("[Success]");
|
||||
|
||||
// print_log!(" Disabling PICs... ");
|
||||
// interrupts::disable_pic();
|
||||
// println_log!("[Success]");
|
||||
|
||||
// print_log!(" Initialising APIC");
|
||||
// enable_apic();
|
||||
// println_log!("[Success]");
|
||||
|
||||
print_log!(" Enabling Interrupts... ");
|
||||
x86_64::instructions::interrupts::enable();
|
||||
println_log!("[Success]");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user