diff --git a/Makefile b/Makefile index df16c52..73a3879 100644 --- a/Makefile +++ b/Makefile @@ -48,7 +48,9 @@ qemu: $(KBUILD)/harddrive.bin else LD=ld QEMUFLAGS+=-enable-kvm -cpu host -machine q35 -smp 4 +ifeq ($(vga),no) QEMUFLAGS+=-nographic -vga none +endif #,int,pcall #-device intel-iommu diff --git a/arch/x86_64/src/device/serial.rs b/arch/x86_64/src/device/serial.rs index 872fad1..cb816f5 100644 --- a/arch/x86_64/src/device/serial.rs +++ b/arch/x86_64/src/device/serial.rs @@ -72,6 +72,22 @@ impl SerialPort { self.data.write(data) } + fn write_translate(&mut self, data: u8) { + match data { + 8 | 0x7F => { + self.write(8); + self.write(b' '); + self.write(8); + }, + b'\r' => { + self.write(b'\n'); + }, + _ => { + self.write(data); + } + } + } + fn init(&mut self) { //TODO: Cleanup self.int_en.write(0x00); @@ -86,19 +102,14 @@ impl SerialPort { pub fn on_receive(&mut self) { let data = self.data.read(); - let _ = write!(self, "SERIAL {:X}\n", data); + self.write_translate(data); } } impl Write for SerialPort { fn write_str(&mut self, s: &str) -> Result<(), fmt::Error> { for byte in s.bytes() { - self.write(byte); - - if byte == 8 { - self.write(b' '); - self.write(8); - } + self.write_translate(byte); } Ok(())