diff --git a/kernel/src/drivers/serial/16550_reg.rs b/kernel/src/drivers/serial/16550_reg.rs index 424b839..e4d7dc0 100644 --- a/kernel/src/drivers/serial/16550_reg.rs +++ b/kernel/src/drivers/serial/16550_reg.rs @@ -68,12 +68,19 @@ impl SerialPort { impl Write for SerialPort { fn write_str(&mut self, s: &str) -> Result { for c in s.bytes() { - if c == 127 { - self.putchar(8); - self.putchar(b' '); - self.putchar(8); - } else { - self.putchar(c); + match c { + 127 => { + self.putchar(8); + self.putchar(b' '); + self.putchar(8); + }, + b'\n' => { + self.putchar(b'\r'); + self.putchar(b'\n'); + }, + c => { + self.putchar(c); + } } } Ok(()) diff --git a/kernel/src/drivers/serial/simple_uart.rs b/kernel/src/drivers/serial/simple_uart.rs index ee5c569..584fc33 100644 --- a/kernel/src/drivers/serial/simple_uart.rs +++ b/kernel/src/drivers/serial/simple_uart.rs @@ -59,12 +59,19 @@ impl SerialPort { impl Write for SerialPort { fn write_str(&mut self, s: &str) -> Result { for c in s.bytes() { - if c == 127 { - self.putchar(8); - self.putchar(b' '); - self.putchar(8); - } else { - self.putchar(c); + match c { + 127 => { + self.putchar(8); + self.putchar(b' '); + self.putchar(8); + }, + b'\n' => { + self.putchar(b'\r'); + self.putchar(b'\n'); + }, + c => { + self.putchar(c); + } } } Ok(()) diff --git a/kernel/src/drivers/serial/ti_16c550c.rs b/kernel/src/drivers/serial/ti_16c550c.rs index 4f5b51a..e4b1973 100644 --- a/kernel/src/drivers/serial/ti_16c550c.rs +++ b/kernel/src/drivers/serial/ti_16c550c.rs @@ -68,12 +68,19 @@ impl SerialPort { impl Write for SerialPort { fn write_str(&mut self, s: &str) -> Result { for c in s.bytes() { - if c == 127 { - self.putchar(8); - self.putchar(b' '); - self.putchar(8); - } else { - self.putchar(c); + match c { + 127 => { + self.putchar(8); + self.putchar(b' '); + self.putchar(8); + }, + b'\n' => { + self.putchar(b'\r'); + self.putchar(b'\n'); + }, + c => { + self.putchar(c); + } } } Ok(())