From 3cb75a7cba7e808c0ae007e4d86750849642304e Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 28 Mar 2012 18:01:36 +0200 Subject: qdev: Move bus properties to a separate global MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Simple code movement in order to simplify future refactoring. Signed-off-by: Paolo Bonzini Signed-off-by: Andreas Färber --- hw/intel-hda.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'hw/intel-hda.c') diff --git a/hw/intel-hda.c b/hw/intel-hda.c index bb11af2..0994f6b 100644 --- a/hw/intel-hda.c +++ b/hw/intel-hda.c @@ -29,13 +29,15 @@ /* --------------------------------------------------------------------- */ /* hda bus */ +static Property hda_props[] = { + DEFINE_PROP_UINT32("cad", HDACodecDevice, cad, -1), + DEFINE_PROP_END_OF_LIST() +}; + static struct BusInfo hda_codec_bus_info = { .name = "HDA", .size = sizeof(HDACodecBus), - .props = (Property[]) { - DEFINE_PROP_UINT32("cad", HDACodecDevice, cad, -1), - DEFINE_PROP_END_OF_LIST() - } + .props = hda_props, }; void hda_codec_bus_init(DeviceState *dev, HDACodecBus *bus, -- cgit v1.1 From bce544740a87cac1636f01c8a28502fec1694b3d Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 28 Mar 2012 18:12:47 +0200 Subject: qdev: Move bus properties to abstract superclasses MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In qdev, each bus in practice identified an abstract superclass, but this was mostly hidden. In QOM, instead, these abstract classes are explicit so we can move bus properties there. All bus property walks are removed, and all device property walks are changed to look along the class hierarchy instead. We would have duplicates if class A defines some properties and its subclass B does not define any, because class_b->props will be left equal to class_a->props. The solution here is to reintroduce the class_base_init TypeInfo callback, that was present in one of the early QOM versions but removed (on my request...) before committing. This breaks global bus properties, an obscure feature when used with the command-line which is actually useful and used when used by backwards-compatible machine types. So this patch also adjusts the global bus properties in hw/pc_piix.c to refer to the abstract class. Globals and other properties must be modified in the same patch to avoid complications related to initialization ordering. Signed-off-by: Paolo Bonzini Signed-off-by: Andreas Färber --- hw/intel-hda.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'hw/intel-hda.c') diff --git a/hw/intel-hda.c b/hw/intel-hda.c index 0994f6b..e2bd41e 100644 --- a/hw/intel-hda.c +++ b/hw/intel-hda.c @@ -37,7 +37,6 @@ static Property hda_props[] = { static struct BusInfo hda_codec_bus_info = { .name = "HDA", .size = sizeof(HDACodecBus), - .props = hda_props, }; void hda_codec_bus_init(DeviceState *dev, HDACodecBus *bus, @@ -1278,6 +1277,7 @@ static void hda_codec_device_class_init(ObjectClass *klass, void *data) k->init = hda_codec_dev_init; k->exit = hda_codec_dev_exit; k->bus_info = &hda_codec_bus_info; + k->props = hda_props; } static TypeInfo hda_codec_device_type_info = { -- cgit v1.1 From 0d936928ef87ca1bb7b41b5b89c400c699a7691c Mon Sep 17 00:00:00 2001 From: Anthony Liguori Date: Wed, 2 May 2012 09:00:20 +0200 Subject: qdev: Convert busses to QEMU Object Model MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is far less interesting than it sounds. We simply add an Object to each BusState and then register the types appropriately. Most of the interesting refactoring will follow in the next patches. Since we're changing fundamental type names (BusInfo -> BusClass), it all needs to convert at once. Fortunately, not a lot of code is affected. Signed-off-by: Anthony Liguori Signed-off-by: Paolo Bonzini [AF: Made all new bus TypeInfos static const.] [AF: Made qbus_free() call object_delete(), required {qom,glib}_allocated] Signed-off-by: Andreas Färber --- hw/intel-hda.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'hw/intel-hda.c') diff --git a/hw/intel-hda.c b/hw/intel-hda.c index e2bd41e..e343096 100644 --- a/hw/intel-hda.c +++ b/hw/intel-hda.c @@ -34,16 +34,17 @@ static Property hda_props[] = { DEFINE_PROP_END_OF_LIST() }; -static struct BusInfo hda_codec_bus_info = { - .name = "HDA", - .size = sizeof(HDACodecBus), +static const TypeInfo hda_codec_bus_info = { + .name = TYPE_HDA_BUS, + .parent = TYPE_BUS, + .instance_size = sizeof(HDACodecBus), }; void hda_codec_bus_init(DeviceState *dev, HDACodecBus *bus, hda_codec_response_func response, hda_codec_xfer_func xfer) { - qbus_create_inplace(&bus->qbus, &hda_codec_bus_info, dev, NULL); + qbus_create_inplace(&bus->qbus, TYPE_HDA_BUS, dev, NULL); bus->response = response; bus->xfer = xfer; } @@ -1276,7 +1277,7 @@ static void hda_codec_device_class_init(ObjectClass *klass, void *data) DeviceClass *k = DEVICE_CLASS(klass); k->init = hda_codec_dev_init; k->exit = hda_codec_dev_exit; - k->bus_info = &hda_codec_bus_info; + k->bus_type = TYPE_HDA_BUS; k->props = hda_props; } @@ -1291,6 +1292,7 @@ static TypeInfo hda_codec_device_type_info = { static void intel_hda_register_types(void) { + type_register_static(&hda_codec_bus_info); type_register_static(&intel_hda_info); type_register_static(&hda_codec_device_type_info); } -- cgit v1.1 From 0866aca1de15a12547f52ff8563cf7c163e1898e Mon Sep 17 00:00:00 2001 From: Anthony Liguori Date: Fri, 23 Dec 2011 15:34:39 -0600 Subject: qbus: Make child devices links MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make qbus children show up as link<> properties. There is no stable addressing for qbus children so we use an unstable naming convention. This is okay in QOM though because the composition name is expected to be what's stable. Signed-off-by: Anthony Liguori Signed-off-by: Paolo Bonzini Signed-off-by: Andreas Färber --- hw/intel-hda.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'hw/intel-hda.c') diff --git a/hw/intel-hda.c b/hw/intel-hda.c index e343096..c11fd30 100644 --- a/hw/intel-hda.c +++ b/hw/intel-hda.c @@ -78,10 +78,11 @@ static int hda_codec_dev_exit(DeviceState *qdev) HDACodecDevice *hda_codec_find(HDACodecBus *bus, uint32_t cad) { - DeviceState *qdev; + BusChild *kid; HDACodecDevice *cdev; - QTAILQ_FOREACH(qdev, &bus->qbus.children, sibling) { + QTAILQ_FOREACH(kid, &bus->qbus.children, sibling) { + DeviceState *qdev = kid->child; cdev = DO_UPCAST(HDACodecDevice, qdev, qdev); if (cdev->cad == cad) { return cdev; @@ -483,10 +484,11 @@ static void intel_hda_parse_bdl(IntelHDAState *d, IntelHDAStream *st) static void intel_hda_notify_codecs(IntelHDAState *d, uint32_t stream, bool running, bool output) { - DeviceState *qdev; + BusChild *kid; HDACodecDevice *cdev; - QTAILQ_FOREACH(qdev, &d->codecs.qbus.children, sibling) { + QTAILQ_FOREACH(kid, &d->codecs.qbus.children, sibling) { + DeviceState *qdev = kid->child; HDACodecDeviceClass *cdc; cdev = DO_UPCAST(HDACodecDevice, qdev, qdev); @@ -1105,15 +1107,16 @@ static const MemoryRegionOps intel_hda_mmio_ops = { static void intel_hda_reset(DeviceState *dev) { + BusChild *kid; IntelHDAState *d = DO_UPCAST(IntelHDAState, pci.qdev, dev); - DeviceState *qdev; HDACodecDevice *cdev; intel_hda_regs_reset(d); d->wall_base_ns = qemu_get_clock_ns(vm_clock); /* reset codecs */ - QTAILQ_FOREACH(qdev, &d->codecs.qbus.children, sibling) { + QTAILQ_FOREACH(kid, &d->codecs.qbus.children, sibling) { + DeviceState *qdev = kid->child; cdev = DO_UPCAST(HDACodecDevice, qdev, qdev); device_reset(DEVICE(cdev)); d->state_sts |= (1 << cdev->cad); -- cgit v1.1