[kvm-unit-tests PATCH 2/2] x86: io: force carriage return on \n put to serial port

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When '\n' (line feed) is put to serial port, put '\r' (carriage return) as
well. This makes the serial port output to look properly (without stairs) at
real hardware. Also the output looks well at QEMU/KVM and BOCHS emulators.

Signed-off-by: Eugene Korenevsky <ekorenevsky@xxxxxxxxx>
---
 lib/x86/io.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/lib/x86/io.c b/lib/x86/io.c
index f697161..edac5bc 100644
--- a/lib/x86/io.c
+++ b/lib/x86/io.c
@@ -22,6 +22,14 @@ static void serial_outb(char ch)
         outb(ch, serial_iobase + 0x00);
 }
 
+static void serial_put(char ch)
+{
+        /* Force carriage return to be performed on \n */
+        if (ch == '\n')
+                serial_outb('\r');
+        serial_outb(ch);
+}
+
 static void serial_init(void)
 {
         u8 lcr;
@@ -61,7 +69,7 @@ static void print_serial(const char *buf)
         }
 
         for (i = 0; i < len; i++) {
-            serial_outb(buf[i]);
+            serial_put(buf[i]);
         }
 #else
         asm volatile ("rep/outsb" : "+S"(buf), "+c"(len) : "d"(0xf1));
-- 
2.18.0


-- 
Eugene




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux