summaryrefslogtreecommitdiff
path: root/kernel/src/init/earlyprintk.rs
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/src/init/earlyprintk.rs')
-rw-r--r--kernel/src/init/earlyprintk.rs46
1 files changed, 20 insertions, 26 deletions
diff --git a/kernel/src/init/earlyprintk.rs b/kernel/src/init/earlyprintk.rs
index 088a4db..ae26a2f 100644
--- a/kernel/src/init/earlyprintk.rs
+++ b/kernel/src/init/earlyprintk.rs
@@ -3,35 +3,29 @@ 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]) } {
+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(()),
- }
- });
-}
+pub macro 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(()),
- }
- });
-}
+pub macro 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(()),
+ }
+}}