Page 1 of 1

Getting grub info after following the Bare Bones tutorial

Posted: Sat May 02, 2015 4:26 am
by matan
i'm quite new to os development so i followed the bare bones tutorial and got a basic kernel that boots from grub.
it is said in the tutorial that: "it(grub) can even forward us important information such as memory maps, but we won't need that yet"
so i followed other tutorials on the web and added:

Code: Select all

void kernel_main(unsigned long magic, unsigned long addr)
{
        terminal_initialize();
        terminal_writelong(magic);
        terminal_writelong(addr);
}

(i wrote my own terminal_writelong function which displays the number as string on the screen)

i'm currently getting these values:
magic - 0x00100810
addr - 0x007D4AC5

firstly , magic is not 0x1BADBOO2 so i think something is wrong.
secondly , if everything is correct , how do i move on getting some valueble info from grub ?

any help is deeply appreciated , thanks in advance !

Re: Getting grub info after following the Bare Bones tutoria

Posted: Sat May 02, 2015 4:59 am
by ExeTwezz
Here is the Multiboot specification: https://www.gnu.org/software/grub/manua ... iboot.html. I'm sure it'll be very helpful for you to read that as it says how to get such info from the bootloader.

Re: Getting grub info after following the Bare Bones tutoria

Posted: Sat May 02, 2015 5:05 am
by Roman
Are you sure it's displayed correctly? That's an unsigned integer, AFAIK.

Re: Getting grub info after following the Bare Bones tutoria

Posted: Sat May 02, 2015 5:41 am
by matan
turns out , i needed to push those to the stack from asm before calling main
so now i'm getting
magic - 0x2BADBOO2
addr - 0x00010000

so why do i need the magic number ? just to verify i was booted correctly ? or is there some other use to it ?
and the address is my key a whole bunch of stuff that grub gives ?
how do i get some basic info such as how much memory I have etc... ?

the most important thing for me is a reliable memory map.

Re: Getting grub info after following the Bare Bones tutoria

Posted: Sat May 02, 2015 7:36 am
by Roman
The magic number tells your kernel, that it was booted by a compatible boot loader.

Re: Getting grub info after following the Bare Bones tutoria

Posted: Wed May 13, 2015 12:02 am
by makerimages