BUILD YOUR OWN OPERATING SYSTEM

Nearly every true computer geek has, at some point, wanted to write an operating system. However, writing a custom kernel and other bits takes years of study, experience and patience. If you intend to keep your sanity, then the best course of action is to use someone else's code.
Cosmos*, or C# open source managed operating system, is a pre-made kernel that provides you with "OS legos" that allow you to quickly and easily create your own operating system.

You will need:

@ Microsoft Visual C# 2008.

@ A knowledge of the C# programming language (don't worry if you don't have this, it's a pretty easy language).

@ The Cosmos user kit (milestone 4).

Microsoft Visual C# can be downloaded free if you get the express edition. You can download it here You can also download the entire Visual Studio including visual basic and visual c++ as an ISO image (these can be tricky, see below for details on reading ISO images). Even on a blazing fast computer, downloading visual studio will take two hours at most, though.
WARNING: make sure that you get the 2008 edition and not 2010. This may seem backwards, but the Cosmos user kit has yet to support 2010.

The cosmos user kit is the platform that we will write our OS in. It's an all-in-one micro-kernel operating system that is written in 100% C#. You can download it here
Daemon tools lite is free and can be found here

A: After downloading it, running the setup program, and re-booting, fire up Daemon tools and click Add File (the picture of the CD with a plus sign).
B: Find the image, and open it.

C: Now, select the file and click Mount. A popup (see pic')  will show you some options, click "run setup.hta". This will install Visual Studio. Alternatively, you can find setup.hta in the virtual drive that was created, located in My Computer under Devices with removable storage.

cBoot shot.PNG

After downloading the file CosmosUserKit.MS4, run it and follow the setup instructions. Visual studio will warn you about unsigned code and potential danger and blah blah blah. Cosmos doesn't have any of that, so just click OK.
Now, if you open up Visual C#, and under the heading Recent projects, you will see the text "Create...project". Click this. It will be where we write all the code for the OS. Name it whatever you please. Now, you will see an option under My templates labeled CosmosBoot. Double click it to open up the Cosmos template, and then double click the "program.cs" text over on the right. You should see this text:

using System;
using Cosmos.Compiler.Builder;

namespace CosmosBoot1
{
    class Program
    {
        #region Cosmos Builder logic
        // Most users wont touch this. This will call the Cosmos Build tool
        [STAThread]
        static void Main(string[] args)
        {
            BuildUI.Run();
        }
        #endregion

        // Main entry point of the kernel
        public static void Init()
        {
            var xBoot = new Cosmos.Sys.Boot();
            xBoot.Execute();
            //There's supposed to be a bit of text here. Change it to Console.WriteLine("Hello world!");
        }
    }
}

In the next step we'll boot up our (very) basic OS.

Picture of Boot!

basic os.PNG 

Now, open up the debug menu, and click Start without debugging. There will be a white popup asking you various questions, but the defaults will suffice for now, so just click OK.
You should see a black console window with a lot of text. Eventually the operating system will finish booting and display "Hello world!". Congratulations, you just made an operating system! Well, okay, so it's not really an OS in the traditional sense, but it's a start.

In addition to providing the template, the Cosmos user kit installs a new Cosmos class. With this, you can do things like shutdown, reboot, and other OS-ey things.

Shutdown:

Cosmos.Sys.Deboot.Shutdown();

Reboot:

Cosmos.Sys.Deboot.Reboot();

NOTE: All the code for the OS will go under the xBoot.Execute() line of code.
 

Previous
Next Post »
3IG