Add kernel print macros
This commit is contained in:
parent
0c0a53f1be
commit
ec115c43c4
@ -1,6 +1,7 @@
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
#[macro_use]
|
||||
mod vga_buffer;
|
||||
|
||||
use core::panic::PanicInfo;
|
||||
@ -12,11 +13,7 @@ fn panic(_info: &PanicInfo) -> !{
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn _start() -> ! {
|
||||
|
||||
use core::fmt::Write;
|
||||
vga_buffer::WRITER.lock().write_str("Gamarjoba, munde").unwrap();
|
||||
write!(vga_buffer::WRITER.lock(), ", hella {} bro", 2).unwrap();
|
||||
|
||||
println!("Gamarjoba, munde: {}", 1);
|
||||
loop {}
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,24 @@ use core::fmt;
|
||||
use spin::Mutex;
|
||||
use lazy_static::lazy_static;
|
||||
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! print {
|
||||
($($arg:tt)*) => ($crate::vga_buffer::_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)]
|
||||
|
Loading…
Reference in New Issue
Block a user