Page 1 of 1

Problems with grub setting the video mode

Posted: Wed Mar 13, 2013 5:10 pm
by justin
I am transitioning to using GRUB 2 as my boot loader. When I use the following header everything works fine. Grub loads my kernel with the video mode set to text mode, provides a memory map, and provides vbe info.

Code: Select all

MBOOT_HEADER_MAGIC  equ 0x1BADB002
MBOOT_HEADER_FLAGS  equ (1<<0) | (1<<1) | (1<<2) | (1<<16)
MBOOT_CHECKSUM      equ -(MBOOT_HEADER_MAGIC + MBOOT_HEADER_FLAGS)

global mboot
extern code
extern bss
extern end

ALIGN 4
mboot:
    dd  MBOOT_HEADER_MAGIC
    dd  MBOOT_HEADER_FLAGS
    dd  MBOOT_CHECKSUM
    dd  mboot
    dd  code
    dd  bss
    dd  end
    dd  start
    dd  1
    dd  0
    dd  0
    dd  0
When I request a graphical mode, things go awry. I use the following header:

Code: Select all

mboot:
    dd  MBOOT_HEADER_MAGIC
    dd  MBOOT_HEADER_FLAGS
    dd  MBOOT_CHECKSUM
    dd  mboot
    dd  code
    dd  bss
    dd  end
    dd  start
    dd  0
    dd  0
    dd  0
    dd  0
Grub puts the multiboot magic value in eax but sets flags to 0 and doesn't provide a memory map or vbe info. It does set a graphical video mode though. In bochs it sets 1024x768x32 and in qemu it sets 1280x1024x16.

I thought it was weird that it set the video mode but didn't provide mode info or even a memory map. I can't find anything in the multiboot spec that would explain it. Does anyone know why it would do this?

Thanks.

Re: Problems with grub setting the video mode

Posted: Wed Mar 13, 2013 11:27 pm
by xenos
I never used GRUB to set a graphics mode, but are you sure about the content of the graphics fields?
Multiboot spec wrote:mode_type
Contains ‘0’ for linear graphics mode or ‘1’ for EGA-standard text mode. Everything else is reserved for future expansion. Note that the boot loader may set a text mode, even if this field contains ‘0’.
http://www.gnu.org/software/grub/manual ... ics-fields

Re: Problems with grub setting the video mode

Posted: Thu Mar 14, 2013 10:00 am
by justin
XenOS wrote:I never used GRUB to set a graphics mode, but are you sure about the content of the graphics fields?
Multiboot spec wrote:mode_type
Contains ‘0’ for linear graphics mode or ‘1’ for EGA-standard text mode. Everything else is reserved for future expansion. Note that the boot loader may set a text mode, even if this field contains ‘0’.
http://www.gnu.org/software/grub/manual ... ics-fields
Yeah, I mixed up the headers in my post but it was right in my code. I fixed the post. Thanks.

Re: Problems with grub setting the video mode

Posted: Sat Aug 17, 2013 9:01 pm
by justin
I've been away from my OS for a few months and I came back and still can't figure out this issue. Has anyone had this problem?

Re: Problems with grub setting the video mode

Posted: Sun Aug 18, 2013 8:35 pm
by justin
Please excuse me. It was due to my own neglect in preventing the multiboot info from being overwritten, which occurred because extra memory was being allocated in graphical mode.

Problem solved.