how to use vga in protected mode?
Posted: Thu Jun 12, 2008 2:07 am
Is possible to write a driver for vga screen mode, without swich my os to real mode or write a virtual mode?
The Place to Start for Operating System Developers
http://f.osdev.org/
No - unless you have access to the specification of your card (possible for ATI and Intel cards at least) you'll need the BIOS to do it for you, so you'll need to drop into real mode, use VM86 mode or write a 16-bit x86 interpreter.Karlosoft wrote:Is possible to write a driver for vga screen mode, without swich my os to real mode or write a virtual mode?
Yeah, you're quite right, I hadn't had my coffee when I checked osdev.org Got it now though!Combuster wrote:@JamesM: I assume that you were half asleep when you posted that...
VGA from protectected mode is easy, its SVGA (or Vesa) that requires you to have knowledge of the card (the card provides bits of this information in the BIOS, but requires the 16-bit environment to work)
The VGA Hardware page holds a lot of hardware tidbits you can start with. If you want to just grab someone else's code and pray it works, try VGA Resources
True, but I support both.
As most people's test computers are pretty old, it's not really viable to rely on a protected mode interface being available, so to access higher resolutions you'll have to use the BIOS interface (real mode).
Hi,robos wrote:You can do VESA in pmode, you're just restricted to setting the graphics mode and getting the address of the linear frame buffer before jumping to pmode and you'll have to select from whatever list of resolutions the VESA bios supports (no widescreen resolutions for example).
In my OS, I drop out of PMode, use BIOS and go right back, after having it do the function to get a linear framebuffer and the video mode info. Its really pretty easy, the whole code fits into 128 bytes of assembled code. I've attached the source file here. A few pointers though:JamesM wrote:Hi,robos wrote:You can do VESA in pmode, you're just restricted to setting the graphics mode and getting the address of the linear frame buffer before jumping to pmode and you'll have to select from whatever list of resolutions the VESA bios supports (no widescreen resolutions for example).
In this case, you're not really "doing" VESA in protected mode at all - you're setting everything up in real mode and using it in protected mode - i.e. you have to drop back to real mode (or use vm86 or use a 16-bit 8086 interpreter) to change setup.
Cheers,
James
You are correct, I should've written my post a little bit different. The question was in regards to vga screen mode, not VESA in particular (you'll just want to use it to setup a graphics mode of interest). My response was meant to say that you can access the frame buffer from pmode and draw graphics etc. without needing to be in real mode after you've set this graphics mode up in real mode.JamesM wrote:In this case, you're not really "doing" VESA in protected mode at all - you're setting everything up in real mode and using it in protected mode - i.e. you have to drop back to real mode (or use vm86 or use a 16-bit 8086 interpreter) to change setup.robos wrote:You can do VESA in pmode, you're just restricted to setting the graphics mode and getting the address of the linear frame buffer before jumping to pmode and you'll have to select from whatever list of resolutions the VESA bios supports (no widescreen resolutions for example).
The original poster didn't specify what features his/her driver needs to have. If there's no requirement to switch graphics mode after it's been setup once there's no reel need to drop into real mode / VM86 or write a custom driver.JamesM wrote:No - unless you have access to the specification of your card (possible for ATI and Intel cards at least) you'll need the BIOS to do it for you, so you'll need to drop into real mode, use VM86 mode or write a 16-bit x86 interpreter.Karlosoft wrote:Is possible to write a driver for vga screen mode, without swich my os to real mode or write a virtual mode?
Yep! I'll agree with that!robos wrote:You are correct, I should've written my post a little bit different. The question was in regards to vga screen mode, not VESA in particular (you'll just want to use it to setup a graphics mode of interest). My response was meant to say that you can access the frame buffer from pmode and draw graphics etc. without needing to be in real mode after you've set this graphics mode up in real mode.JamesM wrote:In this case, you're not really "doing" VESA in protected mode at all - you're setting everything up in real mode and using it in protected mode - i.e. you have to drop back to real mode (or use vm86 or use a 16-bit 8086 interpreter) to change setup.robos wrote:You can do VESA in pmode, you're just restricted to setting the graphics mode and getting the address of the linear frame buffer before jumping to pmode and you'll have to select from whatever list of resolutions the VESA bios supports (no widescreen resolutions for example).
The original poster didn't specify what features his/her driver needs to have. If there's no requirement to switch graphics mode after it's been setup once there's no reel need to drop into real mode / VM86 or write a custom driver.JamesM wrote:No - unless you have access to the specification of your card (possible for ATI and Intel cards at least) you'll need the BIOS to do it for you, so you'll need to drop into real mode, use VM86 mode or write a 16-bit x86 interpreter.Karlosoft wrote:Is possible to write a driver for vga screen mode, without swich my os to real mode or write a virtual mode?
However, if you want to:
1) change graphics resolutions to a predefined list then you need real mode or VM86 etc.
2) change graphics resolutions to whatever the card / monitor supports you'll need a graphics card specific driver
Does that make my response more clear?