From 1e0422eb84988464836a8f17fd7420b9f3cf277b Mon Sep 17 00:00:00 2001 From: Dennis Kobert Date: Sat, 9 Nov 2019 03:12:41 +0100 Subject: Add testing runner functions --- kernel/src/io/serial.rs | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) (limited to 'kernel/src/io/serial.rs') 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 = { - 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 = 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) } } -- cgit v1.2.3-54-g00ecf