[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 07/26] q35: use realize for q35 host
From: |
Hu Tao |
Subject: |
[Qemu-devel] [PATCH v2 07/26] q35: use realize for q35 host |
Date: |
Mon, 1 Jul 2013 18:18:23 +0800 |
and split off memory region initialization into instance_init.
Signed-off-by: Hu Tao <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 61b525f..244e2f5 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 *b = SYS_BUS_DEVICE(dev);
- memory_region_init_io(&pci->conf_mem, &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(b, MCH_HOST_BRIDGE_CONFIG_ADDR, &pci->conf_mem);
+ sysbus_init_ioports(b, MCH_HOST_BRIDGE_CONFIG_ADDR, 4);
- memory_region_init_io(&pci->data_mem, &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(b, MCH_HOST_BRIDGE_CONFIG_DATA, &pci->data_mem);
+ sysbus_init_ioports(b, 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 Property mch_props[] = {
@@ -70,9 +66,8 @@ 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);
- k->init = q35_host_init;
+ dc->realize = q35_host_realize;
dc->props = mch_props;
dc->fw_name = "pci";
}
@@ -80,6 +75,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 *pci = PCI_HOST_BRIDGE(obj);
+
+ memory_region_init_io(&pci->conf_mem, &pci_host_conf_le_ops, pci,
+ "pci-conf-idx", 4);
+ memory_region_init_io(&pci->data_mem, &pci_host_data_le_ops, pci,
+ "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.3.1
- Re: [Qemu-devel] [PATCH v2 02/26] ohci: QOM'ify some more, (continued)
- [Qemu-devel] [PATCH v2 03/26] ohci: use realize for ohci, Hu Tao, 2013/07/01
- [Qemu-devel] [PATCH v2 05/26] i440fx: use type-safe cast instead of directly access of parent dev, Hu Tao, 2013/07/01
- [Qemu-devel] [PATCH v2 04/26] i440fx-pcihost: use realize for i440fx-pcihost, Hu Tao, 2013/07/01
- [Qemu-devel] [PATCH v2 06/26] q35: use type-safe cast instead of directly access of parent dev, Hu Tao, 2013/07/01
- [Qemu-devel] [PATCH v2 08/26] fdc: QOM'ify some more, Hu Tao, 2013/07/01
- [Qemu-devel] [PATCH v2 07/26] q35: use realize for q35 host,
Hu Tao <=
- [Qemu-devel] [PATCH v2 11/26] pflash_cfi01: use realize for pflash_cfi01, Hu Tao, 2013/07/01
- [Qemu-devel] [PATCH v2 09/26] fdc: use realize for fdc., Hu Tao, 2013/07/01
- [Qemu-devel] [PATCH v2 12/26] pflash-cfi02: QOM'ify some more, Hu Tao, 2013/07/01
- [Qemu-devel] [PATCH v2 14/26] ahci: QOM'ify some more, Hu Tao, 2013/07/01
- [Qemu-devel] [PATCH v2 10/26] pflash-cfi01: QOM'ify some more, Hu Tao, 2013/07/01