Skip to contentSkip to conversation

mac99: Bring memory layout closer to real hardware

PATCH In review BALATON Zoltan 2 participants 3 messages Mar 15, 2014 – Apr 11, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mac99: Bring memory layout closer to real hardware

Try to better match the memory map of a PowerMac3,1 model by moving the pci-cfg mappings to where they are on a real machine. Also add the VGA card after the macio to let the latter be mapped from 0x80000000 to match hardware. (On real hardware the graphics card is on a different bus but we don't seem to model that yet.)

---

This patch is intended to bring memory layout closer to what's seen in these dumps:

http://nandra.segv.jp/NetBSD/G4.dump-device-tree.txt
http://raveland.org/ports/eeprom.txt
http://mail-index.netbsd.org/port-macppc/2007/10/24/0000.html
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=604134

It makes MorphOS a little happier and not print alerts when creating its memory map but not happy enough to not crash later.

If this is merged the corresponding addresses need to be changed in OpenBIOS arch/ppc/qemu/init.c also! I can send a patch for that if needed.

 hw/pci-host/uninorth.c | 10 +++++-----
 hw/ppc/mac_newworld.c  | 10 ++++++----
 2 files changed, 11 insertions(+), 9 deletions(-)
hw/pci-host/uninorth.c +5 -5
index e72fe2a..6e88b6a 100644
@@ -230,7 +230,7 @@ PCIBus *pci_pmac_init(qemu_irq *pic,
     d = UNI_NORTH_PCI_HOST_BRIDGE(dev);
     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);
 
@@ -245,8 +245,8 @@ PCIBus *pci_pmac_init(qemu_irq *pic,
     pci_create_simple(h->bus, PCI_DEVFN(11, 0), "uni-north");
 #endif
 
-    sysbus_mmio_map(s, 0, 0xf2800000);
-    sysbus_mmio_map(s, 1, 0xf2c00000);
+    sysbus_mmio_map(s, 0, 0xf3000000);
+    sysbus_mmio_map(s, 1, 0xf3400000);
 
     /* DEC 21154 bridge */
 #if 0
@@ -259,8 +259,8 @@ PCIBus *pci_pmac_init(qemu_irq *pic,
     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);
+    sysbus_mmio_map(s, 0, 0xf1000000);
+    sysbus_mmio_map(s, 1, 0xf1400000);
 
     /* Uninorth internal bus */
 #if 0
hw/ppc/mac_newworld.c +6 -4
index 5e79575..9d4e570 100644
@@ -154,7 +154,9 @@ 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;
@@ -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);
@@ -371,8 +373,6 @@ static void ppc_core99_init(QEMUMachineInitArgs *args)
         machine_arch = ARCH_MAC99;
     }
     /* init basic PC hardware */
-    pci_vga_init(pci_bus);
-
     escc_mem = escc_init(0, pic[0x25], pic[0x24],
                          serial_hds[0], serial_hds[1], ESCC_CLOCK, 4);
     memory_region_init_alias(escc_bar, NULL, "escc-bar",
@@ -418,6 +418,8 @@ static void ppc_core99_init(QEMUMachineInitArgs *args)
         }
     }
 
+    pci_vga_init(pci_bus);
+
     if (graphic_depth != 15 && graphic_depth != 32 && graphic_depth != 8)
         graphic_depth = 15;
 
Signature · 1 line
1.8.1.5
#1 lore raw
Quoted 12 lines · BALATON Zoltan

Try to better match the memory map of a PowerMac3,1 model by moving the pci-cfg mappings to where they are on a real machine. Also add the VGA card after the macio to let the latter be mapped from 0x80000000 to match hardware. (On real hardware the graphics card is on a different bus but we don't seem to model that yet.)

---

This patch is intended to bring memory layout closer to what's seen in these dumps:

Quoted 7 lines

http://nandra.segv.jp/NetBSD/G4.dump-device-tree.txt
http://raveland.org/ports/eeprom.txt
http://mail-index.netbsd.org/port-macppc/2007/10/24/0000.html
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=604134

It makes MorphOS a little happier and not print alerts when creating its memory map but not happy enough to not crash later.

I'm not so sure about this patch either by now. I've come across some logs that show that these MorphOS alerts can happen on real hardware too and are probably not related to the crash but it needs more debugging and experimenting. If anyone has any ideas how to converge QEMU's model to what's seen in the dumps above please let me know.

Regards,
BALATON Zoltan

Quoted 93 lines

If this is merged the corresponding addresses need to be changed in OpenBIOS arch/ppc/qemu/init.c also! I can send a patch for that if needed.

hw/pci-host/uninorth.c | 10 +++++-----
hw/ppc/mac_newworld.c | 10 ++++++----

2 files changed, 11 insertions(+), 9 deletions(-)
hw/pci-host/uninorth.c +5 -5
index e72fe2a..6e88b6a 100644
@@ -230,7 +230,7 @@ PCIBus *pci_pmac_init(qemu_irq *pic,
    d = UNI_NORTH_PCI_HOST_BRIDGE(dev);
    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);
 
@@ -245,8 +245,8 @@ PCIBus *pci_pmac_init(qemu_irq *pic,
    pci_create_simple(h->bus, PCI_DEVFN(11, 0), "uni-north");
 #endif
 
-    sysbus_mmio_map(s, 0, 0xf2800000);
-    sysbus_mmio_map(s, 1, 0xf2c00000);
+    sysbus_mmio_map(s, 0, 0xf3000000);
+    sysbus_mmio_map(s, 1, 0xf3400000);
 
    /* DEC 21154 bridge */
 #if 0
@@ -259,8 +259,8 @@ PCIBus *pci_pmac_init(qemu_irq *pic,
    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);
+    sysbus_mmio_map(s, 0, 0xf1000000);
+    sysbus_mmio_map(s, 1, 0xf1400000);
 
    /* Uninorth internal bus */
 #if 0
hw/ppc/mac_newworld.c +6 -4
index 5e79575..9d4e570 100644
@@ -154,7 +154,9 @@ 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;
@@ -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);
@@ -371,8 +373,6 @@ static void ppc_core99_init(QEMUMachineInitArgs *args)
        machine_arch = ARCH_MAC99;
    }
    /* init basic PC hardware */
-    pci_vga_init(pci_bus);
-
    escc_mem = escc_init(0, pic[0x25], pic[0x24],
                         serial_hds[0], serial_hds[1], ESCC_CLOCK, 4);
    memory_region_init_alias(escc_bar, NULL, "escc-bar",
@@ -418,6 +418,8 @@ static void ppc_core99_init(QEMUMachineInitArgs *args)
        }
    }
 
+    pci_vga_init(pci_bus);
+
    if (graphic_depth != 15 && graphic_depth != 32 && graphic_depth != 8)
        graphic_depth = 15;
 
Signature · 1 line
1.8.1.5
#2 lore raw
Quoted 18 lines · BALATON Zoltan
Quoted 17 lines · BALATON Zoltan

Try to better match the memory map of a PowerMac3,1 model by moving the pci-cfg mappings to where they are on a real machine. Also add the VGA card after the macio to let the latter be mapped from 0x80000000 to match hardware. (On real hardware the graphics card is on a different bus but we don't seem to model that yet.)

---

This patch is intended to bring memory layout closer to what's seen in these dumps:

http://nandra.segv.jp/NetBSD/G4.dump-device-tree.txt
http://raveland.org/ports/eeprom.txt
http://mail-index.netbsd.org/port-macppc/2007/10/24/0000.html
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=604134

Quoted 4 lines
Quoted 2 lines

It makes MorphOS a little happier and not print alerts when creating its memory map but not happy enough to not crash later.

I'm not so sure about this patch either by now. I've come across some logs that show that these MorphOS alerts can happen on real hardware too and are probably not related to the crash but it needs more debugging and experimenting. If anyone has any ideas how to converge QEMU's model to what's seen in the dumps above please let me know.

Yeah, I'd rather hold back on this until we fix a real bug.

The problem with the mac99 target in QEMU is that it doesn't match any real machine out there. It's essentially a hack good enough to get a good amount of Linux and Mac OS X working, but I'm sure if you don't look at the device tree for device creation you'll blow up :).

The "real" fix would be to create a new machine model that models *exactly* a real system from scratch.

Alex