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.
Making GRUB ask for VBE mode
Making GRUB ask for VBE mode
Working on managarm.
-
- Member
- Posts: 307
- Joined: Wed Oct 30, 2013 1:57 pm
- Libera.chat IRC: no92
- Location: Germany
- Contact:
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:
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:
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: Select all
menuentry "MyOS" {
multiboot2 /path/to/my/kernel
set gfxpayload=1920x1080x32
boot
}
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: Select all
menuentry "custom" {
echo "width:"
read __width
echo "height:"
read __height
<your commands>
set gfxpayload=${__width}x${__height}x32
boot
}
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.
Working on managarm.