Add Voodoo2 emulation for Qemu?

About QEMU, a PPC Mac emulator for Windows, macOS and Linux that can run Mac OS 9.0 up to Mac OS X 10.5

Moderators: Cat_7, Ronald P. Regensburg

User avatar
adespoton
Forum All-Star
Posts: 3247
Joined: Fri Nov 27, 2009 5:11 am
Location: Emaculation.com
Contact:

Re: Add Voodoo2 emulation for Qemu?

Post by adespoton »

OK, so that sounds like it's loading it from the VGA patch. So without doing that, it's loading something else for the NDRV. Makes sense, but is still a bit of a black box.
darthnvader
Mac Mechanic
Posts: 174
Joined: Sun Feb 07, 2016 4:40 pm

Re: Add Voodoo2 emulation for Qemu?

Post by darthnvader »

I still don't understand where this "Non-existant Hardware" NDRV is coming from, I think it's part of OS 9.2.1 itself?

Wish I knew why it's not loading the NDRV from the FCode rom I'm injecting.
Programmingkid
Apple Corer
Posts: 243
Joined: Sun Jan 31, 2016 6:01 pm

Re: Add Voodoo2 emulation for Qemu?

Post by Programmingkid »

darthnvader wrote:I still don't understand where this "Non-existant Hardware" NDRV is coming from, I think it's part of OS 9.2.1 itself?

Wish I knew why it's not loading the NDRV from the FCode rom I'm injecting.
From what I heard on the OpenBIOS mailing list, OpenBIOS is actually injecting its own driver. This thread is about making a real video card work in QEMU: https://mail.coreboot.org/pipermail/ope ... 10019.html

I think you have access to the raw text of the NDRV. Maybe you could copy it and use the grep command to locate this same text in OpenBIOS.

Example:
grep -Ril "map-in" <openbios folder path>
Programmingkid
Apple Corer
Posts: 243
Joined: Sun Jan 31, 2016 6:01 pm

Re: Add Voodoo2 emulation for Qemu?

Post by Programmingkid »

Actually this will help you more (no permission denied messages).

grep -Ril "<search terms>" <path> 2>/dev/null
darthnvader
Mac Mechanic
Posts: 174
Joined: Sun Feb 07, 2016 4:40 pm

Re: Add Voodoo2 emulation for Qemu?

Post by darthnvader »

Programmingkid
Apple Corer
Posts: 243
Joined: Sun Jan 31, 2016 6:01 pm

Re: Add Voodoo2 emulation for Qemu?

Post by Programmingkid »

I'm not familiar with this file. What is it?
User avatar
Cat_7
Expert User
Posts: 5256
Joined: Fri Feb 13, 2004 8:59 am
Location: Sittard, The Netherlands

Re: Add Voodoo2 emulation for Qemu?

Post by Cat_7 »

The detoked Fcode as suggested by Mark Cave-Ayland?

Best,
Cat_7
Programmingkid
Apple Corer
Posts: 243
Joined: Sun Jan 31, 2016 6:01 pm

Re: Add Voodoo2 emulation for Qemu?

Post by Programmingkid »

I was wondering how things were going with implementing a new video card in QEMU. Did you ever solve the problem of the mysterious driver? Is there anything someone else could do to help?
darthnvader
Mac Mechanic
Posts: 174
Joined: Sun Feb 07, 2016 4:40 pm

Re: Add Voodoo2 emulation for Qemu?

Post by darthnvader »

I was trying to send a file to myself, as file sharing between the host and guest can be problematic with Qemu with MacOS guests.

I'm working a little with PCI Passthough of an Apple OEM Geforce 6600 PCI-E card. The trouble is Openbios doesn't probe for Option Roms on PCI cards, and the Nvidia Fcode Rom may have words/methods that Openbios den't have.

What would be helpful right now is if we could figure out how to load the Option Rom from a file, and get Openbios to execute the FCode.

https://docs.oracle.com/cd/E19253-01/80 ... ctest.html

I did some work porting the Voodoo2 emulation from PCem to Qemu, and it builds, but I get undefined symbols when it goes to linking. Not sure what the trouble is, I was building on OS X, and only one person ever built PCem on the Mac OS, and said it had to be built i386. I never did figure out how to build Qemu as i386 on OS X, to see if that fixed the linking errors.

I've changed my build env to linux, so I may go back and try again to port the code from PCem.
Programmingkid
Apple Corer
Posts: 243
Joined: Sun Jan 31, 2016 6:01 pm

Re: Add Voodoo2 emulation for Qemu?

Post by Programmingkid »

Lets try to identify and solve each problem in your way.
darthnvader wrote:I was trying to send a file to myself, as file sharing between the host and guest can be problematic with Qemu with MacOS guests.
I made a program called MacQEMU that making file sharing between the host and guest a lot easier. http://www.mediafire.com/file/yuh4gb7j2 ... beta_3.zip
You have these options for file sharing:
1. Using an image file as a usb thumb drive
2. Using QEMU's folder sharing
3. AFP sharing

I have about mastered file sharing between my Mac OS 10.12 host and my Mac OS 10.4 host. If you need additional help please let us know.
darthnvader wrote: I'm working a little with PCI Passthough of an Apple OEM Geforce 6600 PCI-E card. The trouble is Openbios doesn't probe for Option Roms on PCI cards, and the Nvidia Fcode Rom may have words/methods that Openbios den't have.
Sounds really interesting. One problem is with OpenBIOS not actually using the options ROMs from PCI cards. Another problem is there are words that need to be implemented in OpenBIOS. I think Mark Cave-Ayland (OpenBIOS maintainer) could help. Could you post all the identified words that you noticed are missing from OpenBIOS?
darthnvader wrote: What would be helpful right now is if we could figure out how to load the Option Rom from a file, and get Openbios to execute the FCode.

https://docs.oracle.com/cd/E19253-01/80 ... ctest.html
The link looks helpful.
darthnvader wrote: I did some work porting the Voodoo2 emulation from PCem to Qemu, and it builds, but I get undefined symbols when it goes to linking. Not sure what the trouble is, I was building on OS X, and only one person ever built PCem on the Mac OS, and said it had to be built i386. I never did figure out how to build Qemu as i386 on OS X, to see if that fixed the linking errors.

I've changed my build env to linux, so I may go back and try again to port the code from PCem.
If you are experiencing missing symbols, it can be helpful to search for them using Google. Could you post the missing symbols here? I know from experience that there are some functions that may exist on the 32-bit version of a library that don't exist on the 64-bit version. Some Carbon APIs are like this.

There are a lot of dependencies that QEMU need. Using a package manager like homebrew can really help. It basically takes care of all the dependencies for you. You can then download the source code to a newer version of QEMU and build it discarding the version that comes with homebrew.

You install homebrew like this: /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homeb ... er/install)"

Then you install QEMU like this: brew install qemu
darthnvader
Mac Mechanic
Posts: 174
Joined: Sun Feb 07, 2016 4:40 pm

Re: Add Voodoo2 emulation for Qemu?

Post by darthnvader »

Thanks, PK, I'm just a hacker, not really a programer, yet if I look at the code long enough, I can usually figure out how to make it work the way I want to.

Detoking the FCode rom didn't yield anything of use to me, with my level of understanding of raw Forth. I noted a bunch references to unnamed FCode, but I'm not sure what that means.

Man detok wasn't much help.

If my FCode guru was still in the States, I'm sure he would know what that means, if he wanted to work on it.

All the words that I can identify in the detoked Rom are supported by Openbios.

Openbios seems to support FCode debugging, it's just a lot more useful to me if I could load the Rom and get Openbios to actually try and execute the FCode. Really, that is what Openbios should be doing, whoever put it together went for something quick and dirty, rather than a utility boot firmware that meets the Openfirmware standard.

Further, the 'NDRV' patch loads the same 'NDRV' for every display device it finds, and that needs to be fixed. Mark said that Openbios also loads the same FCode for every display device it finds, so that too needs to be fixed.

I'm sure I can fix these things, given enough time, but whoever wrote them could likely do it a lot faster and better than I could.

I'm not throwing stones, Openbios, and Qemu are amazing pieces of software, and I know a lot of people have and do work hard to maintain and improve them. I don't expect anyone to jump up and fix a few issue I find when I'm trying to get something to work, but it would be helpful for people to answer the questions asked.

I don't have any problem building Qemu, on there Mac OS or Linux, some of the code changes I ported from PCem won't link, and I'm unsure why, I'm hoping it's just a bug in OS X that requires it to be built for i386, if it's deeper than that, I'm not really qualified to fix it, google searching the undefined symbols doesn't yield anything useful.

If it's still code in PCem that I need to port over, I'm at a loss, as the compiler doesn't have any errors, and the linker doesn't give me any clue.
Programmingkid
Apple Corer
Posts: 243
Joined: Sun Jan 31, 2016 6:01 pm

Re: Add Voodoo2 emulation for Qemu?

Post by Programmingkid »

Do you have the source code you made with Voodoo implemented available for download? I would like to try and build it myself.

Could you send the linker output message?

For OpenBIOS, is it the pci.c file's vga_config_cb() function that needs to changed?

This command makes me believe that OpenBIOS does try to use the Fcode:
/* Currently we don't read FCode from the hardware but execute it directly */

If what Mark Cave-Ayland said is true and OpenBIOS uses its own driver, then my guess is the vga-driver-fcode word is what points to it. Changing OpenBIOS to load the video card's Fcode could mean changing this line:

feval("['] vga-driver-fcode 2 cells + 1 byte-load");

I will check with Mark to see what he has to say out it.
darthnvader
Mac Mechanic
Posts: 174
Joined: Sun Feb 07, 2016 4:40 pm

Re: Add Voodoo2 emulation for Qemu?

Post by darthnvader »

Yes, I noted that too, after Mark pointed me to the vga_config_cb().

I noticed before, with Voodoo4/5 that loading the Rom didn't do anything, so know I know why, but I'm unsure how to fix it. If other people want to take interest in emulating 3D hardware that would make things go a little faster, I'm limited to trial and error, really a backwards why of doing things, because there is some much I don't understand about the code itself.

Anyone that has proper education, and can write C programs will really work a lot faster than I can.

I'm just doing it to keep myself amused.

I built a new PC, and all my work on porting from PCem is on my old PC's drive, that my new PC doesn't seem to want to read. Once I get the data over, I'll post the code on Github, or somewhere for download. Tho it's shameful the way I hacked it in, and people will make fun of me. :mrgreen:
Programmingkid
Apple Corer
Posts: 243
Joined: Sun Jan 31, 2016 6:01 pm

Re: Add Voodoo2 emulation for Qemu?

Post by Programmingkid »

Don't worry about the people who don't like the code. In thru one ear, out thru the other.

What is the status of the port? Is there any sign that the voodoo card functions in QEMU? Have you tried using qemu-system-i386 with the card yet? I will be more than glad to help test this code out once you post it. Thanks.
darthnvader
Mac Mechanic
Posts: 174
Joined: Sun Feb 07, 2016 4:40 pm

Re: Add Voodoo2 emulation for Qemu?

Post by darthnvader »

The code never links, so there is no binary I can test to see if it works or not. Tho I did run PCem in Wine on OS X, and once I configured everything right the Voodoo2 emulation is spot on. PCem doesn't do a good job of x86 emulation. Meaning it's really slow, as far a the CPU, some of that maybe on purpose, so older software doesn't run too fast.

Anyway, I was getting 25-30 FPS out of UnReal, and URT.
darthnvader
Mac Mechanic
Posts: 174
Joined: Sun Feb 07, 2016 4:40 pm

Re: Add Voodoo2 emulation for Qemu?

Post by darthnvader »

I’ve been working with the fine folks at Openbios and SLOF for PCI Passthough of a VGA card( Apple OEM Geforce 6600 PCI-E ) The host system is Debian x86/AMD64.

The current state of SLOF is I can get the fCode option rom to load to the end0, and it populates the parent, and all the .properties seem to be correct, but the children( NVDA, Display@a/b ) are not properly populated. Need to do some work with get-node extend-device.

With Openbios I’m not getting the correct instance, I believe, and the Rom catches an exception around this operation:

(offset) 9
8010054 : (compile) b(') [ 0x11 ]
8010057 : (compile) b(to) [ 0xc3 ]
801005a : (compile) b(>resolve) [ 0xb2 ]

: b(>resolve) ( ffffffff 1 0 ffffffff 0 0 ffffffff fff41a48 0 0 0 0 0 0 ffffffff fff571c4 0 fff57200 0 )
fff469bc: resolve-orig ( ffffffff 1 0 ffffffff 0 0 ffffffff fff41a48 0 0 0 0 0 0 ffffffff fff571c4 0 )
fff469c0: execute-tmp-comp ( ffffffff 1 0 ffffffff 0 0 ffffffff fff41a48 0 0 0 0 0 0 ffffffff fff571c4 0 )
fff469c4: (semis)
[ Finished b(>resolve) ] 801005b : (compile) b(>resolve) [ 0xb2 ]

: b(>resolve) ( ffffffff 1 0 ffffffff 0 0 ffffffff fff41a48 0 0 0 0 0 0 ffffffff fff571c4 0 )
fff469bc: resolve-orig ( ffffffff 1 0 ffffffff 0 0 ffffffff fff41a48 0 0 0 0 0 0 ffffffff )
fff469c0: execute-tmp-comp
byte-load: exception caught!

For SLOF it seems there is some support for 10de,141 baked in and it should be able to read the option rom from the card, rather than loading it from a disk. For Openbios there is currently no support for reading option rom from pci devices.

Really, we need to make a proper fCode rom for the QEMU,VGA device and load it from qemu-System-ppc, rather than loading a PC VGA Bios, as we do now, and Openbios need to probe the PCI bus for option roms.

If anyone has any interest in advancing this, help would be or insight is welcome.

https://mail.coreboot.org/pipermail/ope ... hread.html

https://lists.ozlabs.org/pipermail/slof ... 02008.html
User avatar
adespoton
Forum All-Star
Posts: 3247
Joined: Fri Nov 27, 2009 5:11 am
Location: Emaculation.com
Contact:

Re: Add Voodoo2 emulation for Qemu?

Post by adespoton »

Thanks for the update! This is outside my wheelhouse, but I'll be happy to review/test.
darthnvader
Mac Mechanic
Posts: 174
Joined: Sun Feb 07, 2016 4:40 pm

Re: Add Voodoo2 emulation for Qemu?

Post by darthnvader »

Programmingkid wrote:I was wondering how things were going with implementing a new video card in QEMU. Did you ever solve the problem of the mysterious driver? Is there anything someone else could do to help?
I finally figured this issue, with the non-existent hardware NDRV.

OS 9 will load this for any display device that it finds if it is the boot display, and it has no NDRV.

Because my emulated Voodoo card was not having it's Fcode Rom read in by Openbios, there was no NDRV.

I went back to basics to figure out how OS 9 drivers load, and what makes the system tick. I got OS 9 running on an iBook G4 that was OS X only. It has a Radeon 9550, that doesn't have an NDRV in boot rom. Once I looked at the IOReg in OS 9, I could see the non-existent hardware 'NDRV' and my display was stuck at 1024x768x8.

So I whipped up an 'NDRV' driver for the 9550 for OS 9, from the one in 10.5.8.

Today I figured out all the bits needed to load and link the rest of the OS 9 ATI drivers.

So, what this means is after I finally get a Voodoo2( still can't win a reasonable priced one on Ebay ) and I finish the Voodoo2 emulation, I can move back to the Rage128, and I already know what I need to do to get the OS 9 drivers to load for it.
User avatar
Cat_7
Expert User
Posts: 5256
Joined: Fri Feb 13, 2004 8:59 am
Location: Sittard, The Netherlands

Re: Add Voodoo2 emulation for Qemu?

Post by Cat_7 »

Great news!

Can you guide us through hardware and software requirements to achieve the same?

Best,
Cat_7
mathieudel
Inquisitive Elf
Posts: 36
Joined: Sat Oct 03, 2009 12:51 am
Location: France

Re: Add Voodoo2 emulation for Qemu?

Post by mathieudel »

darthnvader wrote:still can't win a reasonable priced one on Ebay
What would you call a reasonable price ? I can find a bunch of them in the 40 / 60€ ballpark, that doesn't look that much to me, but I may be biased by the emotional factor :) !

By the way, I think I have one of those (or maybe that's a 3DFX 3, or both of them ??? I don't remember), waiting in a drawer... If your reasonable price seems reasonable to me too, maybe we could have a deal :)
Post Reply