Skip to contentSkip to conversation

Subject: Re: [Qemu-devel] VGA BIOS source code

DISCUSSION Bob Barry 10 participants 16 messages May 31, 2004 – Jun 2, 2004

lore
Share & tools
lore
#1 lore raw

Alright, after digging into QEMU's graphics card emulation and into the VGA BIOS source, I came to a few conclusions:

a) SDD 6.53 is doing something utterly wrong. It switches the graphics card into a banked graphics mode (it specifically requests banked and not LFB) and then simply "forgets" to switch banks. I checked and double-checked, there is simply no call to the bank switching function. I guess this also means the problem with SDD 6.53 can't be fixed by tinkering with QEMU and/or the BIOS.

c) The fact that SDD does something wrong doesn't mean that only SDD is at fault if graphics modes don't work as advertised. The entire VESA VBE implementation is rather broken, shaky and incomplete.

b) The way the graphics card is emulated by QEMU (and Bochs and plex86 for that matter) is totally inefficient, error-prone and overly complicated. The card's logic is split between a few C files (vl.c, hw/vga.c) that get compiled and executed natively and a bunch of C files containing heaps of x86 assembly that get compiled into a VGA BIOS. The host emulator and the BIOS work together in a very complicated way and it is never obvious why a certain function is implemented in the BIOS or on the host.

d) Finally, as a conclusion from a) to c), I believe it would be best to ditch the entire VGA BIOS and implement all functions of the graphics card in C, natively, inside QEMU. This will be more efficient and less error prone. Now, I haven't seen the patches mentioned by Fabrice that emulate a CLGD54xx. But I certainly hope it is all native and not a half-native half-emulated solution like the current one.

- Bartosz

#2 lore raw
Quoted 11 lines · Bartosz Fabianowski

Alright, after digging into QEMU's graphics card emulation and into the VGA BIOS source, I came to a few conclusions:

a) SDD 6.53 is doing something utterly wrong. [snip]

c) [snip] The entire VESA VBE
implementation is rather broken, shaky and incomplete.

b) The way the graphics card is emulated by QEMU (and Bochs and plex86 for that matter) is totally inefficient, error-prone and overly complicated. [snip]

Is there a reasons for the a c b ordering?

I think you are probably a little harsh on this code. It may be far from perfect, but it does (mostly) work.

Quoted 6 lines

d) Finally, as a conclusion from a) to c), I believe it would be best to ditch the entire VGA BIOS and implement all functions of the graphics card in C, natively, inside QEMU. This will be more efficient and less error prone. Now, I haven't seen the patches mentioned by Fabrice that emulate a CLGD54xx. But I certainly hope it is all native and not a half-native half-emulated solution like the current one.

Getting something in place that pretends to be a known chipset and that can act like a dumb framebuffer would probably help. That seems to be the direction that Fabrice and Co. are going.

The Cirrus Logic chipset sounds like a good one for this.

Best,
Kyle

#3 lore raw
Quoted 1 line

Is there a reasons for the a c b ordering?

No ;)

Quoted 1 line

I think you are probably a little harsh on this code. It may be far from perfect, but it does (mostly) work.

Yes, it does work. Maybe I was a bit harsh in my wording after wasting a day on it, sorry.

Quoted 1 line

Getting something in place that pretends to be a known chipset and that can act like a dumb framebuffer would probably help. That seems to be the direction that Fabrice and Co. are going.

That seems like a good idea. Though if you are pretending to be some particular chip set, you should be prepared to emulate the most weird register settings that drivers could set for that chip set. So if the goal is to reach close to 100% compatibility, I fear a substantial subset of the entire spec for the chosen subset will have to be implemented.

Since my main interest is in running Windows inside QEMU, I could also envision adding another driver later, similar to what is done in VMWare. It would be a windows driver that acts as a dumb stub and forwards every request to the dumb side. Since it would be designed from the ground up only for QEMU, it could be limited in its functionality to really only being a frame buffer and nothing else. This would probably accelerate the emulation quite a bit.

- Bartosz

#4 lore raw
Quoted 9 lines · Bartosz Fabianowski
Quoted 1 line

Is there a reasons for the a c b ordering?

No ;)

Quoted 1 line

I think you are probably a little harsh on this code. It may be far from perfect, but it does (mostly) work.

Yes, it does work. Maybe I was a bit harsh in my wording after wasting a day on it, sorry.

Yes, and if you think about it longer, you will see the benefit of the Bochs VESA VBE layer. It is one of the simplest implementation you can think of.

The VMware driver idea is just an extension of it to add some acceleration primitives, and of course it is much more complicated. Adding real hardware support (such as a Cirrus Logic VGA card) will also be more complicated than the Bochs VESA VBE layer.

Quoted 4 lines

Since my main interest is in running Windows inside QEMU, I could also envision adding another driver later, similar to what is done in
VMWare. It would be a windows driver that acts as a dumb stub and forwards every request to the dumb side. Since it would be designed from the ground up only for QEMU, it could be limited in its functionality to really only being a frame buffer and nothing else.
This would probably accelerate the emulation quite a bit.

It is already done for NT (read the faq), at least for a linear frame buffer.

Fabrice.

#5 lore raw
In reply to Bartosz Fabianowski
Quoted 5 lines · Bartosz Fabianowski

That seems like a good idea. Though if you are pretending to be some particular chip set, you should be prepared to emulate the most weird register settings that drivers could set for that chip set. So if the goal is to reach close to 100% compatibility, I fear a substantial subset of the entire spec for the chosen subset will have to be implemented.

and that's the reason to try and pick a simple chip... The good thing about the Cirrus chips, is that (ignoring the Laguna family - '62/'64/'65) the TrueColour ('2x) and Alpine ('3x/'4x/'80) are all basically variations on a theme.

So one should be able to take the work provided for the non PCI version (a '2x or '30 I guess), and update it to be a simple PCI version. Then (if desired) one could morph it into later chips (video windows etc).

Quoted 1 line

From a quick glance at the datasheets and tech refs, it looks as if

the '34 or '36 is the one to target - being early PCI supporting versions and supporting 4M of video memory (i.e. 1024x768 @ 24 bit). They do contain a BitBLT, but it's a relatively simple 2 operand (16 operations) version, and may actually be the same op's as supported by X/Windows - need to check.

I'm not sure, but I guess the '36 is the one to target, as removing the ISA and VL-bus of the '34 may make things simpler. But the '36 BitBLT is slightly more capable (more support at 24/32 bpp, and seems to hang off a FIFO). But it may be that the '34 canonly to 1024x768 @ 16bpp.

Mind the other complexity (some may think it an advantage) is that the '36 has byte swapping PCI windows (think PPC support).

Quoted 2 lines

Since my main interest is in running Windows inside QEMU, I could also envision adding another driver later, similar to what is done in VMWare.

Well the VMware 'chip' interface is documented, you could implement it, however I doubt they'd be happy for you to use their drivers.

DF

#6 lore raw
Quoted 1 line

Well the VMware 'chip' interface is documented, you could implement it, however I doubt they'd be happy for you to use their drivers.

Actually, I wonder how happy Cirrus Logic will be if people use their reference manuals to implement a GD54xx emulation. Clearly, each manual states right at the beginning that you are not allowed to use it as a basis for manufacturing or selling anything, unless you have written permission from them. QEMU is not being sold by anybody AFAIK, but the question whether writing an emulator is manufacturing an item (a software item) still remains.

- Bartosz

#13 lore raw
In reply to Derek Fawcus

El Tue, Jun 01, 2004 at 12:44:18PM +0100, Derek Fawcus escribio:

Quoted 11 lines
Quoted 2 lines

From a quick glance at the datasheets and tech refs, it looks as if

the '34 or '36 is the one to target - being early PCI supporting versions and supporting 4M of video memory (i.e. 1024x768 @ 24 bit). They do contain a BitBLT, but it's a relatively simple 2 operand (16 operations) version, and may actually be the same op's as supported by X/Windows - need to check.

I'm not sure, but I guess the '36 is the one to target, as removing the ISA and VL-bus of the '34 may make things simpler. But the '36 BitBLT is slightly more capable (more support at 24/32 bpp, and seems to hang off a FIFO). But it may be that the '34 canonly to 1024x768 @ 16bpp.

I browsed the leo site, but couldn't find the manuals for the '3x series, only 542x and 5446. Where you found them?

Thanks,

Daniel.

#7 lore raw
In reply to Bartosz Fabianowski

I'm not a lawyer, and anyone who worries about such things should talk to one, but as far as reference docs go:

If they haven't patented some trickiness in their interface, and you haven't signed an NDA, and it's not a trade secret (it ain't if the document is freely downloadable) then there is probably very little to worry about other than upsetting them enough to stop giving out info in the future (which would be bad in the bigger picture for Linux). But I don't see how software emulation of their chip is going to impact their hardware sales in any obvious way.

Copyright infringement is the only thing one would really have to worry about, and unless you are redistributing the document I'm not sure how that would come into play.

-- John.

Quoted 20 lines · Bartosz Fabianowski
Quoted 2 lines

Well the VMware 'chip' interface is documented, you could implement it, however I doubt they'd be happy for you to use their drivers.

Actually, I wonder how happy Cirrus Logic will be if people use their reference manuals to implement a GD54xx emulation. Clearly, each manual states right at the beginning that you are not allowed to use it as a basis for manufacturing or selling anything, unless you have written permission from them. QEMU is not being sold by anybody AFAIK, but the question whether writing an emulator is manufacturing an item (a software item) still remains.

- Bartosz

_______________________________________________
Qemu-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/qemu-devel

#14 lore raw
In reply to Daniel Serpell
Quoted 3 lines · Daniel Serpell

I browsed the leo site, but couldn't find the manuals for the '3x series, only 542x and 5446. Where you found them?

They are described in the '4x manuals. Look for gd544xtrm.pdf

DF

#8 lore raw
In reply to John R. Hogerhuis
Quoted 4 lines · John R. Hogerhuis

Copyright infringement is the only thing one would really have to worry about, and unless you are redistributing the document I'm not sure how that would come into play.

Cirrus sold off the video stuff to another company years ago - Conexant? So I don't know if Cirrus still hold the copyright on the manuals , or if they were passed over to that other company.

DF

#15 lore raw
In reply to Derek Fawcus

El Tue, Jun 01, 2004 at 09:46:40PM +0100, Derek Fawcus escribio:

Quoted 6 lines · Daniel Serpell
Quoted 3 lines

I browsed the leo site, but couldn't find the manuals for the '3x series, only 542x and 5446. Where you found them?

They are described in the '4x manuals. Look for gd544xtrm.pdf

Thanks, I see now :-)

I was browsing the x.org driver sources and none of the cirrus logic chips has any XVideo or Render acceleration. The only supported operations are Screen to Screen Copy and Solid Fill (driver is really tiny).

Also, in the X sources is the vmware driver, with full docs, so perhaps it's easy to write a compatible layer (so, vmware driver can be used in the host).

Daniel.

#9 lore raw
In reply to Bartosz Fabianowski
Quoted 7 lines

Actually, I wonder how happy Cirrus Logic will be if people use their reference manuals to implement a GD54xx emulation. Clearly, each manual states right at the beginning that you are not allowed to use it as a basis for manufacturing or selling anything, unless you have written permission from them. QEMU is not being sold by anybody AFAIK, but the question whether writing an emulator is manufacturing an item (a software item) still remains.

Cirrus Logic has ditched the graphics market long time ago (after ATI has signed big contracts with Intel, HP and Compaq for using ATI chips on those vendors's motherboards) and they're now on the business of Linux/embedded and Windows/Embedded.

See: http://www.cirrus.com/en/products/

I hardly think that emulating a 5+ years chip would make them angry. After all, it's a free publicity for them (and zero work, all drivers are already outside)..

Thanks,
Hetz

#10 lore raw
Quoted 2 lines

I hardly think that emulating a 5+ years chip would make them angry. After all, it's a free publicity for them (and zero work, all drivers are already outside)..

The technical types at Cirrus most likely don't care and might actually be happy if their work from five years ago lives on. The people I was thinking about are the legal types. Those people tend to think in very strange ways that I never really understand. I wouldn't be surprised if for some weird reason some Cirrus Logic lawyer actually would mind. I am quite curious as to what the legal situation is, but I don't have the money to ask a lawyer ;).

- Bartosz

#11 lore raw

Hi,

Quoted 4 lines · Jan Fabianowski

The technical types at Cirrus most likely don't care and might actually be happy if their work from five years ago lives on. The people I was thinking about are the legal types. Those people tend to think in very strange ways that I never really understand.

Actually, they are very easy to understand (especially the ones working in USA): Let them think $$$ and they go berserk. (Not like a perl programmer who thinks about such lovely things as variables, derefs and eol when seeing a single dollar...)

Okay, now seriously: even if they would sell your grandma for half a buck, those types have to be silenced. They can be such a PITA (see SCO vs. everybody else; they just don't shut up). Maybe we should ask groklaw?

Ciao,
Dscho

#12 lore raw
Quoted 1 line

Maybe we should ask groklaw?

Maybe we should ask Cirrus Logic first? Plain out and simple explain what QEMU, what it needs a graphics card emulation for and that the CL-GD54xx series is very well suited for this. Though most people think Cirrus will not mind if such an emulation is based on their docs, having a written permission from Cirrus Logic is even better.

- Bartosz