On Thu, 4 Jul 2019, Mark Cave-Ayland wrote:
On 02/07/2019 12:28, BALATON Zoltan wrote:
On Mon, 1 Jul 2019, BALATON Zoltan wrote:
On Mon, 1 Jul 2019, Mark Cave-Ayland wrote:
Errr... I did spend time making the OpenBIOS bridge code generic so that others could use it, so the theory says that all you have to do is feed in an initial value. If we need workarounds then I accept that these are necessary at times, but cases like this where the work is already done then there is no need for this.
If you think it's trivial to do then please come up with a patch or provide some detailed hints on what needs to be done because I was not able to find it. Where should I feed an inital value? The ob_pci_init() function has no parameter and adding one would require changing all callers that I can't test so I'd rather not do.
I've tried adding a bus_num field to arch struct and set bus from that in ob_pci_init() but then OpenBIOS hangs on startup.
That feels like the right approach, but there certainly shouldn't cause any change in behaviour. Can you push your code somewhere so I can take a look?
I've already reverted that patch and no time to reimplement it but I was adding a uint8_t bus_num field to struct pci_arch_t in include/drivers/pci.h then in drivers/pci.c replaced bus = 0 with bus = arch->bus_num and in arch/ppc/qemu/init.c added .bus_num = 1 to [ARCH_MAC99] in the init of known_arch[].
Also re-reading the patch I'm not sure that {0, 1} is correct under QEMU compared with a real Mac, since there is no PCI bridge present under /pci@f2000000?
I've also tried setting it to {1, 0} instead but same hang as above so I think OpenBIOS cannot handle anything but bus 0 so I gave up. I'm not going to try to debug this as my workaround works well and all this would be unnecessary when passing device tree from QEMU is implemented as suggested before (that would be needed to support Pegasos2 without too many new hacks and workarounds in OpenBIOS and clean up some of the current mess so would be needed eventually if we want to avoid having yet another open firmware implementation in QEMU). But until then having a workaround to be able to run MorphOS without extra effort would have been nice unless it breaks somthing else.
So just to clarify you're saying that with your v5 patch if you simply switch {0, 1} to {1,0} then that also hangs?
Yes, that's what I meant. Have you tried it? Even without the above bus_num patch, just trying to use different value than {0, 1} with my v5 patch it hangs the same way as with above. Since it hangs before init-ing serial I could not get debug logs either so I did not try to find out what's wrong but my guess would be that bus != 0 might cause problem somewhere.
Also as discussed before it's not that I'm completely against an FDT-based setup, but it's an awful lot of work...
It's some work but maybe we can reuse code from SLOF so it's not that much work and it would allow to get rid of all the FW_CFG based hacks and hardcoded values we now have in OpenBIOS (these could be set by the machine models in QEMU where it's simpler to do because we don't need to handle all machines only the one it models) and this would allow making fixes in QEMU in the future without needing to also update OpenBIOS every time so it would make code cleaner and more stable. I've planned to try it eventually to see if OpenBIOS could be used for the Pegasos2 emulation but I haven't got to it yet.
Regards, BALATON Zoltan