OSDev.org
https://forum.osdev.org/

Making GRUB ask for VBE mode
https://forum.osdev.org/viewtopic.php?f=1&t=31933
Page 1 of 1

Author:  qookie [ Fri May 19, 2017 1:08 pm ]
Post subject:  Making GRUB ask for VBE mode

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.

Author:  no92 [ Sat May 20, 2017 4:12 am ]
Post subject:  Re: Making GRUB ask for VBE mode

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
}

Author:  qookie [ Sat May 20, 2017 9:30 am ]
Post subject:  Re: Making GRUB ask for VBE mode

Thank you very much @no92. This was exactly what I was looking for. I must have been doing something incorrectly before.

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/