diff options
Diffstat (limited to 'kernel/src/io/serial.rs')
-rw-r--r-- | kernel/src/io/serial.rs | 25 |
1 files changed, 6 insertions, 19 deletions
diff --git a/kernel/src/io/serial.rs b/kernel/src/io/serial.rs index eb9377c..3f661e9 100644 --- a/kernel/src/io/serial.rs +++ b/kernel/src/io/serial.rs @@ -1,23 +1,15 @@ +use lazy_static::lazy_static; use spin::Mutex; use uart_16550::SerialPort; -/*lazy_static! { +const SERIAL_IO_PORT: u16 = 0x3F8; + +lazy_static! { pub static ref SERIAL1: Mutex<SerialPort> = { - let mut serial_port = unsafe { SerialPort::new(0x3F8) }; + let mut serial_port = unsafe { SerialPort::new(SERIAL_IO_PORT) }; serial_port.init(); Mutex::new(serial_port) }; -}*/ -const SERIAL_IO_PORT: u16 = 0x3F8; - -static CONNECTION: Mutex<Serial> = Mutex::new(Serial { - initialized: false, - port: unsafe { SerialPort::new(SERIAL_IO_PORT) }, -}); - -struct Serial { - pub initialized: bool, - pub port: SerialPort, } pub struct SerialStream {} @@ -30,11 +22,6 @@ impl SerialStream { impl core::fmt::Write for SerialStream { fn write_str(&mut self, s: &str) -> core::fmt::Result { - let mut guard = CONNECTION.lock(); - if !guard.initialized { - guard.port.init(); - guard.initialized = true; - } - guard.port.write_str(s) + SERIAL1.lock().write_str(s) } } |