GRUB multiboot not using requested VGA text mode resolution?

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
Kaius
Posts: 20
Joined: Sat Dec 31, 2022 10:59 am
Libera.chat IRC: Kaius

GRUB multiboot not using requested VGA text mode resolution?

Post by Kaius »

Hello all.

I've been working on a super basic C microkernel that operates in VGA text mode. It uses GRUB as the bootloader and is multiboot compliant.

I read through the multiboot specification and saw an section about how to set flags (e.g. screen resolution) and I noticed that you can request a change from the default 80x25 width and height in VGA text mode. I tried this, requesting a different width and height, but GRUB didn't make the changes.

I tried playing around with the flags a bit, and I know that GRUB is seeing those flags and they're in the right place because when I changed the video mode bit to 0, it successfully switched to VGA graphics mode.

I know that the multiboot spec says that it's just a suggestion, and the bootloader may ignore it as it sees fit, but I've seen other multiboot OSs launched from GRUB change the VGA text resolution on the same machine I'm testing on.

Is there some GRUB-specific thing that I'm missing here? I've scoured the internet but haven't been able to come up with anything.

Here's the beginning of my asm entrypoint:

Code: Select all

; Multiboot header
FLAGS    equ 0b00000111
MAGIC    equ 0x1BADB002
CHECKSUM equ -(MAGIC + FLAGS) ; checksum + (flags + magic) should be 0

section .multiboot
align 4
  dd MAGIC
  dd FLAGS
  dd CHECKSUM

  ; padding to make it 16 bytes long
  times 5 dd 0

  ; video output flags
  dd 1  ; type (1 = text mode)
  dd 81 ; width (1 extra character for testing)
  dd 25 ; height
  dd 0  ; depth, always 0 in text mode
The above code, regardless of the width and height I set, boots into the standard 80x25. I've tried all kinds of different resolutions, both common and uncommon ones, but to no avail. Am I doing something wrong here?
Octocontrabass
Member
Member
Posts: 5486
Joined: Mon Mar 25, 2013 7:01 pm

Re: GRUB multiboot not using requested VGA text mode resolut

Post by Octocontrabass »

Last I checked, GRUB only knows how to set 80x25 text mode. If you want something else, your options are using a linear framebuffer and drawing with your own fonts, poking the VGA registers to change the text mode, dropping back into real mode and calling INT 0x10, or using a different bootloader.

You might want to consider using a linear framebuffer. Modern PCs don't support VGA text mode (or any other VGA mode).
sounds
Member
Member
Posts: 112
Joined: Sat Feb 04, 2012 5:03 pm

Re: GRUB multiboot not using requested VGA text mode resolut

Post by sounds »

Octocontrabass wrote:Modern PCs don't support VGA text mode (or any other VGA mode).
As long as you mean, "some corporate-type locked-down laptops," sure.

I suspect rack-mount servers will support VGA text mode for eternity with their embedded system monitor.
Octocontrabass
Member
Member
Posts: 5486
Joined: Mon Mar 25, 2013 7:01 pm

Re: GRUB multiboot not using requested VGA text mode resolut

Post by Octocontrabass »

sounds wrote:As long as you mean, "some corporate-type locked-down laptops," sure.
No, I mean a good portion of all new PCs, both desktop and laptop. Legacy compatibility is finally starting to go away, and pretty soon it'll be completely gone.
sounds wrote:I suspect rack-mount servers will support VGA text mode for eternity with their embedded system monitor.
Actually, most vendors have already completely dropped legacy compatibility. Soon you won't be able to buy a new server with legacy compatibility either.
Post Reply