aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/fw/paravirt.c3
-rw-r--r--src/fw/paravirt.h3
-rw-r--r--src/hw/serialio.c16
-rw-r--r--src/hw/serialio.h1
4 files changed, 21 insertions, 2 deletions
diff --git a/src/fw/paravirt.c b/src/fw/paravirt.c
index 0770c47b..4fcd8f57 100644
--- a/src/fw/paravirt.c
+++ b/src/fw/paravirt.c
@@ -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)
diff --git a/src/fw/paravirt.h b/src/fw/paravirt.h
index a14d83e1..f7e1d4c5 100644
--- a/src/fw/paravirt.h
+++ b/src/fw/paravirt.h
@@ -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);
diff --git a/src/hw/serialio.c b/src/hw/serialio.c
index 319a85c1..31633443 100644
--- a/src/hw/serialio.c
+++ b/src/hw/serialio.c
@@ -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);
}
diff --git a/src/hw/serialio.h b/src/hw/serialio.h
index 88296fe7..81fed306 100644
--- a/src/hw/serialio.h
+++ b/src/hw/serialio.h
@@ -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