Split crate into lib.rs and main.rs

This commit is contained in:
Philipp Oppermann
2019-01-25 13:44:04 +01:00
parent d007aae993
commit bd39105793
2 changed files with 12 additions and 15 deletions

11
src/lib.rs Normal file
View File

@@ -0,0 +1,11 @@
#![cfg_attr(not(test), no_std)]
pub mod serial;
pub mod vga_buffer;
pub unsafe fn exit_qemu() {
use x86_64::instructions::port::Port;
let mut port = Port::<u32>::new(0xf4);
port.write(0);
}

View File

@@ -2,31 +2,17 @@
#![cfg_attr(not(test), no_main)] #![cfg_attr(not(test), no_main)]
#![cfg_attr(test, allow(unused_imports))] #![cfg_attr(test, allow(unused_imports))]
use blog_os::println;
use core::panic::PanicInfo; use core::panic::PanicInfo;
mod serial;
mod vga_buffer;
#[cfg(not(test))] #[cfg(not(test))]
#[no_mangle] #[no_mangle]
pub extern "C" fn _start() -> ! { pub extern "C" fn _start() -> ! {
println!("Hello World{}", "!"); println!("Hello World{}", "!");
serial_println!("Hello Host{}", "!");
unsafe {
exit_qemu();
}
loop {} loop {}
} }
pub unsafe fn exit_qemu() {
use x86_64::instructions::port::Port;
let mut port = Port::<u32>::new(0xf4);
port.write(0);
}
/// This function is called on panic. /// This function is called on panic.
#[cfg(not(test))] #[cfg(not(test))]
#[panic_handler] #[panic_handler]