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

Where is framebuffer in GRUB?
https://forum.osdev.org/viewtopic.php?f=1&t=33506
Page 1 of 1

Author:  Klakap [ Thu Feb 14, 2019 9:15 am ]
Post subject:  Where is framebuffer in GRUB?

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?

Author:  iansjack [ Thu Feb 14, 2019 9:54 am ]
Post subject:  Re: Where is framebuffer in GRUB?

It's in the Multiboot boot information structure: https://www.gnu.org/software/grub/manua ... ion-format

Author:  Schol-R-LEA [ Thu Feb 14, 2019 10:30 am ]
Post subject:  Re: Where is framebuffer in GRUB?

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:
   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:
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;
};

Author:  Klakap [ Sat Feb 16, 2019 9:26 am ]
Post subject:  Re: Where is framebuffer in GRUB?

Thank you for answers!

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