From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:36588) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SBzLB-00080s-7P for qemu-devel@nongnu.org; Sun, 25 Mar 2012 22:07:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SBzL9-0000SP-BL for qemu-devel@nongnu.org; Sun, 25 Mar 2012 22:07:24 -0400 Received: from e23smtp06.au.ibm.com ([202.81.31.148]:36374) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SBzL6-0000Re-Vg for qemu-devel@nongnu.org; Sun, 25 Mar 2012 22:07:23 -0400 Received: from /spool/local by e23smtp06.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 26 Mar 2012 02:02:31 +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 q2Q20sD83530910 for ; Mon, 26 Mar 2012 13:00:54 +1100 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 q2Q26uEF029324 for ; Mon, 26 Mar 2012 13:06:56 +1100 From: Wanpeng Li Date: Mon, 26 Mar 2012 10:06:45 +0800 Message-Id: <1332727608-26523-4-git-send-email-liwp@linux.vnet.ibm.com> In-Reply-To: <1332727608-26523-1-git-send-email-liwp@linux.vnet.ibm.com> References: <1332727608-26523-1-git-send-email-liwp@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 3/6] convert pci-host to QOM List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Wanpeng Li , Anthony Liguori , Avi Kivity , Gavin Shan 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