mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-16 14:27:49 +00:00
Split crate into lib.rs and main.rs
This commit is contained in:
11
src/lib.rs
Normal file
11
src/lib.rs
Normal 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);
|
||||||
|
}
|
||||||
16
src/main.rs
16
src/main.rs
@@ -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]
|
||||||
|
|||||||
Reference in New Issue
Block a user