diff --git a/src/boot/boot.asm b/src/boot/boot.asm index e2b1679..a7943c2 100644 --- a/src/boot/boot.asm +++ b/src/boot/boot.asm @@ -164,7 +164,7 @@ p2_table: resb 4096 stack_bottom: - resb 64 + resb 4096 stack_top: diff --git a/src/lib.rs b/src/lib.rs index 03571a4..7bc92a5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,17 +1,20 @@ #![no_std] #![no_main] +use core::panic::PanicInfo; + #[panic_handler] -fn panic(_info: &core::panic::PanicInfo) -> ! { +fn panic_handler(info: &PanicInfo) -> ! { + println!("{}", info); loop {} } -use core::fmt::Write; mod vga; #[no_mangle] pub extern "C" fn julios_main() -> ! { - vga::WRITER.lock().write_str("Hello").unwrap(); - write!(vga::WRITER.lock(), " {}!\n{}", "World", "***JuliOS***").unwrap(); + println!("Hello World!"); + println!("{}", "***JuliOS***"); + panic!("Test panick"); loop {} } diff --git a/src/vga.rs b/src/vga.rs index c69de7e..aa171a2 100644 --- a/src/vga.rs +++ b/src/vga.rs @@ -1,5 +1,5 @@ use volatile::Volatile; -use core::fmt::{self, Write}; +use core::fmt; use lazy_static::lazy_static; use spin::Mutex; @@ -14,6 +14,24 @@ lazy_static! { }); } +#[macro_export] +macro_rules! print { + ($($arg:tt)*) => ($crate::vga::_print(format_args!($($arg)*))); +} + +#[macro_export] +macro_rules! println { + () => ($crate::print!("\n")); + ($($arg:tt)*) => ($crate::print!("{}\n", format_args!($($arg)*))); +} + +#[doc(hidden)] +pub fn _print(args: fmt::Arguments) { + use core::fmt::Write; + WRITER.lock().write_fmt(args).unwrap(); +} + + #[allow(dead_code)] #[derive(Debug, Clone, Copy, PartialEq, Eq)] #[repr(u8)]