Page 1 of 1

protected/long mode video examples for common emulators?

Posted: Thu May 27, 2010 8:39 pm
by proxy
Are there any clear and simple examples for doing the basic video tasks on the common emulators without using v86 mode?

I suppose the first question is. What type of video card do the common emulators simulate (or are compatible with).

I've done some basic googling, but for the most part, I've seen people say "look at the linux drivers". I'm looking for something simple and straightforward, no need for advanced features for the moment.

The bare minimum I'm looking to get going is simply enumerate video modes and their properties, change video modes, get framebuffer.

As I type this, I'm downloading the Haiku sources, and I'll be looking through some other open source projects. But at the moment, I'm not 100% sure which driver I should be looking through for Virtual Box or VMWare.

Has anyone here made a simple no acceleration driver for protected mode?

Re: protected/long mode video examples for common emulators?

Posted: Fri May 28, 2010 2:28 am
by Combuster
I suppose the first question is. What type of video card do the common emulators simulate (or are compatible with).
They all emulate original VGA Hardware. From there on it differs.
Bochs and qemu emulate the BGA interface when enabled (requires the correct config settings/command line switches), which is very easy to program for. Alternatively, you might have both emulate a Cirrus Logic GD544x chip.
VirtualPC emulates a Trio64V - which is slightly problematic with documentation since the resources you'll find are slightly out of date (most issues are about getting the bitdepth correctly). Hardware acceleration works as expected though.

VMWare uses a proprietary interface - don't bother with anything high-resolution. I haven't tried VirtualBox, but you are probably stuck with the VGA method on there too, unless you decide to scrap your v8086 limitation or write an emulator.
simply enumerate video modes and their properties,
There's no enumeration on video cards. They technically support any multiple-of-8 resolution, and within certain bounds, so do most CRT monitors (based on minimum and maximum frequencies). So if you compute them all you'll have about 16000 different valid resolutions that way. And that's only one bit depth. In practice, you need to ask the monitor for what it prefers and stick to common resolution formats.
get framebuffer
get a PCI BAR for starters.
Has anyone here made a simple no acceleration driver for protected mode?
Regarding actual drivers, they aren't that simple. I have a fully working BGA driver, The verite, mach64, trio64, gma and voodoo drivers are still in various stages of construction, mostly because of interoperability issues with similar chipsets that are different enough to break your assumptions about them. If you want to get started with known broken code, try here

If you just want to get started the cheap way: Register dump collection

Re: protected/long mode video examples for common emulators?

Posted: Fri May 28, 2010 6:49 am
by nedbrek
Combuster wrote:If you just want to get started the cheap way: Register dump collection
How were these dumps gathered? I have an NVIDIA GeForce 5200 which I would be glad to extract data from...

Re: protected/long mode video examples for common emulators?

Posted: Fri May 28, 2010 7:54 am
by Combuster
nedbrek wrote:How were these dumps gathered? I have an NVIDIA GeForce 5200 which I would be glad to extract data from...
Most of them using windows '98: Set the mode you want, then use port I/O to read the registers you want. Lack of protection ftw.

The alternative is to write a real-mode bootsector with VBE support, have it set the mode you want, grab the registers, then dump them where you can use them (either on screen after returning to text mode, or by writing blocks to hardcoded locations on a floppy drive). It gets difficult to get to a video card with only MMIO and still fit it in 512 bytes - you need PCI and unreal/protected mode support to pull that off. In any case, you should figure out in advance what you ought to be looking at. Setting 10 modes with minimal differences allows you to diff out the registers that do change (and why).