Received: from eggs.gnu.org ([208.118.235.92]:48100) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T0xFK-0000F4-66 for qemu-devel@nongnu.org; Mon, 13 Aug 2012 12:12:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T0xFH-0003IC-R3 for qemu-devel@nongnu.org; Mon, 13 Aug 2012 12:12:01 -0400 Received: from cantor2.suse.de ([195.135.220.15]:39326 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T0xFH-0003Hs-Ga for qemu-devel@nongnu.org; Mon, 13 Aug 2012 12:11:59 -0400 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Mon, 13 Aug 2012 18:11:33 +0200 Message-Id: <1344874295-5619-13-git-send-email-afaerber@suse.de> In-Reply-To: <1344874295-5619-1-git-send-email-afaerber@suse.de> References: <1344874295-5619-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH for-1.2 v6 12/14] pci_host: Turn into SysBus-derived QOM type List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Anthony Liguori , mst@redhat.com, jbaron@redhat.com, =?UTF-8?q?Andreas=20F=C3=A4rber?= , anthony@codemonkey.ws, =?UTF-8?q?Andreas=20F=C3=A4rber?= , liwanp@linux.vnet.ibm.com From: Andreas F=C3=A4rber The preceding commits fixed misuses of FROM_SYSBUS() that led people to add a bogus busdev field. For qdev the field order was less relevant but for QOM the PCIHostState field (including the SysBusDevice actually initialized with a value) must be placed first within the state struct. To facilitate accessing the PCIHostState fields, derive all PCI host bridges from TYPE_PCI_HOST_BRIDGE rather than TYPE_SYS_BUS_DEVICE. We can now access PCIHostState QOM-style, with PCI_HOST_BRIDGE() macro. Signed-off-by: Anthony Liguori Signed-off-by: Wanpeng Li Signed-off-by: Andreas F=C3=A4rber Signed-off-by: Andreas F=C3=A4rber Acked-by: Michael S. Tsirkin --- hw/pci_host.c | 12 ++++++++++++ hw/pci_host.h | 5 +++++ 2 files changed, 17 insertions(+), 0 deletions(-) diff --git a/hw/pci_host.c b/hw/pci_host.c index 8041778..3950e94 100644 --- a/hw/pci_host.c +++ b/hw/pci_host.c @@ -165,4 +165,16 @@ const MemoryRegionOps pci_host_data_be_ops =3D { .endianness =3D DEVICE_BIG_ENDIAN, }; =20 +static const TypeInfo pci_host_type_info =3D { + .name =3D TYPE_PCI_HOST_BRIDGE, + .parent =3D TYPE_SYS_BUS_DEVICE, + .abstract =3D true, + .instance_size =3D sizeof(PCIHostState), +}; + +static void pci_host_register_types(void) +{ + type_register_static(&pci_host_type_info); +} =20 +type_init(pci_host_register_types) diff --git a/hw/pci_host.h b/hw/pci_host.h index 359e38f..4b9c300 100644 --- a/hw/pci_host.h +++ b/hw/pci_host.h @@ -30,8 +30,13 @@ =20 #include "sysbus.h" =20 +#define TYPE_PCI_HOST_BRIDGE "pci-host-bridge" +#define PCI_HOST_BRIDGE(obj) \ + OBJECT_CHECK(PCIHostState, (obj), TYPE_PCI_HOST_BRIDGE) + struct PCIHostState { SysBusDevice busdev; + MemoryRegion conf_mem; MemoryRegion data_mem; MemoryRegion mmcfg; --=20 1.7.7