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...Love4Boobies wrote:Multiboot 2. You're welcome!
Multiboot 2 Specification
- iocoder
- 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
Re: Multiboot 2 Specification
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.Love4Boobies wrote:Multiboot 2. You're welcome!
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.
Re: Multiboot 2 Specification
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.
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();}
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
Re: Multiboot 2 Specification
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.
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.