rustos/src/main.rs
2025-03-28 19:20:59 -04:00

34 lines
832 B
Rust

#![no_std]
#![no_main]
#![feature(custom_test_frameworks)]
#![test_runner(rustos::test_runner)]
#![reexport_test_harness_main = "test_main"]
use core::panic::PanicInfo;
use rustos::println;
// 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
#[cfg(test)]
test_main();
println!("Hey, it didn't crash!");
rustos::hlt_loop();
}
// fn panic ::: prints panic message
// info: &PanicInfo :param: passed by panic_handler, includes panic information
#[panic_handler]
fn panic(info: &PanicInfo) -> ! {
#[cfg(test)]
rustos::test_panic_handler(info);
#[cfg(not(test))]
{
println!("{}", info);
rustos::hlt_loop();
};
}