From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MqUK1-0006ES-Hd for qemu-devel@nongnu.org; Wed, 23 Sep 2009 12:04:01 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MqUJx-0006C2-IV for qemu-devel@nongnu.org; Wed, 23 Sep 2009 12:04:01 -0400 Received: from [199.232.76.173] (port=56123 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MqUJx-0006Bn-72 for qemu-devel@nongnu.org; Wed, 23 Sep 2009 12:03:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:62220) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MqUJw-0006li-EI for qemu-devel@nongnu.org; Wed, 23 Sep 2009 12:03:56 -0400 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n8NG3tNa009822 for ; Wed, 23 Sep 2009 12:03:55 -0400 Date: Wed, 23 Sep 2009 19:02:00 +0300 From: "Michael S. Tsirkin" Subject: Re: [Qemu-devel] [PATCH 06/13] convert pci bridge to qdev Message-ID: <20090923160200.GC18203@redhat.com> References: <1253611767-6483-1-git-send-email-kraxel@redhat.com> <1253611767-6483-7-git-send-email-kraxel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1253611767-6483-7-git-send-email-kraxel@redhat.com> List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gerd Hoffmann Cc: qemu-devel@nongnu.org On Tue, Sep 22, 2009 at 11:29:20AM +0200, Gerd Hoffmann wrote: > @@ -890,15 +890,12 @@ PCIDevice *pci_find_device(int bus_num, int slot, int function) > return bus->devices[PCI_DEVFN(slot, function)]; > } > > -PCIBus *pci_bridge_init(PCIBus *bus, int devfn, uint16_t vid, uint16_t did, > - pci_map_irq_fn map_irq, const char *name) > +static int pci_bridge_initfn(PCIDevice *dev) pci_bridge_dev_init a better name? > { > - PCIBridge *s; > - s = (PCIBridge *)pci_register_device(bus, name, sizeof(PCIBridge), > - devfn, NULL, pci_bridge_write_config); > + PCIBridge *s = DO_UPCAST(PCIBridge, dev, dev); > > - pci_config_set_vendor_id(s->dev.config, vid); > - pci_config_set_device_id(s->dev.config, did); > + pci_config_set_vendor_id(s->dev.config, s->vid); > + pci_config_set_device_id(s->dev.config, s->did); > > s->dev.config[0x04] = 0x06; // command = bus master, pci mem > s->dev.config[0x05] = 0x00; > @@ -911,9 +908,23 @@ PCIBus *pci_bridge_init(PCIBus *bus, int devfn, uint16_t vid, uint16_t did, > s->dev.config[PCI_HEADER_TYPE] = > PCI_HEADER_TYPE_MULTI_FUNCTION | PCI_HEADER_TYPE_BRIDGE; // header_type > s->dev.config[0x1E] = 0xa0; // secondary status > + return 0; > +} > > - s->bus = pci_register_secondary_bus(&s->dev, map_irq, name); > - return s->bus; > +PCIBus *pci_bridge_init(PCIBus *bus, int devfn, uint16_t vid, uint16_t did, > + pci_map_irq_fn map_irq, const char *name) > +{ > + PCIDevice *dev; > + PCIBridge *s; > + > + dev = pci_create_noinit(bus, devfn, "pci-bridge"); > + qdev_prop_set_uint32(&dev->qdev, "vendorid", vid); > + qdev_prop_set_uint32(&dev->qdev, "deviceid", did); > + qdev_init(&dev->qdev); > + > + s = DO_UPCAST(PCIBridge, dev, dev); > + pci_register_secondary_bus(&s->bus, &s->dev, map_irq, name); > + return &s->bus; > } > > static int pci_qdev_init(DeviceState *qdev, DeviceInfo *base) > @@ -1074,3 +1085,22 @@ static void pcibus_dev_print(Monitor *mon, DeviceState *dev, int indent) > r->addr, r->addr + r->size - 1); > } > } > + > +static PCIDeviceInfo bridge_info = { > + .qdev.name = "pci-bridge", > + .qdev.size = sizeof(PCIBridge), > + .init = pci_bridge_initfn, > + .config_write = pci_bridge_write_config, > + .qdev.props = (Property[]) { > + DEFINE_PROP_HEX32("vendorid", PCIBridge, vid, 0), > + DEFINE_PROP_HEX32("deviceid", PCIBridge, did, 0), > + DEFINE_PROP_END_OF_LIST(), > + } > +}; > + > +static void pci_register_devices(void) > +{ > + pci_qdev_register(&bridge_info); > +} > + > +device_init(pci_register_devices) > -- > 1.6.2.5 > >