aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Liguori <aliguori@us.ibm.com>2011-12-04 11:52:49 -0600
committerAnthony Liguori <aliguori@us.ibm.com>2012-01-27 10:50:47 -0600
commit8f04ee0882aec9fe91fb70f767edf5dacff59835 (patch)
tree01ebc9678569233858c2343c9cb04e62c2df55ad
parente855761ca8fa08ebe29c1e69abc6f0863a453f92 (diff)
downloadqemu-8f04ee0882aec9fe91fb70f767edf5dacff59835.zip
qemu-8f04ee0882aec9fe91fb70f767edf5dacff59835.tar.gz
qemu-8f04ee0882aec9fe91fb70f767edf5dacff59835.tar.bz2
isa: pic: convert to QEMU Object Model
This converts two devices at once because PIC subclasses ISA and converting subclasses independently is extremely hard. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
-rw-r--r--hw/applesmc.c18
-rw-r--r--hw/cirrus_vga.c17
-rw-r--r--hw/cs4231a.c20
-rw-r--r--hw/debugcon.c16
-rw-r--r--hw/fdc.c24
-rw-r--r--hw/gus.c20
-rw-r--r--hw/i82374.c19
-rw-r--r--hw/i8254.c22
-rw-r--r--hw/i8259.c15
-rw-r--r--hw/i8259_common.c45
-rw-r--r--hw/i8259_internal.h27
-rw-r--r--hw/ide/isa.c20
-rw-r--r--hw/isa-bus.c38
-rw-r--r--hw/isa.h23
-rw-r--r--hw/kvm/i8259.c19
-rw-r--r--hw/m48t59.c20
-rw-r--r--hw/mc146818rtc.c22
-rw-r--r--hw/ne2000-isa.c16
-rw-r--r--hw/parallel.c16
-rw-r--r--hw/pc.c20
-rw-r--r--hw/pckbd.c18
-rw-r--r--hw/sb16.c20
-rw-r--r--hw/serial.c18
-rw-r--r--hw/sga.c15
-rw-r--r--hw/vga-isa.c18
-rw-r--r--hw/vmmouse.c22
-rw-r--r--hw/vmport.c16
-rw-r--r--hw/wdt_ib700.c18
28 files changed, 390 insertions, 192 deletions
diff --git a/hw/applesmc.c b/hw/applesmc.c
index c47b592..a6e88bc 100644
--- a/hw/applesmc.c
+++ b/hw/applesmc.c
@@ -220,12 +220,18 @@ static int applesmc_isa_init(ISADevice *dev)
return 0;
}
-static ISADeviceInfo applesmc_isa_info = {
- .qdev.name = "isa-applesmc",
- .qdev.size = sizeof(struct AppleSMCStatus),
- .qdev.reset = qdev_applesmc_isa_reset,
- .init = applesmc_isa_init,
- .qdev.props = (Property[]) {
+static void qdev_applesmc_class_init(ObjectClass *klass, void *data)
+{
+ ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
+ ic->init = applesmc_isa_init;
+}
+
+static DeviceInfo applesmc_isa_info = {
+ .name = "isa-applesmc",
+ .size = sizeof(struct AppleSMCStatus),
+ .reset = qdev_applesmc_isa_reset,
+ .class_init = qdev_applesmc_class_init,
+ .props = (Property[]) {
DEFINE_PROP_HEX32("iobase", struct AppleSMCStatus, iobase,
APPLESMC_DEFAULT_IOBASE),
DEFINE_PROP_STRING("osk", struct AppleSMCStatus, osk),
diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c
index 5b22cc3..1d36892 100644
--- a/hw/cirrus_vga.c
+++ b/hw/cirrus_vga.c
@@ -2898,11 +2898,18 @@ static int vga_initfn(ISADevice *dev)
return 0;
}
-static ISADeviceInfo isa_cirrus_vga_info = {
- .qdev.name = "isa-cirrus-vga",
- .qdev.size = sizeof(ISACirrusVGAState),
- .qdev.vmsd = &vmstate_cirrus_vga,
- .init = vga_initfn,
+static void isa_cirrus_vga_class_init(ObjectClass *klass, void *data)
+{
+ ISADeviceClass *k = ISA_DEVICE_CLASS(klass);
+
+ k->init = vga_initfn;
+}
+
+static DeviceInfo isa_cirrus_vga_info = {
+ .name = "isa-cirrus-vga",
+ .size = sizeof(ISACirrusVGAState),
+ .vmsd = &vmstate_cirrus_vga,
+ .class_init = isa_cirrus_vga_class_init,
};
static void isa_cirrus_vga_register(void)
diff --git a/hw/cs4231a.c b/hw/cs4231a.c
index dc77a3a..811c76b 100644
--- a/hw/cs4231a.c
+++ b/hw/cs4231a.c
@@ -665,13 +665,19 @@ int cs4231a_init (ISABus *bus)
return 0;
}
-static ISADeviceInfo cs4231a_info = {
- .qdev.name = "cs4231a",
- .qdev.desc = "Crystal Semiconductor CS4231A",
- .qdev.size = sizeof (CSState),
- .qdev.vmsd = &vmstate_cs4231a,
- .init = cs4231a_initfn,
- .qdev.props = (Property[]) {
+static void cs4231a_class_initfn(ObjectClass *klass, void *data)
+{
+ ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
+ ic->init = cs4231a_initfn;
+}
+
+static DeviceInfo cs4231a_info = {
+ .name = "cs4231a",
+ .desc = "Crystal Semiconductor CS4231A",
+ .size = sizeof (CSState),
+ .vmsd = &vmstate_cs4231a,
+ .class_init = cs4231a_class_initfn,
+ .props = (Property[]) {
DEFINE_PROP_HEX32 ("iobase", CSState, port, 0x534),
DEFINE_PROP_UINT32 ("irq", CSState, irq, 9),
DEFINE_PROP_UINT32 ("dma", CSState, dma, 3),
diff --git a/hw/debugcon.c b/hw/debugcon.c
index c9ee6d9..f290122 100644
--- a/hw/debugcon.c
+++ b/hw/debugcon.c
@@ -87,11 +87,17 @@ static int debugcon_isa_initfn(ISADevice *dev)
return 0;
}
-static ISADeviceInfo debugcon_isa_info = {
- .qdev.name = "isa-debugcon",
- .qdev.size = sizeof(ISADebugconState),
- .init = debugcon_isa_initfn,
- .qdev.props = (Property[]) {
+static void debugcon_isa_class_initfn(ObjectClass *klass, void *data)
+{
+ ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
+ ic->init = debugcon_isa_initfn;
+}
+
+static DeviceInfo debugcon_isa_info = {
+ .name = "isa-debugcon",
+ .size = sizeof(ISADebugconState),
+ .class_init = debugcon_isa_class_initfn,
+ .props = (Property[]) {
DEFINE_PROP_HEX32("iobase", ISADebugconState, iobase, 0xe9),
DEFINE_PROP_CHR("chardev", ISADebugconState, state.chr),
DEFINE_PROP_HEX32("readback", ISADebugconState, state.readback, 0xe9),
diff --git a/hw/fdc.c b/hw/fdc.c
index 70aa5c7..f761221 100644
--- a/hw/fdc.c
+++ b/hw/fdc.c
@@ -1959,15 +1959,21 @@ static const VMStateDescription vmstate_isa_fdc ={
}
};
-static ISADeviceInfo isa_fdc_info = {
- .init = isabus_fdc_init1,
- .qdev.name = "isa-fdc",
- .qdev.fw_name = "fdc",
- .qdev.size = sizeof(FDCtrlISABus),
- .qdev.no_user = 1,
- .qdev.vmsd = &vmstate_isa_fdc,
- .qdev.reset = fdctrl_external_reset_isa,
- .qdev.props = (Property[]) {
+static void isabus_fdc_class_init1(ObjectClass *klass, void *data)
+{
+ ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
+ ic->init = isabus_fdc_init1;
+}
+
+static DeviceInfo isa_fdc_info = {
+ .class_init = isabus_fdc_class_init1,
+ .name = "isa-fdc",
+ .fw_name = "fdc",
+ .size = sizeof(FDCtrlISABus),
+ .no_user = 1,
+ .vmsd = &vmstate_isa_fdc,
+ .reset = fdctrl_external_reset_isa,
+ .props = (Property[]) {
DEFINE_PROP_DRIVE("driveA", FDCtrlISABus, state.drives[0].bs),
DEFINE_PROP_DRIVE("driveB", FDCtrlISABus, state.drives[1].bs),
DEFINE_PROP_INT32("bootindexA", FDCtrlISABus, bootindexA, -1),
diff --git a/hw/gus.c b/hw/gus.c
index ab872d8..6603aab 100644
--- a/hw/gus.c
+++ b/hw/gus.c
@@ -299,13 +299,19 @@ int GUS_init (ISABus *bus)
return 0;
}
-static ISADeviceInfo gus_info = {
- .qdev.name = "gus",
- .qdev.desc = "Gravis Ultrasound GF1",
- .qdev.size = sizeof (GUSState),
- .qdev.vmsd = &vmstate_gus,
- .init = gus_initfn,
- .qdev.props = (Property[]) {
+static void gus_class_initfn(ObjectClass *klass, void *data)
+{
+ ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
+ ic->init = gus_initfn;
+}
+
+static DeviceInfo gus_info = {
+ .name = "gus",
+ .desc = "Gravis Ultrasound GF1",
+ .size = sizeof (GUSState),
+ .vmsd = &vmstate_gus,
+ .class_init = gus_class_initfn,
+ .props = (Property[]) {
DEFINE_PROP_UINT32 ("freq", GUSState, freq, 44100),
DEFINE_PROP_HEX32 ("iobase", GUSState, port, 0x240),
DEFINE_PROP_UINT32 ("irq", GUSState, emu.gusirq, 7),
diff --git a/hw/i82374.c b/hw/i82374.c
index 616d1fc..2814379 100644
--- a/hw/i82374.c
+++ b/hw/i82374.c
@@ -135,12 +135,19 @@ static int i82374_isa_init(ISADevice *dev)
return 0;
}
-static ISADeviceInfo i82374_isa_info = {
- .qdev.name = "i82374",
- .qdev.size = sizeof(ISAi82374State),
- .qdev.vmsd = &vmstate_isa_i82374,
- .init = i82374_isa_init,
- .qdev.props = (Property[]) {
+static void i82374_class_init(ObjectClass *klass, void *data)
+{
+ ISADeviceClass *k = ISA_DEVICE_CLASS(klass);
+
+ k->init = i82374_isa_init;
+}
+
+static DeviceInfo i82374_isa_info = {
+ .name = "i82374",
+ .size = sizeof(ISAi82374State),
+ .vmsd = &vmstate_isa_i82374,
+ .class_init = i82374_class_init,
+ .props = (Property[]) {
DEFINE_PROP_HEX32("iobase", ISAi82374State, iobase, 0x400),
DEFINE_PROP_END_OF_LIST()
},
diff --git a/hw/i8254.c b/hw/i8254.c
index cf9ed2f..add1fab 100644
--- a/hw/i8254.c
+++ b/hw/i8254.c
@@ -535,14 +535,20 @@ static int pit_initfn(ISADevice *dev)
return 0;
}
-static ISADeviceInfo pit_info = {
- .qdev.name = "isa-pit",
- .qdev.size = sizeof(PITState),
- .qdev.vmsd = &vmstate_pit,
- .qdev.reset = pit_reset,
- .qdev.no_user = 1,
- .init = pit_initfn,
- .qdev.props = (Property[]) {
+static void pit_class_initfn(ObjectClass *klass, void *data)
+{
+ ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
+ ic->init = pit_initfn;
+}
+
+static DeviceInfo pit_info = {
+ .name = "isa-pit",
+ .size = sizeof(PITState),
+ .vmsd = &vmstate_pit,
+ .reset = pit_reset,
+ .no_user = 1,
+ .class_init = pit_class_initfn,
+ .props = (Property[]) {
DEFINE_PROP_UINT32("irq", PITState, irq, -1),
DEFINE_PROP_HEX32("iobase", PITState, iobase, -1),
DEFINE_PROP_END_OF_LIST(),
diff --git a/hw/i8259.c b/hw/i8259.c
index 3005ce2..e083bb6 100644
--- a/hw/i8259.c
+++ b/hw/i8259.c
@@ -472,10 +472,17 @@ qemu_irq *i8259_init(ISABus *bus, qemu_irq parent_irq)
return irq_set;
}
-static PICCommonInfo i8259_info = {
- .isadev.qdev.name = "isa-i8259",
- .isadev.qdev.reset = pic_reset,
- .init = pic_init,
+static void i8259_class_init(ObjectClass *klass, void *data)
+{
+ PICCommonClass *k = PIC_COMMON_CLASS(klass);
+
+ k->init = pic_init;
+}
+
+static DeviceInfo i8259_info = {
+ .name = "isa-i8259",
+ .reset = pic_reset,
+ .class_init = i8259_class_init,
};
static void pic_register(void)
diff --git a/hw/i8259_common.c b/hw/i8259_common.c
index 7536897..24b1076 100644
--- a/hw/i8259_common.c
+++ b/hw/i8259_common.c
@@ -48,8 +48,7 @@ void pic_reset_common(PICCommonState *s)
static void pic_dispatch_pre_save(void *opaque)
{
PICCommonState *s = opaque;
- PICCommonInfo *info =
- DO_UPCAST(PICCommonInfo, isadev.qdev, qdev_get_info(&s->dev.qdev));
+ PICCommonClass *info = PIC_COMMON_GET_CLASS(s);
if (info->pre_save) {
info->pre_save(s);
@@ -59,8 +58,7 @@ static void pic_dispatch_pre_save(void *opaque)
static int pic_dispatch_post_load(void *opaque, int version_id)
{
PICCommonState *s = opaque;
- PICCommonInfo *info =
- DO_UPCAST(PICCommonInfo, isadev.qdev, qdev_get_info(&s->dev.qdev));
+ PICCommonClass *info = PIC_COMMON_GET_CLASS(s);
if (info->post_load) {
info->post_load(s);
@@ -71,8 +69,7 @@ static int pic_dispatch_post_load(void *opaque, int version_id)
static int pic_init_common(ISADevice *dev)
{
PICCommonState *s = DO_UPCAST(PICCommonState, dev, dev);
- PICCommonInfo *info =
- DO_UPCAST(PICCommonInfo, isadev.qdev, qdev_get_info(&dev->qdev));
+ PICCommonClass *info = PIC_COMMON_GET_CLASS(s);
info->init(s);
@@ -136,12 +133,34 @@ static Property pic_properties_common[] = {
DEFINE_PROP_END_OF_LIST(),
};
-void pic_qdev_register(PICCommonInfo *info)
+void pic_qdev_register(DeviceInfo *info)
{
- info->isadev.init = pic_init_common;
- info->isadev.qdev.size = sizeof(PICCommonState);
- info->isadev.qdev.vmsd = &vmstate_pic_common;
- info->isadev.qdev.no_user = 1;
- info->isadev.qdev.props = pic_properties_common;
- isa_qdev_register(&info->isadev);
+ info->size = sizeof(PICCommonState);
+ info->vmsd = &vmstate_pic_common;
+ info->no_user = 1;
+ info->props = pic_properties_common;
+ isa_qdev_register_subclass(info, TYPE_PIC_COMMON);
}
+
+static void pic_common_class_init(ObjectClass *klass, void *data)
+{
+ ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
+
+ ic->init = pic_init_common;
+}
+
+static TypeInfo pic_common_type = {
+ .name = TYPE_PIC_COMMON,
+ .parent = TYPE_ISA_DEVICE,
+ .instance_size = sizeof(PICCommonState),
+ .class_size = sizeof(PICCommonClass),
+ .class_init = pic_common_class_init,
+ .abstract = true,
+};
+
+static void register_devices(void)
+{
+ type_register_static(&pic_common_type);
+}
+
+device_init(register_devices);
diff --git a/hw/i8259_internal.h b/hw/i8259_internal.h
index 13deb14..e9d1732 100644
--- a/hw/i8259_internal.h
+++ b/hw/i8259_internal.h
@@ -31,6 +31,22 @@
typedef struct PICCommonState PICCommonState;
+#define TYPE_PIC_COMMON "pic-common"
+#define PIC_COMMON(obj) \
+ OBJECT_CHECK(PICCommon, (obj), TYPE_PIC_COMMON)
+#define PIC_COMMON_CLASS(klass) \
+ OBJECT_CLASS_CHECK(PICCommonClass, (klass), TYPE_PIC_COMMON)
+#define PIC_COMMON_GET_CLASS(obj) \
+ OBJECT_GET_CLASS(PICCommonClass, (obj), TYPE_PIC_COMMON)
+
+typedef struct PICCommonClass
+{
+ ISADeviceClass parent_class;
+ void (*init)(PICCommonState *s);
+ void (*pre_save)(PICCommonState *s);
+ void (*post_load)(PICCommonState *s);
+} PICCommonClass;
+
struct PICCommonState {
ISADevice dev;
uint8_t last_irr; /* edge detection */
@@ -58,19 +74,10 @@ struct PICCommonState {
MemoryRegion elcr_io;
};
-typedef struct PICCommonInfo PICCommonInfo;
-
-struct PICCommonInfo {
- ISADeviceInfo isadev;
- void (*init)(PICCommonState *s);
- void (*pre_save)(PICCommonState *s);
- void (*post_load)(PICCommonState *s);
-};
-
void pic_reset_common(PICCommonState *s);
ISADevice *i8259_init_chip(const char *name, ISABus *bus, bool master);
-void pic_qdev_register(PICCommonInfo *info);
+void pic_qdev_register(DeviceInfo *info);
#endif /* !QEMU_I8259_INTERNAL_H */
diff --git a/hw/ide/isa.c b/hw/ide/isa.c
index 219f3a4..464473a 100644
--- a/hw/ide/isa.c
+++ b/hw/ide/isa.c
@@ -94,13 +94,19 @@ ISADevice *isa_ide_init(ISABus *bus, int iobase, int iobase2, int isairq,
return dev;
}
-static ISADeviceInfo isa_ide_info = {
- .qdev.name = "isa-ide",
- .qdev.fw_name = "ide",
- .qdev.size = sizeof(ISAIDEState),
- .init = isa_ide_initfn,
- .qdev.reset = isa_ide_reset,
- .qdev.props = (Property[]) {
+static void isa_ide_class_initfn(ObjectClass *klass, void *data)
+{
+ ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
+ ic->init = isa_ide_initfn;
+}
+
+static DeviceInfo isa_ide_info = {
+ .name = "isa-ide",
+ .fw_name = "ide",
+ .size = sizeof(ISAIDEState),
+ .class_init = isa_ide_class_initfn,
+ .reset = isa_ide_reset,
+ .props = (Property[]) {
DEFINE_PROP_HEX32("iobase", ISAIDEState, iobase, 0x1f0),
DEFINE_PROP_HEX32("iobase2", ISAIDEState, iobase2, 0x3f6),
DEFINE_PROP_UINT32("irq", ISAIDEState, isairq, 14),
diff --git a/hw/isa-bus.c b/hw/isa-bus.c
index 5af790b..6943194 100644
--- a/hw/isa-bus.c
+++ b/hw/isa-bus.c
@@ -112,20 +112,29 @@ void isa_register_portio_list(ISADevice *dev, uint16_t start,
static int isa_qdev_init(DeviceState *qdev, DeviceInfo *base)
{
- ISADevice *dev = DO_UPCAST(ISADevice, qdev, qdev);
- ISADeviceInfo *info = DO_UPCAST(ISADeviceInfo, qdev, base);
+ ISADevice *dev = ISA_DEVICE(qdev);
+ ISADeviceClass *klass = ISA_DEVICE_GET_CLASS(dev);
dev->isairq[0] = -1;
dev->isairq[1] = -1;
- return info->init(dev);
+ if (klass->init) {
+ return klass->init(dev);
+ }
+
+ return 0;
+}
+
+void isa_qdev_register_subclass(DeviceInfo *info, const char *parent)
+{
+ info->init = isa_qdev_init;
+ info->bus_info = &isa_bus_info;
+ qdev_register_subclass(info, parent);
}
-void isa_qdev_register(ISADeviceInfo *info)
+void isa_qdev_register(DeviceInfo *info)
{
- info->qdev.init = isa_qdev_init;
- info->qdev.bus_info = &isa_bus_info;
- qdev_register(&info->qdev);
+ isa_qdev_register_subclass(info, TYPE_ISA_DEVICE);
}
ISADevice *isa_create(ISABus *bus, const char *name)
@@ -137,7 +146,7 @@ ISADevice *isa_create(ISABus *bus, const char *name)
name);
}
dev = qdev_create(&bus->qbus, name);
- return DO_UPCAST(ISADevice, qdev, dev);
+ return ISA_DEVICE(dev);
}
ISADevice *isa_try_create(ISABus *bus, const char *name)
@@ -149,7 +158,7 @@ ISADevice *isa_try_create(ISABus *bus, const char *name)
name);
}
dev = qdev_try_create(&bus->qbus, name);
- return DO_UPCAST(ISADevice, qdev, dev);
+ return ISA_DEVICE(dev);
}
ISADevice *isa_create_simple(ISABus *bus, const char *name)
@@ -163,7 +172,7 @@ ISADevice *isa_create_simple(ISABus *bus, const char *name)
static void isabus_dev_print(Monitor *mon, DeviceState *dev, int indent)
{
- ISADevice *d = DO_UPCAST(ISADevice, qdev, dev);
+ ISADevice *d = ISA_DEVICE(dev);
if (d->isairq[1] != -1) {
monitor_printf(mon, "%*sisa irqs %d,%d\n", indent, "",
@@ -188,9 +197,18 @@ static SysBusDeviceInfo isabus_bridge_info = {
.qdev.no_user = 1,
};
+static TypeInfo isa_device_type_info = {
+ .name = TYPE_ISA_DEVICE,
+ .parent = TYPE_DEVICE,
+ .instance_size = sizeof(ISADevice),
+ .abstract = true,
+ .class_size = sizeof(ISADeviceClass),
+};
+
static void isabus_register_devices(void)
{
sysbus_register_withprop(&isabus_bridge_info);
+ type_register_static(&isa_device_type_info);
}
static char *isabus_get_fw_dev_path(DeviceState *dev)
diff --git a/hw/isa.h b/hw/isa.h
index b11a0be..9f5d158 100644
--- a/hw/isa.h
+++ b/hw/isa.h
@@ -10,7 +10,19 @@
#define ISA_NUM_IRQS 16
typedef struct ISADevice ISADevice;
-typedef struct ISADeviceInfo ISADeviceInfo;
+
+#define TYPE_ISA_DEVICE "isa-device"
+#define ISA_DEVICE(obj) \
+ OBJECT_CHECK(ISADevice, (obj), TYPE_ISA_DEVICE)
+#define ISA_DEVICE_CLASS(klass) \
+ OBJECT_CLASS_CHECK(ISADeviceClass, (klass), TYPE_ISA_DEVICE)
+#define ISA_DEVICE_GET_CLASS(obj) \
+ OBJECT_GET_CLASS(ISADeviceClass, (obj), TYPE_ISA_DEVICE)
+
+typedef struct ISADeviceClass {
+ DeviceClass parent_class;
+ int (*init)(ISADevice *dev);
+} ISADeviceClass;
struct ISABus {
BusState qbus;
@@ -25,17 +37,12 @@ struct ISADevice {
int ioport_id;
};
-typedef int (*isa_qdev_initfn)(ISADevice *dev);
-struct ISADeviceInfo {
- DeviceInfo qdev;
- isa_qdev_initfn init;
-};
-
ISABus *isa_bus_new(DeviceState *dev, MemoryRegion *address_space_io);
void isa_bus_irqs(ISABus *bus, qemu_irq *irqs);
qemu_irq isa_get_irq(ISADevice *dev, int isairq);
void isa_init_irq(ISADevice *dev, qemu_irq *p, int isairq);
-void isa_qdev_register(ISADeviceInfo *info);
+void isa_qdev_register(DeviceInfo *info);
+void isa_qdev_register_subclass(DeviceInfo *info, const char *parent);
MemoryRegion *isa_address_space(ISADevice *dev);
ISADevice *isa_create(ISABus *bus, const char *name);
ISADevice *isa_try_create(ISABus *bus, const char *name);
diff --git a/hw/kvm/i8259.c b/hw/kvm/i8259.c
index 64bb5c2..b34901c 100644
--- a/hw/kvm/i8259.c
+++ b/hw/kvm/i8259.c
@@ -112,12 +112,19 @@ qemu_irq *kvm_i8259_init(ISABus *bus)
return qemu_allocate_irqs(kvm_pic_set_irq, NULL, ISA_NUM_IRQS);
}
-static PICCommonInfo kvm_i8259_info = {
- .isadev.qdev.name = "kvm-i8259",
- .isadev.qdev.reset = kvm_pic_reset,
- .init = kvm_pic_init,
- .pre_save = kvm_pic_get,
- .post_load = kvm_pic_put,
+static void kvm_i8259_class_init(ObjectClass *klass, void *data)
+{
+ PICCommonClass *k = PIC_COMMON_CLASS(klass);
+
+ k->init = kvm_pic_init;
+ k->pre_save = kvm_pic_get;
+ k->post_load = kvm_pic_put;
+}
+
+static DeviceInfo kvm_i8259_info = {
+ .name = "kvm-i8259",
+ .reset = kvm_pic_reset,
+ .class_init = kvm_i8259_class_init,
};
static void kvm_pic_register(void)
diff --git a/hw/m48t59.c b/hw/m48t59.c
index c043996..5912cd6 100644
--- a/hw/m48t59.c
+++ b/hw/m48t59.c
@@ -720,13 +720,19 @@ static int m48t59_init1(SysBusDevice *dev)
return 0;
}
-static ISADeviceInfo m48t59_isa_info = {
- .init = m48t59_init_isa1,
- .qdev.name = "m48t59_isa",
- .qdev.size = sizeof(M48t59ISAState),
- .qdev.reset = m48t59_reset_isa,
- .qdev.no_user = 1,
- .qdev.props = (Property[]) {
+static void m48t59_init_class_isa1(ObjectClass *klass, void *data)
+{
+ ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
+ ic->init = m48t59_init_isa1;
+}
+
+static DeviceInfo m48t59_isa_info = {
+ .class_init = m48t59_init_class_isa1,
+ .name = "m48t59_isa",
+ .size = sizeof(M48t59ISAState),
+ .reset = m48t59_reset_isa,
+ .no_user = 1,
+ .props = (Property[]) {
DEFINE_PROP_UINT32("size", M48t59ISAState, state.size, -1),
DEFINE_PROP_UINT32("type", M48t59ISAState, state.type, -1),
DEFINE_PROP_HEX32( "io_base", M48t59ISAState, state.io_base, 0),
diff --git a/hw/mc146818rtc.c b/hw/mc146818rtc.c
index 657fa10..685eb89 100644
--- a/hw/mc146818rtc.c
+++ b/hw/mc146818rtc.c
@@ -629,7 +629,7 @@ static void visit_type_int32(Visitor *v, int *value, const char *name, Error **e
static void rtc_get_date(DeviceState *dev, Visitor *v, void *opaque,
const char *name, Error **errp)
{
- ISADevice *isa = DO_UPCAST(ISADevice, qdev, dev);
+ ISADevice *isa = ISA_DEVICE(dev);
RTCState *s = DO_UPCAST(RTCState, dev, isa);
visit_start_struct(v, NULL, "struct tm", name, 0, errp);
@@ -699,13 +699,19 @@ ISADevice *rtc_init(ISABus *bus, int base_year, qemu_irq intercept_irq)
return dev;
}
-static ISADeviceInfo mc146818rtc_info = {
- .qdev.name = "mc146818rtc",
- .qdev.size = sizeof(RTCState),
- .qdev.no_user = 1,
- .qdev.vmsd = &vmstate_rtc,
- .init = rtc_initfn,
- .qdev.props = (Property[]) {
+static void rtc_class_initfn(ObjectClass *klass, void *data)
+{
+ ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
+ ic->init = rtc_initfn;
+}
+
+static DeviceInfo mc146818rtc_info = {
+ .name = "mc146818rtc",
+ .size = sizeof(RTCState),
+ .no_user = 1,
+ .vmsd = &vmstate_rtc,
+ .class_init = rtc_class_initfn,
+ .props = (Property[]) {
DEFINE_PROP_INT32("base_year", RTCState, base_year, 1980),
DEFINE_PROP_END_OF_LIST(),
}
diff --git a/hw/ne2000-isa.c b/hw/ne2000-isa.c
index 5bc5f2a..25a7a31 100644
--- a/hw/ne2000-isa.c
+++ b/hw/ne2000-isa.c
@@ -82,11 +82,17 @@ static int isa_ne2000_initfn(ISADevice *dev)
return 0;
}
-static ISADeviceInfo ne2000_isa_info = {
- .qdev.name = "ne2k_isa",
- .qdev.size = sizeof(ISANE2000State),
- .init = isa_ne2000_initfn,
- .qdev.props = (Property[]) {
+static void isa_ne2000_class_initfn(ObjectClass *klass, void *data)
+{
+ ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
+ ic->init = isa_ne2000_initfn;
+}
+
+static DeviceInfo ne2000_isa_info = {
+ .name = "ne2k_isa",
+ .size = sizeof(ISANE2000State),
+ .class_init = isa_ne2000_class_initfn,
+ .props = (Property[]) {
DEFINE_PROP_HEX32("iobase", ISANE2000State, iobase, 0x300),
DEFINE_PROP_UINT32("irq", ISANE2000State, isairq, 9),
DEFINE_NIC_PROPERTIES(ISANE2000State, ne2000.c),
diff --git a/hw/parallel.c b/hw/parallel.c
index c4c5dbe..cadcffb 100644
--- a/hw/parallel.c
+++ b/hw/parallel.c
@@ -583,11 +583,17 @@ bool parallel_mm_init(MemoryRegion *address_space,
return true;
}
-static ISADeviceInfo parallel_isa_info = {
- .qdev.name = "isa-parallel",
- .qdev.size = sizeof(ISAParallelState),
- .init = parallel_isa_initfn,
- .qdev.props = (Property[]) {
+static void parallel_isa_class_initfn(ObjectClass *klass, void *data)
+{
+ ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
+ ic->init = parallel_isa_initfn;
+}
+
+static DeviceInfo parallel_isa_info = {
+ .name = "isa-parallel",
+ .size = sizeof(ISAParallelState),
+ .class_init = parallel_isa_class_initfn,
+ .props = (Property[]) {
DEFINE_PROP_UINT32("index", ISAParallelState, index, -1),
DEFINE_PROP_HEX32("iobase", ISAParallelState, iobase, -1),
DEFINE_PROP_UINT32("irq", ISAParallelState, isairq, 7),
diff --git a/hw/pc.c b/hw/pc.c
index f3124d3..31608d3 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -497,13 +497,19 @@ static int port92_initfn(ISADevice *dev)
return 0;
}
-static ISADeviceInfo port92_info = {
- .qdev.name = "port92",
- .qdev.size = sizeof(Port92State),
- .qdev.vmsd = &vmstate_port92_isa,
- .qdev.no_user = 1,
- .qdev.reset = port92_reset,
- .init = port92_initfn,
+static void port92_class_initfn(ObjectClass *klass, void *data)
+{
+ ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
+ ic->init = port92_initfn;
+}
+
+static DeviceInfo port92_info = {
+ .name = "port92",
+ .size = sizeof(Port92State),
+ .vmsd = &vmstate_port92_isa,
+ .no_user = 1,
+ .reset = port92_reset,
+ .class_init = port92_class_initfn,
};
static void port92_register(void)
diff --git a/hw/pckbd.c b/hw/pckbd.c
index 06b40c5..2ebe1c5 100644
--- a/hw/pckbd.c
+++ b/hw/pckbd.c
@@ -497,12 +497,18 @@ static int i8042_initfn(ISADevice *dev)
return 0;
}
-static ISADeviceInfo i8042_info = {
- .qdev.name = "i8042",
- .qdev.size = sizeof(ISAKBDState),
- .qdev.vmsd = &vmstate_kbd_isa,
- .qdev.no_user = 1,
- .init = i8042_initfn,
+static void i8042_class_initfn(ObjectClass *klass, void *data)
+{
+ ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
+ ic->init = i8042_initfn;
+}
+
+static DeviceInfo i8042_info = {
+ .name = "i8042",
+ .size = sizeof(ISAKBDState),
+ .vmsd = &vmstate_kbd_isa,
+ .no_user = 1,
+ .class_init = i8042_class_initfn,
};
static void i8042_register(void)
diff --git a/hw/sb16.c b/hw/sb16.c
index 887b32e..67357ce 100644
--- a/hw/sb16.c
+++ b/hw/sb16.c
@@ -1391,13 +1391,19 @@ int SB16_init (ISABus *bus)
return 0;
}
-static ISADeviceInfo sb16_info = {
- .qdev.name = "sb16",
- .qdev.desc = "Creative Sound Blaster 16",
- .qdev.size = sizeof (SB16State),
- .qdev.vmsd = &vmstate_sb16,
- .init = sb16_initfn,
- .qdev.props = (Property[]) {
+static void sb16_class_initfn(ObjectClass *klass, void *data)
+{
+ ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
+ ic->init = sb16_initfn;
+}
+
+static DeviceInfo sb16_info = {
+ .name = "sb16",
+ .desc = "Creative Sound Blaster 16",
+ .size = sizeof (SB16State),
+ .vmsd = &vmstate_sb16,
+ .class_init = sb16_class_initfn,
+ .props = (Property[]) {
DEFINE_PROP_HEX32 ("version", SB16State, ver, 0x0405), /* 4.5 */
DEFINE_PROP_HEX32 ("iobase", SB16State, port, 0x220),
DEFINE_PROP_UINT32 ("irq", SB16State, irq, 5),
diff --git a/hw/serial.c b/hw/serial.c
index d35c7a9..2644b13 100644
--- a/hw/serial.c
+++ b/hw/serial.c
@@ -879,12 +879,18 @@ SerialState *serial_mm_init(MemoryRegion *address_space,
return s;
}
-static ISADeviceInfo serial_isa_info = {
- .qdev.name = "isa-serial",
- .qdev.size = sizeof(ISASerialState),
- .qdev.vmsd = &vmstate_isa_serial,
- .init = serial_isa_initfn,
- .qdev.props = (Property[]) {
+static void serial_isa_class_initfn(ObjectClass *klass, void *data)
+{
+ ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
+ ic->init = serial_isa_initfn;
+}
+
+static DeviceInfo serial_isa_info = {
+ .name = "isa-serial",
+ .size = sizeof(ISASerialState),
+ .vmsd = &vmstate_isa_serial,
+ .class_init = serial_isa_class_initfn,
+ .props = (Property[]) {
DEFINE_PROP_UINT32("index", ISASerialState, index, -1),
DEFINE_PROP_HEX32("iobase", ISASerialState, iobase, -1),
DEFINE_PROP_UINT32("irq", ISASerialState, isairq, -1),
diff --git a/hw/sga.c b/hw/sga.c
index ea11937..d612cb6 100644
--- a/hw/sga.c
+++ b/hw/sga.c
@@ -40,12 +40,17 @@ static int sga_initfn(ISADevice *dev)
rom_add_vga(SGABIOS_FILENAME);
return 0;
}
+static void sga_class_initfn(ObjectClass *klass, void *data)
+{
+ ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
+ ic->init = sga_initfn;
+}
-static ISADeviceInfo sga_info = {
- .qdev.name = "sga",
- .qdev.desc = "Serial Graphics Adapter",
- .qdev.size = sizeof(ISASGAState),
- .init = sga_initfn,
+static DeviceInfo sga_info = {
+ .name = "sga",
+ .desc = "Serial Graphics Adapter",
+ .size = sizeof(ISASGAState),
+ .class_init = sga_class_initfn,
};
static void sga_register(void)
diff --git a/hw/vga-isa.c b/hw/vga-isa.c
index 4825313..cb6af91 100644
--- a/hw/vga-isa.c
+++ b/hw/vga-isa.c
@@ -69,12 +69,18 @@ static int vga_initfn(ISADevice *dev)
return 0;
}
-static ISADeviceInfo vga_info = {
- .qdev.name = "isa-vga",
- .qdev.size = sizeof(ISAVGAState),
- .qdev.vmsd = &vmstate_vga_common,
- .qdev.reset = vga_reset_isa,
- .init = vga_initfn,
+static void vga_class_initfn(ObjectClass *klass, void *data)
+{
+ ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
+ ic->init = vga_initfn;
+}
+
+static DeviceInfo vga_info = {
+ .name = "isa-vga",
+ .size = sizeof(ISAVGAState),
+ .vmsd = &vmstate_vga_common,
+ .reset = vga_reset_isa,
+ .class_init = vga_class_initfn,
};
static void vga_register(void)
diff --git a/hw/vmmouse.c b/hw/vmmouse.c
index 1113f33..da2ea32 100644
--- a/hw/vmmouse.c
+++ b/hw/vmmouse.c
@@ -269,14 +269,20 @@ static int vmmouse_initfn(ISADevice *dev)
return 0;
}
-static ISADeviceInfo vmmouse_info = {
- .init = vmmouse_initfn,
- .qdev.name = "vmmouse",
- .qdev.size = sizeof(VMMouseState),
- .qdev.vmsd = &vmstate_vmmouse,
- .qdev.no_user = 1,
- .qdev.reset = vmmouse_reset,
- .qdev.props = (Property[]) {
+static void vmmouse_class_initfn(ObjectClass *klass, void *data)
+{
+ ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
+ ic->init = vmmouse_initfn;
+}
+
+static DeviceInfo vmmouse_info = {
+ .class_init = vmmouse_class_initfn,
+ .name = "vmmouse",
+ .size = sizeof(VMMouseState),
+ .vmsd = &vmstate_vmmouse,
+ .no_user = 1,
+ .reset = vmmouse_reset,
+ .props = (Property[]) {
DEFINE_PROP_PTR("ps2_mouse", VMMouseState, ps2_mouse),
DEFINE_PROP_END_OF_LIST(),
}
diff --git a/hw/vmport.c b/hw/vmport.c
index 0a3dbc5..c4582d6 100644
--- a/hw/vmport.c
+++ b/hw/vmport.c
@@ -144,11 +144,17 @@ static int vmport_initfn(ISADevice *dev)
return 0;
}
-static ISADeviceInfo vmport_info = {
- .qdev.name = "vmport",
- .qdev.size = sizeof(VMPortState),
- .qdev.no_user = 1,
- .init = vmport_initfn,
+static void vmport_class_initfn(ObjectClass *klass, void *data)
+{
+ ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
+ ic->init = vmport_initfn;
+}
+
+static DeviceInfo vmport_info = {
+ .name = "vmport",
+ .size = sizeof(VMPortState),
+ .no_user = 1,
+ .class_init = vmport_class_initfn,
};
static void vmport_dev_register(void)
diff --git a/hw/wdt_ib700.c b/hw/wdt_ib700.c
index ba1d92d..6deb0de 100644
--- a/hw/wdt_ib700.c
+++ b/hw/wdt_ib700.c
@@ -120,12 +120,18 @@ static WatchdogTimerModel model = {
.wdt_description = "iBASE 700",
};
-static ISADeviceInfo wdt_ib700_info = {
- .qdev.name = "ib700",
- .qdev.size = sizeof(IB700State),
- .qdev.vmsd = &vmstate_ib700,
- .qdev.reset = wdt_ib700_reset,
- .init = wdt_ib700_init,
+static void wdt_ib700_class_init(ObjectClass *klass, void *data)
+{
+ ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
+ ic->init = wdt_ib700_init;
+}
+
+static DeviceInfo wdt_ib700_info = {
+ .name = "ib700",
+ .size = sizeof(IB700State),
+ .vmsd = &vmstate_ib700,
+ .reset = wdt_ib700_reset,
+ .class_init = wdt_ib700_class_init,
};
static void wdt_ib700_register_devices(void)