How to load karnel from a bootloader?

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
ClarionCoder51
Member
Member
Posts: 28
Joined: Sun Aug 16, 2009 11:52 am
Location: Georgia, USA

Re: How to load karnel from a bootloader?

Post by ClarionCoder51 »

It is possible, but I couldn't tell ya. I program my OS exclusively in ASM. I recommend writing the bootloader in ASM for now if you don't get an answer fast enough, since the only thing that you'll be messing with most of the time is the kernel, which I suppose is written in C, correct?
Besides, the only thing you need to change is how many sectors the loader reads.
"The n00b zone is for loading and unloading newbies only."
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: How to load karnel from a bootloader?

Post by Combuster »

Please, if you suggest something especially promoting bad practice, please tell why. Especially when someone else says otherwise.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
ClarionCoder51
Member
Member
Posts: 28
Joined: Sun Aug 16, 2009 11:52 am
Location: Georgia, USA

Re: How to load karnel from a bootloader?

Post by ClarionCoder51 »

And what would be "bad practice" that I am telling electritwist? (hope I spelled that right)
"The n00b zone is for loading and unloading newbies only."
User avatar
neon
Member
Member
Posts: 1568
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: How to load karnel from a bootloader?

Post by neon »

Hello,
Thank you all for the answers, but they didn't help me out, I'm trying to figure it out with a friend.
What is it that you are having trouble with? Just read up on your boot file system and have your bootloader parse it and load the kernel into memory.
off topic: Can anyone give me an easy and short example of how to write boot loader written with C language? Is it even possible?
What I do in my bootloader is prepend an assembly program to my PE program (my bootloader written in C). The assembly program does basic tasks such as going into protected mode, enabling paging, etc and is responsible for relocating the PE program and executing it. It is possible to create an interface that will allow the C program to interact with the BIOS via RMode as well if needed.

This method is a little tricky, but works quite well. Perhaps a method like this can help? There are other methods, so keep your options open :)
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
Locked