]> xenbits.xensource.com Git - seabios.git/commitdiff
Flush debugging serial output after every line.
authorKevin O'Connor <kevin@koconnor.net>
Sat, 16 May 2009 02:22:12 +0000 (22:22 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Sat, 16 May 2009 02:22:12 +0000 (22:22 -0400)
Wait for the serial port to be ready after every debug function.
This fixes an issue with serial port detection.

src/output.c

index 96f444f8800f7d4d3bf03aefa0aeea4e110f3878..9cebf95abef2ed6d6807ff656c37611a0b664815 100644 (file)
@@ -38,6 +38,8 @@ debug_serial_setup()
 static void
 debug_serial(char c)
 {
+    if (!CONFIG_DEBUG_SERIAL)
+        return;
     int timeout = DEBUG_TIMEOUT;
     while ((inb(DEBUG_PORT+SEROFF_LSR) & 0x60) != 0x60)
         if (!timeout--)
@@ -46,6 +48,19 @@ debug_serial(char c)
     outb(c, DEBUG_PORT+SEROFF_DATA);
 }
 
+// Write a character to the serial port.
+static void
+debug_serial_flush()
+{
+    if (!CONFIG_DEBUG_SERIAL)
+        return;
+    int timeout = DEBUG_TIMEOUT;
+    while ((inb(DEBUG_PORT+SEROFF_LSR) & 0x40) != 0x40)
+        if (!timeout--)
+            // Ran out of time.
+            return;
+}
+
 // Show a character on the screen.
 static void
 screenc(u8 c)
@@ -68,12 +83,10 @@ putc(u16 action, char c)
         if (! CONFIG_COREBOOT)
             // Send character to debug port.
             outb(c, PORT_BIOS_DEBUG);
-        if (CONFIG_DEBUG_SERIAL) {
-            // Send character to serial port.
-            if (c == '\n')
-                debug_serial('\r');
-            debug_serial(c);
-        }
+        // Send character to serial port.
+        if (c == '\n')
+            debug_serial('\r');
+        debug_serial(c);
     }
 
     if (action) {
@@ -244,6 +257,7 @@ bvprintf(u16 action, const char *fmt, va_list args)
         }
         s = n;
     }
+    debug_serial_flush();
 }
 
 void
@@ -298,6 +312,7 @@ hexdump(void *d, int len)
         d+=4;
     }
     putc(0, '\n');
+    debug_serial_flush();
 }
 
 static void
@@ -320,6 +335,7 @@ __debug_isr(const char *fname)
 {
     puts_cs(0, fname);
     putc(0, '\n');
+    debug_serial_flush();
 }
 
 // Function called on handler startup.