commented, reformatted

This commit is contained in:
mtgmonkey 2025-03-28 19:20:59 -04:00
parent b4dab5c048
commit 723662b2a1
6 changed files with 127 additions and 67 deletions

View file

@ -7,21 +7,12 @@
use core::panic::PanicInfo;
use rustos::println;
// SAFETY: make sure no other global fn _start exists
// called on start
#[unsafe(no_mangle)]
// fn _start ::: called on start
#[unsafe(no_mangle)] // SAFETY: make sure no other global fn _start exists
pub extern "C" fn _start() -> ! {
println!("Hello World{}", "!");
rustos::init(); // initializes kernel
use x86_64::registers::control::Cr3;
let (level_4_page_table, _) = Cr3::read();
println!(
"Level 4 page table at: {:?}",
level_4_page_table.start_address()
);
#[cfg(test)]
test_main();
@ -29,19 +20,15 @@ pub extern "C" fn _start() -> ! {
rustos::hlt_loop();
}
// called on test panic
// prints to console error message
#[cfg(test)]
// fn panic ::: prints panic message
// info: &PanicInfo :param: passed by panic_handler, includes panic information
#[panic_handler]
fn panic(info: &PanicInfo) -> ! {
rustos::test_panic_handler(info)
}
// called on panic
// prints to vga error message
#[cfg(not(test))]
#[panic_handler]
fn panic(info: &PanicInfo) -> ! {
println!("{}", info);
rustos::hlt_loop();
#[cfg(test)]
rustos::test_panic_handler(info);
#[cfg(not(test))]
{
println!("{}", info);
rustos::hlt_loop();
};
}