From d69ba91101eae64111d8aa4ff25433eaa9c73b61 Mon Sep 17 00:00:00 2001 From: Able Date: Mon, 29 Nov 2021 14:49:32 -0600 Subject: [PATCH] worked on issue #2 --- ableos/src/arch/riscv/drivers/serial.rs | 21 ++++++++++++++++----- ableos/src/arch/riscv/mod.rs | 5 ++++- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/ableos/src/arch/riscv/drivers/serial.rs b/ableos/src/arch/riscv/drivers/serial.rs index 42ae31d..6a58d9e 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 919f759..b890df0 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() }