From patchwork Wed Jul 18 13:19:03 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wanpeng Li X-Patchwork-Id: 171670 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 34CAC2C0380 for ; Wed, 18 Jul 2012 23:20:38 +1000 (EST) Received: from localhost ([::1]:41213 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SrUBA-0005wu-5t for incoming@patchwork.ozlabs.org; Wed, 18 Jul 2012 09:20:36 -0400 Received: from eggs.gnu.org ([208.118.235.92]:59341) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SrUAQ-0005HW-5d for qemu-devel@nongnu.org; Wed, 18 Jul 2012 09:20:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SrUA0-000734-8j for qemu-devel@nongnu.org; Wed, 18 Jul 2012 09:19:50 -0400 Received: from e23smtp08.au.ibm.com ([202.81.31.141]:50210) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SrU9z-00071P-OL for qemu-devel@nongnu.org; Wed, 18 Jul 2012 09:19:24 -0400 Received: from /spool/local by e23smtp08.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 18 Jul 2012 13:15:57 +1000 Received: from d23relay04.au.ibm.com (202.81.31.246) by e23smtp08.au.ibm.com (202.81.31.205) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 18 Jul 2012 13:15:55 +1000 Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay04.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q6IDBGWb3735840 for ; Wed, 18 Jul 2012 23:11:16 +1000 Received: from d23av03.au.ibm.com (loopback [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q6IDJGJK002584 for ; Wed, 18 Jul 2012 23:19:16 +1000 Received: from localhost ([9.123.247.28]) by d23av03.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q6IDJFMH002573; Wed, 18 Jul 2012 23:19:16 +1000 From: Wanpeng Li To: Anthony Liguori Date: Wed, 18 Jul 2012 21:19:03 +0800 Message-Id: <1342617545-9261-4-git-send-email-liwanp@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1342617545-9261-1-git-send-email-liwanp@linux.vnet.ibm.com> References: <1342617545-9261-1-git-send-email-liwanp@linux.vnet.ibm.com> x-cbid: 12071803-5140-0000-0000-000001C3F987 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 202.81.31.141 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 v4 3/5] 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 [CCing ML] 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 8041778..095bfe3 100644 --- a/hw/pci_host.c +++ b/hw/pci_host.c @@ -165,4 +165,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_info = { + .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_info); +} + +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;