XeOS/src/main.rs

48 lines
971 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;
2019-10-24 15:24:17 +00:00
use alloc::string::ToString;
2019-10-24 00:30:47 +00:00
use bootloader::{entry_point, BootInfo};
2019-10-23 23:19:02 +00:00
use core::panic::PanicInfo;
2019-10-24 14:02:28 +00:00
use xe_os::println;
2019-10-23 23:19:02 +00:00
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
#[cfg(test)]
test_main();
2019-10-24 14:43:38 +00:00
// Read the rtc date time using this year
2019-10-24 15:24:17 +00:00
let now = xe_os::clock::current_time();
println!("{}", now.to_string());
2019-10-24 14:43:38 +00:00
2019-10-24 14:21:48 +00:00
println!("Running WASM:");
2019-10-24 02:45:19 +00:00
2019-10-24 13:43:00 +00:00
xe_os::wasm::run();
2019-10-24 14:21:48 +00:00
println!("[ ] success");
2019-10-24 14:43:38 +00:00
2019-10-23 23:36:24 +00:00
xe_os::hlt_loop();
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);
}