1use lazy_static::lazy_static;
2use uart_16550::SerialPort;
3use spin::Mutex;
4use x86_64::instructions::interrupts::without_interrupts;
5use core::{fmt::*};
6
7lazy_static! {
8 static ref SERIAL : Mutex<SerialPort> = Mutex::new(unsafe {
9 SerialPort::new(0x3F8)
10 });
11}
12
13pub macro debug($($args:tt)*) {
14 $crate::logger::_debug(format_args!("\x1b[0;36m[DEBUG] - \x1b[0m"));
15 $crate::logger::_debug(format_args!($($args)*));
16 $crate::logger::_debug(format_args!("\r\n"));
17}
18
19pub macro log($($args:tt)*) {
20 $crate::logger::_log(format_args!("\x1b[0;32m[LOG] - \x1b[0m"));
21 $crate::logger::_log(format_args!($($args)*));
22 $crate::logger::_debug(format_args!("\r\n"));
23}
24
25pub macro warn($($args:tt)*) {
26 $crate::logger::_warn(format_args!("\x1b[0;33m[WARN] - \x1b[0m"));
27 $crate::logger::_warn(format_args!($($args)*));
28 $crate::logger::_debug(format_args!("\r\n"));
29}
30
31
32pub macro error($($args:tt)*) {
33 $crate::logger::_error(format_args!("\x1b[0;31m[LOG] - \x1b[0m"));
34 $crate::logger::_error(format_args!($($args)*));
35 $crate::logger::_debug(format_args!("\r\n"));
36}
37
38pub macro print($($args:tt)*) {
39 $crate::logger::_log(format_args!($($args)*));
40
41}
42
43pub macro println($($args:tt)*) {
44 $crate::logger::_log(format_args!($($args)*));
45 $crate::logger::_log(format_args!("\r\n"));
46}
47
48#[doc(hidden)]
49pub fn _debug(args : Arguments) {
50 without_interrupts(|| {
51 SERIAL.lock().write_fmt(args).expect("");
52 });
53}
54
55#[doc(hidden)]
56pub fn _log(args : Arguments) {
57 without_interrupts(|| {
58 SERIAL.lock().write_fmt(args).expect("");
59 });
60}
61
62#[doc(hidden)]
63pub fn _warn(args : Arguments) {
64 without_interrupts(|| {
65 SERIAL.lock().write_fmt(args).expect("");
66 });
67}
68
69#[doc(hidden)]
70pub fn _error(args : Arguments) {
71 without_interrupts(|| {
72 SERIAL.lock().write_fmt(args).expect("");
73 });
74}