54 lines
1.2 KiB
Rust
54 lines
1.2 KiB
Rust
#![no_std]
|
|
#![no_main]
|
|
#![feature(custom_test_frameworks)]
|
|
#![test_runner(xe_os::test_runner)]
|
|
#![reexport_test_harness_main = "test_main"]
|
|
|
|
extern crate alloc;
|
|
|
|
use bootloader::{entry_point, BootInfo};
|
|
use core::panic::PanicInfo;
|
|
use xe_os::println;
|
|
|
|
entry_point!(kernel_main);
|
|
|
|
fn kernel_main(boot_info: &'static BootInfo) -> ! {
|
|
use cmos::{CMOSCenturyHandler, CMOS};
|
|
// Create a CMOS object (unsafe due to the use of port I/O)
|
|
let mut cmos = unsafe { CMOS::new() };
|
|
|
|
xe_os::init(&boot_info);
|
|
|
|
#[cfg(test)]
|
|
test_main();
|
|
|
|
// Read the rtc date time using this year
|
|
let rtc = cmos.read_rtc(CMOSCenturyHandler::CurrentYear(2019));
|
|
println!(
|
|
"current time: {}:{}:{} {} M{} {}",
|
|
rtc.hour, rtc.minute, rtc.second, rtc.year, rtc.month, rtc.day
|
|
);
|
|
|
|
println!("Running WASM:");
|
|
|
|
xe_os::wasm::run();
|
|
println!("[ ] success");
|
|
|
|
xe_os::hlt_loop();
|
|
}
|
|
|
|
// our existing panic handler
|
|
#[cfg(not(test))] // new attribute
|
|
#[panic_handler]
|
|
fn panic(info: &PanicInfo) -> ! {
|
|
println!("{}", info);
|
|
xe_os::hlt_loop();
|
|
}
|
|
|
|
// our panic handler in test mode
|
|
#[cfg(test)]
|
|
#[panic_handler]
|
|
fn panic(info: &PanicInfo) -> ! {
|
|
xe_os::test_panic_handler(info);
|
|
}
|