VESA in P-Mode

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.
Jacobbus
Posts: 7
Joined: Thu Apr 10, 2008 2:49 am

VESA in P-Mode

Post by Jacobbus »

Hi,

Is it possible to switch to a VESA resolution once you are in protected mode?
I am aware of the way to switch with bios interrupts, and know of bankswitching without the bios.
But I would like to see a windows like system where you can change the resolution on the fly, but don't know if that is only possible with drivers.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post by Combuster »

In the category "answered ways to change mode questions":
1) Write a VGA driver.
2) Go (back to) real mode and call the bios from there.
3) Use v8086 mode.
4) Write drivers for each card.
5) Write your own real mode emulator.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
svdmeer
Member
Member
Posts: 87
Joined: Tue May 06, 2008 9:32 am
Location: The Netherlands

Post by svdmeer »

6) (the easiest way) The function for changing videomode is in VESA 3.0 available in protected mode.
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post by AJ »

Caveat with option 6: The Protected mode interface will not be supported in VESA 1.x and 2.x implementations and is also an optional part of the VESA 3.0 specification. This means that your OS still has to handle the case where the PM entry point is not supported.

If you rely on VBE3 with the PM interface, expect that your OS may not be able to run on a large number of machines.

Cheers,
Adam
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Post by Dex »

Plus the biggest draw back of using (6), is you need to go back to 16bit Pmode to use it, so its not much differant than going to realmode and back.
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post by AJ »

...not to mention that looking at the VBE3 spec, setting up for PMode looks anything but simple.

My suggestion: If doing this directly from a 32 bit kernel, use Combuster's option 3. If doing it once at startup from your boot loader, use Combusters options 2 or 3.

Once your kernel progresses, try options 1, 4 or 5. On each occasion, attempt to set the mode with an LFB - you will later have to add support for systems that do not support this, but in my experience most do.

Cheers,
Adam
Jacobbus
Posts: 7
Joined: Thu Apr 10, 2008 2:49 am

Post by Jacobbus »

But when you ask the bios to switch to a vesa mode the bios isn't performing magic (I hope)
So it should be possible to write a 32 bit version of what the bios does,
Or am I missing something
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

Jacobbus wrote:But when you ask the bios to switch to a vesa mode the bios isn't performing magic (I hope)
So it should be possible to write a 32 bit version of what the bios does,
Or am I missing something
But the bios is generally closed-source and proprietary. It would be difficult if not impossible to replicate, and may not be the same for all cards.
svdmeer
Member
Member
Posts: 87
Joined: Tue May 06, 2008 9:32 am
Location: The Netherlands

Post by svdmeer »

AJ wrote:...not to mention that looking at the VBE3 spec, setting up for PMode looks anything but simple.

My suggestion: If doing this directly from a 32 bit kernel, use Combuster's option 3. If doing it once at startup from your boot loader, use Combusters options 2 or 3.

Cheers,
Adam
Wat's better: Switching to realmode or use vm86?
User avatar
JAAman
Member
Member
Posts: 879
Joined: Wed Oct 27, 2004 11:00 pm
Location: WA

Post by JAAman »

But when you ask the bios to switch to a vesa mode the bios isn't performing magic (I hope)
So it should be possible to write a 32 bit version of what the bios does,
Or am I missing something
yes, your missing the fact that the 'BIOS' calls which switch video modes, are on the video card -- not the MB, which means that code which actually does the switching is different for each video controller
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post by AJ »

svdmeer wrote:Wat's better: Switching to realmode or use vm86?
It really depends on your environment. If you already have task switching with ring 3 support and are happy writing a Virtual Mode Monitor (or are just using CPU's which suport VM extensions) and just want video mode switching, go for v86 every time.

I am writing a boot loader where I have none of this environment and I want to use BIOS disk access functions (which can't be used in v86 - they want control over interrupts). Real mode is more appropriate for this situation.

Cheers,
Adam
svdmeer
Member
Member
Posts: 87
Joined: Tue May 06, 2008 9:32 am
Location: The Netherlands

Post by svdmeer »

AJ wrote:
svdmeer wrote:Wat's better: Switching to realmode or use vm86?

I am writing a boot loader where I have none of this environment and I want to use BIOS disk access functions (which can't be used in v86 - they want control over interrupts). Real mode is more appropriate for this situation.

Cheers,
Adam
A few years ago, I wrote a function to call BIOS-interrupts from protectedmode. The function switches to vm86 mode, calls interrupt functions and returns. It happened from a single-tasking environment, meant for a bootloader. I even used interrupts: From every interrupt routine, I switched to vm86 mode and called the vector in the realmode vector-table. It worked ok. Without using any features newer than 386. From protectedmode, realmode interrupts are used. For example the BIOS-keyboard buffer worked from protectedmode when I pressed a key.
Sadly, there is a major bug. All int 10h functions work, but int 13h gives an exception, a bug I could never solve. Maybe I will reuse this code soon. But I think it's possible to use BIOS interrupt handling & BIOS routines from a single tasking protectedmode environment without own drivers.
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post by AJ »

Hi,

IIRC, the Intel Manuals themselves suggest not using v86 for disk I/O (such as int 0x13) - or was it on RBIL? Either way, I would not suggest using int 0x13 in v86 - even if you get it going on one machine, I think there are far less guarantees than with using BIOS int 0x10.

Cheers,
Adam
svdmeer
Member
Member
Posts: 87
Joined: Tue May 06, 2008 9:32 am
Location: The Netherlands

Post by svdmeer »

AJ wrote:Hi,

IIRC, the Intel Manuals themselves suggest not using v86 for disk I/O (such as int 0x13) - or was it on RBIL? Either way, I would not suggest using int 0x13 in v86 - even if you get it going on one machine, I think there are far less guarantees than with using BIOS int 0x10.

Cheers,
Adam
Microsoft Windows '95 does use int 13h @ vm86 (16-bit disk access) doesn't it?
User avatar
edfed
Member
Member
Posts: 42
Joined: Wed Apr 09, 2008 5:44 pm
Location: Mars

Post by edfed »

the bios don't contain all the drivers for all video cards.

if you buy a PC with a "X videocard X" onto, then, at boot (using bios), you will set vesa modes.

if you change the video card, you don't have to change your bios to set the video mode, because VGA bios is not PC bios.

by evidence, there is a STANDARD layer somewhere between BIOS and VESA that permits to change all video modes with the simple int 10h ( in fact, a function inside the bios that wil call some functions into the VGA bios????
welcome in my dream.
Post Reply