diff --git a/src/main.rs b/src/main.rs index 0996381..84561a6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -14,7 +14,7 @@ use popcorn::{ hlt_loop, init, low_level::vga_buffer::{clear_screen, Color}, print_with_colors, println, - userspace::output::MessageToVga, + userspace::output::MessageToVga, log, warn, error, }; entry_point!(kernel_main); @@ -26,7 +26,9 @@ fn kernel_main(boot_info: &'static BootInfo) -> ! { MessageToVga::new(Color::LightBlue, Color::Black, "Popcorn Kernel!") ); println!(); //Newline being other than black and white caused a bug with the cursor + log!("Initializing..."); init(boot_info); + log!("Initialized!"); hlt_loop(); } diff --git a/src/userspace/output.rs b/src/userspace/output.rs index b65d794..dbc5f0c 100644 --- a/src/userspace/output.rs +++ b/src/userspace/output.rs @@ -21,6 +21,49 @@ macro_rules! println { () => ($crate::print!("\n")); ($($arg:tt)*) => ($crate::print!("{}\n", format_args!($($arg)*))); } + +/// log!("text") - this will get the file that called this, and say it as [file_name] +#[macro_export] +macro_rules! log { + ($($arg:tt)*) => ( + $crate::print_with_colors!( + $crate::userspace::output::MessageToVga::new($crate::low_level::vga_buffer::Color::LightBlue, $crate::low_level::vga_buffer::Color::Black, "["), + $crate::userspace::output::MessageToVga::new($crate::low_level::vga_buffer::Color::Black, $crate::low_level::vga_buffer::Color::LightGreen, core::file!()), + $crate::userspace::output::MessageToVga::new($crate::low_level::vga_buffer::Color::LightBlue, $crate::low_level::vga_buffer::Color::Black, "] "), + $crate::userspace::output::MessageToVga::new($crate::low_level::vga_buffer::Color::White, $crate::low_level::vga_buffer::Color::Black, $($arg)*) + ); + $crate::println!(); + ) +} + +/// warn!("text") - this will get the file that called this, and say it as [file_name] +#[macro_export] +macro_rules! warn { + ($($arg:tt)*) => ( + $crate::print_with_colors!( + $crate::userspace::output::MessageToVga::new($crate::low_level::vga_buffer::Color::LightBlue, $crate::low_level::vga_buffer::Color::Black, "["), + $crate::userspace::output::MessageToVga::new($crate::low_level::vga_buffer::Color::Black, $crate::low_level::vga_buffer::Color::Yellow, core::file!()), + $crate::userspace::output::MessageToVga::new($crate::low_level::vga_buffer::Color::LightBlue, $crate::low_level::vga_buffer::Color::Black, "] "), + $crate::userspace::output::MessageToVga::new($crate::low_level::vga_buffer::Color::Yellow, $crate::low_level::vga_buffer::Color::Black, $($arg)*) + ); + $crate::println!(); + ) +} + +/// error!("text") - this will get the file that called this, and say it as [file_name] +#[macro_export] +macro_rules! error { + ($($arg:tt)*) => ( + $crate::print_with_colors!( + $crate::userspace::output::MessageToVga::new($crate::low_level::vga_buffer::Color::LightBlue, $crate::low_level::vga_buffer::Color::Black, "["), + $crate::userspace::output::MessageToVga::new($crate::low_level::vga_buffer::Color::Black, $crate::low_level::vga_buffer::Color::LightRed, core::file!()), + $crate::userspace::output::MessageToVga::new($crate::low_level::vga_buffer::Color::LightBlue, $crate::low_level::vga_buffer::Color::Black, "] "), + $crate::userspace::output::MessageToVga::new($crate::low_level::vga_buffer::Color::LightRed, $crate::low_level::vga_buffer::Color::Black, $($arg)*) + ); + $crate::println!(); + ) +} + pub struct MessageToVga<'a> { foreground: Color, background: Color,