//! # Kernel //! //! Kernel Start #![no_std] // don't link the Rust standard library #![no_main] // disable all Rust-level entry points #![feature(const_mut_refs)] #![feature(custom_test_frameworks)] #![test_runner(crate::test_runner)] #![reexport_test_harness_main = "test_main"] mod serial; mod sync; mod tests; mod vga; use core::panic::PanicInfo; use serial::*; use vga::*; #[cfg(test)] mod qemu; #[cfg(test)] use qemu::*; #[cfg(test)] use tests::*; /// This function is called on panic. #[cfg(test)] #[panic_handler] fn panic(info: &PanicInfo) -> ! { serial_println!("[failed]\n"); serial_println!("Error: {}\n", info); exit_qemu(QemuExitCode::Failed); loop {} } /// This function is called on panic. #[cfg(not(test))] #[panic_handler] fn panic(info: &PanicInfo) -> ! { println!("{}", info); loop {} } /// # Initialization /// /// Provides serial and VGA initialization. fn kernel_init() { WRITER.init(); SERIAL1.init(); } /// # x86_64 Kernel #[no_mangle] pub extern "C" fn _start() -> ! { kernel_init(); #[cfg(not(test))] { println!("{}", 5); } #[cfg(test)] test_main(); loop {} }