From patchwork Mon Mar 26 09:22:33 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wanpeng Li X-Patchwork-Id: 148666 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 B541AB6FA4 for ; Mon, 26 Mar 2012 20:23:28 +1100 (EST) Received: from localhost ([::1]:55773 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SC697-0001Ky-0u for incoming@patchwork.ozlabs.org; Mon, 26 Mar 2012 05:23:25 -0400 Received: from eggs.gnu.org ([208.118.235.92]:44635) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SC68u-0001KI-4h for qemu-devel@nongnu.org; Mon, 26 Mar 2012 05:23:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SC68n-00005Y-Mh for qemu-devel@nongnu.org; Mon, 26 Mar 2012 05:23:11 -0400 Received: from e28smtp06.in.ibm.com ([122.248.162.6]:60660) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SC68j-0008JV-DZ for qemu-devel@nongnu.org; Mon, 26 Mar 2012 05:23:05 -0400 Received: from /spool/local by e28smtp06.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 26 Mar 2012 14:52:38 +0530 Received: from d28relay04.in.ibm.com (9.184.220.61) by e28smtp06.in.ibm.com (192.168.1.136) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 26 Mar 2012 14:52:36 +0530 Received: from d28av03.in.ibm.com (d28av03.in.ibm.com [9.184.220.65]) by d28relay04.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q2Q9MYWV3072226 for ; Mon, 26 Mar 2012 14:52:35 +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 q2QEpm73022167 for ; Tue, 27 Mar 2012 01:51:49 +1100 Received: from localhost ([9.123.236.97]) by d28av03.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q2QEpmE2022150; Tue, 27 Mar 2012 01:51:48 +1100 Date: Mon, 26 Mar 2012 17:22:33 +0800 From: Wanpeng Li To: qemu-devel Message-ID: <20120326092233.GB545@liwp@linux.vnet.ibm.com> References: <1332727608-26523-1-git-send-email-liwp@linux.vnet.ibm.com> <1332727608-26523-4-git-send-email-liwp@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1332727608-26523-4-git-send-email-liwp@linux.vnet.ibm.com> User-Agent: Mutt/1.5.21 (2010-09-15) x-cbid: 12032609-9574-0000-0000-000001F985F8 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 122.248.162.6 Cc: Gavin Shan , Stefan Hajnoczi , Anthony Liguori , Avi Kivity , liwp@linux.vnet.ibm.com Subject: Re: [Qemu-devel] [PATCH 3/6] convert pci-host to QOM X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: Wanpeng Li 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 On Mon, Mar 26, 2012 at 10:06:45AM +0800, Wanpeng Li wrote: > >From: Anthony Liguori > > >Signed-off-by: Anthony Liguori >Signed-off-by: Wanpeng Li > >--- > hw/pci_host.c | 26 ++++++++++++++++++++++++++ > hw/pci_host.h | 5 +++++ > 2 files changed, 31 insertions(+), 0 deletions(-) > >diff --git a/hw/pci_host.c b/hw/pci_host.c >index 44c6c20..44d7e55 100644 >--- a/hw/pci_host.c >+++ b/hw/pci_host.c >@@ -162,4 +162,30 @@ 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(obj); >+ >+ object_property_add_link(obj, "mmio", TYPE_MEMORY_REGION, >+ (Object **)&s->address_space, NULL); >+} >+ >+static TypeInfo pci_host_type = { >+ .name = TYPE_PCI_HOST, >+ .parent = TYPE_SYS_BUS_DEVICE, >+ .instance_size = sizeof(PCIHostState), >+ .instance_init = pci_host_initfn, >+}; >+ >+static void register_devices(void) >+{ >+ type_register_static(&pci_host_type); >+} >+ >+type_init(register_devices); > >diff --git a/hw/pci_host.h b/hw/pci_host.h >index 359e38f..084e15c 100644 >--- a/hw/pci_host.h >+++ b/hw/pci_host.h >@@ -30,6 +30,9 @@ > > #include "sysbus.h" > >+#define TYPE_PCI_HOST "pci-host" >+#define PCI_HOST(obj) OBJECT_CHECK(PCIHostState, (obj), TYPE_PCI_HOST) >+ > struct PCIHostState { > SysBusDevice busdev; > MemoryRegion conf_mem; >@@ -49,6 +52,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; >-- >1.7.5.4 > From 72bc193e6e25cb393437317843a701b82a9b9233 Mon Sep 17 00:00:00 2001 From: Wanpeng Li Date: Thu, 22 Mar 2012 17:57:30 +0800 Subject: [PATCH 3/6] convert pci-host to QOM From: Anthony Liguori Signed-off-by: Anthony Liguori Signed-off-by: Wanpeng Li --- hw/pci_host.c | 26 ++++++++++++++++++++++++++ hw/pci_host.h | 5 +++++ 2 files changed, 31 insertions(+), 0 deletions(-) diff --git a/hw/pci_host.c b/hw/pci_host.c index 44c6c20..44d7e55 100644 --- a/hw/pci_host.c +++ b/hw/pci_host.c @@ -162,4 +162,30 @@ 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(obj); + + object_property_add_link(obj, "mmio", TYPE_MEMORY_REGION, + (Object **)&s->address_space, NULL); +} + +static TypeInfo pci_host_type = { + .name = TYPE_PCI_HOST, + .parent = TYPE_SYS_BUS_DEVICE, + .instance_size = sizeof(PCIHostState), + .instance_init = pci_host_initfn, +}; + +static void register_devices(void) +{ + type_register_static(&pci_host_type); +} + +type_init(register_devices); diff --git a/hw/pci_host.h b/hw/pci_host.h index 359e38f..084e15c 100644 --- a/hw/pci_host.h +++ b/hw/pci_host.h @@ -30,6 +30,9 @@ #include "sysbus.h" +#define TYPE_PCI_HOST "pci-host" +#define PCI_HOST(obj) OBJECT_CHECK(PCIHostState, (obj), TYPE_PCI_HOST) + struct PCIHostState { SysBusDevice busdev; MemoryRegion conf_mem; @@ -49,6 +52,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; -- 1.7.5.4