MOSA Booting on Real Hardware

by Phil 14. June 2009 14:19

While most of the development and testing of MOSA is done using virtualization software, MOSA does indeed boot on real hardware too. At the moment we support booting MOSA from either a CD or USB key. We created a short one minute video showing MOSA being written to a USB Drive and the same PC booted with it: 

Booting MOSA from USB Drive

Here are the detailed instructions for writing MOSA to a USB Drive:

1. Download the dd utility for windows from http://www.chrysocome.net/dd.

2. Extract the dd.exe executable to the mosa\trunk\Setup\Boot\build directory.

3. Open a command prompt window and change directory to the build directory.

4. Connect the USB key you wish to ERASE and install MOSA onto. (WARNING: Data on the USB drive will be lost!)

5. Determine the device path for the USB key.

Type "dd --list" to display a list all the block devices on your system. Find the one for the USB Key you just connected. Be careful, if you select or mistype the wrong device, you can corrupt your hard drive or other storage devices. Unless you understand these steps completely, do not proceed.

6.Type "dd of=\\?\Device\HarddiskX\PartitionX if=bootimage.img bs=512 --progress" and substitute the of= parameter with the device path found in the previous step.

7. Wait until all the blocks are written to the USB key before disconnecting it.

8. Now boot a PC or laptop with the USB Key connected!

Tags: , ,

MOSA

TheadPool Helper Class

by Phil 10. May 2009 06:42

Lately, I have written a lot of multithreaded code in C#. I use the ThreadPool class object to launch and manage many parallel threads - mostly for TCP communications with client applications. It automatically throttles the numbers of active threads by the number of processors. Unfortunately, the ThreadPool class was written before .NET 2.0 and therefore it does not take advantage of generics. So you end up casting function methods and callback parameters. It can be a bit messy.

However, you can simplify things with the following helper class:

   1: static class ThreadPoolHelper
   2: {
   3:     public delegate void Function();
   4:  
   5:     public static void Execute(Function function)
   6:     {
   7:         ThreadPool.QueueUserWorkItem(new WaitCallback(Call), (object)function);
   8:     }
   9:  
  10:     private static void Call(object o)
  11:     {
  12:         ((Function)o)();
  13:     }
  14: }

To create a thread in the pool with this helper class, you simple use:

   1: TheadPoolHelper.Execute(someFunction);

Where someFunction is the name of a function method. 

If you need to pass a parameter, here's the helper class for that too:

   1: static class ThreadPoolHelperWithParam<T>
   2: {
   3:     public delegate void Function(T param);
   4:  
   5:     public static void Execute(Function function, T param)
   6:     {
   7:         ThreadPool.QueueUserWorkItem(new WaitCallback(Call), new KeyValuePair<object, T>((object)function, param));
   8:     }
   9:  
  10:     private static void Call(object o)
  11:     {
  12:         KeyValuePair<object, T> lObject = (KeyValuePair<object, T>)o;
  13:  
  14:         ((Function)lObject.Key)(lObject.Value);
  15:     }
  16: }

Now you can also pass an object of any type, like this:

   1: ThreadPoolHelperWithParam<someObjectType>.Execute(someMethod, someObject); 

 

Where the someObjectType is the type of object you are passing, and someObject with actual object you wish to pass as a parameter. Simple!

Tags:

Code

Incorporating the Mono Class Libraries in MOSA – Part I

by Phil 9. May 2009 20:42

The first challenge to incorporating the Mono Class Libraries into MOSA is how to replace the external method calls in the class libraries with our own custom implementation. There are two basic approaches to this challenge. In part one of this blog series, we will explore the one used by other managed open source projects and its unique challenges.

The most common approach is to replace the call to the external methods with a call to the another custom method instead. This approach seems to be the simplest and most elegant solution – as you only have to supply the CIL code for the custom method and then have the compiler call the replacement method.

Ideally the replacement method would be implemented similar to this:

   1: namespace InternalSystem
   2: {
   3:     [TargetNamespace("System")]
   4:     public class SomeMonoClass
   5:     {
   6:         public int NewMethod()
   7:         {
   8:             return this.X * this.Y;
   9:         }
  10:     }
  11: }
 
Of course, this method will not compile because the member variables X and Y do not exist to the C# compiler. One possible solution is to create stubs for these member variables so they will exist while the code is compiled to CIL. Here we add those two member variables:
 
   1: namespace InternalSystem
   2: {
   3:     [TargetNamespace("System")]
   4:     public class SomeMonoClass
   5:     {
   6:         int X;
   7:         int Y;
   8:  
   9:         public int NewMethod()
  10:         {
  11:             return this.X * this.Y;
  12:         }
  13:     }
  14: }
 
Now the code compiles. And given some special CIL to native compiler, the external method call will be redirected to this other method instead. Creating stubs to expose these “hidden” member methods and variables seems like a fair compromise. But look at this example:
 
   1: namespace InternalSystem
   2: {
   3:     [TargetNamespace("System")]
   4:     public class SomeMonoClass
   5:     {
   6:         int x;
   7:         int y;
   8:  
   9:         public ClassC NewMethod(ClassA b, ClassB b)
  10:         {
  11:             return new ClassC(z, b.X, c.Y);
  12:         }
  13:     }
  14: }
 
Now additional stubs are required to represent the ClassA, ClassB, and ClassC classes, and stubs for each of their member methods and variables before this code will compile. Do you see where this is going? Given a rich framework with many dependencies between classes, like the .NET framework, this approach can results in the creation hundreds of stubs!
 
MOSA will approach this problem in another way, which I will be blogging about next.

Tags: ,

Code | MOSA

Boot Image Creation Tool

by Phil 3. May 2009 06:24

configFor the MOSA project, we needed a tool to create image files for various Virtual machine software, such as for Microsoft Virtual PC and Microsoft Virtual Server, VMware, and VirtualBox, including simulators such as QEMU, and Bochs.

The use of virtualization software would help us facilitate the building and testing of the MOSA AOT/JIT compiler, the reference Operating System, and CIL based runtime libraries.

So we need an virtual disk image tool that could:

1. Create disk images in various virtual disk formats: IMG, VHD and VDI.

2. Create Master Boot Block (MBR) and partition to the disk image.

3. Create FAT12 or FAT16 partitions (or EXT partitions).

4. Incorporate a multi-stage boot loader with support for the Multiboot Specification.

5. Add files to the file system.

6. Execute on Windows or Linux platforms.

After an exhaustive search across various open source operating systems, I was unable to find a single tool that could do all of this. Most projects use a tool set of utilities, such as GRUB, LILO, mkfatfs, fdisk, and Syslinux, and custom scripts to create the single boot image. Unfortunately those tools and their related scripts were always platform specific to either Linux or Windows.

So I decided to roll my boot image creation tool in C# that incorporated all these features. One of the good things about having written parts of the device drivers, driver system, and file system support for MOSA is already having code for creating, reading and writing MBR, partitions, and FAT12/16. Implementing basic support for the virtual disk formats was relatively straightforward after reading the specifications and understanding the Cluster-Head-Sector (CHS) address legacy. The most difficult part was incorporating the Syslinux boot record and boot loader binaries. Those binary executables required very specific in-place modifications based on the virtual disk geometry and file system.

The result is a tool simply called “CreateBootImage.exe”. It run on both Windows and Linux (with Mono), and is now available as part of the MOSA project.

Here’s how to use the tool:

The tool accepts two command line arguments:

CreateBootImage.exe <configuration file> <image file>

The configuration file contains a list of options, one per line, with arguments separated by a tab. The following options are supported:

option Arguments Description
-volume Volume Name Set the volume name for the first partition
-blocks # of Blocks Set the number of 512-byte blocks
-fat12   Use FAT12 file system
-fat16   Use FAT16 file system
-fat32   Use FAT32 file system (untested)
-vhd   Create image in VHD (Virtual PC/Virtual Server) format
-vdi   Create image in VDI (VirtualBox) format
-img   Create image in IMG format
-syslinux   Patch disk image for Syslinux
-mbr Filename Use file for Master Boot Record
-boot Filename Use file for Boot Record
-file Filename, Destination Include file in file system (destination optional)


The tool can create disk images for the following emulators:

Emulator File Format
Virtual PC 2004/2007 .VHD
Virtual Server .VHD
VMware .VHD
VirtualBox .VDI
QEMU .IMG
Raw Image .IMG

Tags: , ,

Virtualization | MOSA

Managed Operating System Alliance (MOSA) Framework

by Phil 25. April 2009 15:36

Mosa-Idea3Over the past six months, Michael Ruck (aka grover), Simon Wollwage (aka rootnode) and I (aka tgiphil) have been super busy developing a set of tools, specifications and source code to foster the development of managed operating systems based on the Common Intermediate Language. MOSA has partnered with the SharpOS and Ensemble projects to jointly develop a common CIL JIT/AOT Compiler, Device Drivers, and Runtime libraries.

MosaBootProgress has been slow, but not without achievements. We have the beginnings of an AOT/JIT Compiler (mosacl), a working boot image creation tool, device drive framework and several device drivers. The build framework can compile and boot a simplistic OS kernel (see the screen shot).

Currently we are working to improve the compiler and support all the CIL instructions, and a tool to directly transform the source code of class libraries from Mono Project so we can compile and use it with this project. I’ll blog more about the transform tool later in a future blog.

The MOSA Project is currently hosted at CodePlex. Check it out!

Tags: , ,

MOSA

BlogEngine.NET Extension Pack 1.3.1 Release

by Phil 6. September 2008 04:40

wrenchA new release of the BlogEngine.NET Extension Pack has just been released on CodePlex. This pack includes a total of fourteen extensions, including six new ones from contributors:

  • DotNetKicksOnTheFly - Adds a DotNetKicks button to a post where the token kickit is found on the fly.
  • GoogleAnalytics - Adds Google Analytics code to BlogEngine.
  • SEOPack - Optimizes your BlogEngine blog for Search Engines (SEO).
  • TranslatePost - Automatic translation for your blog post by using Google Translation Services.
  • TypograFix - A typographic reformatting extension.
  • WowLinkItem - Creates a link and mouse over for World of Warcraft Items.

Check it out.

Tags:

BlogEngine.NET

Water on Mars!

by Phil 31. July 2008 01:05

IceOnMars

Today, NASA's Phoenix Mars Lander confirms that water exists on Mars!  While the spacecraft had previously photographed evidence of water ice, this is the first time that sensitive instruments on the surface of the planet have detected water in the Martian soil.

Additional tests show that the Martian soil is similar to soil on Earth, except without any biological organics. The tests turned up magnesium, sodium, potassium and chloride, all of which are useful in organic processes. The soil is also alkaline, with a pH balance between 8 and 9. Leading some scientist to conclude that the Martian soil is capable of sustaining plant life.

Now did anyone remember to put some seeds on the spacecraft?

Tags: , ,

News

Joined the SharpOS Provisional Government Board

by Phil 29. July 2008 02:16

SharpOS-Boot Today, I accepted an invitation to join the Provisional Government Board of the open source SharpOS Project. The SharpOS Project is a community effort to write an operating system based on .NET technology, with a strong sense of security and manageability. 

Tags:

The Phoenix has landed!

by Phil 25. May 2008 20:28

230160main_foot2Earlier today, NASA successfully landed the Phoenix spacecraft on the planet Mars!  That is an amazing accomplishment. Mars is roughly 90 million miles from Earth. That's like making a hole-in-one on another golf course on the other side of the planet. Kudos to NASA and their expert teams of engineers and scientists!

Photo: Phoenix footpad on Mars!

Tags: , ,

News

New BlogEngine Theme - iTheme

by Phil 15. May 2008 03:56

iThemeI was so impressed with the iTheme theme that Nick La created for WordPress that I decided to port it to BlogEngine.NET.  So if you have an iPod, iPhone, iTouch, or even an iMac, this theme is designed for you (even if BlogEngine.NET currently only runs on Windows and Linux platforms).

The only feature not ported yet over is the drag and drop side bar feature - however, it will be coming once the BlogEngine.NET new Widget support is completed.

Nick has release the theme to the public under a very generous license, please check his blog for details.

Download: iTheme.zip (143.78 kb) Updated: 5/23/08

Tags: ,

BlogEngine.NET

Powered by BlogEngine.NET 1.5.0.7
Theme by Mads Kristensen | Modified by Mooglegiant

Projects

Software Stack

Recent Comments

Comment RSS

Badges

Enhanced with Snapshots