A Demonstrative Bare-Bones OS

Dennis J. McWherter, Jr. bio photo By Dennis J. McWherter, Jr. Comment

Today I found a piece of code I wrote (on my own time) for a presentation I gave while at my previous job. In summary, it is a quick (i.e. <1 week worth of work) example of writing a bare-bones OS from scratch. You can see the source code here.

Now, this isn€™t the most stellar piece of code anyone has written, but I think it may be useful to some people looking for more information on how to even start. In short, you will want to look at boot.s to see how we actually start the boot process (i.e. after the bootloader) and kernel.c to see how we initialize and what happens in the main kernel loop.

Though I believe it is a nice tool for learning and exploration, I do not suggest you build your next major OS from this codebase. Instead, I suggest you take the apparent concepts and apply them in a more organized fashion. In general, this is probably a better starting point than the full Linux kernel because– if for no other reason– it is a small piece of code. Everything should be reasonably understandable (depending on your knowledge of C and x86 assembly). The more important concept to realize is that when doing kernel programming, datasheets matter. You will notice that I have a few Intel manual references in there; we do indeed care at this level how to manipulate the processor directly and modify its state.

All that being said, this about wraps up this short PSA-style post. I just wanted to make people aware that I was releasing this source that I have previously used a a short teaching aid. Happy kernel hacking!

comments powered by Disqus