From patchwork Thu Apr 4 12:58:26 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 15920 Return-Path: X-Original-To: linaro@staging.patches.linaro.org Delivered-To: linaro@staging.patches.linaro.org Received: from mail-qc0-f197.google.com (mail-qc0-f197.google.com [209.85.216.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9A4BC27796 for ; Thu, 4 Apr 2013 12:58:52 +0000 (UTC) Received: by mail-qc0-f197.google.com with SMTP id b14sf3346827qcs.0 for ; Thu, 04 Apr 2013 05:58:47 -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=3zXrmznTEpIXsa4fh/iPCVU8tQ8v+TUPbliGwvuMR8Q=; b=jm9F+4NdPmY82PgA1I0siHbAeVFlmODT0tGPDOI9zEYF+AtjHzGi8qQAYcdpIDhWdb MQ92JBG4bp5fNpCPE9Qh3EnfsXHsMc5ZJK7r2/ErXzitzQWPP/BNWKfILoj4zKYJuTMU fNXNoF+YDVQac/QLNUok8KQNImBOnUOEQiHI4uUkA13LSZZ7ikJLKkuAMdbNmYRuHF0f XadRRrQvQJYkQ/eP0yr+cOzAVL6O7+GqhqtEQxfRQC9sWV6JrTFRgaErwUXVQWBTWNB2 v8P1ZrY0EXJOnNP/8sTtBtvVkIPmh8ZZk14huPFkicv5ZyH7W+OHQKBSh22YGr45H6Cl HBZg== X-Received: by 10.224.18.132 with SMTP id w4mr3261289qaa.1.1365080327525; Thu, 04 Apr 2013 05:58:47 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.25.195 with SMTP id e3ls1329760qeg.47.gmail; Thu, 04 Apr 2013 05:58:47 -0700 (PDT) X-Received: by 10.220.222.72 with SMTP id if8mr4520204vcb.61.1365080327420; Thu, 04 Apr 2013 05:58:47 -0700 (PDT) Received: from mail-vc0-f178.google.com (mail-vc0-f178.google.com [209.85.220.178]) by mx.google.com with ESMTPS id gr9si8100060veb.19.2013.04.04.05.58.47 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 04 Apr 2013 05:58:47 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.178 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.178; Received: by mail-vc0-f178.google.com with SMTP id hz11so2322824vcb.9 for ; Thu, 04 Apr 2013 05:58:47 -0700 (PDT) X-Received: by 10.52.21.212 with SMTP id x20mr3845665vde.106.1365080327316; Thu, 04 Apr 2013 05:58:47 -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 h8csp214675vez; Thu, 4 Apr 2013 05:58:38 -0700 (PDT) X-Received: by 10.194.93.97 with SMTP id ct1mr9405370wjb.48.1365080318042; Thu, 04 Apr 2013 05:58:38 -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 p14si8467843wie.67.2013.04.04.05.58.37 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 04 Apr 2013 05:58:37 -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 1UNjkP-0005RG-Lc; Thu, 04 Apr 2013 13:58:33 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Arnd Bergmann , "Michael S. Tsirkin" , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Will Deacon , Paul Brook , Aurelien Jarno Subject: [PATCH v3 04/11] versatile_pci: Change to subclassing TYPE_PCI_HOST_BRIDGE Date: Thu, 4 Apr 2013 13:58:26 +0100 Message-Id: <1365080313-20875-5-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1365080313-20875-1-git-send-email-peter.maydell@linaro.org> References: <1365080313-20875-1-git-send-email-peter.maydell@linaro.org> X-Gm-Message-State: ALoCoQk8HhqlDIOv1K6qWh9LAjAmlXlew23xq5Jd2Iq1GbpRwVZhbKZNNk0rYYW0cUUaBD4RhGBX X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.178 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 541f6b5..dfd3001 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)); + 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); + + 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, };