newbie OS developper guide (^_^)

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.
Post Reply
[AlAdDiN]
Member
Member
Posts: 107
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

newbie OS developper guide (^_^)

Post by [AlAdDiN] »

I noticed that there is more and more people int this forum interested to start their own OS and don't know how to begin, and what to do ...

so i decided to start this thread to allow more experimented developpers to put some guidelines here.

I'll start with what NOT to do :
- 1 - Dont start thinking about usless features to your kernel : for example, trying to detect CPU speed while your OS is running just fine without, don't try to detect graphic card features / PCI devices /Chipsets if you don't really need it ...

- 2 - Dont jump steps : i saw some developpers who want to run binaries whith no fileformat support or multitasking stuff

- 3 - Dont start from the end ;) : some people want to start developping a GUI before having a working kernel !!!

- 4 - Dont try to do everything yourself, if you find a public code whitch do something you want to implement in your OS, there is no need to rewrite it (since it will do the same think ;) )

- 5 - and finally : dont leave your social life :p


next time i'll post other instructions about steps to develop an OS (if i find the time)

and dont hesitate to post your own opinions and correct me if i said something wrong

Cheers
-----------------------
There are 10 types of people in this world... those that understand binary, and those that don't.
kattmat
Posts: 7
Joined: Wed Feb 23, 2005 12:00 am

Re: newbie OS developper guide (^_^)

Post by kattmat »

[AlAdDiN] wrote: - 4 - Dont try to do everything yourself, if you find a public code whitch do something you want to implement in your OS, there is no need to rewrite it (since it will do the same think ;) )
Just don't forget to FULLY UNDERSTAND exactly what the code does.
Otherwise you'll just be cutting and pasting pieces, which might work for a while, but when you actually do run into problems, you'll have no clue what so ever what has gone wrong.
[AlAdDiN]
Member
Member
Posts: 107
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

Re: newbie OS developper guide (^_^)

Post by [AlAdDiN] »

agree =D
-----------------------
There are 10 types of people in this world... those that understand binary, and those that don't.
rlee0001
Posts: 3
Joined: Sun Feb 27, 2005 12:00 am

Re: newbie OS developper guide (^_^)

Post by rlee0001 »

Design it first. Do the research first. Know the tools. Debug as you go, even if some things have to be debugged in bochs or (if applicable) as an exe under dos. Don't rely on bochs for debugging. :o)

Also, set goals and know what you want you're OS to do.

Understand and use as much off-the-shelf parts as you can. For example, use GRUB instead of writing your own boot loader. There's also pretty of code which works great that switches to PMODE, enables A20, detects PCI devices and so forth. Not to mention drivers for VGA text, keyboard, mouse...even sound. If you're going to use them:

1. Get permission if not explicitly usable.
2. Give credit regardless of licenses.
3. Understand all code.
4. Debug everything you use. Don't assume the publisher did this!

Use the best possible programming practices. I know this is middle school stuff but it is very important in a project this complicated. Best programming practices include:

1. Comment your code.
2. Seperate libraries into .obj modules for static linking.
3. Use header/include files where appropriate.
4. Name files and variables properly.
5. Indent/capitalize and so forth consistantly.
6. Record all TODO 's in the code no matter how trivial.
...blaaa...your get the idea...just do it.

Remember, its a long term project and you'll probably put stuff away for months before going back to it. You might also want to take notes on the side to remind myself of stuff later. I always did. Also, I versioned by date initially; IE: "...in version 15MAY03F I added..." This kept me straight on stuff early on. I guess you could do both (date or versions seperate while using major.minor versions). If your use x.x.xxxx format, use it properly (major, minor and build). You might want to tie your goals in with your minor version numbers if you use them (keep your major version number at zero until your ready for Best Buy retail box edition...lol).

Thats about it I think.
trey_monty
Member
Member
Posts: 44
Joined: Thu Mar 10, 2005 12:00 am

Re: newbie OS developper guide (^_^)

Post by trey_monty »

Im new to programming all together. i need to know what compiler to download. i want to use c but i am ready for suggestions.
[AlAdDiN]
Member
Member
Posts: 107
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

Re: newbie OS developper guide (^_^)

Post by [AlAdDiN] »

use the compiler of your preffered language ....
if you want to develop with C or C++ use GCC for linux or MingW for windows ...

if you preffer another language it's prefferable to use a portable one, and that allow you to acces low level ....

IMHO : C is the best choice for first steps kernel developpement : scheduler, memory manager, contexts ... , then C ++ is a good choice to developp modules or extentions since it offer OOP plus all C feature.


don't forget that eaven if you use C or other language you have to know asm, because some parts of the kernel (arch dependent) are can't be wrot without asm (or inline asm) ...
-----------------------
There are 10 types of people in this world... those that understand binary, and those that don't.
blackcatcoder
Member
Member
Posts: 132
Joined: Wed Nov 03, 2004 12:00 am
Location: Austria
Contact:

Re: newbie OS developper guide (^_^)

Post by blackcatcoder »

Don't forget to save the source code if you change a part of your Os ! ;-)

Do it step by step !

Try to solve a Problem. And don't work around!

...
[AlAdDiN]
Member
Member
Posts: 107
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

Re: newbie OS developper guide (^_^)

Post by [AlAdDiN] »

blackcatcoder wrote:Don't forget to save the source code if you change a part of your Os ! ;-)
Right, and if you can, use CVS, it's a tool that seems useless .... since it save your life one day ;)
-----------------------
There are 10 types of people in this world... those that understand binary, and those that don't.
[AlAdDiN]
Member
Member
Posts: 107
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

Re: newbie OS developper guide (^_^)

Post by [AlAdDiN] »

In this post i'll speak about the boot loader
- Why a bootloader ?
- Existing bootloaders
- writing your own bootloader


*Why a bootloader ?
The bootloader is a peace of code that will do some very initial operations before launching the kernel.
Generally, the BIOS will load some Kb into a given memory adress (0x7C0 for ~x86) the give it the controle, this code will do some initialisations then load/run the kernel (or a second stage loader)

*Existing bootloaders :
There is many OpenSource bootloaders that can be found around the web, but the most popular one is GRUB, GRUB is a bootloader for any OS, it Multiboot standards complients, and is relatively easy to install and use, for more information about GRUB go here http://www.mega-tokyo.com/osfaq2/index.php/GRUB.
Other bootloaders can be used such as (XOSL, Bootmagic, System commander ...) but IMHO, they are more complicated to use with your own OS than GRUB.


*Writing your own BootLoader :
this step is not really needed since you can use an existing bootloader (like GRUB) or pick one from another small OS ...
but i recomand to try writing your own Bootloader since this step will help you understand some low level stuff which can be helpful for futur OS Debugging or for writing low level routines, and also, because this part is the only one that must be totally written in asm (a good exercice) :D

I personnaly write a personalised bootloader with two stages :
-The bootsector (1st stage) loads the kernel and the loader to given memory addresses and gives control to the loader.
-The second stage does some basic hardware detections, switch to Pmode, move the kernel above the first Megabyte then launch it.

you can take a look at my bootloader if you want here :
http://xos.freezee.org/downloads/xossrc_23092004.tar.gz

the bootloader is in xolo/ directory (comments are in french, will be translated later ;) )


two stages bootloaders are useful when you want to move your kernel from the first Mb (and this is very recomanded) ....
Last edited by [AlAdDiN] on Fri Mar 11, 2005 12:00 am, edited 1 time in total.
-----------------------
There are 10 types of people in this world... those that understand binary, and those that don't.
trey_monty
Member
Member
Posts: 44
Joined: Thu Mar 10, 2005 12:00 am

Re: newbie OS developper guide (^_^)

Post by trey_monty »

I need to know if GCC will run on windows. I tried to download MingW but it took so long using those mirror sites i couldnt getit.any sugggetions on a C compiler to download would be very helpful.
rexlunae
Member
Member
Posts: 134
Joined: Sun Oct 24, 2004 11:00 pm
Location: North Dakota, where the buffalo roam

Re: newbie OS developper guide (^_^)

Post by rexlunae »

trey_monty wrote:I need to know if GCC will run on windows. I tried to download MingW but it took so long using those mirror sites i couldnt getit.any sugggetions on a C compiler to download would be very helpful.
If you are on Windows, your best options (other than ditching Windows) is to get either MingW or djgpp. Both are free and based on gcc.
__matt__
Posts: 15
Joined: Thu Feb 03, 2005 12:00 am
Location: Right behind you
Contact:

Re: newbie OS developper guide (^_^)

Post by __matt__ »

trey_monty wrote:I need to know if GCC will run on windows. I tried to download MingW but it took so long using those mirror sites i couldnt getit.any sugggetions on a C compiler to download would be very helpful.
You already asked this question, and I replied to it here:
http://www.osdev.org/index.html?module= ... 175&p=#916
Last edited by __matt__ on Sat Mar 12, 2005 12:00 am, edited 1 time in total.
Post Reply