Load the kernel from my 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.
CameronD
Posts: 4
Joined: Mon Oct 26, 2009 3:01 pm

Load the kernel from my bootloader

Post by CameronD »

I'm trying to work out how I load and run my kernel from the bootloader I have created, but I'm not finding anything. The bootloader is written in assembly, and the kernel has a asm entry point, and then is written in C. Can anyone help?
(Btw I'm new at this so please be nice :) )

Thanks

Cameron
tantrikwizard
Member
Member
Posts: 153
Joined: Sun Jan 07, 2007 9:40 am
Contact:

Re: Load the kernel from my bootloader

Post by tantrikwizard »

smeezekitty wrote:post your code and please ignore combusto if he tells you you dont have enough experence.
So allow me to tell you that you dont have enough experience. Try searching the wiki before wasting people's time.

http://wiki.osdev.org/Bootloader
http://wiki.osdev.org/Rolling_Your_Own_Bootloader
http://wiki.osdev.org/GRUB

That should get you started and took less than 30 seconds.
CameronD
Posts: 4
Joined: Mon Oct 26, 2009 3:01 pm

Re: Load the kernel from my bootloader

Post by CameronD »

tantrikwizard:
I have read all of those pages, unfortunately none of them helped me too much. Sorry if you feel I am wasting your time and I appreciate you trying to help.

smeezekitty:
At the moment my code is just basic bootloader, switching to protected mode and print something to the screen. And the kernel is something shamefully ripped straight out of a tutorial as well, I'm just hoping to get it all working first.

Thanks

Cameron
User avatar
bluechill
Posts: 21
Joined: Tue Oct 20, 2009 8:10 pm
Contact:

Re: Load the kernel from my bootloader

Post by bluechill »

here.

OS Dev tutorial

takes you through the process of making a boot laoder and loading a kernel from a fat12 formatted floppy (kernel is PE) and much more. (did not write it just found it useful very useful).

I'm soon going to be posting some which work with gcc based off of these (the author has said I can) and so if your using gcc your going to have to wait about a week to 2 weeks.

This uses windows
FrostOS Lead Developer
OS Developer
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: Load the kernel from my bootloader

Post by neon »

Hello,

I am not understanding what the problem is. If you already have a bootloader, just have it load and execute the kernel image. The steps to do this depend on your file system and kernel binary type (Elf, PE, binary, etc.)
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
User avatar
gravaera
Member
Member
Posts: 737
Joined: Tue Jun 02, 2009 4:35 pm
Location: Supporting the cause: Use \tabs to indent code. NOT \x20 spaces.

Re: Load the kernel from my bootloader

Post by gravaera »

...so if your using gcc your going to have to wait about a week to 2 weeks.

This uses windows
Hi:

I'm not too sure whether I'm correct in correcting him here, but GCC and windows are two different things. Also, you may use cygwin for a Linux-like environment for development on Windows. Look into that if you will :) .
17:56 < sortie> Paging is called paging because you need to draw it on pages in your notebook to succeed at it.
CameronD
Posts: 4
Joined: Mon Oct 26, 2009 3:01 pm

Re: Load the kernel from my bootloader

Post by CameronD »

I'm using gcc now under ubuntu, and I have found some samples which tell me i need to put the kernel in the second sector of the disk image, and then call it from the bootloader, I try to do this and just print some text to the screen and it won't work. I'm slightly confused.
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: Load the kernel from my bootloader

Post by Combuster »

Anything that tells you what but not why is a failure.

Read again, and maybe go find a better tutorial.
"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 ]
CameronD
Posts: 4
Joined: Mon Oct 26, 2009 3:01 pm

Re: Load the kernel from my bootloader

Post by CameronD »

I have been searching solidly for the last two days :/. Does anybody know of one that shows (and explains) this process from the ground up?

Thanks
dosfan
Member
Member
Posts: 65
Joined: Tue Oct 14, 2008 1:18 pm
Location: Scotland

Re: Load the kernel from my bootloader

Post by dosfan »

In short:

1. Find the kernel on your boot media (fat filesystem, hardcoded sectors etc etc)
2. Read it into memory somewhere
3. Jump to the entry point.

If you didn't know that, you're not ready to write an operating system. Try splitting the functions of a boot sector into smaller programs. For example, write some code that is able to read a file from a FAT filesystem, perhaps under DOS first.

Sorry if this sounds harsh.



Cheers.
All your base are belong to us.
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: Load the kernel from my bootloader

Post by neon »

Hello,

What you are wanting to do is not what is recommended. While placing the kernel at a specific sector, and just loading and executing the sector is easier at the beginning, it is harder in the long run.

Nontheless, there is nothing complicated here - just load it and execute it. If it is a sector, load the sector and execute it. If its a file, load the file and execute it. If the kernel is flat binary, to execute just jump to the first byte. If its a specific format, find the entry point and then jump to that. Nothing complicated.

If you need further assistance - please explain exactally what your intentions are (kernel as a file, PE/Elf format, Kernel in a sector, et al..) and what it is that you need help with.

Also, if something "doesnt work" - posting just that is pointless. Programming is all about the details - we cannot help without details.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
User avatar
ehenkes
Member
Member
Posts: 124
Joined: Mon Mar 23, 2009 3:15 am
Location: Germany
Contact:

Re: Load the kernel from my bootloader

Post by ehenkes »

You can find both processes here: http://www.henkessoft.de/OS_Dev/OS_Dev1.htm ff.
User avatar
XanClic
Member
Member
Posts: 138
Joined: Wed Feb 13, 2008 9:38 am

Re: Load the kernel from my bootloader

Post by XanClic »

ehenkes wrote:You can find both processes here: http://www.henkessoft.de/OS_Dev/OS_Dev1.htm ff.
Did you consider he is maybe unable to understand German? :wink:

I don't know if he really is. But the possibility is not too low. One can maybe understand the code without reading the text, but I wouldn't bet on that.
User avatar
Andr3w
Member
Member
Posts: 76
Joined: Tue Jun 09, 2009 4:09 am
Location: Somewhere

Re: Load the kernel from my bootloader

Post by Andr3w »

XanClic wrote:Did you consider he is maybe unable to understand German? :wink:
This tutorial is really good! :) I don't understand German, but I Google Translator translates it to English well! =D>
User avatar
XanClic
Member
Member
Posts: 138
Joined: Wed Feb 13, 2008 9:38 am

Re: Load the kernel from my bootloader

Post by XanClic »

qandrew wrote:Google Translator translates it to English well!
Then it's all right. :D
Post Reply