OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Apr 25, 2024 11:32 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 12 posts ] 
Author Message
 Post subject: About booting the kernel
PostPosted: Tue Feb 05, 2002 5:21 am 
First of all, hi ;)
I have a basic question on programming an Operating System:
Allright, I have programmed a kernel.c and I linked it to kernel.bin... .
Now I put it on a floppy disk and tell the BIOS to boot up from the floppy disk. But how can the program be executed, I always thought it needed the OS it was build on. For example, I compile and link my kernel on Linux, can the kernel only be executed in Linux, does the kernel need Linux for beeing executed?
Thanks and regards,
A. Blessing


Top
  
 
 Post subject: Re: About booting the kernel
PostPosted: Tue Feb 05, 2002 7:30 am 
Hi,

In fact, the only thing you need is a bootloader.

This is a small app that is executed just after the BIOS.
It is located at the begining of the boot disc.

The bootloader just look for the kernel, load it in memory and jump to it.


Top
  
 
 Post subject: Re: About booting the kernel
PostPosted: Tue Feb 05, 2002 1:16 pm 
More accuratly, you will need to make a bootsector that is copied to the first sector of a floppy(assuming that you want to boot from a floppy). The bootsector that you write will need to written in assembly lanuage and compile it into a binary file. The bootsector's job is to find your kernel.bin file on the floppy then and load it into memory and then jump to it. One thing that you need to be sure of is that your kernel and/or bootsector is written in assembly that you don't use any int 21h calls as those are provided by DOS and DOS won't be availible to your kernel and/or bootsector. It appears that you have written your kernel in C so also be sure that there are no printf's because these rely on Linux, DOS, or another OS. Also make sure that you don't link with the standard libc library that comes with Linux because most of the functions in it need Linux to work.

Basically, a boot off a floppy disk works like this:
1. pc is turned on
2. the pc's bios looks for a floppy in the floppy drive
3. if found the bios loads the first sector(the bootsector) of the floppy into memory and jumps to it and runs it
4. the bootsector then loads the kernel into memory from the floppy
5. the bootsector jumps to the kernel and runs it

If you would like some well commented bootsectors then I suggest that you look at John Fine's:

http://www.execpc.com/~geezer/johnfine/index.htm

Hope that helps you :).

K.J.


Top
  
 
 Post subject: Re: About booting the kernel
PostPosted: Wed Feb 06, 2002 1:15 am 
> Hope that helps you :).
Oh yes, it does! Thanks very much.
Thanks to those people who created this board, I think it helps many people who want to build their own OS... .
Just one other question for now:
Did Linus Torvalds compile his kernel on Minix?

Thanks and regards,
A. Blessing


Top
  
 
 Post subject: Re: About booting the kernel
PostPosted: Wed Feb 06, 2002 1:30 pm 
Did Linus Torvalds compile his kernel on Minix?

I think that I read somewhere that he did originaly. Now the Linux kernel is compiled on Linux.

K.J.


Top
  
 
 Post subject: Re: About booting the kernel
PostPosted: Thu Feb 07, 2002 3:01 am 
Sorry, I still have a question... .
You said, I should not use any printf() functions, because they use functions that are specific to the OS on which it was compiled... .
So I have to compile my own printf(). But are there any printf() sources, I can use? How do these printf() functions differ from the printf() function in the libc? Do they use functions that are different in each OS?


Top
  
 
 Post subject: Re: About booting the kernel
PostPosted: Thu Feb 07, 2002 4:11 pm 
>You said, I should not use any printf() functions, because they use functions that are specific to the OS on which it was compiled...

Right. printf() and related functions call sub-functions to
do the actual printing, but there is no standard for these.
Maybe printf() calls putchar() to do the actual printing;
maybe not. Maybe fprintf() calls fputc() to print; maybe not.

>So I have to compile my own printf(). But are there any printf() sources, I can use?

You can use mine if you want:
http://www.execpc.com/~geezer/osd/libc/ ... tm#problem
It doesn't support floating point numbers, but it's pretty
complete otherwise.


Top
  
 
 Post subject: Re: About booting the kernel
PostPosted: Fri Feb 08, 2002 3:41 am 
Thanks for replying!
But if a printf() function calls putchar(), what's wrong with that? Gcc will include this function and so everything would be right, wouldn't it? The only problem I see would be, if the Library was dynamic... .
So, that's the first question... .
The second is: What's the difference between your printf() function and the putchar() function of gcc?
Pleeeeease help me, that's quite important to me... .


Top
  
 
 Post subject: Re: About booting the kernel
PostPosted: Fri Feb 08, 2002 4:59 am 
Offline
Member
Member
User avatar

Joined: Fri Oct 22, 2004 11:00 pm
Posts: 1076
:-X you cant include any functions in gcc! you can use the built in printf, or the builtin putchar. all yuor routines must be written to use your OS. if your using gcc on unix, or on windows, putchar is designed to use win32 api, or unix api.

you must write them all to use your own API. why do you think you cant run windows executables on unix? etc.

_________________
-- Stu --


Top
 Profile  
 
 Post subject: Re: About booting the kernel
PostPosted: Fri Feb 08, 2002 5:30 am 
Allright, got that, but why are there some source codes for printf() functions I can use for my OS? Do these functions not use an API, but communicate directly with the hardware?
Thanks for replying


Top
  
 
 Post subject: Re: About booting the kernel
PostPosted: Fri Feb 08, 2002 5:49 am 
Offline
Member
Member
User avatar

Joined: Fri Oct 22, 2004 11:00 pm
Posts: 1076
becuase the authors have written them with their own api, often this is the hardware, 0xB80000

(which is exactly what mine does)

_________________
-- Stu --


Top
 Profile  
 
 Post subject: Re: About booting the kernel
PostPosted: Fri Feb 08, 2002 6:05 am 
Allright, thanks, this answers my question (well, I hope so ;))


Top
  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Majestic-12 [Bot] and 237 guests


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:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group