M3 Operating System Development

A chronicle of the development of the M3 operating system

Boot Loaders from other Operating Systems

leave a comment »

I was in the bookstore last night, a place that I often find myself, and was happy to see that there were two books on operating system design and development. Of course, these were college-level textbooks, and therefore cost upwards of $100, so I was content to peruse them in the store instead of contributing to the madness that is textbook pricing.

One of the books was all theory, which wasn’t all that interesting to me, since I already own several books on OS theory. The other was theory mixed with examples from actual operating systems, which was much more useful to me.

Since I am currently trying to write the boot loader for M3, I paid close attention to the examples of boot loaders. I read about the booting process for Inferno, and the boot process for Linux. The Inferno example was very interesting to me, since Inferno basically initializes the system, loads up its kernel, and then launches a virtual machine on which all user-space processes run. This is actually very similar to what I’m thinking about for M3. I would ultimately like M3 to boot up and launch a Java Virtual Machine, so that all user applications could be written in Java or some other language that targets the JVM.

Inferno uses a VM named Dis that the developer (Bell Labs) wrote from scratch. Programs targeting the Dis VM are written in a language called Limbo, which has C-like syntax. For M3, I don’t want to write my own VM, and I don’t want my application developers to learn a completely new language in order to target my OS. That’s why I’m thinking about using the JVM. If I can get the JVM running on M3, then M3 will be able to run the 50 kajillion Java apps that are already out there.

Anyways, Inferno is a pretty cool OS, built by brilliant people with some interesting ideas. Unfortunately, Bell Labs is no more, but you can read about and download the Inferno OS here. It’s now open source, so you can dig into all the gritty coding details too.

OK – back to the boot loaders. After I read about Inferno’s boot process, I read about Linux’s. Boy, I never realized how involved the boot process was for Linux. It does a ton of stuff in assembly code before it jumps into the kernel. A lot of the complexity comes from the fact that the kernel code may be compressed, and so the boot loader needs to not only load the kernel into memory, but decompress it as well. The boot loader has many stages, and is much more involved than what I want M3’s loader to do. The other complexity comes from the fact that Linux was started back when the 386 was still new, and therefore the boot code needed to do many more hardware checks to determine what features were available to the system. With M3, I’m going to assume a minimum level of functionality, rather than testing for each and every specific feature.

For M3’s boot loader, I want to keep the code to the bare minimum necessary to get the kernel up and running. I want to keep the assembly code at a minimum, and get into C as soon as possible.


Written by m3os

March 7, 2009 at 3:37 pm

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: