diff options
| author | Christian Cunningham <c@localhost> | 2022-08-26 20:14:10 -0700 |
|---|---|---|
| committer | Christian Cunningham <c@localhost> | 2022-08-26 20:14:10 -0700 |
| commit | 1fd2fcd086be2b988dc1dce9358d808ea10995cd (patch) | |
| tree | df0f2d66ce57ce9b7e5bbe45ac2e4091ca812701 | |
| parent | 7a0781efd95a2a40942821724d94dd876e7fc874 (diff) | |
| -rw-r--r-- | src/lib.rs | 1 | ||||
| -rw-r--r-- | src/serial.rs | 46 |
2 files changed, 47 insertions, 0 deletions
@@ -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)*)); + }) +} |
