Page 1 of 1

GRUB multiboot header query

Posted: Sat May 20, 2006 1:49 pm
by Midas
Okay, quick question, does GRUB ignore the multiboot header video mode request fields (as of course, the multiboot specification permits), or am I doing something wrong?

Code: Select all

; Multiboot header details - used later
MAGIC   equ   0x1BADB002      ; Bootloader finds header with this
FLAGS   equ   0x00000007      ; Flags field
CHECK   equ   -(MAGIC + FLAGS)   ; Checksum - must == 0
NULL   equ   0x00000000      ; For unused fields
VIDMODE   equ   0x00000000      ; Video mode - 0 linear graphics
VIDWID   equ   0x00000320      ; Width 800 px
VIDHEI   equ   0x00000258      ; Height 600 px
VIDDEP   equ   0x00000010      ; 16 bit colour depth
...

Code: Select all

MBH:   dd   MAGIC         ; Where the MBH is stored
   dd   FLAGS         ; Flags
   dd   CHECK         ; Checksum for 'magic' fields
   dd   NULL         ; Unused header_addr
   dd   NULL         ; Unused load_addr
   dd   NULL         ; Unused load_end_addr
   dd   NULL         ; Unused bss_end_addr
   dd   NULL         ; Unused entry_addr
   dd   VIDMODE         ; Video mode
   dd   VIDWID         ; Width
   dd   VIDHEI         ; Height
   dd   VIDDEP         ; Colour depth

Re:GRUB multiboot header query

Posted: Sat May 20, 2006 2:09 pm
by mystran
IIRC you need a specially patched GRUB.

Btw, make your life easier, and just specify the width/height in decimal. ;)

Re:GRUB multiboot header query

Posted: Sat May 20, 2006 2:22 pm
by Midas
Ah right. In that case I'm probably as well just waiting 'til I've got v8086 mode set up (I know there are other ways, but this would be my preferred) and then using the int 10 BIOS functions to set it up. Thanks. :)

Hehe I'm not sure why, but I always feel more comfortable using hex and including the leading zeros. I should probably use decimal for some things rather than adding an extra second or so to reading the number. :P

Re:GRUB multiboot header query

Posted: Sat May 20, 2006 2:32 pm
by bluecode
In case someone out there needs it:
Here is a patch, but I did not check whether it works or not.

Re:GRUB multiboot header query

Posted: Sat May 20, 2006 2:53 pm
by mystran
Midas wrote: Hehe I'm not sure why, but I always feel more comfortable using hex and including the leading zeros. I should probably use decimal for some things rather than adding an extra second or so to reading the number. :P
I've got a good rule for hex vs. decimal:
I (usually) use hex when bits matter, and decimal when it's just a number.

That way when I see hexadecimals in my sources, I know that it's very likely that it's doing something with specific bits. When I see decimals, I know that unless it's power of 2 (or close), it's just a number and pretty safe to change to some other number.

A power of 2 as decimal in my sources usually (althought this is not a hard rule) indicates that it's really just a number, but is related to some bit-twiddling, not just some random value.

Finally, if I write something in octal, it most likely means I'm out of my mind, or trying to make things hard to read.

Re:GRUB multiboot header query

Posted: Sun May 21, 2006 12:45 pm
by Candy
mystran wrote:
Midas wrote: Hehe I'm not sure why, but I always feel more comfortable using hex and including the leading zeros. I should probably use decimal for some things rather than adding an extra second or so to reading the number. :P
I've got a good rule for hex vs. decimal:
I (usually) use hex when bits matter, and decimal when it's just a number.

That way when I see hexadecimals in my sources, I know that it's very likely that it's doing something with specific bits. When I see decimals, I know that unless it's power of 2 (or close), it's just a number and pretty safe to change to some other number.

A power of 2 as decimal in my sources usually (althought this is not a hard rule) indicates that it's really just a number, but is related to some bit-twiddling, not just some random value.

Finally, if I write something in octal, it most likely means I'm out of my mind, or trying to make things hard to read.
The times I use octal are reduced to dinosaur-unix-legacy-interoperability. Specifically, mode flags for file access and reading/writing TAR files (which don't use binary numbers but octal written-out numbers...). Also, when making a test program for printf/scanf or such would include one or two octal numbers.

Hexadecimal is for times when it's necessary to read numbers that don't start at bit 0 and when numbers are easier to read in hex (pointers, powers of two, bitmasks etc).

Decimal is for times you just use a given number that's also used in normal calculations. Such as 42, 1048 and so on.

There are cases in which you doubt, such as sector size (which is 0x200 or 512, where 512 is common but 0x200 would be more logical). I tend to let logic speak for itself, making it slightly harder for current humans (but probably easier for future computer people).