From patchwork Wed Jul 4 17:19:31 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 169027 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 8D4FD2C0086 for ; Thu, 5 Jul 2012 03:29:57 +1000 (EST) Received: from localhost ([::1]:39825 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SmTFS-0001Ot-V3 for incoming@patchwork.ozlabs.org; Wed, 04 Jul 2012 13:20:18 -0400 Received: from eggs.gnu.org ([208.118.235.92]:46272) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SmTF8-0000eI-VD for qemu-devel@nongnu.org; Wed, 04 Jul 2012 13:20:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SmTF6-0004Yu-FZ for qemu-devel@nongnu.org; Wed, 04 Jul 2012 13:19:58 -0400 Received: from cantor2.suse.de ([195.135.220.15]:47820 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SmTF6-0004YV-5u for qemu-devel@nongnu.org; Wed, 04 Jul 2012 13:19:56 -0400 Received: from relay2.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id A7815A2FB8; Wed, 4 Jul 2012 19:19:52 +0200 (CEST) From: =?UTF-8?q?Andreas=20F=C3=A4rber?= To: qemu-devel@nongnu.org Date: Wed, 4 Jul 2012 19:19:31 +0200 Message-Id: <1341422373-13614-13-git-send-email-afaerber@suse.de> X-Mailer: git-send-email 1.7.7 In-Reply-To: <1341422373-13614-1-git-send-email-afaerber@suse.de> References: <1341422373-13614-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 X-Received-From: 195.135.220.15 Cc: Anthony Liguori , Wanpeng Li , mst@redhat.com, jbaron@redhat.com, =?UTF-8?q?Andreas=20F=C3=A4rber?= , anthony@codemonkey.ws, pbonzini@redhat.com, =?UTF-8?q?Andreas=20F=C3=A4rber?= Subject: [Qemu-devel] [PATCH v3 12/14] pci_host: Turn into SysBus-derived QOM type X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Andreas Färber 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ärber Signed-off-by: Andreas Färber --- 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 = { .endianness = DEVICE_BIG_ENDIAN, }; +static const TypeInfo pci_host_type_info = { + .name = TYPE_PCI_HOST_BRIDGE, + .parent = TYPE_SYS_BUS_DEVICE, + .abstract = true, + .instance_size = sizeof(PCIHostState), +}; + +static void pci_host_register_types(void) +{ + type_register_static(&pci_host_type_info); +} +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 @@ #include "sysbus.h" +#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;