Getting grub info after following the Bare Bones tutorial

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
matan
Posts: 13
Joined: Sat May 02, 2015 4:15 am
Libera.chat IRC: matan

Getting grub info after following the Bare Bones tutorial

Post 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 !
ExeTwezz
Member
Member
Posts: 104
Joined: Sun Sep 21, 2014 7:16 am
Libera.chat IRC: exetwezz

Re: Getting grub info after following the Bare Bones tutoria

Post 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.
Last edited by ExeTwezz on Thu May 14, 2015 8:09 am, edited 2 times in total.
User avatar
Roman
Member
Member
Posts: 568
Joined: Thu Mar 27, 2014 3:57 am
Location: Moscow, Russia
Contact:

Re: Getting grub info after following the Bare Bones tutoria

Post by Roman »

Are you sure it's displayed correctly? That's an unsigned integer, AFAIK.
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
- Alan Kay
matan
Posts: 13
Joined: Sat May 02, 2015 4:15 am
Libera.chat IRC: matan

Re: Getting grub info after following the Bare Bones tutoria

Post 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.
User avatar
Roman
Member
Member
Posts: 568
Joined: Thu Mar 27, 2014 3:57 am
Location: Moscow, Russia
Contact:

Re: Getting grub info after following the Bare Bones tutoria

Post by Roman »

The magic number tells your kernel, that it was booted by a compatible boot loader.
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
- Alan Kay
User avatar
makerimages
Member
Member
Posts: 27
Joined: Sun Dec 28, 2014 11:16 am
Libera.chat IRC: Makerimages
Location: Estonia

Re: Getting grub info after following the Bare Bones tutoria

Post by makerimages »

Working on SinusOS.
Post Reply