use spin::Mutex; use uart_16550::SerialPort; /*lazy_static! { pub static ref SERIAL1: Mutex = { let mut serial_port = unsafe { SerialPort::new(0x3F8) }; 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 {} impl SerialStream { pub fn new() -> Self { 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) } }