[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 33/55] q35: Use QOM realize for q35 host bridge
From: |
Andreas Färber |
Subject: |
[Qemu-devel] [PULL 33/55] q35: Use QOM realize for q35 host bridge |
Date: |
Tue, 23 Jul 2013 01:46:14 +0200 |
From: Hu Tao <address@hidden>
And split off MemoryRegion initialization into instance_init.
Signed-off-by: Hu Tao <address@hidden>
Signed-off-by: Andreas Färber <address@hidden>
---
hw/pci-host/q35.c | 29 +++++++++++++++--------------
1 file changed, 15 insertions(+), 14 deletions(-)
diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c
index 86dd298..6b1b3b7 100644
--- a/hw/pci-host/q35.c
+++ b/hw/pci-host/q35.c
@@ -34,31 +34,27 @@
* Q35 host
*/
-static int q35_host_init(SysBusDevice *dev)
+static void q35_host_realize(DeviceState *dev, Error **errp)
{
PCIHostState *pci = PCI_HOST_BRIDGE(dev);
Q35PCIHost *s = Q35_HOST_DEVICE(dev);
+ SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
- memory_region_init_io(&pci->conf_mem, OBJECT(pci), &pci_host_conf_le_ops,
pci,
- "pci-conf-idx", 4);
- sysbus_add_io(dev, MCH_HOST_BRIDGE_CONFIG_ADDR, &pci->conf_mem);
- sysbus_init_ioports(dev, MCH_HOST_BRIDGE_CONFIG_ADDR, 4);
+ sysbus_add_io(sbd, MCH_HOST_BRIDGE_CONFIG_ADDR, &pci->conf_mem);
+ sysbus_init_ioports(sbd, MCH_HOST_BRIDGE_CONFIG_ADDR, 4);
- memory_region_init_io(&pci->data_mem, OBJECT(pci), &pci_host_data_le_ops,
pci,
- "pci-conf-data", 4);
- sysbus_add_io(dev, MCH_HOST_BRIDGE_CONFIG_DATA, &pci->data_mem);
- sysbus_init_ioports(dev, MCH_HOST_BRIDGE_CONFIG_DATA, 4);
+ sysbus_add_io(sbd, MCH_HOST_BRIDGE_CONFIG_DATA, &pci->data_mem);
+ sysbus_init_ioports(sbd, MCH_HOST_BRIDGE_CONFIG_DATA, 4);
if (pcie_host_init(PCIE_HOST_BRIDGE(s)) < 0) {
- return -1;
+ error_setg(errp, "failed to initialize pcie host");
+ return;
}
pci->bus = pci_bus_new(DEVICE(s), "pcie.0",
s->mch.pci_address_space, s->mch.address_space_io,
0, TYPE_PCIE_BUS);
qdev_set_parent_bus(DEVICE(&s->mch), BUS(pci->bus));
qdev_init_nofail(DEVICE(&s->mch));
-
- return 0;
}
static const char *q35_host_root_bus_path(PCIHostState *host_bridge,
@@ -77,11 +73,10 @@ static Property mch_props[] = {
static void q35_host_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
- SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
PCIHostBridgeClass *hc = PCI_HOST_BRIDGE_CLASS(klass);
hc->root_bus_path = q35_host_root_bus_path;
- k->init = q35_host_init;
+ dc->realize = q35_host_realize;
dc->props = mch_props;
dc->fw_name = "pci";
}
@@ -89,6 +84,12 @@ static void q35_host_class_init(ObjectClass *klass, void
*data)
static void q35_host_initfn(Object *obj)
{
Q35PCIHost *s = Q35_HOST_DEVICE(obj);
+ PCIHostState *phb = PCI_HOST_BRIDGE(obj);
+
+ memory_region_init_io(&phb->conf_mem, obj, &pci_host_conf_le_ops, phb,
+ "pci-conf-idx", 4);
+ memory_region_init_io(&phb->data_mem, obj, &pci_host_data_le_ops, phb,
+ "pci-conf-data", 4);
object_initialize(&s->mch, TYPE_MCH_PCI_DEVICE);
object_property_add_child(OBJECT(s), "mch", OBJECT(&s->mch), NULL);
--
1.8.1.4
- [Qemu-devel] [PULL 21/55] display/vmware_vga: QOM casting sweep, (continued)
- [Qemu-devel] [PULL 21/55] display/vmware_vga: QOM casting sweep, Andreas Färber, 2013/07/22
- [Qemu-devel] [PULL 22/55] display/vmware_vga: QOM parent field cleanup, Andreas Färber, 2013/07/22
- [Qemu-devel] [PULL 23/55] misc/ivshmem: QOM Upcast Sweep, Andreas Färber, 2013/07/22
- [Qemu-devel] [PULL 25/55] xen/xen_platform: QOM casting sweep, Andreas Färber, 2013/07/22
- [Qemu-devel] [PULL 26/55] xen/xen_platform: QOM parent field cleanup, Andreas Färber, 2013/07/22
- [Qemu-devel] [PULL 27/55] sysbus: Document SysBusDeviceClass::init and realize semantics, Andreas Färber, 2013/07/22
- [Qemu-devel] [PULL 24/55] misc/ivshmem: QOM parent field cleanup, Andreas Färber, 2013/07/22
- [Qemu-devel] [PULL 29/55] ohci: Use QOM realize for OHCI, Andreas Färber, 2013/07/22
- [Qemu-devel] [PULL 28/55] ohci: QOM'ify some more, Andreas Färber, 2013/07/22
- [Qemu-devel] [PULL 31/55] i440fx-pcihost: Use QOM realize for i440fx-pcihost, Andreas Färber, 2013/07/22
- [Qemu-devel] [PULL 33/55] q35: Use QOM realize for q35 host bridge,
Andreas Färber <=
- [Qemu-devel] [PULL 30/55] i440fx: Use type-safe cast instead of direct access of parent dev, Andreas Färber, 2013/07/22
- [Qemu-devel] [PULL 35/55] pflash-cfi01: QOM'ify some more, Andreas Färber, 2013/07/22
- [Qemu-devel] [PULL 34/55] fdc: QOM'ify some more, Andreas Färber, 2013/07/22
- [Qemu-devel] [PULL 32/55] q35: Use type-safe cast instead of direct access of parent dev, Andreas Färber, 2013/07/22
- [Qemu-devel] [PULL 36/55] pflash-cfi02: QOM'ify some more, Andreas Färber, 2013/07/22
- [Qemu-devel] [PULL 38/55] fwcfg: QOM'ify some more, Andreas Färber, 2013/07/22
- [Qemu-devel] [PULL 37/55] ahci: QOM'ify some more, Andreas Färber, 2013/07/22
- [Qemu-devel] [PULL 39/55] scsi/esp: QOM'ify some more, Andreas Färber, 2013/07/22
- [Qemu-devel] [PULL 41/55] kvm/clock: QOM'ify some more, Andreas Färber, 2013/07/22
- [Qemu-devel] [PULL 40/55] hpet: QOM'ify some more, Andreas Färber, 2013/07/22