]> xenbits.xensource.com Git - people/andrewcoop/seabios.git/commitdiff
qemu: avoid debug prints if debugcon is not enabled
authorStefano Garzarella <sgarzare@redhat.com>
Sun, 2 Dec 2018 13:10:13 +0000 (14:10 +0100)
committerKevin O'Connor <kevin@koconnor.net>
Tue, 11 Dec 2018 03:03:30 +0000 (22:03 -0500)
In order to speed up the boot phase, we can check the QEMU
debugcon device, and disable the writes if it is not recognized.

This patch allow us to save around 10 msec (time measured
between SeaBIOS entry point and "linuxboot" entry point)
when CONFIG_DEBUG_LEVEL=1 and debugcon is not enabled.

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
src/fw/paravirt.c
src/fw/paravirt.h
src/hw/serialio.c
src/hw/serialio.h

index 0770c47b12e7f4fccb1793ccd344d8fc86b4d376..4fcd8f570673ebd14f2122708d7db544c7312300 100644 (file)
@@ -75,6 +75,9 @@ static void qemu_detect(void)
     if (!CONFIG_QEMU_HARDWARE)
         return;
 
+    // Setup QEMU debug output port
+    qemu_debug_preinit();
+
     // check northbridge @ 00:00.0
     u16 v = pci_config_readw(0, PCI_VENDOR_ID);
     if (v == 0x0000 || v == 0xffff)
index a14d83e101a3df89480302c1c96935fc35717a1f..f7e1d4c551d91426310132a02a67942c45c4e81a 100644 (file)
@@ -49,6 +49,9 @@ static inline int runningOnKVM(void) {
 // QEMU_CFG_DMA ID bit
 #define QEMU_CFG_VERSION_DMA    2
 
+// QEMU debugcon read value
+#define QEMU_DEBUGCON_READBACK  0xe9
+
 int qemu_cfg_enabled(void);
 int qemu_cfg_dma_enabled(void);
 void qemu_preinit(void);
index 319a85c16bfc9b6426c52f966879b224fb28c03d..31633443780a2ee0cb514334c06562bf72ba7dd4 100644 (file)
@@ -103,11 +103,23 @@ serial_debug_flush(void)
 
 u16 DebugOutputPort VARFSEG = 0x402;
 
+void
+qemu_debug_preinit(void)
+{
+    /* Check if the QEMU debug output port is active */
+    if (CONFIG_DEBUG_IO &&
+        inb(GET_GLOBAL(DebugOutputPort)) != QEMU_DEBUGCON_READBACK)
+        DebugOutputPort = 0;
+}
+
 // Write a character to the special debugging port.
 void
 qemu_debug_putc(char c)
 {
-    if (CONFIG_DEBUG_IO && runningOnQEMU())
+    if (!CONFIG_DEBUG_IO || !runningOnQEMU())
+        return;
+    u16 port = GET_GLOBAL(DebugOutputPort);
+    if (port)
         // Send character to debug port.
-        outb(c, GET_GLOBAL(DebugOutputPort));
+        outb(c, port);
 }
index 88296fe7fb8ea8646adb30e2737ee6fbd1092d3d..81fed3064ef5c7f646965234230ae64dbd08a418 100644 (file)
@@ -24,6 +24,7 @@ void serial_debug_preinit(void);
 void serial_debug_putc(char c);
 void serial_debug_flush(void);
 extern u16 DebugOutputPort;
+void qemu_debug_preinit(void);
 void qemu_debug_putc(char c);
 
 #endif // serialio.h