From patchwork Sat Apr 6 15:44:29 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 15953 Return-Path: X-Original-To: linaro@staging.patches.linaro.org Delivered-To: linaro@staging.patches.linaro.org Received: from mail-gh0-f200.google.com (mail-gh0-f200.google.com [209.85.160.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 715CF26EC2 for ; Sat, 6 Apr 2013 15:45:02 +0000 (UTC) Received: by mail-gh0-f200.google.com with SMTP id 10sf6250724ghy.3 for ; Sat, 06 Apr 2013 08:44:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:mime-version:x-beenthere:x-received:received-spf :x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe; bh=kbXe2pUEda6Dbo6n05cWaFdRQeEqH294NxMza/bWp/s=; b=Ta8JvLxfDOR7mUkPXEo+QCO+7eggEK6x9YpTTplvmQqjZ4hYmOdGRRHXrghoeyxeGk OWIDVFlkjbU61OikswmlLfKwdSo22GKHKEq3pfDISZdJNrwd551rWaVT/gf1c6/HTO99 5CSJ2qaSlDM8rrOt/kZ9h+Nefs3nqn9tg7ztYcFgjQruvE7oUeZ+ECMwpH7irQ4tYjW9 ljwPxYb4XkXk94Ix31K6/sxh+IP57oZUV28OunYcaxm7uYRjeTs2L8MgDifI1JPrsRqp edOuvQQ1btQD5C8YbDrOC0WKr3FZQ7/oHaEVpv5VUVGtssiRhnU7UaeH04a0aZ+eQ1LN 3ILA== X-Received: by 10.224.18.132 with SMTP id w4mr1484248qaa.1.1365263092337; Sat, 06 Apr 2013 08:44:52 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.25.83 with SMTP id a19ls2293734qeg.33.gmail; Sat, 06 Apr 2013 08:44:52 -0700 (PDT) X-Received: by 10.220.39.69 with SMTP id f5mr11422158vce.45.1365263092250; Sat, 06 Apr 2013 08:44:52 -0700 (PDT) Received: from mail-vb0-x234.google.com (mail-vb0-x234.google.com [2607:f8b0:400c:c02::234]) by mx.google.com with ESMTPS id ij9si3417519vdb.17.2013.04.06.08.44.52 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 06 Apr 2013 08:44:52 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c02::234 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c02::234; Received: by mail-vb0-f52.google.com with SMTP id w8so2853721vbf.11 for ; Sat, 06 Apr 2013 08:44:52 -0700 (PDT) X-Received: by 10.58.238.65 with SMTP id vi1mr11328381vec.31.1365263092120; Sat, 06 Apr 2013 08:44:52 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.58.85.136 with SMTP id h8csp296692vez; Sat, 6 Apr 2013 08:44:51 -0700 (PDT) X-Received: by 10.180.103.40 with SMTP id ft8mr4584856wib.28.1365263084494; Sat, 06 Apr 2013 08:44:44 -0700 (PDT) Received: from mnementh.archaic.org.uk (1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.d.1.0.0.b.8.0.1.0.0.2.ip6.arpa. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id t8si21974440eeg.4.2013.04.06.08.44.43 (version=TLSv1 cipher=RC4-SHA bits=128/128); Sat, 06 Apr 2013 08:44:44 -0700 (PDT) Received-SPF: neutral (google.com: 2001:8b0:1d0::1 is neither permitted nor denied by best guess record for domain of pm215@archaic.org.uk) client-ip=2001:8b0:1d0::1; Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.72) (envelope-from ) id 1UOVID-0004PI-1C; Sat, 06 Apr 2013 16:44:37 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, =?UTF-8?q?Andreas=20F=C3=A4rber?= , "Michael S. Tsirkin" , Paul Brook , Arnd Bergmann , Will Deacon Subject: [PATCH v4 04/11] versatile_pci: Change to subclassing TYPE_PCI_HOST_BRIDGE Date: Sat, 6 Apr 2013 16:44:29 +0100 Message-Id: <1365263076-16909-5-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1365263076-16909-1-git-send-email-peter.maydell@linaro.org> References: <1365263076-16909-1-git-send-email-peter.maydell@linaro.org> X-Gm-Message-State: ALoCoQngG9DbWROBxstsNNV2pl+ea92gEY0tUNaDiLZtttBQJ7+z+y44cSP/P2cffRyeUXeChVE0 X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c02::234 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Change versatile_pci to subclass TYPE_PCI_HOST_BRIDGE and generally handle PCI in a more QOM-like fashion. Signed-off-by: Peter Maydell Acked-by: Paul Brook --- hw/versatile_pci.c | 41 ++++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/hw/versatile_pci.c b/hw/versatile_pci.c index ad33ce7..9e0ece0 100644 --- a/hw/versatile_pci.c +++ b/hw/versatile_pci.c @@ -9,16 +9,22 @@ #include "hw/sysbus.h" #include "hw/pci/pci.h" +#include "hw/pci/pci_bus.h" #include "hw/pci/pci_host.h" #include "exec/address-spaces.h" typedef struct { - SysBusDevice busdev; + PCIHostState parent_obj; + qemu_irq irq[4]; - int realview; MemoryRegion mem_config; MemoryRegion mem_config2; MemoryRegion isa; + PCIBus pci_bus; + PCIDevice pci_dev; + + /* Constant for life of device: */ + int realview; } PCIVPBState; #define TYPE_VERSATILE_PCI "versatile_pci" @@ -66,20 +72,31 @@ static void pci_vpb_set_irq(void *opaque, int irq_num, int level) qemu_set_irq(pic[irq_num], level); } +static void pci_vpb_init(Object *obj) +{ + PCIHostState *h = PCI_HOST_BRIDGE(obj); + PCIVPBState *s = PCI_VPB(obj); + + pci_bus_new_inplace(&s->pci_bus, DEVICE(obj), "pci", + get_system_memory(), get_system_io(), + PCI_DEVFN(11, 0), TYPE_PCI_BUS); + h->bus = &s->pci_bus; + + object_initialize(&s->pci_dev, TYPE_VERSATILE_PCI_HOST); + qdev_set_parent_bus(DEVICE(&s->pci_dev), BUS(&s->pci_bus)); +} + static void pci_vpb_realize(DeviceState *dev, Error **errp) { PCIVPBState *s = PCI_VPB(dev); SysBusDevice *sbd = SYS_BUS_DEVICE(dev); - PCIBus *bus; int i; for (i = 0; i < 4; i++) { sysbus_init_irq(sbd, &s->irq[i]); } - bus = pci_register_bus(dev, "pci", - pci_vpb_set_irq, pci_vpb_map_irq, s->irq, - get_system_memory(), get_system_io(), - PCI_DEVFN(11, 0), 4, TYPE_PCI_BUS); + + pci_bus_irqs(&s->pci_bus, pci_vpb_set_irq, pci_vpb_map_irq, s->irq, 4); /* ??? Register memory space. */ @@ -88,16 +105,17 @@ static void pci_vpb_realize(DeviceState *dev, Error **errp) * 1 : PCI config window * 2 : PCI IO window */ - memory_region_init_io(&s->mem_config, &pci_vpb_config_ops, bus, + memory_region_init_io(&s->mem_config, &pci_vpb_config_ops, &s->pci_bus, "pci-vpb-selfconfig", 0x1000000); sysbus_init_mmio(sbd, &s->mem_config); - memory_region_init_io(&s->mem_config2, &pci_vpb_config_ops, bus, + memory_region_init_io(&s->mem_config2, &pci_vpb_config_ops, &s->pci_bus, "pci-vpb-config", 0x1000000); sysbus_init_mmio(sbd, &s->mem_config2); isa_mmio_setup(&s->isa, 0x0100000); sysbus_init_mmio(sbd, &s->isa); - pci_create_simple(bus, -1, "versatile_pci_host"); + /* TODO Remove once realize propagates to child devices. */ + object_property_set_bool(OBJECT(&s->pci_dev), true, "realized", errp); } static int versatile_pci_host_init(PCIDevice *d) @@ -134,8 +152,9 @@ static void pci_vpb_class_init(ObjectClass *klass, void *data) static const TypeInfo pci_vpb_info = { .name = TYPE_VERSATILE_PCI, - .parent = TYPE_SYS_BUS_DEVICE, + .parent = TYPE_PCI_HOST_BRIDGE, .instance_size = sizeof(PCIVPBState), + .instance_init = pci_vpb_init, .class_init = pci_vpb_class_init, };