Thanks Mark, I’m unsure how to get Openbios to execute the Fcode, I can load it to the correct address on my PCI card, via a little hack to Openbios.

I’d really like to just go ahead and fix the fact that Openbios doesn’t probe for Fcode Rom’s on PCI devices. I know this will likely break a few things, requiring other fixes. If I had some idea of where to start, some sample code I maybe able to hack something together, but it would likely break more than it fixes.

I’m sure you're busy, I’m retired and this is just something to keep my occupied, tho I’m not really qualified to do it.

If it could be added as a priority to Openbios, to probe and execute FCode Rom’s on PCI devices, that would be great. I’m sure someone will take it up when they have a little spare time.

I’m having trouble CC ing the list, I know stupid of me.

Any idea what the unnamed FCode in the detok is?

Does detok just not understand it, or is it words or methods?





On Dec 15, 2017, at 4:08 PM, Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> wrote:

On 12/12/17 09:06, Jd Lyons wrote:
On Dec 12, 2017, at 3:24 AM, Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk <mailto:mark.cave-ayland@ilande.co.uk>> wrote:

On 12/12/17 03:24, Jd Lyons wrote:

I’m assuming that Openbios is not reading the Option Rom of the card, but I’m not sure why.

Well... at the moment we actually cheat ;)  Instead of reading the VGA FCode ROM from the virtual display adapter, OpenBIOS embeds its own copy of the FCode ROM and executes it unconditionally when it detects a VGA display device. I must admit I hadn't considered that someone would be interested in legacy device passthough to enable a device that isn't the standard QEMU display adapter.
Are we talking about the ‘NDRV’ patch?
I noticed that the ‘NDRV’ for the QEMU,VGA loads to any VGA card in the system. Yet the vga-pci.c loads a PC Video bios for the qemu,vga device, tho I’m pretty sure Openbios doesn’t use it. I’m having trouble locating how the QEMU,VGA device is able to be used by Openbios, how does it “init” the device?

The NDRV driver is loaded into the "driver,AAPL..." property after the device node has been created by the FCode device so that occurs later in the process.

OpenBIOS creates a basic PCI device node for every device it finds during a PCI bus scan and then executes a callback depending upon the resulting vendorid/deviceid. The code in OpenBIOS is in vga_config_cb() and as you can see, it currently executes the in-built FCode directly rather than trying to map the ROM using the process documented at http://mirror.informatimago.com/next/developer.apple.com/technotes/tn/tn2000.html.

As a starting point I'd suggest that if you still have the old hardware lying around, you can use the article above to extract the ROM from a real Mac and then run the resulting code through fcode-utils detok which effectively "decompiles" the ROM and therefore give us an idea as to how many Forth words need to be implemented.

Ok, I’ve done some detok of nVidia Fcode Rom’s before, and I know about words that Openfirmware doesn’t understand, years ago I wanted two get an nVidia card to work in my Old World PM8600, and I figured it was the “map-in” bug, but as it turns out, it was some words in nVidia's FCode Rom that my version of OF didn’t have.
Atriu Itra was able to get an nVidia card to work in OpenFimware on an Old World machine, but it wouldn’t boot the OS, however if he had stayed at it, I’m sure he’d have figured it out. He did basically what you are preposing. Guy was an Fcode master, we could really use him on this project.

Sounds like someone has already done some of the work here - do you have a copy of the detok FCode or any emails related to the subject at all?

Otherwise I would say the first step would be to hack OpenBIOS to expose the passthrough ROM and then dump it out from within QEMU.
We had an online forum were we discussed hacking Fcode Roms, all gone now tho, but a lot of info, and Rom still at:
http://themacelite.wikidot.com
Most of all the old Fcode Roms in the downloads section, I don’t think anyone added the old 3dfx Roms for Powermac’s, but they can be extracted from the 3dfx control panel. I did some work emulating the Voodoo cards for Openbios/Qemu_PPC, really I’m just wanting to emulate a Voodo2, so I’m playing around with PCI Passthough while waiting to find an affordable Voodoo2, you wouldn’t believe what they sell for these days.
The 6600 was only a few bucks, so I got it, but I was hoping to lighten the Emulated cpu load, as screen redraws seem to suck up all the CPU cycles under OS X. So a little QE may help there.
Anyway, the Voodoo2 didn’t have a rom, and it wasn’t really a VGA card, those some people have hacked it to display the desktop, it was really a 3D Accelerator with VGA Passthough for the main system display card. So I don’t think I’ll have any trouble with PCI Passthrough with that.
Anyway, I think we may want to work on some code for Openbios that detects vfio-pci and reads the rom for the device and tries to execute the Fcode, rather than what we have now, it’s not really a workable solution for PCI Passthrough of VGA. The pseries firmware is aware of a vfio-pci device, but it doesn’t seem to be aware of the Rom on the card either.
I did some hacks to Openbios and got the rom mapped in @0x30 for the 6600, but Openbios still does not try and execute the rom.
A quick look at the detok Fcode:

Thanks for the dump of the ROM. At first glance I don't see anything too unusual in there - the main culprits to look at will be map-in, my-address and the config-* words for accessing PCI config space...

Once you're able to run the FCode you can also do:

true to fcode-debug?

which should dump out the FCode tokens on the console as they are being debugged.


ATB,

Mark.