Emulating BIOS for VBE

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
rdos
Member
Member
Posts: 3311
Joined: Wed Oct 01, 2008 1:55 pm

Emulating BIOS for VBE

Post by rdos »

I think I will start on this now that I've solved the USB-issues. In order to be able to boot from UEFI, I first must remove the reliance my VBE driver has on the real BIOS.

One way to do this would be to take some emulator BIOS and run it in an emulator, but I find this both slow and overkill. I don't think the VBE requires many of the fancy BIOS functions. Thus, I instead plan to run a virtual BIOS in VM86-mode.

If I implement the card-detection & startup procedure that the BIOS normally does at boot, and set all interrupts to go to a dummy interrupt handler that contains an "int 3", I can figure out what really is needed. Then I should probably also initialize the BDA to something reasonable.

Somebody should already have done this, but I guess the big OSes either use the emulator approach, or has non-open source code.
Antti
Member
Member
Posts: 923
Joined: Thu Jul 05, 2012 5:12 am
Location: Finland

Re: Emulating BIOS for VBE

Post by Antti »

This does not sound very good. Why do you want to have such an unrealiable hack? It will not work very long. Use Graphics Output Protocol (GOP) or write native drivers.
User avatar
Owen
Member
Member
Posts: 1700
Joined: Fri Jun 13, 2008 3:21 pm
Location: Cambridge, United Kingdom
Contact:

Re: Emulating BIOS for VBE

Post by Owen »

You'll find the (ratsnest) of code which implements VBE on both PC+BIOS and NonPC at the int10 section of the XOrg source
rdos
Member
Member
Posts: 3311
Joined: Wed Oct 01, 2008 1:55 pm

Re: Emulating BIOS for VBE

Post by rdos »

Antti wrote:This does not sound very good. Why do you want to have such an unrealiable hack? It will not work very long. Use Graphics Output Protocol (GOP) or write native drivers.
I need it in order to be able to boot from UEFI, since my current code depends on it. In addition to that, I want to avoid GOP as long as possible, and hope that video cards will continue to support VBE even in the absence of a BIOS which can enable it.

In fact, I don't see how GOP could work with a random video-card without some kind of code in the video card, which I suspect is the VBE interface today. I don't think that GOP will provide native drivers for every imaginable video-card. It might in laptops, but not in stationary computers that can use an external video-card.
User avatar
Owen
Member
Member
Posts: 1700
Joined: Fri Jun 13, 2008 3:21 pm
Location: Cambridge, United Kingdom
Contact:

Re: Emulating BIOS for VBE

Post by Owen »

GOP works the same way VBE does. That is, the card provides the driver in an option ROM!

Just, this time the driver is a UEFI driver rather than a VBE one.
PearOs
Member
Member
Posts: 194
Joined: Mon Apr 08, 2013 3:03 pm
Location: Usually at my keyboard!

Re: Emulating BIOS for VBE

Post by PearOs »

rdos wrote:I think I will start on this now that I've solved the USB-issues. In order to be able to boot from UEFI, I first must remove the reliance my VBE driver has on the real BIOS.

One way to do this would be to take some emulator BIOS and run it in an emulator, but I find this both slow and overkill. I don't think the VBE requires many of the fancy BIOS functions. Thus, I instead plan to run a virtual BIOS in VM86-mode.

If I implement the card-detection & startup procedure that the BIOS normally does at boot, and set all interrupts to go to a dummy interrupt handler that contains an "int 3", I can figure out what really is needed. Then I should probably also initialize the BDA to something reasonable.

Somebody should already have done this, but I guess the big OSes either use the emulator approach, or has non-open source code.

Edit: Wait Nvm, your trying to use UEFI. In that case your only hope is an emulator..
rdos
Member
Member
Posts: 3311
Joined: Wed Oct 01, 2008 1:55 pm

Re: Emulating BIOS for VBE

Post by rdos »

On my Sony Vaio portable, it works with an empty int 15 handler. The video initialization routine (0xC000:0x0003) calls the int 15 handler with AH=5F a couple of times (which I return unsupported function for), and then gives up. When I call the video mode change, nothing else happens, and it works very well. Will test on some other computers as well to see if it is as simple as that. :)
rdos
Member
Member
Posts: 3311
Joined: Wed Oct 01, 2008 1:55 pm

Re: Emulating BIOS for VBE

Post by rdos »

PearOs wrote:
rdos wrote:I think I will start on this now that I've solved the USB-issues. In order to be able to boot from UEFI, I first must remove the reliance my VBE driver has on the real BIOS.

One way to do this would be to take some emulator BIOS and run it in an emulator, but I find this both slow and overkill. I don't think the VBE requires many of the fancy BIOS functions. Thus, I instead plan to run a virtual BIOS in VM86-mode.

If I implement the card-detection & startup procedure that the BIOS normally does at boot, and set all interrupts to go to a dummy interrupt handler that contains an "int 3", I can figure out what really is needed. Then I should probably also initialize the BDA to something reasonable.

Somebody should already have done this, but I guess the big OSes either use the emulator approach, or has non-open source code.
Edit: Wait Nvm, your trying to use UEFI. In that case your only hope is an emulator..
Not so. I map the first page in VM86 mode to default interrupt vectors + a dummy int 15 + a zeroed BDA. Then I provide a BIOS which only calls the video initialization entry-point (C000:0003), and returns.
After that I call int 0x10 with AL=3 to set video mode to text. I do this before PCI initialization. UEFI can do nothing about this as long as there is a video BIOS at C000. UEFI is only software, and thus must initialize the video BIOS itself, which I then redo to my own preferences.
PearOs
Member
Member
Posts: 194
Joined: Mon Apr 08, 2013 3:03 pm
Location: Usually at my keyboard!

Re: Emulating BIOS for VBE

Post by PearOs »

rdos wrote:
PearOs wrote:
rdos wrote:I think I will start on this now that I've solved the USB-issues. In order to be able to boot from UEFI, I first must remove the reliance my VBE driver has on the real BIOS.

One way to do this would be to take some emulator BIOS and run it in an emulator, but I find this both slow and overkill. I don't think the VBE requires many of the fancy BIOS functions. Thus, I instead plan to run a virtual BIOS in VM86-mode.

If I implement the card-detection & startup procedure that the BIOS normally does at boot, and set all interrupts to go to a dummy interrupt handler that contains an "int 3", I can figure out what really is needed. Then I should probably also initialize the BDA to something reasonable.

Somebody should already have done this, but I guess the big OSes either use the emulator approach, or has non-open source code.
Edit: Wait Nvm, your trying to use UEFI. In that case your only hope is an emulator..
Not so. I map the first page in VM86 mode to default interrupt vectors + a dummy int 15 + a zeroed BDA. Then I provide a BIOS which only calls the video initialization entry-point (C000:0003), and returns.
After that I call int 0x10 with AL=3 to set video mode to text. I do this before PCI initialization. UEFI can do nothing about this as long as there is a video BIOS at C000. UEFI is only software, and thus must initialize the video BIOS itself, which I then redo to my own preferences.
Interesting. I will have to remember that when I attempt UEFI some day.. *shudder*

Edit: But wait, one Video Bios doesn't work with every board does it?

Thanks, Matt
User avatar
Owen
Member
Member
Posts: 1700
Joined: Fri Jun 13, 2008 3:21 pm
Location: Cambridge, United Kingdom
Contact:

Re: Emulating BIOS for VBE

Post by Owen »

Repeating what I said earlier: the graphics card provides the video BIOS. It also provides the video UEFI.
rdos
Member
Member
Posts: 3311
Joined: Wed Oct 01, 2008 1:55 pm

Re: Emulating BIOS for VBE

Post by rdos »

Owen wrote:Repeating what I said earlier: the graphics card provides the video BIOS. It also provides the video UEFI.
Possible. However, if you plug in the video card in a stationary PC in some PCI-slot, then the systems UEFI has no idea about the card, and the card thus cannot provide the GOP. The only thing it provides is a VBE BIOS. Which means the systems UEFI must use VBE to provide GOP.
rdos
Member
Member
Posts: 3311
Joined: Wed Oct 01, 2008 1:55 pm

Re: Emulating BIOS for VBE

Post by rdos »

Confirmed that this also works on another laptop with an Intel Atom processor. Seems like most modern video BIOS doesn't use anything else than int 15, AH=5F in their initialization code, which makes it very easy to put them in VBE-mode. On older PCs it doesn't matter as those have no UEFI, and thus has to be booted with BIOS, and then the usual VBE driver which uses the real BIOS is more suitable.
devsau
Member
Member
Posts: 35
Joined: Thu Jun 13, 2013 12:07 pm

Re: Emulating BIOS for VBE

Post by devsau »

I was going to make a new thread, but I saw this thread floating at the top and since my question is slightly related I figured why not just ask here.

Question is, anyone know if I can use the uefi setmode services for GOP to get the same resolution that my card offers using vesa/vbe?
rdos
Member
Member
Posts: 3311
Joined: Wed Oct 01, 2008 1:55 pm

Re: Emulating BIOS for VBE

Post by rdos »

Adding an error return for int 15, AH=4E, and I can run on two stationary AMD-based computers as well, one of them at least 5 years old. It seems like this is a working concept, and no emulator is needed. The virtual BIOS is only some 50 bytes long :)
rdos
Member
Member
Posts: 3311
Joined: Wed Oct 01, 2008 1:55 pm

Re: Emulating BIOS for VBE

Post by rdos »

devsau wrote: Question is, anyone know if I can use the uefi setmode services for GOP to get the same resolution that my card offers using vesa/vbe?
I don't know, but I suspect the answer should be "yes". At least I don't think GOP will offer more resolutions than VBE, especially if GOP gathers information from VBE.
Post Reply