I've followed a few tutorials for bootloader and kernels but i haven't found one explaining how to call a kernel from the bootloader.

I'm using NASM, gcc and partcopy. Can anyone point me or explain how to do this, I'm really looking for a simple example.

Fri May 07, 2010 1:03 pm

MTK358

Joined: Tue Apr 20, 2010 9:08 amPosts: 20

Re: Load kernel from bootloader

If the boot loader in written in ASM and the kernel's main function in C:

Kernel:

Code:

void kernel_main(){// do stuff here}

Bootloader:

Code:

extern kernel_maincall kernel_main

Fri May 07, 2010 3:30 pm

DrYap

Joined: Fri May 07, 2010 1:00 pmPosts: 2

Re: Load kernel from bootloader

Ok thanks for the starter. I understand what your code is doing but where do I put everything on the floppy. From what I've read the bootloader has to be 512 bytes but compiling and linking my code makes somthing hat is too big.

Sat May 08, 2010 1:43 am

brodeur235

Joined: Wed Jan 06, 2010 11:25 pmPosts: 2

Re: Load kernel from bootloader

If you're calling the C function "kernel_main" from assembly, don't you need to declare it like so in asm:

Code:

extern _kernel_maincall _kernel_main

With the leading underscore? I may be wrong.

Also, once you assemble the boot loader it should be exactly 512 bytes (make sure you have the boot signature). Once you link it, yes the image will get larger because you've linked it to your kernel modules. I may have just said a whole bunch of stuff you already know and if so, my bad.

Brodeur235

Tue Jun 01, 2010 12:53 am

ctimko

Joined: Wed Oct 14, 2009 9:39 amPosts: 198Location: United States

Re: Load kernel from bootloader

Wouldn't you have to use the bootloader to load the kernel into memory, then call the kernel_main address location? And in order to call the kernel_main address location, you need to have code that interprets the ELF header (if you are compiling into elf), but that is a lot of code, I would think you would shove into stage 2 of your bootloader (the part that isn't in the first 512bytes).

Now I am curious, has anyone accomplished a fullscale bootloader to kernel execution (without using a pre-existing bootloader)? If so, you want to work up a tutorial? Or share some codez? Or share your codez with me and I will write the tutoiral

Who is online

Users browsing this forum: No registered users and 1 guest

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum