From patchwork Mon Jul 23 12:35:59 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Wanpeng Li X-Patchwork-Id: 172654 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 3DB7F2C035B for ; Mon, 23 Jul 2012 22:36:41 +1000 (EST) Received: from localhost ([::1]:39950 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1StHsN-0004dR-9P for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2012 08:36:39 -0400 Received: from eggs.gnu.org ([208.118.235.92]:53480) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1StHsA-0004aP-RO for qemu-devel@nongnu.org; Mon, 23 Jul 2012 08:36:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1StHs6-000664-Ex for qemu-devel@nongnu.org; Mon, 23 Jul 2012 08:36:26 -0400 Received: from e28smtp02.in.ibm.com ([122.248.162.2]:37531) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1StHs5-00065t-Qt for qemu-devel@nongnu.org; Mon, 23 Jul 2012 08:36:22 -0400 Received: from /spool/local by e28smtp02.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 23 Jul 2012 18:06:19 +0530 Received: from d28relay03.in.ibm.com (9.184.220.60) by e28smtp02.in.ibm.com (192.168.1.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 23 Jul 2012 18:06:16 +0530 Received: from d28av03.in.ibm.com (d28av03.in.ibm.com [9.184.220.65]) by d28relay03.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q6NCaGCb21889206 for ; Mon, 23 Jul 2012 18:06:16 +0530 Received: from d28av03.in.ibm.com (loopback [127.0.0.1]) by d28av03.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q6NCaFRG011739 for ; Mon, 23 Jul 2012 22:36:16 +1000 Received: from localhost ([9.123.236.43]) by d28av03.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q6NCaEYJ011725; Mon, 23 Jul 2012 22:36:15 +1000 From: Wanpeng Li To: Anthony Liguori Date: Mon, 23 Jul 2012 20:35:59 +0800 Message-Id: <1343046959-6659-4-git-send-email-liwanp@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1343046959-6659-1-git-send-email-liwanp@linux.vnet.ibm.com> References: <1343046959-6659-1-git-send-email-liwanp@linux.vnet.ibm.com> x-cbid: 12072312-5816-0000-0000-000003B0A588 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 122.248.162.2 Cc: Ram Pai , Gavin Shan , "Michael S. Tsirkin" , Jan Kiszka , qemu-devel@nongnu.org, Liu Ping Fan , Blue Swirl , Stefan Weil , Avi Kivity , Paolo Bonzini , Wanpeng Li Subject: [Qemu-devel] [PATCH v5 3/3] convert pci-host to QOM 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: Anthony Liguori makes pci_host a proper QOM type. Changelog: * against Andreas pci_host branch * make host bridge TypeInfos const * use PCI_HOST_BRIDGE() where appropriate Signed-off-by: Anthony Liguori Signed-off-by: Wanpeng Li Signed-off-by: Andreas Färber --- hw/i440fx.c | 6 +++--- hw/pc.c | 2 +- hw/pci_host.c | 14 ++++++++++++++ hw/pci_host.h | 2 ++ hw/piix3.c | 4 ++-- 5 files changed, 22 insertions(+), 6 deletions(-) diff --git a/hw/i440fx.c b/hw/i440fx.c index 720a25a..fdf040b 100644 --- a/hw/i440fx.c +++ b/hw/i440fx.c @@ -191,7 +191,7 @@ static const VMStateDescription vmstate_i440fx_pmc = { static int i440fx_realize(SysBusDevice *dev) { I440FXState *s = I440FX(dev); - PCIHostState *h = PCI_HOST(s); + PCIHostState *h = PCI_HOST_BRIDGE(s); int bios_size, isa_bios_size; char *filename; int ret; @@ -401,7 +401,7 @@ static void i440fx_pmc_class_init(ObjectClass *klass, void *data) dc->vmsd = &vmstate_i440fx_pmc; } -static TypeInfo i440fx_pmc_info = { +static const TypeInfo i440fx_pmc_info = { .name = TYPE_I440FX_PMC, .parent = TYPE_PCI_DEVICE, .instance_size = sizeof(I440FXPMCState), @@ -418,7 +418,7 @@ static void i440fx_class_init(ObjectClass *klass, void *data) dc->no_user = 1; } -static TypeInfo i440fx_info = { +static const TypeInfo i440fx_info = { .name = TYPE_I440FX, .parent = TYPE_PCI_HOST_BRIDGE, .instance_size = sizeof(I440FXState), diff --git a/hw/pc.c b/hw/pc.c index d9a0443..f095109 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -1217,7 +1217,7 @@ static PCIBus *i440fx_init(I440FXPMCState **pi440fx_state, int *piix3_devfn, PCIHostState *h; s = I440FX(object_new(TYPE_I440FX)); - h = PCI_HOST(s); + h = PCI_HOST_BRIDGE(s); /* FIXME make a properties */ h->address_space = address_space_mem; diff --git a/hw/pci_host.c b/hw/pci_host.c index 3950e94..4e10042 100644 --- a/hw/pci_host.c +++ b/hw/pci_host.c @@ -165,11 +165,25 @@ const MemoryRegionOps pci_host_data_be_ops = { .endianness = DEVICE_BIG_ENDIAN, }; +void pci_host_set_mmio(PCIHostState *s, MemoryRegion *value) +{ + object_property_set_link(OBJECT(s), OBJECT(value), "mmio", NULL); +} + +static void pci_host_initfn(Object *obj) +{ + PCIHostState *s = PCI_HOST_BRIDGE(obj); + + object_property_add_link(obj, "mmio", "memory-region", + (Object **)&s->address_space, NULL); +} + static const TypeInfo pci_host_type_info = { .name = TYPE_PCI_HOST_BRIDGE, .parent = TYPE_SYS_BUS_DEVICE, .abstract = true, .instance_size = sizeof(PCIHostState), + .instance_init = pci_host_initfn, }; static void pci_host_register_types(void) diff --git a/hw/pci_host.h b/hw/pci_host.h index 4b9c300..9f28728 100644 --- a/hw/pci_host.h +++ b/hw/pci_host.h @@ -54,6 +54,8 @@ uint32_t pci_host_config_read_common(PCIDevice *pci_dev, uint32_t addr, void pci_data_write(PCIBus *s, uint32_t addr, uint32_t val, int len); uint32_t pci_data_read(PCIBus *s, uint32_t addr, int len); +void pci_host_set_mmio(PCIHostState *s, MemoryRegion *value); + extern const MemoryRegionOps pci_host_conf_le_ops; extern const MemoryRegionOps pci_host_conf_be_ops; extern const MemoryRegionOps pci_host_data_le_ops; diff --git a/hw/piix3.c b/hw/piix3.c index eca6ec8..3b69b15 100644 --- a/hw/piix3.c +++ b/hw/piix3.c @@ -204,7 +204,7 @@ static void piix3_class_init(ObjectClass *klass, void *data) k->class_id = PCI_CLASS_BRIDGE_ISA; } -static TypeInfo piix3_info = { +static const TypeInfo piix3_info = { .name = TYPE_PIIX3, .parent = TYPE_PCI_DEVICE, .instance_size = sizeof(PIIX3State), @@ -219,7 +219,7 @@ static void piix3_xen_class_init(ObjectClass *klass, void *data) k->config_write = piix3_write_config_xen; }; -static TypeInfo piix3_xen_info = { +static const TypeInfo piix3_xen_info = { .name = "PIIX3-xen", .parent = TYPE_PIIX3, .instance_size = sizeof(PIIX3State),