diff options
author | Anthony Liguori <aliguori@us.ibm.com> | 2012-01-24 13:12:29 -0600 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2012-01-27 10:50:50 -0600 |
commit | 999e12bbe85c5dcf49bef13bce4f97399c7105f4 (patch) | |
tree | 73b6ed8633a73134e9f728baa1ed2b1dab58b5b0 /hw/sysbus.c | |
parent | 40021f08882aaef93c66c8c740087b6d3031b63a (diff) |
sysbus: apic: ioapic: convert to QEMU Object Model
This converts three devices because apic and ioapic are subclasses of sysbus.
Converting subclasses independently of their base class is prohibitively hard.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/sysbus.c')
-rw-r--r-- | hw/sysbus.c | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/hw/sysbus.c b/hw/sysbus.c index 2e06fe823c..7d122f9eb5 100644 --- a/hw/sysbus.c +++ b/hw/sysbus.c @@ -107,29 +107,24 @@ void sysbus_init_ioports(SysBusDevice *dev, pio_addr_t ioport, pio_addr_t size) static int sysbus_device_init(DeviceState *dev, DeviceInfo *base) { - SysBusDeviceInfo *info = container_of(base, SysBusDeviceInfo, qdev); + SysBusDevice *sd = SYS_BUS_DEVICE(dev); + SysBusDeviceClass *sbc = SYS_BUS_DEVICE_GET_CLASS(sd); - return info->init(sysbus_from_qdev(dev)); + return sbc->init(sd); } -void sysbus_register_withprop(SysBusDeviceInfo *info) +void sysbus_qdev_register_subclass(DeviceInfo *info, const char *parent) { - info->qdev.init = sysbus_device_init; - info->qdev.bus_info = &system_bus_info; + info->init = sysbus_device_init; + info->bus_info = &system_bus_info; - assert(info->qdev.size >= sizeof(SysBusDevice)); - qdev_register(&info->qdev); + assert(info->size >= sizeof(SysBusDevice)); + qdev_register_subclass(info, parent); } -void sysbus_register_dev(const char *name, size_t size, sysbus_initfn init) +void sysbus_qdev_register(DeviceInfo *info) { - SysBusDeviceInfo *info; - - info = g_malloc0(sizeof(*info)); - info->qdev.name = g_strdup(name); - info->qdev.size = size; - info->init = init; - sysbus_register_withprop(info); + sysbus_qdev_register_subclass(info, TYPE_SYS_BUS_DEVICE); } DeviceState *sysbus_create_varargs(const char *name, @@ -258,3 +253,18 @@ MemoryRegion *sysbus_address_space(SysBusDevice *dev) { return get_system_memory(); } + +static TypeInfo sysbus_device_type_info = { + .name = TYPE_SYS_BUS_DEVICE, + .parent = TYPE_DEVICE, + .instance_size = sizeof(SysBusDevice), + .abstract = true, + .class_size = sizeof(SysBusDeviceClass), +}; + +static void sysbus_register(void) +{ + type_register_static(&sysbus_device_type_info); +} + +device_init(sysbus_register); |