bootloader_x86_64_common/
serial.rs1use core::fmt;
2
3pub struct SerialPort {
4 port: uart_16550::SerialPort,
5}
6
7impl SerialPort {
8 pub unsafe fn init() -> Self {
12 let mut port = unsafe { uart_16550::SerialPort::new(0x3F8) };
13 port.init();
14 Self { port }
15 }
16}
17
18impl fmt::Write for SerialPort {
19 fn write_str(&mut self, s: &str) -> fmt::Result {
20 for char in s.bytes() {
21 match char {
22 b'\n' => self.port.write_str("\r\n").unwrap(),
23 byte => self.port.send(byte),
24 }
25 }
26 Ok(())
27 }
28}