From patchwork Thu Apr 4 12:58:25 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 15930 Return-Path: X-Original-To: linaro@staging.patches.linaro.org Delivered-To: linaro@staging.patches.linaro.org Received: from mail-gg0-f198.google.com (mail-gg0-f198.google.com [209.85.161.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9DCA127796 for ; Thu, 4 Apr 2013 13:12:41 +0000 (UTC) Received: by mail-gg0-f198.google.com with SMTP id a5sf3370198ggn.1 for ; Thu, 04 Apr 2013 06:12:36 -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=InlfCI5nSwiiiFYgV84Pkf1Ezao1Bg4jlOadZeWnvnw=; b=R0HVdtl/tblJTFh7f127pJlw+dfTlEn6hGmD8yF5UraZ4vhILSsJTClL92ozKODDlC A1GjtxEWQ93OVRPDxhmw5yjtVjAW3VcjDc/B7nsqFdrWukR9B9p8cdc22P8PaS21PZR8 ml8pU8pItq/sQcpj9TqXoqosJ94VHfjL6QTjs+eMJHXupvRKnmR4sKNEQzhG+jZ3rmT+ /09aiIQ9lJukR3RPhQ3f2FHL8Yf//J2wFNX3wbGifS0iy6rvFNwtti33G/erbgLe7G6b dzdfWd32NQ7gkln++GSXcfL8RjVYAZiPDMEig17KEcIe293RIyiq1eiIwygZNMtG2X1Q Zw9w== X-Received: by 10.236.28.19 with SMTP id f19mr2779469yha.17.1365081156359; Thu, 04 Apr 2013 06:12:36 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.1.4 with SMTP id 4ls267096qei.68.gmail; Thu, 04 Apr 2013 06:12:36 -0700 (PDT) X-Received: by 10.220.155.8 with SMTP id q8mr4608030vcw.42.1365081156251; Thu, 04 Apr 2013 06:12:36 -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 cr8si8122928vdc.116.2013.04.04.06.12.36 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 04 Apr 2013 06:12:36 -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 hz11so2334561vcb.9 for ; Thu, 04 Apr 2013 06:12:36 -0700 (PDT) X-Received: by 10.58.48.166 with SMTP id m6mr4528895ven.59.1365081156133; Thu, 04 Apr 2013 06:12:36 -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 h8csp215294vez; Thu, 4 Apr 2013 06:12:35 -0700 (PDT) X-Received: by 10.194.123.103 with SMTP id lz7mr9611639wjb.10.1365081154953; Thu, 04 Apr 2013 06:12:34 -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 gf9si4280151wib.56.2013.04.04.06.12.34 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 04 Apr 2013 06:12:34 -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-0005RE-KK; 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 03/11] versatile_pci: Update to realize and instance init functions Date: Thu, 4 Apr 2013 13:58:25 +0100 Message-Id: <1365080313-20875-4-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: ALoCoQmvl2iB7S9H2ziMtV002wARPKbeEn6G5744V83XrUMZjZjiill1sHXqSn78m/dzlpmrLjSH 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: , Update the Versatile PCI controller to use a realize function rather than SysBusDevice::init. To reflect the fact that the 'realview_pci' class is taking most of its implementation from 'versatile_pci' (and to make the QOM casts work) we make 'realview_pci' a subclass of 'versatile_pci'. Signed-off-by: Peter Maydell Acked-by: Paul Brook --- hw/versatile_pci.c | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/hw/versatile_pci.c b/hw/versatile_pci.c index 1312f46..541f6b5 100644 --- a/hw/versatile_pci.c +++ b/hw/versatile_pci.c @@ -21,6 +21,14 @@ typedef struct { MemoryRegion isa; } PCIVPBState; +#define TYPE_VERSATILE_PCI "versatile_pci" +#define PCI_VPB(obj) \ + OBJECT_CHECK(PCIVPBState, (obj), TYPE_VERSATILE_PCI) + +#define TYPE_VERSATILE_PCI_HOST "versatile_pci_host" +#define PCI_VPB_HOST(obj) \ + OBJECT_CHECK(PCIDevice, (obj), TYPE_VERSATILE_PCIHOST) + static inline uint32_t vpb_pci_config_addr(hwaddr addr) { return addr & 0xffffff; @@ -58,16 +66,17 @@ static void pci_vpb_set_irq(void *opaque, int irq_num, int level) qemu_set_irq(pic[irq_num], level); } -static int pci_vpb_init(SysBusDevice *dev) +static void pci_vpb_realize(DeviceState *dev, Error **errp) { - PCIVPBState *s = FROM_SYSBUS(PCIVPBState, dev); + PCIVPBState *s = PCI_VPB(dev); + SysBusDevice *sbd = SYS_BUS_DEVICE(dev); PCIBus *bus; int i; for (i = 0; i < 4; i++) { - sysbus_init_irq(dev, &s->irq[i]); + sysbus_init_irq(sbd, &s->irq[i]); } - bus = pci_register_bus(&dev->qdev, "pci", + 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); @@ -81,22 +90,14 @@ static int pci_vpb_init(SysBusDevice *dev) */ memory_region_init_io(&s->mem_config, &pci_vpb_config_ops, bus, "pci-vpb-selfconfig", 0x1000000); - sysbus_init_mmio(dev, &s->mem_config); + sysbus_init_mmio(sbd, &s->mem_config); memory_region_init_io(&s->mem_config2, &pci_vpb_config_ops, bus, "pci-vpb-config", 0x1000000); - sysbus_init_mmio(dev, &s->mem_config2); + sysbus_init_mmio(sbd, &s->mem_config2); isa_mmio_setup(&s->isa, 0x0100000); - sysbus_init_mmio(dev, &s->isa); + sysbus_init_mmio(sbd, &s->isa); pci_create_simple(bus, -1, "versatile_pci_host"); - return 0; -} - -static int pci_realview_init(SysBusDevice *dev) -{ - PCIVPBState *s = FROM_SYSBUS(PCIVPBState, dev); - s->realview = 1; - return pci_vpb_init(dev); } static int versatile_pci_host_init(PCIDevice *d) @@ -118,7 +119,7 @@ static void versatile_pci_host_class_init(ObjectClass *klass, void *data) } static const TypeInfo versatile_pci_host_info = { - .name = "versatile_pci_host", + .name = TYPE_VERSATILE_PCI_HOST, .parent = TYPE_PCI_DEVICE, .instance_size = sizeof(PCIDevice), .class_init = versatile_pci_host_class_init, @@ -126,30 +127,29 @@ static const TypeInfo versatile_pci_host_info = { static void pci_vpb_class_init(ObjectClass *klass, void *data) { - SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(klass); + DeviceClass *dc = DEVICE_CLASS(klass); - sdc->init = pci_vpb_init; + dc->realize = pci_vpb_realize; } static const TypeInfo pci_vpb_info = { - .name = "versatile_pci", + .name = TYPE_VERSATILE_PCI, .parent = TYPE_SYS_BUS_DEVICE, .instance_size = sizeof(PCIVPBState), .class_init = pci_vpb_class_init, }; -static void pci_realview_class_init(ObjectClass *klass, void *data) +static void pci_realview_init(Object *obj) { - SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(klass); + PCIVPBState *s = PCI_VPB(obj); - sdc->init = pci_realview_init; + s->realview = 1; } static const TypeInfo pci_realview_info = { .name = "realview_pci", - .parent = TYPE_SYS_BUS_DEVICE, - .instance_size = sizeof(PCIVPBState), - .class_init = pci_realview_class_init, + .parent = TYPE_VERSATILE_PCI, + .instance_init = pci_realview_init, }; static void versatile_pci_register_types(void)