Bona Fide OS Development

Load kernel from bootloader
Page 1 of 1

Author:  DrYap [ Fri May 07, 2010 1:03 pm ]
Post subject:  Load kernel from bootloader


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.

Author:  MTK358 [ Fri May 07, 2010 3:30 pm ]
Post subject:  Re: Load kernel from bootloader

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


void kernel_main()
// do stuff here


extern kernel_main
call kernel_main

Author:  DrYap [ Sat May 08, 2010 1:43 am ]
Post subject:  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.

Author:  brodeur235 [ Tue Jun 01, 2010 12:53 am ]
Post subject:  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:
extern _kernel_main
call _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.


Author:  ctimko [ Thu Jul 22, 2010 9:02 am ]
Post subject:  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 :-P

Author:  Kieran [ Sat Jul 24, 2010 6:30 am ]
Post subject:  Re: Load kernel from bootloader

It has been done, there is a Multiboot compliant bootloader written by someone over at I think. It might support ELF, not %100 on that though.

Page 1 of 1 All times are UTC - 6 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group