aboutsummaryrefslogtreecommitdiff
path: root/hw/isa-bus.c
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 /hw/isa-bus.c
parente855761ca8fa08ebe29c1e69abc6f0863a453f92 (diff)
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>
Diffstat (limited to 'hw/isa-bus.c')
-rw-r--r--hw/isa-bus.c38
1 files changed, 28 insertions, 10 deletions
diff --git a/hw/isa-bus.c b/hw/isa-bus.c
index 5af790bf81..6943194edd 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)