j
: Next unread message k
: Previous unread message j a
: Jump to all threads
j l
: Jump to MailingList overview
QEMU mac99 emulates two of the three PCI buses found on real PowerMac3,1 but OpenBIOS currently only handles a single PCI bus and inits and puts info in the device tree of the second PCI bus only (which is where devices are connected). However, some clients (e.g. MorphOS) may have hardcoded assumptions and erroneously use the address of the first bus to access PCI config registers for devices on the second bus if the first bus is missing from the device tree, which silently fails as these requests will go to the other empty bus emulated and return invalid values as the device they address are not present there.
As a result devices mapped via MMIO still appear to work but they may not be correctly initialised and some cards are not detected because of this. One such case might be enabling bus master bit for network cards which the OS should do but OpenBIOS has workaround for it now. Once both PCI buses appear in device tree those workarounds may not be needed any more.
Until proper support for multiple PCI buses is implemented add an empty node in the device tree for the first bus on QEMU mac99 to let OSes know about it. This fixes detecting PCI devices (such as USB) under MorphOS and allows it to boot.
Signed-off-by: BALATON Zoltan balaton@eik.bme.hu --- arch/ppc/qemu/init.c | 113 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+)
diff --git a/arch/ppc/qemu/init.c b/arch/ppc/qemu/init.c index 45cd77e..2bee848 100644 --- a/arch/ppc/qemu/init.c +++ b/arch/ppc/qemu/init.c @@ -716,6 +716,116 @@ static void kvm_of_init(void) fword("finish-device"); }
+static void encode_int_plus(int n, ...) +{ + int i; + ucell v; + va_list ap; + + va_start(ap, n); + for (i = 0; i < n; i++) { + v = va_arg(ap, ucell); + PUSH(v); + fword("encode-int"); + if (i > 0) { + fword("encode+"); + } + } + va_end(ap); +} + +static void empty_pci_bus_init(void) +{ + if (machine_id != ARCH_MAC99) { + return; + } + fword("new-device"); + push_str("pci"); + fword("device-name"); + push_str("pci"); + fword("device-type"); + push_str("AAPL,UniNorth"); + fword("encode-string"); + push_str("model"); + fword("property"); + push_str("uni-north"); + fword("encode-string"); + push_str("compatible"); + fword("property"); + encode_int_plus(2, 0xf0000000, 0x02000000); + push_str("reg"); + fword("property"); + PUSH(3); + fword("encode-int"); + push_str("#address-cells"); + fword("property"); + PUSH(2); + fword("encode-int"); + push_str("#size-cells"); + fword("property"); + PUSH(1); + fword("encode-int"); + push_str("#interrupt-cells"); + fword("property"); + PUSH(66666666); + fword("encode-int"); + push_str("clock-frequency"); + fword("property"); + PUSH(0x800); + fword("encode-int"); + push_str("UNI-N"); + fword("encode-string"); + fword("encode+"); + push_str("built-in-names"); + fword("property"); + PUSH(0x10000); + fword("encode-int"); + push_str("SLOT-A"); + fword("encode-string"); + fword("encode+"); + push_str("slot-names"); + fword("property"); + encode_int_plus(18, + 0x02000000, 0, 0xf1000000, 0xf1000000, 0, 0x01000000, + 0x01000000, 0, 0, 0xf0000000, 0, 0x00800000, + 0x02000000, 0, 0x90000000, 0x90000000, 0, 0x10000000); + push_str("ranges"); + fword("property"); + encode_int_plus(2, 0, 0); + push_str("bus-range"); + fword("property"); + fword("finish-device"); +} + +static void empty_pci_bus_interrupts(void) +{ + phandle_t pic, dnode; + u32 props[8]; + + if (machine_id != ARCH_MAC99) { + return; + } + pic = dt_iterate_type(0, "open-pic"); + dnode = find_dev("/pci@f0000000"); + props[0] = 0x2d; + props[1] = 0x1; + set_property(dnode, "interrupts", (char *)props, 2 * sizeof(u32)); + set_int_property(dnode, "interrupt_patent", pic); + props[0] = 0x8000; + props[1] = 0; + props[2] = 0; + props[3] = 0; + props[4] = pic; + props[5] = 0x30; + props[6] = 0x1; + set_property(dnode, "interrupt-map", (char *)props, 7 * sizeof(u32)); + props[0] = 0xf800; + props[1] = 0; + props[2] = 0; + props[3] = 0; + set_property(dnode, "interrupt-map-mask", (char *)props, 4 * sizeof(u32)); +} + /* * filll ( addr bytes quad -- ) */ @@ -868,8 +978,11 @@ arch_of_init(void) case ARCH_MAC99_U3: /* The NewWorld NVRAM is not located in the MacIO device */ macio_nvram_init("/", 0); + /* We only handle 1 PCI bus but MorphOS needs info for both to boot */ + empty_pci_bus_init(); ob_pci_init(); ob_unin_init(); + empty_pci_bus_interrupts(); break; default: ob_pci_init();