Problems with grub setting the video mode

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
justin
Member
Member
Posts: 43
Joined: Sun Jan 11, 2009 2:09 pm

Problems with grub setting the video mode

Post 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.
Last edited by justin on Sat Aug 17, 2013 9:01 pm, edited 2 times in total.
User avatar
xenos
Member
Member
Posts: 1121
Joined: Thu Aug 11, 2005 11:00 pm
Libera.chat IRC: xenos1984
Location: Tartu, Estonia
Contact:

Re: Problems with grub setting the video mode

Post 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
Programmers' Hardware Database // GitHub user: xenos1984; OS project: NOS
justin
Member
Member
Posts: 43
Joined: Sun Jan 11, 2009 2:09 pm

Re: Problems with grub setting the video mode

Post 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.
justin
Member
Member
Posts: 43
Joined: Sun Jan 11, 2009 2:09 pm

Re: Problems with grub setting the video mode

Post 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?
justin
Member
Member
Posts: 43
Joined: Sun Jan 11, 2009 2:09 pm

Re: Problems with grub setting the video mode

Post 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.
Post Reply