Bona Fide OS Developer
View unanswered posts | View active topics It is currently Mon Dec 17, 2018 12:45 am



Post new topic Reply to topic  [ 6 posts ] 
 Load kernel from bootloader 
Author Message

Joined: Fri May 07, 2010 1:00 pm
Posts: 2
Post Load kernel from bootloader
Hi

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
Profile

Joined: Tue Apr 20, 2010 9:08 am
Posts: 20
Post 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_main
call kernel_main


Fri May 07, 2010 3:30 pm
Profile

Joined: Fri May 07, 2010 1:00 pm
Posts: 2
Post 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
Profile

Joined: Wed Jan 06, 2010 11:25 pm
Posts: 2
Post 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_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.

Brodeur235


Tue Jun 01, 2010 12:53 am
Profile

Joined: Wed Oct 14, 2009 9:39 am
Posts: 198
Location: United States
Post 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

_________________
Charles Timko
push %esp ;Musings of a computer addict


Thu Jul 22, 2010 9:02 am
Profile WWW
Site Admin

Joined: Sat Jul 25, 2009 7:44 am
Posts: 274
Location: United Kingdom
Post Re: Load kernel from bootloader
It has been done, there is a Multiboot compliant bootloader written by someone over at osdev.org I think. It might support ELF, not %100 on that though.

_________________
Thank you for reading,

Kieran C G Foot


Sat Jul 24, 2010 6:30 am
Profile WWW
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 


Who is online

Users browsing this forum: No registered users and 1 guest


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

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by Vjacheslav Trushkin and tweaked by the BF Team.