blob: 088a4db9ee0c35f7e6b5f295677a008c8636ca5f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
use spin::{lazylock::LazyLock, mutex::Mutex};
use crate::io::output::serial::uart_16550::Uart16550;
// TODO: use linkme instead
pub static EARLY_PRINTK_SERIAL: LazyLock<Option<Mutex<Uart16550>>> = LazyLock::new(|| {
match unsafe { Uart16550::init([Some(Default::default()), None, None, None]) } {
Ok(o) => Some(Mutex::new(o)),
Err(_) => None,
}
});
#[macro_export]
// TODO: configurable via option or arguments
// or use a system similar to the drivers(`linkme`)
macro_rules! printk {
($($arg:tt)*) => ({
use ::core::fmt::Write;
match &*$crate::init::earlyprintk::EARLY_PRINTK_SERIAL {
// TODO: elim the unwrap
Some(m) => write!(m.lock().coms[0].as_mut().unwrap(), $($arg)*),
// TODO: if needed find a way to return an error here, but for now just ignore it
None => Ok(()),
}
});
}
#[macro_export]
macro_rules! printlnk {
($($arg:tt)*) => ({
use ::core::fmt::Write;
match &*$crate::init::earlyprintk::EARLY_PRINTK_SERIAL {
Some(m) => writeln!(m.lock().coms[0].as_mut().unwrap(), $($arg)*),
None => Ok(()),
}
});
}
|