Setting VBE modes with GRUB2

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.
User avatar
abcdef4bfd
Member
Member
Posts: 492
Joined: Fri Apr 03, 2015 9:41 am

Setting VBE modes with GRUB2

Post 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.
Coomer69
Member
Member
Posts: 31
Joined: Thu Feb 20, 2014 4:49 am

Re: Setting VBE modes with GRUB2

Post 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
User avatar
abcdef4bfd
Member
Member
Posts: 492
Joined: Fri Apr 03, 2015 9:41 am

Re: Setting VBE modes with GRUB2

Post by abcdef4bfd »

SapphireOS wrote: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
Thanks, 1024x768x32 mode is now set, but how to get the VBE Mode Info?
User avatar
BrightLight
Member
Member
Posts: 901
Joined: Sat Dec 27, 2014 9:11 am
Location: Maadi, Cairo, Egypt
Contact:

Re: Setting VBE modes with GRUB2

Post 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.
You know your OS is advanced when you stop using the Intel programming guide as a reference.
User avatar
abcdef4bfd
Member
Member
Posts: 492
Joined: Fri Apr 03, 2015 9:41 am

Re: Setting VBE modes with GRUB2

Post 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.
User avatar
BrightLight
Member
Member
Posts: 901
Joined: Sat Dec 27, 2014 9:11 am
Location: Maadi, Cairo, Egypt
Contact:

Re: Setting VBE modes with GRUB2

Post 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.
You know your OS is advanced when you stop using the Intel programming guide as a reference.
User avatar
abcdef4bfd
Member
Member
Posts: 492
Joined: Fri Apr 03, 2015 9:41 am

Re: Setting VBE modes with GRUB2

Post 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.
kzinti
Member
Member
Posts: 898
Joined: Mon Feb 02, 2015 7:11 pm

Re: Setting VBE modes with GRUB2

Post by kzinti »

catnikita255 wrote:Thanks. That's all. Thank you, I'll add you into my secret authors info.
Is that a good thing?
User avatar
abcdef4bfd
Member
Member
Posts: 492
Joined: Fri Apr 03, 2015 9:41 am

Re: Setting VBE modes with GRUB2

Post 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.
User avatar
abcdef4bfd
Member
Member
Posts: 492
Joined: Fri Apr 03, 2015 9:41 am

Re: Setting VBE modes with GRUB2

Post 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.
User avatar
BrightLight
Member
Member
Posts: 901
Joined: Sat Dec 27, 2014 9:11 am
Location: Maadi, Cairo, Egypt
Contact:

Re: Setting VBE modes with GRUB2

Post 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.
You know your OS is advanced when you stop using the Intel programming guide as a reference.
User avatar
abcdef4bfd
Member
Member
Posts: 492
Joined: Fri Apr 03, 2015 9:41 am

Re: Setting VBE modes with GRUB2

Post 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?
User avatar
BrightLight
Member
Member
Posts: 901
Joined: Sat Dec 27, 2014 9:11 am
Location: Maadi, Cairo, Egypt
Contact:

Re: Setting VBE modes with GRUB2

Post 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. :roll:
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.
You know your OS is advanced when you stop using the Intel programming guide as a reference.
User avatar
abcdef4bfd
Member
Member
Posts: 492
Joined: Fri Apr 03, 2015 9:41 am

Re: Setting VBE modes with GRUB2

Post 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. :roll:
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;

}
User avatar
BrightLight
Member
Member
Posts: 901
Joined: Sat Dec 27, 2014 9:11 am
Location: Maadi, Cairo, Egypt
Contact:

Re: Setting VBE modes with GRUB2

Post by BrightLight »

You know your OS is advanced when you stop using the Intel programming guide as a reference.
Post Reply