initial commit
This commit is contained in:
commit
b4dab5c048
16 changed files with 838 additions and 0 deletions
47
src/main.rs
Normal file
47
src/main.rs
Normal file
|
@ -0,0 +1,47 @@
|
|||
#![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;
|
||||
|
||||
// SAFETY: make sure no other global fn _start exists
|
||||
// called on start
|
||||
#[unsafe(no_mangle)]
|
||||
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();
|
||||
|
||||
println!("Hey, it didn't crash!");
|
||||
rustos::hlt_loop();
|
||||
}
|
||||
|
||||
// called on test panic
|
||||
// prints to console error message
|
||||
#[cfg(test)]
|
||||
#[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();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue