Kernel Developement

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
vibhory2j

Kernel Developement

Post by vibhory2j »

Hello,

i have had just started reading about kernel development.i want to know that what kind of Programming languages are required to develope a kernel.
Do kernel developement deals with the applications of assembly langusges or we can use C C++ ,etc languages.

Some places i read we can should have sound knowledge of C but others say you also need to know assembly languages.

So i am a bit confused and i want to know is that is it sufficient to know C or do i need to also know a assembly language.Please help me.

Thanks in advance , for any assistance.

cheers
vibhor
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Kernel Developement

Post by Pype.Clicker »

- you need to know the *machine* you're dealing with to code an OS, and yes, imho it includes that you must know assembly aswell (but not necessarily having to use it, note the subtle difference ;) )

- http://www.osdev.org/osfaq2/ will virtually tell you everything you need to start a kernel in C

- http://www.invalidsoftware.net/ will tell you everything we know to start a kernel in C++
mystran

Re:Kernel Developement

Post by mystran »

Indeed, you can write most of your kernel in C (or C++) but like Pype said, you need know the machine, including understanding the instruction set, and once you understand the instruction set, you "know" your target assembly.

You don't need to be assembly programmer though. Basicly you need to be able to write small snippets of assembly to do those parts that can't be done in normal C (like setting up the initial environment for the C code to run in, and going from kernel to usermode and back) and then you need to use a few lines inline assembly here and there, to support those special instructions that are needed, but can't be generated with C code. Most of that can be done with a few macros though, so you mainly need the knowledge of what they are for.

That said, being able to READ assembler is nice, since it allows you to track down bugs with nothing but the register dumps and kernel disassembly. This helps a lot, especially once you have a panic routine that prints those registers, and you are running on real hardware (where you can't easily use a debugger).

Also, contrary to what the FAQ says, you DON'T need to write your own bootloader. I'd suggests against it. It's just waste of time. Use GRUB instead. =) In any case, you still need a small amount of assembler for the startup (which GRUB calls after it's loaded your kernel) but you can copy-paste that from the GRUB example if you are happy with GNU GPL.
Schol-R-LEA

Re:Kernel Developement

Post by Schol-R-LEA »

mystran wrote:Also, contrary to what the FAQ says, you DON'T need to write your own bootloader. I'd suggests against it. It's just waste of time. Use GRUB instead. =) In any case, you still need a small amount of assembler for the startup (which GRUB calls after it's loaded your kernel) but you can copy-paste that from the GRUB example if you are happy with GNU GPL.
Actually, Mystran, if you look at the current version of the FAQ, it mentions GRUB right at the start, and discusses using it a length, though it stops short of actually recommending it in order to avoid the inevitable flame wars from bot-liader partisans.

My feelings on the matter are that you ought to know how the boot loader works, and perhaps write a simple one of your own (just enough to print a message, and maybe read a sector from disk and transfer control to it, as mine does), but that beyond that it simply isn't a very important part of the OS itself and that you are much better off with an existing multiboot loader like GRUB. That having been said, I'll admit that I've continued experimenting with my own boot loader, for reasons of my own.
mystran

Re:Kernel Developement

Post by mystran »

Schol-R-LEA wrote: Actually, Mystran, if you look at the current version of the FAQ, it mentions GRUB right at the start, and discusses using it a length, though it stops short of actually recommending it in order to avoid the inevitable flame wars from bot-liader partisans.
Oops, it just wasn't mentioned on the "what parts you can't code in C" page, and since that page said you can't code your bootloader in C and only mentioned "third-party bootloaders" in passing I thought this was some political conspiracy again. =)
Schol-R-LEA

Re:Kernel Developement

Post by Schol-R-LEA »

Well, one of the advantages of a Wiki-based FAQ is that you can always edit the FAQ yourself, if you feel you have something to contribute. Of course, if you screw up badly, or if someone "graffiti's" a page, or if you offend The Cabal ;), the moderators can always roll back the page, and others can edit it as well.

EDIT: I've changed the section in question to mention 3rd-party bootloaders, and GRUB in particular, more prominently. HTH.
Post Reply