Page 1 of 2
Setting VBE modes with GRUB2
Posted: Fri Oct 16, 2015 8:02 am
by abcdef4bfd
Hello, everybody. So i tried to set VBE modes with grub2, but I don't know, how to do that. I'm tried this:
Code: Select all
menuentry "OS365" {
multiboot /boot/os365.bin
set vbemode=1024x768x32
boot
}
Is it's fully wrong, is I need to do something in Multiboot header? On QEMU it's not setting the mode, but I'm passing -vga=std to it.
Re: Setting VBE modes with GRUB2
Posted: Fri Oct 16, 2015 9:59 am
by Coomer69
There are some flags to set in the multiboot header in the kernel image. Check the muiltiboot specification.
https://www.gnu.org/software/grub/manua ... ics-fields
Re: Setting VBE modes with GRUB2
Posted: Fri Oct 16, 2015 10:26 am
by abcdef4bfd
Thanks, 1024x768x32 mode is now set, but how to get the VBE Mode Info?
Re: Setting VBE modes with GRUB2
Posted: Fri Oct 16, 2015 10:32 am
by BrightLight
From the multiboot specification:
If bit 11 in the ‘flags’ is set, the graphics table is available. This must only be done if the kernel has indicated in the ‘Multiboot Header’ that it accepts a graphics mode.
The fields ‘vbe_control_info’ and ‘vbe_mode_info’ contain the physical addresses of vbe control information returned by the vbe Function 00h and vbe mode information returned by the vbe Function 01h, respectively.
So get what you need from the multiboot structure that is passed by GRUB to your kernel.
Re: Setting VBE modes with GRUB2
Posted: Fri Oct 16, 2015 12:11 pm
by abcdef4bfd
OK, now I have a last thing to ask. Is GRUB puts Multiboot info into some register or putting it to the stack? Sorry if I'm really annoying, sorry, I'm new to the GRUB2.
Re: Setting VBE modes with GRUB2
Posted: Fri Oct 16, 2015 12:53 pm
by BrightLight
catnikita255 wrote:OK, now I have a last thing to ask. Is GRUB puts Multiboot info into some register or putting it to the stack? Sorry if I'm really annoying, sorry, I'm new to the GRUB2.
Seriously, the multiboot specification isn't that hard to read.
When GRUB gives control to your kernel, the EAX register contains 0x2BADB002 and the EBX register points to the
physical location of the multiboot information structure.
Re: Setting VBE modes with GRUB2
Posted: Fri Oct 16, 2015 1:00 pm
by abcdef4bfd
omarrx024 wrote:catnikita255 wrote:OK, now I have a last thing to ask. Is GRUB puts Multiboot info into some register or putting it to the stack? Sorry if I'm really annoying, sorry, I'm new to the GRUB2.
Seriously, the multiboot specification isn't that hard to read.
When GRUB gives control to your kernel, the EAX register contains 0x2BADB002 and the EBX register points to the
physical location of the multiboot information structure.
Thanks. That's all. Thank you, I'll add you into my secret authors info.
Re: Setting VBE modes with GRUB2
Posted: Fri Oct 16, 2015 2:56 pm
by kzinti
catnikita255 wrote:Thanks. That's all. Thank you, I'll add you into my secret authors info.
Is that a good thing?
Re: Setting VBE modes with GRUB2
Posted: Sat Oct 17, 2015 1:40 am
by abcdef4bfd
kiznit wrote:catnikita255 wrote:Thanks. That's all. Thank you, I'll add you into my secret authors info.
Is that a good thing?
Yes.
Re: Setting VBE modes with GRUB2
Posted: Sat Oct 17, 2015 1:41 am
by abcdef4bfd
And another question: how to write pixels? Please, do not give me the code, I need to learn myself. Just give me theory.
Re: Setting VBE modes with GRUB2
Posted: Sat Oct 17, 2015 2:51 am
by BrightLight
catnikita255 wrote:And another question: how to write pixels?
You write to the VESA framebuffer. VESA 2.0 specs aren't that hard to read either.
Re: Setting VBE modes with GRUB2
Posted: Sat Oct 17, 2015 3:02 am
by abcdef4bfd
omarrx024 wrote:catnikita255 wrote:And another question: how to write pixels?
You write to the VESA framebuffer. VESA 2.0 specs aren't that hard to read either.
I know, but
how I need to do this? Just write the RGB value to the framebuffer, or something more complicated?
Re: Setting VBE modes with GRUB2
Posted: Sat Oct 17, 2015 3:15 am
by BrightLight
catnikita255 wrote:I know, but how I need to do this? Just write the RGB value to the framebuffer, or something more complicated?
Trial and error should get you decent results.
In 32-bit graphical modes, you simply write a 32-bit RGB value to the framebuffer. For example, red would be 0xFF0000. The uppermost 8 bits should be zero, because they are unused.
Re: Setting VBE modes with GRUB2
Posted: Sat Oct 17, 2015 3:56 am
by abcdef4bfd
omarrx024 wrote:catnikita255 wrote:I know, but how I need to do this? Just write the RGB value to the framebuffer, or something more complicated?
Trial and error should get you decent results.
In 32-bit graphical modes, you simply write a 32-bit RGB value to the framebuffer. For example, red would be 0xFF0000. The uppermost 8 bits should be zero, because they are unused.
I tried it, it displays me black screen.
Code:
Code: Select all
inline void putpixel(int x,int y,uint32_t color)
{
unsigned long pixindex=y*1024+x;
framebuffer[pixindex]=color;
}
Re: Setting VBE modes with GRUB2
Posted: Sat Oct 17, 2015 4:33 am
by BrightLight