Nothing to see here, move along
1use uart_16550::SerialPort;
2
3use crate::sync::IrqMutex;
4
5const COM1_PORT: u16 = 0x3F8;
6
7static SERIAL: IrqMutex<Option<SerialPort>, 255> = IrqMutex::new(None);
8
9pub fn init() {
10 let mut port = unsafe { SerialPort::new(COM1_PORT) };
11 port.init();
12 *SERIAL.lock() = Some(port);
13}
14
15pub fn write_str(s: &str) {
16 if let Some(ref mut port) = *SERIAL.lock() {
17 crate::console::write_bytes(s.as_bytes());
18 s.bytes().for_each(|b| port.send(b));
19 }
20}
21
22pub struct SerialWriter;
23
24impl core::fmt::Write for SerialWriter {
25 fn write_str(&mut self, s: &str) -> core::fmt::Result {
26 write_str(s);
27 Ok(())
28 }
29}