M3 Operating System Development

A chronicle of the development of the M3 operating system

Development Environment for M3 Operating System Development

leave a comment »

One of the first things that an operating system developer must do is decide on a development environment and a set of development tools. In this post, I will describe the development environment that I plan to use for M3 development.

In 2001, I bought my first Mac. I was intrigued by OS X. A really nice GUI built on top of rock-solid UNIX sounded like a winning combination, and oh boy is it a rockin’ combination! Since then, I have not purchased another PC. In recent years, many other developers have followed suit, and Macs have become quite a popular development platform. In my current job, I develop ASP.Net websites using a MacBook Pro running VMWare Fusion. I’ve got a virtual Windows 2003 server instance that I do my .Net development on, but for everything else, I use native OS X software. It’s a sweet setup.

So I decided right off the bat that my development environment would be OS X. Because it’s UNIX, there are a zillion dev tools available, many of them bundled with OS X on the included developer tools CD.

I also mentioned VMs. I decided that my life would be a whole lot easier if I ran M3 on a VM or an emulator during development, rather than try to run it on the actual target hardware. When I first started getting into OS development, about 10 years ago now, I remember having to write the boot loader and kernel to an actual 3.5″ floppy disk. To test, I would need to boot the computer off the floppy. If it didn’t work (as was often the case), I would need to figure out what went wrong, fix the code, compile, write the code to the floppy, and reboot the computer. Not an optimal development cycle by any stretch of the imagination.

Today, my Mac doesn’t even have a floppy drive. I haven’t bought or owned a floppy disk in years. That fact, combined with the painful floppy development cycle had me looking for more optimal ways to test operating system code. And I decided that what I needed was an emulator.

Right now, there seem to be two popular choices for IA32 emulation: Bochs and QEMU.

Bochs is an open-source IA32 emulator that runs on a variety of platforms. It is well-maintained, and there is plenty of help available out there if you need it.

QEMU is another open-source emulator that runs on a variety of platforms. For OS X, there is the Q project, which provides a nice Cocoa front-end to QEMU.

I haven’t yet decided which emulator I’ll use for my testing. I’m currently evaluating them to determine which will better suit my needs. 

Coding Tools

I’m getting a bit ahead of myself though. Before I can get to the testing stage, I need to have actually written and built some code.

The core M3 kernel will be written in C. Perhaps some of the other pieces will be written in a higher-level language, but the core – the task schedule, the memory manager, etc – will be written in C.

For C programming, I’m not going to look any further than the GNU C Compiler (gcc). It’s not even up for discussion. gcc is an excellent compiler, and available on a zillion platforms. There’s copious documentation, and it’s open-source. 

M3 will need to have certain parts written in assembly, primarily the boot loader. For assembly code, I’m currently evaluating two options: GNU Assembler (gas) and NASM.

GNU Assembler is the back-end assembler used by gcc. The benefit of using gas would be that I would remain within the GNU toolset. However, gas uses a different syntax than a lot of other assemblers (AT&T syntax as opposed to Intel), and I think that might make it more difficult for me to incorporate sample assembly code available on the Internet. I don’t want to have to translate from Intel to AT&T syntax.

Nasm – the Netwide Assembler is an open-source assembler project that is portable across many platforms and supports a wide variety of output formats. It is currently a very popular choice for assembly programming. 

I’m currently leaning towards using Nasm. I just like the assembly syntax a lot better.

Other Tools

For my text editor, I’ll most likely be using TextMate. It’s not free, but it’s well worth the money.

I’ll use make to script the build/linking process and make that easier. I don’t want to sit there and type a bunch of commands everytime I want to build M3. I’d rather just type

make m3

and have make do all the heavy lifting. Yeah, I’m lazy like that.

If I come across other tools that I find useful, I will be sure to note them in the blog.

Advertisements

Written by m3os

February 27, 2009 at 10:37 am

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: