diff --git a/ableos/src/arch/riscv/drivers/serial.rs b/ableos/src/arch/riscv/drivers/serial.rs index 42ae31de..6a58d9e9 100644 --- a/ableos/src/arch/riscv/drivers/serial.rs +++ b/ableos/src/arch/riscv/drivers/serial.rs @@ -4,14 +4,25 @@ use core::fmt::Error; /// Prints to the host through the serial interface. #[macro_export] macro_rules! serial_print { - ($($arg:tt)*) => {}; + ($($arg:tt)*) => { + +crate::arch::drivers::serial::SERIAL.lock().out(format_args!($($arg)*)) + + }; } /// Prints to the host through the serial interface, appending a newline. #[macro_export] macro_rules! serial_println { - () => {}; - ($fmt:expr) => {}; - ($fmt:expr, $($arg:tt)*) => {}; + () => { + crate::arch::drivers::serial::SERIAL + .lock() + .out(format_args!("\r\n")) + }; + + ($($arg:tt)*) => ($crate::print!("{}\r\n", format_args!($($arg)*))); + + + } pub struct Serial123 { @@ -20,7 +31,7 @@ pub struct Serial123 { impl Serial123 { pub fn out(&mut self, s: ::core::fmt::Arguments) { - let uart_data = 0x10000000 as *mut u8; + let uart_data = self.uart_data as *mut u8; for c in b"Hello, world!\n" { unsafe { uart_data.write_volatile(*c) }; } diff --git a/ableos/src/arch/riscv/mod.rs b/ableos/src/arch/riscv/mod.rs index 919f759f..b890df08 100644 --- a/ableos/src/arch/riscv/mod.rs +++ b/ableos/src/arch/riscv/mod.rs @@ -31,11 +31,14 @@ unsafe extern "C" fn _boot() -> ! { } extern "C" fn _start() -> ! { + /* let uart_data = 0x10000000 as *mut u8; for c in b"Hardcoded serial output\n" { unsafe { uart_data.write_volatile(*c) }; } - + */ + crate::serial_print!("Hi"); + crate::kmain::kernel_main(); sloop() }