Fix locking in serial port
This commit is contained in:
parent
b756dd59eb
commit
979d80a8c7
|
@ -19,13 +19,8 @@ extern crate x86;
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! print {
|
macro_rules! print {
|
||||||
($($arg:tt)*) => ({
|
($($arg:tt)*) => ({
|
||||||
{
|
|
||||||
use core::fmt::Write;
|
use core::fmt::Write;
|
||||||
//TODO: let mut serial_console = $crate::serial::SERIAL_CONSOLE.lock();
|
let _ = write!($crate::serial::SerialConsole, $($arg)*);
|
||||||
let mut serial_console = $crate::serial::SerialConsole::new();
|
|
||||||
let _ = write!(serial_console, $($arg)*);
|
|
||||||
drop(serial_console);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,16 +3,16 @@ use spin::Mutex;
|
||||||
|
|
||||||
use super::io::{Io, Pio};
|
use super::io::{Io, Pio};
|
||||||
|
|
||||||
pub static SERIAL_CONSOLE: Mutex<SerialConsole> = Mutex::new(SerialConsole::new());
|
static SERIAL_PORT: Mutex<SerialPort> = Mutex::new(SerialPort::new());
|
||||||
|
|
||||||
pub struct SerialConsole {
|
struct SerialPort {
|
||||||
status: Pio<u8>,
|
status: Pio<u8>,
|
||||||
data: Pio<u8>
|
data: Pio<u8>
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SerialConsole {
|
impl SerialPort {
|
||||||
pub const fn new() -> SerialConsole {
|
pub const fn new() -> SerialPort {
|
||||||
SerialConsole {
|
SerialPort {
|
||||||
status: Pio::new(0x3F8 + 5),
|
status: Pio::new(0x3F8 + 5),
|
||||||
data: Pio::new(0x3F8)
|
data: Pio::new(0x3F8)
|
||||||
}
|
}
|
||||||
|
@ -34,9 +34,11 @@ impl SerialConsole {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub struct SerialConsole;
|
||||||
|
|
||||||
impl fmt::Write for SerialConsole {
|
impl fmt::Write for SerialConsole {
|
||||||
fn write_str(&mut self, s: &str) -> Result<(), fmt::Error> {
|
fn write_str(&mut self, s: &str) -> Result<(), fmt::Error> {
|
||||||
self.write(s.as_bytes());
|
SERIAL_PORT.lock().write(s.as_bytes());
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue