summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Cunningham <c@localhost>2022-08-26 20:14:10 -0700
committerChristian Cunningham <c@localhost>2022-08-26 20:14:10 -0700
commit1fd2fcd086be2b988dc1dce9358d808ea10995cd (patch)
treedf0f2d66ce57ce9b7e5bbe45ac2e4091ca812701 /src
parent7a0781efd95a2a40942821724d94dd876e7fc874 (diff)
Serial macrosHEADmaster
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs1
-rw-r--r--src/serial.rs46
2 files changed, 47 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 550b78f..476ef60 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -3,5 +3,6 @@
//! Processor independent code for operating systems!
//! Provides common structures for synchronization, memory, etc.
#![no_std]
+pub mod serial;
pub mod sync;
pub mod util;
diff --git a/src/serial.rs b/src/serial.rs
new file mode 100644
index 0000000..91bc8eb
--- /dev/null
+++ b/src/serial.rs
@@ -0,0 +1,46 @@
+//! Serial Printing
+
+/// # Print without newline
+///
+/// Print formatted arguments without a newline
+#[macro_export]
+macro_rules! serial_print {
+ ($($arg:tt)*) => (crate::_serial_print(format_args!($($arg)*)));
+}
+
+/// # Print with newline
+///
+/// Print formatted arguments with a newline
+#[macro_export]
+macro_rules! serial_println {
+ () => ($crate::serial_print!("\n"));
+ ($($arg:tt)*) => ({
+ crate::_serial_print(format_args_nl!($($arg)*));
+ })
+}
+
+/// # Debug print without newline
+///
+/// Print formatted arguments without a newline but only with `verbose` feature
+#[macro_export]
+macro_rules! serial_vprint {
+ ($($arg:tt)*) => ({
+ #[cfg(feature="verbose")]
+ crate::_serial_print(format_args!($($arg)*))
+ });
+}
+
+/// # Debug print with newline
+///
+/// Print formatted arguments with a newline but only with `verbose` feature
+#[macro_export]
+macro_rules! serial_vprintln {
+ () => ({
+ #[cfg(feature="verbose")]
+ $crate::serial_print!("\n")
+ });
+ ($($arg:tt)*) => ({
+ #[cfg(feature="verbose")]
+ crate::_serial_print(format_args_nl!($($arg)*));
+ })
+}