Hi,
I've just started writing my kernel, and actually put effort into it. I decided to use GRUB2 as a bootloader as it is far easier to do that than to write a bootloader too. The problem, or rather the challenge is that I need to get the multiboot info passed by GRUB.
The multiboot specification says that GRUB passes the address of this structure in the ebx register. I got the value in the register, but now I need to access this structure. I need to copy it to the c representation of the same structure.
I am newish to c and asm, and very new to gcc, how would I create a copy of that structure so I can use the various things in it. What is the best/easies way to do it. This really seems like a simple problem, but I just can't get it to work.
I don't even know if the address I get is correct, when ii boot my kernel using GRUB on real hardware, the value in the register is returned as 0x10000. Is this correct? It does seem to be exactly the same every time I boot so it ssems right.
Thanks.
Archangel
Multiboot/GRUB Question
Re: Multiboot/GRUB Question
You will want a copy of multiboot.h. Consult the documentation you got along with GRUB.
Re: Multiboot/GRUB Question
Hi,
I do have multiboot.h and the multiboot info structure defined, it's just that I'm not sure how to copy the in-memory structure pointed to by the ebx register into my structure so I can use it.
I do have multiboot.h and the multiboot info structure defined, it's just that I'm not sure how to copy the in-memory structure pointed to by the ebx register into my structure so I can use it.
-
- Posts: 2
- Joined: Sat Dec 12, 2009 12:05 pm
Re: Multiboot/GRUB Question
Assuming you're working in C, provide it as an argument to your kernel's C code. Upon entry in assembly, set up your stack, push your arguments (EBX) in reverse order onto the stack, and then call your kernel's function (e.g. kmain).
You would do well to review the C calling convention.
You would do well to review the C calling convention.
Re: Multiboot/GRUB Question
Hi,
Looking at JamesM's and Brans kernel development tutorials I noticed they pass the multiboot header that way, makes sense. Ill try it. Thank you
Regards
Archangel
Looking at JamesM's and Brans kernel development tutorials I noticed they pass the multiboot header that way, makes sense. Ill try it. Thank you
Regards
Archangel
Re: Multiboot/GRUB Question
I tried it, and it worked like a charm. Thaks a lot!
Archangel
Archangel
-
- Posts: 2
- Joined: Sat Dec 12, 2009 12:05 pm
Re: Multiboot/GRUB Question
Glad to hear it!