debugcon.c (7087d3df18b8e8d27a2115dfc5d56614073e55de) debugcon.c (db895a1e6a97e919f9b86d60c969377357b05066)
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

--- 67 unchanged lines hidden (view full) ---

76static const MemoryRegionOps debugcon_ops = {
77 .read = debugcon_ioport_read,
78 .write = debugcon_ioport_write,
79 .valid.min_access_size = 1,
80 .valid.max_access_size = 1,
81 .endianness = DEVICE_LITTLE_ENDIAN,
82};
83
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

--- 67 unchanged lines hidden (view full) ---

76static const MemoryRegionOps debugcon_ops = {
77 .read = debugcon_ioport_read,
78 .write = debugcon_ioport_write,
79 .valid.min_access_size = 1,
80 .valid.max_access_size = 1,
81 .endianness = DEVICE_LITTLE_ENDIAN,
82};
83
84static void debugcon_init_core(DebugconState *s)
84static void debugcon_realize_core(DebugconState *s, Error **errp)
85{
86 if (!s->chr) {
85{
86 if (!s->chr) {
87 fprintf(stderr, "Can't create debugcon device, empty char device\n");
88 exit(1);
87 error_setg(errp, "Can't create debugcon device, empty char device");
88 return;
89 }
90
91 qemu_chr_add_handlers(s->chr, NULL, NULL, NULL, s);
92}
93
89 }
90
91 qemu_chr_add_handlers(s->chr, NULL, NULL, NULL, s);
92}
93
94static int debugcon_isa_initfn(ISADevice *dev)
94static void debugcon_isa_realizefn(DeviceState *dev, Error **errp)
95{
95{
96 ISADevice *d = ISA_DEVICE(dev);
96 ISADebugconState *isa = ISA_DEBUGCON_DEVICE(dev);
97 DebugconState *s = &isa->state;
97 ISADebugconState *isa = ISA_DEBUGCON_DEVICE(dev);
98 DebugconState *s = &isa->state;
99 Error *err = NULL;
98
100
99 debugcon_init_core(s);
101 debugcon_realize_core(s, &err);
102 if (err != NULL) {
103 error_propagate(errp, err);
104 return;
105 }
100 memory_region_init_io(&s->io, &debugcon_ops, s,
101 TYPE_ISA_DEBUGCON_DEVICE, 1);
106 memory_region_init_io(&s->io, &debugcon_ops, s,
107 TYPE_ISA_DEBUGCON_DEVICE, 1);
102 memory_region_add_subregion(isa_address_space_io(dev),
108 memory_region_add_subregion(isa_address_space_io(d),
103 isa->iobase, &s->io);
109 isa->iobase, &s->io);
104 return 0;
105}
106
107static Property debugcon_isa_properties[] = {
108 DEFINE_PROP_HEX32("iobase", ISADebugconState, iobase, 0xe9),
109 DEFINE_PROP_CHR("chardev", ISADebugconState, state.chr),
110 DEFINE_PROP_HEX32("readback", ISADebugconState, state.readback, 0xe9),
111 DEFINE_PROP_END_OF_LIST(),
112};
113
114static void debugcon_isa_class_initfn(ObjectClass *klass, void *data)
115{
116 DeviceClass *dc = DEVICE_CLASS(klass);
110}
111
112static Property debugcon_isa_properties[] = {
113 DEFINE_PROP_HEX32("iobase", ISADebugconState, iobase, 0xe9),
114 DEFINE_PROP_CHR("chardev", ISADebugconState, state.chr),
115 DEFINE_PROP_HEX32("readback", ISADebugconState, state.readback, 0xe9),
116 DEFINE_PROP_END_OF_LIST(),
117};
118
119static void debugcon_isa_class_initfn(ObjectClass *klass, void *data)
120{
121 DeviceClass *dc = DEVICE_CLASS(klass);
117 ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
118 ic->init = debugcon_isa_initfn;
122
123 dc->realize = debugcon_isa_realizefn;
119 dc->props = debugcon_isa_properties;
120}
121
122static const TypeInfo debugcon_isa_info = {
123 .name = TYPE_ISA_DEBUGCON_DEVICE,
124 .parent = TYPE_ISA_DEVICE,
125 .instance_size = sizeof(ISADebugconState),
126 .class_init = debugcon_isa_class_initfn,
127};
128
129static void debugcon_register_types(void)
130{
131 type_register_static(&debugcon_isa_info);
132}
133
134type_init(debugcon_register_types)
124 dc->props = debugcon_isa_properties;
125}
126
127static const TypeInfo debugcon_isa_info = {
128 .name = TYPE_ISA_DEBUGCON_DEVICE,
129 .parent = TYPE_ISA_DEVICE,
130 .instance_size = sizeof(ISADebugconState),
131 .class_init = debugcon_isa_class_initfn,
132};
133
134static void debugcon_register_types(void)
135{
136 type_register_static(&debugcon_isa_info);
137}
138
139type_init(debugcon_register_types)