Saturday, January 26, 2008

OS Development and Debugging

Well, I've finally gotten back into my OS developing - this is now the third rewrite of Mattise (titled "Mattise 3.0") and I'm truly starting from scratch on this one. I'm spending a lot longer getting the basic x86 code implemented (stuff like paging and the descriptor tables) and putting it through a lot of tests to verify that it's ready to do the job. Once I've finished with these tests I can add layers to it, such as context switching (threads and processes, although processes are really just a set of threads) or a driver system.

Debugging all this is proving to be the hardest thing out of all the code I've written. At the moment I have to use a whole bunch of printing calls to output state until I finally figure out the source of the problem (and hope it's not those same printing calls). I've heard of people writing a dprintf interface to the Bochs port E9 hack but I personally think that sounds pretty, well, hacky, and means testing in other emulators is harder. My favorite idea is a debugging system that talks to the kernel via a serial line, but I'd still need to verify that the serial line works properly. A serial driver could even be written inline, not using a proper driver interface, to make life easier.

I'm happy with my first couple of days re-entering the fray that is OS development on the x86 architecture. All I need to do is wait for the Intel Manuals to arrive in the mail and I'm set. I'll make an effort to keep this blog up to date with all that's happening as a reference point not only for everyone else but for myself.

The project page hasn't been modified yet but it's at http://www.sourceforge.net/projects/mattise.