Revision c9f398e5

b/Makefile.target
210 210
obj-i386-y += cirrus_vga.o apic.o ioapic.o parallel.o acpi.o piix_pci.o
211 211
obj-i386-y += usb-uhci.o vmmouse.o vmport.o vmware_vga.o hpet.o
212 212
obj-i386-y += device-hotplug.o pci-hotplug.o smbios.o wdt_ib700.o
213
obj-i386-y += ne2000-isa.o
213
obj-i386-y += ne2000-isa.o debugcon.o
214 214

  
215 215
# shared objects
216 216
obj-ppc-y = ppc.o ide/core.o ide/qdev.o ide/isa.o ide/pci.o ide/macio.o
b/hw/debugcon.c
1
/*
2
 * QEMU Bochs-style debug console ("port E9") emulation
3
 *
4
 * Copyright (c) 2003-2004 Fabrice Bellard
5
 * Copyright (c) 2008 Citrix Systems, Inc.
6
 * Copyright (c) Intel Corporation; author: H. Peter Anvin
7
 *
8
 * Permission is hereby granted, free of charge, to any person obtaining a copy
9
 * of this software and associated documentation files (the "Software"), to deal
10
 * in the Software without restriction, including without limitation the rights
11
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
 * copies of the Software, and to permit persons to whom the Software is
13
 * furnished to do so, subject to the following conditions:
14
 *
15
 * The above copyright notice and this permission notice shall be included in
16
 * all copies or substantial portions of the Software.
17
 *
18
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
 * THE SOFTWARE.
25
 */
26

  
27
#include "hw.h"
28
#include "qemu-char.h"
29
#include "isa.h"
30
#include "pc.h"
31

  
32
//#define DEBUG_DEBUGCON
33

  
34
typedef struct DebugconState {
35
    CharDriverState *chr;
36
    uint32_t readback;
37
} DebugconState;
38

  
39
typedef struct ISADebugconState {
40
    ISADevice dev;
41
    uint32_t iobase;
42
    DebugconState state;
43
} ISADebugconState;
44

  
45
static void debugcon_ioport_write(void *opaque, uint32_t addr, uint32_t val)
46
{
47
    DebugconState *s = opaque;
48
    unsigned char ch = val;
49

  
50
#ifdef DEBUG_DEBUGCON
51
    printf("debugcon: write addr=0x%04x val=0x%02x\n", addr, val);
52
#endif
53

  
54
    qemu_chr_write(s->chr, &ch, 1);
55
}
56

  
57

  
58
static uint32_t debugcon_ioport_read(void *opaque, uint32_t addr)
59
{
60
    DebugconState *s = opaque;
61

  
62
#ifdef DEBUG_DEBUGCON
63
    printf("debugcon: read addr=0x%04x\n", addr, val);
64
#endif
65

  
66
    return s->readback;
67
}
68

  
69
static void debugcon_init_core(DebugconState *s)
70
{
71
    if (!s->chr) {
72
        fprintf(stderr, "Can't create debugcon device, empty char device\n");
73
        exit(1);
74
    }
75

  
76
    qemu_chr_add_handlers(s->chr, NULL, NULL, NULL, s);
77
}
78

  
79
static int debugcon_isa_initfn(ISADevice *dev)
80
{
81
    ISADebugconState *isa = DO_UPCAST(ISADebugconState, dev, dev);
82
    DebugconState *s = &isa->state;
83

  
84
    debugcon_init_core(s);
85
    register_ioport_write(isa->iobase, 1, 1, debugcon_ioport_write, s);
86
    register_ioport_read(isa->iobase, 1, 1, debugcon_ioport_read, s);
87
    return 0;
88
}
89

  
90
static ISADeviceInfo debugcon_isa_info = {
91
    .qdev.name  = "isa-debugcon",
92
    .qdev.size  = sizeof(ISADebugconState),
93
    .init       = debugcon_isa_initfn,
94
    .qdev.props = (Property[]) {
95
        DEFINE_PROP_HEX32("iobase", ISADebugconState, iobase, 0xe9),
96
        DEFINE_PROP_CHR("chardev",  ISADebugconState, state.chr),
97
        DEFINE_PROP_HEX32("readback", ISADebugconState, state.readback, 0xe9),
98
        DEFINE_PROP_END_OF_LIST(),
99
    },
100
};
101

  
102
static void debugcon_register_devices(void)
103
{
104
    isa_qdev_register(&debugcon_isa_info);
105
}
106

  
107
device_init(debugcon_register_devices)
b/qemu-options.hx
1598 1598
Setup monitor on chardev @var{name}.
1599 1599
ETEXI
1600 1600

  
1601
DEF("debugcon", HAS_ARG, QEMU_OPTION_debugcon, \
1602
    "-debugcon dev   redirect the debug console to char device 'dev'\n")
1603
STEXI
1604
@item -debugcon @var{dev}
1605
Redirect the debug console to host device @var{dev} (same devices as the
1606
serial port).  The debug console is an I/O port which is typically port
1607
0xe9; writing to that I/O port sends output to this device.
1608
The default device is @code{vc} in graphical mode and @code{stdio} in
1609
non graphical mode.
1610
ETEXI
1611

  
1601 1612
DEF("pidfile", HAS_ARG, QEMU_OPTION_pidfile, \
1602 1613
    "-pidfile file   write PID to 'file'\n")
1603 1614
STEXI
b/vl.c
4748 4748
        DEV_SERIAL,    /* -serial        */
4749 4749
        DEV_PARALLEL,  /* -parallel      */
4750 4750
        DEV_VIRTCON,   /* -virtioconsole */
4751
        DEV_DEBUGCON,  /* -debugcon */
4751 4752
    } type;
4752 4753
    const char *cmdline;
4753 4754
    QTAILQ_ENTRY(device_config) next;
......
4845 4846
    return 0;
4846 4847
}
4847 4848

  
4849
static int debugcon_parse(const char *devname)
4850
{   
4851
    QemuOpts *opts;
4852

  
4853
    if (!qemu_chr_open("debugcon", devname, NULL)) {
4854
        exit(1);
4855
    }
4856
    opts = qemu_opts_create(&qemu_device_opts, "debugcon", 1);
4857
    if (!opts) {
4858
        fprintf(stderr, "qemu: already have a debugcon device\n");
4859
        exit(1);
4860
    }
4861
    qemu_opt_set(opts, "driver", "isa-debugcon");
4862
    qemu_opt_set(opts, "chardev", "debugcon");
4863
    return 0;
4864
}
4865

  
4848 4866
int main(int argc, char **argv, char **envp)
4849 4867
{
4850 4868
    const char *gdbstub_dev = NULL;
......
5390 5408
                add_device_config(DEV_PARALLEL, optarg);
5391 5409
                default_parallel = 0;
5392 5410
                break;
5411
            case QEMU_OPTION_debugcon:
5412
                add_device_config(DEV_DEBUGCON, optarg);
5413
                break;
5393 5414
	    case QEMU_OPTION_loadvm:
5394 5415
		loadvm = optarg;
5395 5416
		break;
......
5927 5948
        exit(1);
5928 5949
    if (foreach_device_config(DEV_VIRTCON, virtcon_parse) < 0)
5929 5950
        exit(1);
5951
    if (foreach_device_config(DEV_DEBUGCON, debugcon_parse) < 0)
5952
        exit(1);
5930 5953

  
5931 5954
    module_call_init(MODULE_INIT_DEVICE);
5932 5955

  

Also available in: Unified diff