aboutsummaryrefslogtreecommitdiff
path: root/hw/sysbus.c
diff options
context:
space:
mode:
Diffstat (limited to 'hw/sysbus.c')
-rw-r--r--hw/sysbus.c40
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);