worked on issue #2

This commit is contained in:
Able 2021-11-29 14:49:32 -06:00
parent b1bd0cacf6
commit d69ba91101
2 changed files with 20 additions and 6 deletions

View file

@ -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) };
}

View file

@ -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()
}