From 4d29482952850927e2505a4b38b61dd5392206b1 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Thu, 24 Sep 2015 18:20:26 +0200 Subject: [PATCH] Add custom `print` and `println` macros --- src/vga_buffer.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/vga_buffer.rs b/src/vga_buffer.rs index 75a9b95c..e16c1647 100644 --- a/src/vga_buffer.rs +++ b/src/vga_buffer.rs @@ -11,6 +11,18 @@ pub static WRITER: Mutex = Mutex::new(Writer { buffer: unsafe{Unique::new(0xb8000 as *mut _)}, }); +macro_rules! println { + ($fmt:expr) => (print!(concat!($fmt, "\n"))); + ($fmt:expr, $($arg:tt)*) => (print!(concat!($fmt, "\n"), $($arg)*)); +} + +macro_rules! print { + ($($arg:tt)*) => ({ + use core::fmt::Write; + $crate::vga_buffer::WRITER.lock().write_fmt(format_args!($($arg)*)).unwrap(); + }); +} + #[allow(dead_code)] #[repr(u8)] pub enum Color {