Grub Bootloader and video modes

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.
Post Reply
sevobal
Member
Member
Posts: 63
Joined: Sun Oct 22, 2006 7:11 am

Grub Bootloader and video modes

Post by sevobal »

Hi,
I'm using GRUB to boot my os and it works perfect. The best thing is that I'm already in PMODE.

I've heard that GRUB is able to setup a video mode before booting an OS. So do you know how to do this? Would be very nice THX! :D
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: Grub Bootloader and video modes

Post by Brendan »

Hi,
sevobal wrote:I'm using GRUB to boot my os and it works perfect. The best thing is that I'm already in PMODE.
Switching to protected mode takes about 30 bytes (which is mostly data) - it's not a huge bonus IMHO....
sevobal wrote:I've heard that GRUB is able to setup a video mode before booting an OS. So do you know how to do this? Would be very nice THX! :D
I've never tried it, and AFAIK you need a special version of GRUB that actually supports it, but the information on how to do it is in the Multiboot Specification.

More specifically, you'd set bit 2 in the flags field of the Multiboot Header, then set "desired" values in the graphics fields of the Multiboot Header. Then, after GRUB (or any other "Multiboot compliant" boot loader) starts your OS you'd check the VBE fields in the Multiboot Information Structure to figure out details for the video mode that was set.

The problem is that your OS has no real control over what sort of video mode the boot loader will select, and because of this your OS would need to handle all possible video modes. This includes text modes, modes with messed up pixel formats (e.g. BGR instead of RGB), modes with 24 bits per pixel, etc.

If you don't want your OS to support every messed up video mode ever invented, then a better way may be to switch back to real mode, use the video ROM's functions yourself to select a "good" mode that your OS does support, and then switch back to protected mode....

It'd also be good idea to collect a list of video modes that could have been used, so that while the user is using your OS they could select a different video mode from the list (e.g. right click on the desktop and choose it from a "video properties" dialog box) , so that the video mode the user selected is set the next time the OS boots. This isn't as good as allowing the user to change video modes without rebooting (but allowing the user to change video modes without rebooting can be a huge problem, depending on your OS design and if you use long mode or not).


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post by AJ »

Hi,

As well as not knowing what video mode was set by GRUB, your multiboot compliant kernel also has to handle the case in which GRUB does not successfully return video information.

As Brendan suggests, your best bet is probably to use Real Mode or V86 to set the desired video mode.

Adam
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Re: Grub Bootloader and video modes

Post by pcmattman »

sevobal wrote:Hi,
I'm using GRUB to boot my os and it works perfect. The best thing is that I'm already in PMODE.

I've heard that GRUB is able to setup a video mode before booting an OS. So do you know how to do this? Would be very nice THX! :D
Using your own video switcher is more reliable, and the GRUB way has no method of remembering user settings (so you'll have an unchangeable desktop resolution - not a good idea).
Post Reply