1
0
Fork 0
forked from AbleOS/ableos

Setting up serial to be out putted to more easily

This commit is contained in:
Able 2021-11-18 00:35:50 -06:00
parent 6675d7e1fb
commit b6ba831ea0
3 changed files with 33 additions and 8 deletions

View file

@ -1,3 +1,7 @@
use core::fmt::Arguments;
use core::fmt::Error;
/// Prints to the host through the serial interface.
#[macro_export]
macro_rules! serial_print {
($($arg:tt)*) => {};
@ -9,3 +13,28 @@ macro_rules! serial_println {
($fmt:expr) => {};
($fmt:expr, $($arg:tt)*) => {};
}
pub struct Serial123 {
uart_data: u32,
}
impl Serial123 {
pub fn out(&mut self, s: ::core::fmt::Arguments) {
let uart_data = 0x10000000 as *mut u8;
for c in b"Hello, world!\n" {
unsafe { uart_data.write_volatile(*c) };
}
}
}
use spin::Mutex;
use lazy_static::lazy_static;
lazy_static! {
pub static ref SERIAL: Mutex<Serial123> = {
let serial_port = Serial123 {
uart_data: 0x10000000,
};
Mutex::new(serial_port)
};
}

View file

@ -29,13 +29,10 @@ unsafe extern "C" fn _boot() -> ! {
",
sym _start, options(noreturn));
}
use crate::serial::SERIAL;
extern "C" fn _start() -> ! {
let uart_data = 0x10000000 as *mut u8;
for c in b"Hello, world!\n" {
unsafe { uart_data.write_volatile(*c) };
}
SERIAL.lock().out(format_args!("Hi"));
// Serial123::out();
sloop()
}

View file

@ -49,8 +49,7 @@ fn main() -> anyhow::Result<()> {
-kernel target/aarch64-ableos/release/ableos
-device virtio-keyboard
"
)
.run()?;
).run()?;
}
MachineType::RISCV => {
xshell::cmd!("cargo build --release --target=riscv64gc-unknown-none-elf")