diff options
author | Anthony Liguori <aliguori@us.ibm.com> | 2011-12-07 21:34:16 -0600 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2012-02-03 10:41:06 -0600 |
commit | 39bffca2030950ef6efe57c2fac8327a45ae1015 (patch) | |
tree | 325262f44978e6116c9e43f688c900e08ee83738 /hw/ide/qdev.c | |
parent | 212ad111683a5b5a79a74d6141a4b75f532a4c8f (diff) | |
download | qemu-39bffca2030950ef6efe57c2fac8327a45ae1015.zip qemu-39bffca2030950ef6efe57c2fac8327a45ae1015.tar.gz qemu-39bffca2030950ef6efe57c2fac8327a45ae1015.tar.bz2 |
qdev: register all types natively through QEMU Object Model
This was done in a mostly automated fashion. I did it in three steps and then
rebased it into a single step which avoids repeatedly touching every file in
the tree.
The first step was a sed-based addition of the parent type to the subclass
registration functions.
The second step was another sed-based removal of subclass registration functions
while also adding virtual functions from the base class into a class_init
function as appropriate.
Finally, a python script was used to convert the DeviceInfo structures and
qdev_register_subclass functions to TypeInfo structures, class_init functions,
and type_register_static calls.
We are almost fully converted to QOM after this commit.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/ide/qdev.c')
-rw-r--r-- | hw/ide/qdev.c | 93 |
1 files changed, 53 insertions, 40 deletions
diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c index b507e34..1335615 100644 --- a/hw/ide/qdev.c +++ b/hw/ide/qdev.c @@ -91,13 +91,6 @@ err: return -1; } -static void ide_qdev_register(DeviceInfo *info) -{ - info->init = ide_qdev_init; - info->bus_info = &ide_bus_info; - qdev_register_subclass(info, TYPE_IDE_DEVICE); -} - IDEDevice *ide_create_drive(IDEBus *bus, int unit, DriveInfo *drive) { DeviceState *dev; @@ -182,73 +175,93 @@ static int ide_drive_initfn(IDEDevice *dev) DEFINE_PROP_STRING("ver", IDEDrive, dev.version), \ DEFINE_PROP_STRING("serial", IDEDrive, dev.serial) +static Property ide_hd_properties[] = { + DEFINE_IDE_DEV_PROPERTIES(), + DEFINE_PROP_END_OF_LIST(), +}; + static void ide_hd_class_init(ObjectClass *klass, void *data) { + DeviceClass *dc = DEVICE_CLASS(klass); IDEDeviceClass *k = IDE_DEVICE_CLASS(klass); k->init = ide_hd_initfn; + dc->fw_name = "drive"; + dc->desc = "virtual IDE disk"; + dc->props = ide_hd_properties; } -static DeviceInfo ide_hd_info = { - .name = "ide-hd", - .fw_name = "drive", - .desc = "virtual IDE disk", - .size = sizeof(IDEDrive), - .class_init = ide_hd_class_init, - .props = (Property[]) { - DEFINE_IDE_DEV_PROPERTIES(), - DEFINE_PROP_END_OF_LIST(), - } +static TypeInfo ide_hd_info = { + .name = "ide-hd", + .parent = TYPE_IDE_DEVICE, + .instance_size = sizeof(IDEDrive), + .class_init = ide_hd_class_init, +}; + +static Property ide_cd_properties[] = { + DEFINE_IDE_DEV_PROPERTIES(), + DEFINE_PROP_END_OF_LIST(), }; static void ide_cd_class_init(ObjectClass *klass, void *data) { + DeviceClass *dc = DEVICE_CLASS(klass); IDEDeviceClass *k = IDE_DEVICE_CLASS(klass); k->init = ide_cd_initfn; + dc->fw_name = "drive"; + dc->desc = "virtual IDE CD-ROM"; + dc->props = ide_cd_properties; } -static DeviceInfo ide_cd_info = { - .name = "ide-cd", - .fw_name = "drive", - .desc = "virtual IDE CD-ROM", - .size = sizeof(IDEDrive), - .class_init = ide_cd_class_init, - .props = (Property[]) { - DEFINE_IDE_DEV_PROPERTIES(), - DEFINE_PROP_END_OF_LIST(), - } +static TypeInfo ide_cd_info = { + .name = "ide-cd", + .parent = TYPE_IDE_DEVICE, + .instance_size = sizeof(IDEDrive), + .class_init = ide_cd_class_init, +}; + +static Property ide_drive_properties[] = { + DEFINE_IDE_DEV_PROPERTIES(), + DEFINE_PROP_END_OF_LIST(), }; static void ide_drive_class_init(ObjectClass *klass, void *data) { + DeviceClass *dc = DEVICE_CLASS(klass); IDEDeviceClass *k = IDE_DEVICE_CLASS(klass); k->init = ide_drive_initfn; + dc->fw_name = "drive"; + dc->desc = "virtual IDE disk or CD-ROM (legacy)"; + dc->props = ide_drive_properties; } -static DeviceInfo ide_drive_info = { - .name = "ide-drive", /* legacy -device ide-drive */ - .fw_name = "drive", - .desc = "virtual IDE disk or CD-ROM (legacy)", - .size = sizeof(IDEDrive), - .class_init = ide_drive_class_init, - .props = (Property[]) { - DEFINE_IDE_DEV_PROPERTIES(), - DEFINE_PROP_END_OF_LIST(), - } +static TypeInfo ide_drive_info = { + .name = "ide-drive", + .parent = TYPE_IDE_DEVICE, + .instance_size = sizeof(IDEDrive), + .class_init = ide_drive_class_init, }; +static void ide_device_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *k = DEVICE_CLASS(klass); + k->init = ide_qdev_init; + k->bus_info = &ide_bus_info; +} + static TypeInfo ide_device_type_info = { .name = TYPE_IDE_DEVICE, .parent = TYPE_DEVICE, .instance_size = sizeof(IDEDevice), .abstract = true, .class_size = sizeof(IDEDeviceClass), + .class_init = ide_device_class_init, }; static void ide_dev_register(void) { - ide_qdev_register(&ide_hd_info); - ide_qdev_register(&ide_cd_info); - ide_qdev_register(&ide_drive_info); + type_register_static(&ide_hd_info); + type_register_static(&ide_cd_info); + type_register_static(&ide_drive_info); type_register_static(&ide_device_type_info); } device_init(ide_dev_register); |