Where is framebuffer in GRUB?

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.
Post Reply
Klakap
Member
Member
Posts: 299
Joined: Sat Mar 10, 2018 10:16 am

Where is framebuffer in GRUB?

Post by Klakap »

Good day!
I am use GRUB to set graphic mode, but I dont know where is framebuffer. I am search on wiki, but I dont find anything. Please, where is it?
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Where is framebuffer in GRUB?

Post by iansjack »

It's in the Multiboot boot information structure: https://www.gnu.org/software/grub/manua ... ion-format
User avatar
Schol-R-LEA
Member
Member
Posts: 1925
Joined: Fri Oct 27, 2006 9:42 am
Location: Athens, GA, USA

Re: Where is framebuffer in GRUB?

Post by Schol-R-LEA »

TL;DR For Grub Legacy, you want multiboot_info.framebuffer_addr, while for GRUB 2 you want multiboot_tag_framebuffer_common.framebuffer_addr.

Don't take this quite as gospel, as I haven't used it myself yet, but that should be in the right ballpark.

In more detail: the information you seek is in the Multiboot data structure(s) which [wiki]GRUB[wiki] passes to your kernel. However, the multiboot_info structure you would get from a MB v.1 boot loader is different from the set of structs passed by a MB v.2 boot loader, so which you want depends on the version of GRUB you're using. GRUB Legacy (version 0.99 and earlier) implements MB v.1; GRUB 2.0 implements MB v.2.

For GRUB Legacy, the relevant part is at the end of the multiboot_info struct definition in the Multiboot 1.x struct definitions:

Code: Select all

   multiboot_uint64_t framebuffer_addr;
  multiboot_uint32_t framebuffer_pitch;
  multiboot_uint32_t framebuffer_width;
  multiboot_uint32_t framebuffer_height;
  multiboot_uint8_t framebuffer_bpp;
#define MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED 0
#define MULTIBOOT_FRAMEBUFFER_TYPE_RGB     1
#define MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT	2
  multiboot_uint8_t framebuffer_type;
  union
  {
    struct
    {
      multiboot_uint32_t framebuffer_palette_addr;
      multiboot_uint16_t framebuffer_palette_num_colors;
    };
    struct
    {
      multiboot_uint8_t framebuffer_red_field_position;
      multiboot_uint8_t framebuffer_red_mask_size;
      multiboot_uint8_t framebuffer_green_field_position;
      multiboot_uint8_t framebuffer_green_mask_size;
      multiboot_uint8_t framebuffer_blue_field_position;
      multiboot_uint8_t framebuffer_blue_mask_size;
    };
  };
There is more there, but you can look into it more at the link I gave above.

For GRUB 2, which uses the Multiboot 2.x struct definitions, things are arranged differently, with the different sections defined as their own structures, but the basics are similar.

Code: Select all

struct multiboot_tag_framebuffer_common
{
  multiboot_uint32_t type;
  multiboot_uint32_t size;

  multiboot_uint64_t framebuffer_addr;
  multiboot_uint32_t framebuffer_pitch;
  multiboot_uint32_t framebuffer_width;
  multiboot_uint32_t framebuffer_height;
  multiboot_uint8_t framebuffer_bpp;
#define MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED 0
#define MULTIBOOT_FRAMEBUFFER_TYPE_RGB     1
#define MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT	2
  multiboot_uint8_t framebuffer_type;
  multiboot_uint16_t reserved;
};
Last edited by Schol-R-LEA on Tue Nov 26, 2019 10:31 am, edited 2 times in total.
Rev. First Speaker Schol-R-LEA;2 LCF ELF JAM POEE KoR KCO PPWMTF
Ordo OS Project
Lisp programmers tend to seem very odd to outsiders, just like anyone else who has had a religious experience they can't quite explain to others.
Klakap
Member
Member
Posts: 299
Joined: Sat Mar 10, 2018 10:16 am

Re: Where is framebuffer in GRUB?

Post by Klakap »

Thank you for answers!
Post Reply