Skip to contentSkip to conversation

debugcon: support for debugging consoles (e.g. Bochs port 0xe9)

PATCH In review H. Peter Anvin 2 participants 2 messages Dec 3, 2009 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 debugcon: support for debugging consoles (e.g. Bochs port 0xe9)

Add generic support for debugging consoles (simple I/O ports which when written to cause debugging output to be written to a target.) The current implementation matches Bochs' port 0xe9, allowing the same debugging code to be used for both Bochs and Qemu.

There is no vm state associated with the debugging port, simply because it has none -- the entire interface is a single, stateless, write-only port.

Most of the code was cribbed from the serial port driver.

v2: removed non-ISA variants (they can be introduced when/if someone wants them, using code from the serial port); added configurable readback (Bochs returns 0xe9 on a read from this register, mimic that by default) This retains the apparently somewhat controversial user friendly option, however.

v3: reimplemented the user friendly option as a synthetic option ("-debugcon foo" basically ends up being a parser-level shorthand for "-chardev stdio,id=debugcon -device isa-debugcon,chardev=debugcon") -- this dramatically reduced the complexity while keeping the same level of user friendliness.

---
 Makefile.target |    2 +-
 hw/debugcon.c   |  107 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 qemu-options.hx |   11 ++++++
 vl.c            |   12 ++++++
 4 files changed, 131 insertions(+), 1 deletions(-)
 create mode 100644 hw/debugcon.c
Makefile.target +1 -1
index 2985658..df4a7b2 100644
@@ -197,7 +197,7 @@ obj-i386-y += fdc.o mc146818rtc.o serial.o i8259.o i8254.o pcspk.o pc.o
 obj-i386-y += cirrus_vga.o apic.o ioapic.o parallel.o acpi.o piix_pci.o
 obj-i386-y += usb-uhci.o vmmouse.o vmport.o vmware_vga.o hpet.o
 obj-i386-y += device-hotplug.o pci-hotplug.o smbios.o wdt_ib700.o
-obj-i386-y += ne2000-isa.o
+obj-i386-y += ne2000-isa.o debugcon.o
 
 # shared objects
 obj-ppc-y = ppc.o ide/core.o ide/qdev.o ide/isa.o ide/pci.o ide/macio.o
hw/debugcon.c new file +107 -0

107 lines not on this page · raw message

qemu-options.hx +11 -0
index b65fd74..efa74df 100644
@@ -1586,6 +1586,17 @@ The default device is @code{vc} in graphical mode and @code{stdio} in
 non graphical mode.
 ETEXI
 
+DEF("debugcon", HAS_ARG, QEMU_OPTION_debugcon, \
+    "-debugcon dev   redirect the debug console to char device 'dev'\n")
+STEXI
+@item -debugcon @var{dev}
+Redirect the debug console to host device @var{dev} (same devices as the
+serial port).  The debug console is an I/O port which is typically port
+0xe9; writing to that I/O port sends output to this device.
+The default device is @code{vc} in graphical mode and @code{stdio} in
+non graphical mode.
+ETEXI
+
 DEF("pidfile", HAS_ARG, QEMU_OPTION_pidfile, \
     "-pidfile file   write PID to 'file'\n")
 STEXI
vl.c +12 -0
index 44763af..547ca3c 100644
@@ -5149,6 +5149,18 @@ int main(int argc, char **argv, char **envp)
                 parallel_devices[parallel_device_index] = optarg;
                 parallel_device_index++;
                 break;
+	    case QEMU_OPTION_debugcon:
+		if (!qemu_chr_open("debugcon", optarg, NULL)) {
+		    exit(1);
+		}
+		opts = qemu_opts_create(&qemu_device_opts, "debugcon", 1);
+		if (!opts) {
+		    fprintf(stderr, "qemu: already have a debugcon device\n");
+		    exit(1);
+		}
+		qemu_opt_set(opts, "driver", "isa-debugcon");
+		qemu_opt_set(opts, "chardev", "debugcon");
+		break;
 	    case QEMU_OPTION_loadvm:
 		loadvm = optarg;
 		break;
Signature · 1 line
1.6.2.5
#1 lore raw
Quoted 23 lines · H. Peter Anvin

Add generic support for debugging consoles (simple I/O ports which when written to cause debugging output to be written to a target.) The current implementation matches Bochs' port 0xe9, allowing the same debugging code to be used for both Bochs and Qemu.

There is no vm state associated with the debugging port, simply because it has none -- the entire interface is a single, stateless, write-only port.

Most of the code was cribbed from the serial port driver.

v2: removed non-ISA variants (they can be introduced when/if someone wants them, using code from the serial port); added configurable readback (Bochs returns 0xe9 on a read from this register, mimic that by default) This retains the apparently somewhat controversial user friendly option, however.

v3: reimplemented the user friendly option as a synthetic option ("-debugcon foo" basically ends up being a parser-level shorthand for "-chardev stdio,id=debugcon -device isa-debugcon,chardev=debugcon") -- this dramatically reduced the complexity while keeping the same level of user friendliness.

[..snip..]

hw/debugcon.c line 100

Quoted 12 lines
hw/debugcon.c new file +12 -0
+
+static ISADeviceInfo debugcon_isa_info = {
+    .qdev.name  = "isa-debugcon",
+    .qdev.size  = sizeof(ISADebugconState),
+    .init       = debugcon_isa_initfn,
+    .qdev.props = (Property[]) {
+        DEFINE_PROP_HEX32("iobase", ISADebugconState, iobase, 0xe9),
+        DEFINE_PROP_CHR("chardev",  ISADebugconState, state.chr),
+	DEFINE_PROP_HEX32("readback", ISADebugconState, state.readback, 0xe9),
+        DEFINE_PROP_END_OF_LIST(),
+    },
+};

The above is tab damaged.

[..snip..]

Signature · 1 line
mailto:[email protected]