debug: Add runtime option to not report the debug serial port to the OS.

DOS resets the serial ports reported by the BIOS.  This can mess up
debugging and timing when the serial baud rate changes on the debug
port.  The new "etc/advertise-serial-debug-port" option allows one to
suppress the debug serial port from the normal list of serial ports
the BIOS reports to DOS.

Signed-off-by: Kevin O'Connor <>
diff --git a/src/serial.c b/src/serial.c
index 9b6d29f..00c6eb7 100644
--- a/src/serial.c
+++ b/src/serial.c
@@ -9,6 +9,7 @@
 #include "bregs.h" // struct bregs
 #include "hw/serialio.h" // SEROFF_IER
 #include "output.h" // debug_enter
+#include "romfile.h" // romfile_loadint
 #include "stacks.h" // yield
 #include "util.h" // serial_setup
@@ -20,6 +21,9 @@
 static u16
 detect_serial(u16 port, u8 timeout, u8 count)
+        && !romfile_loadint("etc/advertise-serial-debug-port", 1))
+        return 0;
     outb(0x02, port+SEROFF_IER);
     u8 ier = inb(port+SEROFF_IER);
     if (ier != 0x02)