OSDev.org

The Place to Start for Operating System Developers
It is currently Tue Dec 12, 2017 10:24 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Making GRUB ask for VBE mode
PostPosted: Fri May 19, 2017 1:08 pm 
Offline

Joined: Sun Apr 30, 2017 12:16 pm
Posts: 11
Hello! I'm working on my OS. I've been able to get different video modes by setting Multiboot flags. I have been wondering how do you get GRUB to ask what video mode to choose. Contents of grub.cfg
Setting the GRUB_GFXMODE and GRUB_GFXPAYLOAD doesn't work(when the video mode specified in Multiboot header cannot be found, it defaults to 640x480 in QEMU and VirtualBox). Sorry for my bad English, I'm not a native English speaker. Thanks in advance.

_________________
クッキーOS


Top
 Profile  
 
 Post subject: Re: Making GRUB ask for VBE mode
PostPosted: Sat May 20, 2017 4:12 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 30, 2013 1:57 pm
Posts: 286
Location: Germany
There are a number of ways to do it, although it is not clear to me which one you're looking for exactly.

First off, as you mentioned, you can request a resolution in your Multiboot flags. This is hardcoded in the binary, therefore not really good in terms of letting the user choose a resolution.

As you rightfully state, you can set (read: request) a resolution using a GRUB variable: it is called 'gfxpayload'. For me, this overrides my Multiboot2-header resolution. Typically, I use it as:
Code:
menuentry "MyOS" {
    multiboot2 /path/to/my/kernel
    set gfxpayload=1920x1080x32
    boot
}

You can create multiple entries using different resolutions, letting the user choose one of the predefined options in GRUB. To clean things up, use a submenu for that. Here's how I do it.

If you want ultimate flexibility, you can let the user input the values. Use GRUB's read command for this. After that, you can construct the resolution and set gfxpayload to that value.

I haven't done this, but IIRC it looks something like this:
Code:
menuentry "custom" {
    echo "width:"
    read __width
    echo "height:"
    read __height
    <your commands>
    set gfxpayload=${__width}x${__height}x32
    boot
}

_________________
OSDev Discord
vineyard, a x86 OS.


Top
 Profile  
 
 Post subject: Re: Making GRUB ask for VBE mode
PostPosted: Sat May 20, 2017 9:30 am 
Offline

Joined: Sun Apr 30, 2017 12:16 pm
Posts: 11
Thank you very much @no92. This was exactly what I was looking for. I must have been doing something incorrectly before.

_________________
クッキーOS


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 17 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group