From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:51649) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RhscX-0001WX-5P for qemu-devel@nongnu.org; Mon, 02 Jan 2012 19:52:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RhscT-0008JV-NK for qemu-devel@nongnu.org; Mon, 02 Jan 2012 19:52:52 -0500 Received: from e3.ny.us.ibm.com ([32.97.182.143]:49022) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RhscT-0008J6-Jl for qemu-devel@nongnu.org; Mon, 02 Jan 2012 19:52:49 -0500 Received: from /spool/local by e3.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 2 Jan 2012 19:52:48 -0500 Received: from d01av02.pok.ibm.com (d01av02.pok.ibm.com [9.56.224.216]) by d01relay01.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q030qR5S256030 for ; Mon, 2 Jan 2012 19:52:27 -0500 Received: from d01av02.pok.ibm.com (loopback [127.0.0.1]) by d01av02.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q030qQgk001211 for ; Mon, 2 Jan 2012 22:52:27 -0200 From: Anthony Liguori Date: Mon, 2 Jan 2012 18:51:53 -0600 Message-Id: <1325551939-24749-5-git-send-email-aliguori@us.ibm.com> In-Reply-To: <1325551939-24749-1-git-send-email-aliguori@us.ibm.com> References: <1325551939-24749-1-git-send-email-aliguori@us.ibm.com> Subject: [Qemu-devel] [PATCH 04/30] ppc_prep: convert host bridge to qdev List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Anthony Liguori , Markus Armbruster , =?UTF-8?q?Andreas=20F=C3=A4rber?= Untested beyond compile. But it's a very simple conversion. Signed-off-by: Anthony Liguori --- hw/prep_pci.c | 38 +++++++++++++++++++++++++++----------- 1 files changed, 27 insertions(+), 11 deletions(-) diff --git a/hw/prep_pci.c b/hw/prep_pci.c index ea9fb69..16c036f 100644 --- a/hw/prep_pci.c +++ b/hw/prep_pci.c @@ -106,12 +106,37 @@ static void prep_set_irq(void *opaque, int irq_num, int level) qemu_set_irq(pic[(irq_num & 1) ? 11 : 9] , level); } +static int prep_hb_initfn(PCIDevice *d) +{ + d->config[0x0C] = 0x08; // cache_line_size + d->config[0x0D] = 0x10; // latency_timer + d->config[0x34] = 0x00; // capabilities_pointer + + return 0; +} + +static PCIDeviceInfo prep_hb_info = { + .qdev.name = "PREP Host Bridge - Motorola Raven", + .qdev.size = sizeof(PCIDevice), + .init = prep_hb_initfn, + .vendor_id = PCI_VENDOR_ID_MOTOROLA, + .device_id = PCI_DEVICE_ID_MOTOROLA_RAVEN, + .revision = 0x00, + .class_id = PCI_CLASS_BRIDGE_HOST, +}; + +static void prep_register(void) +{ + pci_qdev_register(&prep_hb_info); +} + +device_init(prep_register); + PCIBus *pci_prep_init(qemu_irq *pic, MemoryRegion *address_space_mem, MemoryRegion *address_space_io) { PREPPCIState *s; - PCIDevice *d; s = g_malloc0(sizeof(PREPPCIState)); s->bus = pci_register_bus(NULL, "pci", @@ -133,16 +158,7 @@ PCIBus *pci_prep_init(qemu_irq *pic, memory_region_init_io(&s->mmcfg, &PPC_PCIIO_ops, s, "pciio", 0x00400000); memory_region_add_subregion(address_space_mem, 0x80800000, &s->mmcfg); - /* PCI host bridge */ - d = pci_register_device(s->bus, "PREP Host Bridge - Motorola Raven", - sizeof(PCIDevice), 0, NULL, NULL); - pci_config_set_vendor_id(d->config, PCI_VENDOR_ID_MOTOROLA); - pci_config_set_device_id(d->config, PCI_DEVICE_ID_MOTOROLA_RAVEN); - d->config[0x08] = 0x00; // revision - pci_config_set_class(d->config, PCI_CLASS_BRIDGE_HOST); - d->config[0x0C] = 0x08; // cache_line_size - d->config[0x0D] = 0x10; // latency_timer - d->config[0x34] = 0x00; // capabilities_pointer + pci_create_simple(s->bus, 0, "PREP Host Bridge - Motorola Raven"); return s->bus; } -- 1.7.4.1