Multiboot 2 Specification

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.
User avatar
iocoder
Member
Member
Posts: 208
Joined: Sun Oct 18, 2009 5:47 pm
Libera.chat IRC: iocoder
Location: Alexandria, Egypt | Ottawa, Canada
Contact:

Re: Multiboot 2 Specification

Post by iocoder »

Love4Boobies wrote:Multiboot 2. You're welcome! :)
Thanks! my code in the first applied to this document. the problem is that it doesn't work with multiboot2 command in my GRUB2, as gerryg400 says...
User avatar
Apophis
Posts: 8
Joined: Wed Nov 03, 2010 2:29 am

Re: Multiboot 2 Specification

Post by Apophis »

Love4Boobies wrote:Multiboot 2. You're welcome! :)
I looked over the linked document and could not find anything that indicates what the size of the kernel is. I'm running into the same problem of trying to figure out how to get GRUB (I'm using legacy at the moment) to tell me what my kernel size is so I can initialize the memory manager. I know that GRUB knows it because when I use the kernel command to load my kernel file, it tells me there what the size is. I just don't know how to get this from within the kernel.

The linker script fix won't work for me (as far as I know) because I'm using Visual C++ to develop my kernel. If there's a way to use that solution with VC then I can go that route.
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: Multiboot 2 Specification

Post by neon »

Hello,

Why not just have the kernel parse its own headers to get the size? :? It shouldnt be to hard (a little tricker do to section alignments) but possible. This would provide less coupling with a specific bootloader and doesnt rely on linker-dependent functionality.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
User avatar
turdus
Member
Member
Posts: 496
Joined: Tue Feb 08, 2011 1:58 pm

Re: Multiboot 2 Specification

Post by turdus »

Ugly workaround (really ugly), but it works for any compiler and any project manager.
in your kernel, create an initialized variable (like const int kernel_end=0xDEADBEEF). Also create a small c code, that expects a filename as an argument, and does this: look for 0xDEADBEEF, if found, overwrite it with the file's size. Compile and run this utility after your kernel binary is ready.

I use this approach when creating fs images, it would be hard to calculate CRC by assembly macros, so I simply mark the locations by 0xDEADCC32, and my mkfs utility calculates and stores the right values afterwards.
Post Reply