On Sat, 15 Mar 2014, BALATON Zoltan wrote: > I'm trying to change hw/ppc/mac_newworld.c and hw/pci-host/uninorth.c to > bring the mac99 machine type closer to what's seen in these dumps:
I've also tried the patch below based on what I've seen in pci_apb_init but it only results in this error: qemu-system-ppc: hw/core/qdev.c:162: qdev_init: Assertion `!dev->realized' failed. Aborted Is there some explanation available somewhere on how to do this correctly? Thank you, BALATON Zoltan diff --git a/hw/pci-host/uninorth.c b/hw/pci-host/uninorth.c index e72fe2a..485c446 100644 --- a/hw/pci-host/uninorth.c +++ b/hw/pci-host/uninorth.c @@ -25,6 +25,8 @@ #include "hw/ppc/mac.h" #include "hw/pci/pci.h" #include "hw/pci/pci_host.h" +#include "hw/pci/pci_bridge.h" +#include "hw/pci/pci_bus.h" /* debug UniNorth */ //#define DEBUG_UNIN @@ -214,54 +216,67 @@ static int pci_unin_internal_init_device(SysBusDevice *dev) PCIBus *pci_pmac_init(qemu_irq *pic, MemoryRegion *address_space_mem, - MemoryRegion *address_space_io) + MemoryRegion *address_space_io, + PCIBus **bus2) { DeviceState *dev; SysBusDevice *s; PCIHostState *h; UNINState *d; + PCIDevice *pdev; /* Use values found on a real PowerMac */ - /* Uninorth main bus */ - dev = qdev_create(NULL, TYPE_UNI_NORTH_PCI_HOST_BRIDGE); + /* Uninorth AGP bus */ + dev = qdev_create(NULL, TYPE_UNI_NORTH_AGP_HOST_BRIDGE); qdev_init_nofail(dev); s = SYS_BUS_DEVICE(dev); h = PCI_HOST_BRIDGE(s); - d = UNI_NORTH_PCI_HOST_BRIDGE(dev); + d = UNI_NORTH_AGP_HOST_BRIDGE(dev); + /* config space */ + sysbus_mmio_map(s, 0, 0xf1000000); + sysbus_mmio_map(s, 1, 0xf1400000); + /* mmio space */ + memory_region_init(&d->pci_mmio, OBJECT(d), "agp-mmio", 0x100000000ULL); + memory_region_init_alias(&d->pci_hole, OBJECT(d), "agp-hole", &d->pci_mmio, + 0x90000000ULL, 0x10000000ULL); + memory_region_add_subregion(address_space_mem, 0x90000000ULL, + &d->pci_hole); + h->bus = pci_register_bus(dev, NULL, + pci_unin_set_irq, pci_unin_map_irq, pic, + &d->pci_mmio, + address_space_io, + PCI_DEVFN(11, 0), 4, TYPE_PCI_BUS); + pci_create_simple(h->bus, PCI_DEVFN(11, 0), "uni-north-agp"); + + /* Uninorth PCI bus */ + pdev = pci_create_simple_multifunction(h->bus, PCI_DEVFN(12, 0), true, + "uni-north-pci"); + qdev_init_nofail(&pdev->qdev); + *bus2 = pci_bridge_get_sec_bus(PCI_BRIDGE(pdev)); +#if 0 + d = UNI_NORTH_PCI_HOST_BRIDGE(pdev); memory_region_init(&d->pci_mmio, OBJECT(d), "pci-mmio", 0x100000000ULL); memory_region_init_alias(&d->pci_hole, OBJECT(d), "pci-hole", &d->pci_mmio, - 0x80000000ULL, 0x70000000ULL); + 0x80000000ULL, 0x10000000ULL); memory_region_add_subregion(address_space_mem, 0x80000000ULL, &d->pci_hole); - h->bus = pci_register_bus(dev, NULL, + bus2 = pci_register_bus(pdev, NULL, pci_unin_set_irq, pci_unin_map_irq, pic, &d->pci_mmio, - address_space_io, + address_space_io + 0x2000000ULL, PCI_DEVFN(11, 0), 4, TYPE_PCI_BUS); -#if 0 - pci_create_simple(h->bus, PCI_DEVFN(11, 0), "uni-north"); + sysbus_mmio_map(s, 0, 0xf3000000); + sysbus_mmio_map(s, 1, 0xf3400000); #endif - - sysbus_mmio_map(s, 0, 0xf2800000); - sysbus_mmio_map(s, 1, 0xf2c00000); - /* DEC 21154 bridge */ #if 0 /* XXX: not activated as PPC BIOS doesn't handle multiple buses properly */ pci_create_simple(h->bus, PCI_DEVFN(12, 0), "dec-21154"); #endif - /* Uninorth AGP bus */ - pci_create_simple(h->bus, PCI_DEVFN(11, 0), "uni-north-agp"); - dev = qdev_create(NULL, TYPE_UNI_NORTH_AGP_HOST_BRIDGE); - qdev_init_nofail(dev); - s = SYS_BUS_DEVICE(dev); - sysbus_mmio_map(s, 0, 0xf0800000); - sysbus_mmio_map(s, 1, 0xf0c00000); - /* Uninorth internal bus */ #if 0 /* XXX: not needed for now */ diff --git a/hw/ppc/mac.h b/hw/ppc/mac.h index c1faf9c..c14c7d6 100644 --- a/hw/ppc/mac.h +++ b/hw/ppc/mac.h @@ -155,7 +155,8 @@ PCIBus *pci_grackle_init(uint32_t base, qemu_irq *pic, /* UniNorth PCI */ PCIBus *pci_pmac_init(qemu_irq *pic, MemoryRegion *address_space_mem, - MemoryRegion *address_space_io); + MemoryRegion *address_space_io, + PCIBus **bus2); PCIBus *pci_pmac_u3_init(qemu_irq *pic, MemoryRegion *address_space_mem, MemoryRegion *address_space_io); diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c index 5e79575..a074935 100644 --- a/hw/ppc/mac_newworld.c +++ b/hw/ppc/mac_newworld.c @@ -154,12 +154,14 @@ static void ppc_core99_init(QEMUMachineInitArgs *args) qemu_irq *pic, **openpic_irqs; MemoryRegion *isa = g_new(MemoryRegion, 1); MemoryRegion *unin_memory = g_new(MemoryRegion, 1); +#if 0 MemoryRegion *unin2_memory = g_new(MemoryRegion, 1); +#endif int linux_boot, i, j, k; MemoryRegion *ram = g_new(MemoryRegion, 1), *bios = g_new(MemoryRegion, 1); hwaddr kernel_base, initrd_base, cmdline_base = 0; long kernel_size, initrd_size; - PCIBus *pci_bus; + PCIBus *pci_bus, *pci_bus2; PCIDevice *macio; MACIOIDEState *macio_ide; BusState *adb_bus; @@ -296,10 +298,10 @@ static void ppc_core99_init(QEMUMachineInitArgs *args) /* UniN init: XXX should be a real device */ memory_region_init_io(unin_memory, NULL, &unin_ops, token, "unin", 0x1000); memory_region_add_subregion(get_system_memory(), 0xf8000000, unin_memory); - +#if 0 memory_region_init_io(unin2_memory, NULL, &unin_ops, token, "unin", 0x1000); memory_region_add_subregion(get_system_memory(), 0xf3000000, unin2_memory); - +#endif openpic_irqs = g_malloc0(smp_cpus * sizeof(qemu_irq *)); openpic_irqs[0] = g_malloc0(smp_cpus * sizeof(qemu_irq) * OPENPIC_OUTPUT_NB); @@ -367,11 +369,12 @@ static void ppc_core99_init(QEMUMachineInitArgs *args) pci_bus = pci_pmac_u3_init(pic, get_system_memory(), get_system_io()); machine_arch = ARCH_MAC99_U3; } else { - pci_bus = pci_pmac_init(pic, get_system_memory(), get_system_io()); + pci_bus = pci_pmac_init(pic, get_system_memory(), get_system_io(), + &pci_bus2); machine_arch = ARCH_MAC99; } /* init basic PC hardware */ - pci_vga_init(pci_bus); + pci_vga_init(pci_bus2); escc_mem = escc_init(0, pic[0x25], pic[0x24], serial_hds[0], serial_hds[1], ESCC_CLOCK, 4);