XeOS/src/main.rs

45 lines
891 B
Rust
Raw Normal View History

2019-10-23 23:19:02 +00:00
#![no_std]
#![no_main]
#![feature(custom_test_frameworks)]
#![test_runner(xe_os::test_runner)]
#![reexport_test_harness_main = "test_main"]
2019-10-24 00:30:47 +00:00
extern crate alloc;
use alloc::boxed::Box;
use bootloader::{entry_point, BootInfo};
2019-10-23 23:19:02 +00:00
use core::panic::PanicInfo;
use xe_os::println;
2019-10-24 00:30:47 +00:00
entry_point!(kernel_main);
fn kernel_main(boot_info: &'static BootInfo) -> ! {
xe_os::init(&boot_info);
2019-10-23 23:19:02 +00:00
println!("Hello World{}", "!");
#[cfg(test)]
test_main();
println!("It did not crash!");
2019-10-23 23:36:24 +00:00
xe_os::hlt_loop();
2019-10-23 23:19:02 +00:00
}
2019-10-24 01:10:36 +00:00
fn run_wasm() {
let bytes = include_bytes!("../data/h.wasm");
}
2019-10-23 23:19:02 +00:00
// our existing panic handler
#[cfg(not(test))] // new attribute
#[panic_handler]
fn panic(info: &PanicInfo) -> ! {
println!("{}", info);
2019-10-23 23:36:24 +00:00
xe_os::hlt_loop();
2019-10-23 23:19:02 +00:00
}
// our panic handler in test mode
#[cfg(test)]
#[panic_handler]
fn panic(info: &PanicInfo) -> ! {
xe_os::test_panic_handler(info);
}