mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-19 20:39:01 +00:00
199 lines
11 KiB
HTML
199 lines
11 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml" >
|
|
<head>
|
|
<title>Untitled Page</title>
|
|
</head>
|
|
<body>
|
|
|
|
<h3>
|
|
Cosmos?</h3>
|
|
<p>
|
|
Cosmos is short for C# Open Source Managed Operating System. Despite C# being in
|
|
the name, VB.NET, Fortran, and any .NET language can be used. We chose the C#
|
|
title because our work is done in C#, and VBOSMOS just does not sound as nice.</p>
|
|
<p>
|
|
Cosmos is not an operating system in the traditional sense, but instead it is
|
|
"Operating System Kit", or as I like to say "Operating System Legos", that allow
|
|
you to create your own operating system. However having been down this path
|
|
before, we wanted to make it easy to use and build. Most users can write and
|
|
boot their own operating system in just a few minutes, and using Visual Studio.</p>
|
|
<p>
|
|
Cosmos lets Visual Studio compile your code to IL and then Cosmos compiles the
|
|
IL into machine code.</p>
|
|
<h3>
|
|
Dev Kit or User Kit?</h3>
|
|
<p>
|
|
Cosmos comes in two flavors, a user kit and a dev kit. The user kit hides the
|
|
kernel source away from the user and presents a new project type in file, new.
|
|
Building a new operating system is as simple as file, new, writing a few lines
|
|
of code and pressing F5 to build and run it. The user kit is a bit old though,
|
|
and is really only designed to interest people in obtaining the dev kit.</p>
|
|
<p>
|
|
The dev kit is available as a project on <a href="http://www.CodePlex.com/Cosmos/">CodePlex</a>, and the Cosmos website
|
|
is <a href="http://www.GoCosmos.org">www.GoCosmos.org</a>..</p>
|
|
<h3>
|
|
Dev Kit</h3>
|
|
<p>
|
|
To get the dev kit simply sync the sources from the CodePlex project. It might
|
|
appear daunting at first, 43 projects? A lot of these projects are demos, tests,
|
|
and playgrounds.</p>
|
|
<p>
|
|
Note that Visual Studio Express cannot handle the solution folders. Because of
|
|
this Express users should use the Flat solution file, but first you must update
|
|
the Flat solution file from the main solution using the Flat file updater
|
|
utility.</p>
|
|
<p>
|
|
<img alt="" src="SNAG-0000.jpg" style="width: 203px; height: 178px" /></p>
|
|
<p>
|
|
In the Boot folder, and then the Demo folder you will see a CosmosBoot project.
|
|
This is the empty shell used in the User Kit for the new project template. This
|
|
is the minimal Operating System that Cosmos can build. You can copy this file
|
|
and change it to your needs. Let's take a quick look.</p>
|
|
<p>
|
|
<img src="SNAG-0001.jpg" style="width: 138px; height: 74px" /></p>
|
|
<p>
|
|
Properties and References are standard parts of any .NET project. Let's look in
|
|
Program.cs<p>
|
|
Note on images: CodeProject limits images to 600 pixels in width. I've chosen to
|
|
crop the width to retain readability.<p>
|
|
<img src="SNAG-0002.jpg" style="width: 700px; height: 339px" /></p>
|
|
<p>
|
|
Init is the entry point that will be called after the system is booted. This is
|
|
where you put your code. Some sample code has been generated already and you can
|
|
change it. Be sure to leave the first two lines alone, they initialize memory,
|
|
hardware, etc.</p>
|
|
<p>
|
|
Let's take a look at something a little more complex though. Here is a demo
|
|
called Guess. It is a simple application which asks the user to guess a number.
|
|
As you can see, it is all standard C# code, and aside from the first two lines
|
|
for booting the code can function unchanged on Windows.</p>
|
|
<p>
|
|
<img src="SNAG-0004.jpg" style="width: 661px; height: 459px" /></p>
|
|
<p>
|
|
NNow let's run it. Are you expecting some complicated process involving batch
|
|
files and CD-R's? If so you will be disappointed. Simply press F5 in Visual
|
|
Studio to run it. Instead of the project running immediately, you will see a
|
|
Cosmos Builder Options window.</p>
|
|
<p>
|
|
<img src="SNAG-0007.jpg" style="width: 452px; height: 663px" /></p>
|
|
<p>
|
|
The builder support many environments including physical hardware. Virtual
|
|
Machines are easier to develop against, and are certainly easier to take
|
|
screenshots of so I will use VMWare for this article.
|
|
</p>
|
|
<p>
|
|
With these options set, I clicked the Build button (The Enter key also
|
|
proceeds). Next a build progress window will appear. Cosmos is now compiling the
|
|
IL to machine code, linking and preparing the boot image.</p>
|
|
<p>
|
|
<img src="SNAG-0011.jpg" style="width: 300px; height: 300px" /></p>
|
|
<p>
|
|
When this is done, the window will disappear and VMWare will automatically be
|
|
launched with an ISO mounted./p>
|
|
<p>
|
|
<img src="SNAG-0012.jpg" style="width: 637px; height: 518px" /></p>
|
|
<p>
|
|
Select "Power on this virtual machine" and the Guess demo will boot.</p>
|
|
<p>
|
|
<img src="SNAG-0014.jpg" style="width: 743px; height: 551px" /></p>
|
|
<p>
|
|
TThis is the demo, booted directly to hardware. There is no need for Windows,
|
|
Linux or any other operating system to run this code. During the boot process
|
|
you may notice SysLinux. SysLinux however is not a Linux distribution, but
|
|
instead just a boot loader used to read files from the disk. We use SysLinux
|
|
instead of Grub because it has support for PXE and other options. SysLinux is
|
|
only used for initial loading of the Cosmos binaries and as soon as Cosmos is
|
|
loaded SysLinux is unloaded is not used to run Cosmos code.</p>
|
|
<h3>
|
|
Graphics, Network, File Systems/h3>
|
|
<p>
|
|
Ease of use, or what I like to call "Nail the basics" is a priority for us.
|
|
However graphics and other things will follow in the future. Currently we are
|
|
working on a wide range of file systems including FAT and ext2. We are also
|
|
working on Ethernet support and can already send basic UDP packets, and are
|
|
working on TCP support as well.</p>
|
|
<h3>
|
|
DDebugging</h3>
|
|
<p>
|
|
Debugging operating systems is typically inconvenient and hinders progress.
|
|
Because of this, just as we did with making the build and boot process, we
|
|
strived to make the debugging process easy. The debugger is still a work in
|
|
progress, but is already quite advanced for an operating system debugger.</p>
|
|
<p>
|
|
<img src="SNAG-0018.jpg" style="width: 268px; height: 85px" /></p>
|
|
<p>
|
|
Adding the Cosmos.Debug namespace gives the code access to communicate directly
|
|
with the debugger.</p>
|
|
<p>
|
|
<img src="SNAG-0022.jpg" style="width: 294px; height: 161px" /></p>
|
|
<p>
|
|
In the Guess demo I am adding a Debugger.Send, which will write a debug string
|
|
to the debugger. These can be used to track code execution, but can also be used
|
|
for watching variables. In this case I will use it to write out the magic
|
|
number.</p>
|
|
<p>
|
|
<img src="SNAG-0023.jpg" style="width: 347px; height: 125px" /></p>
|
|
<p>
|
|
Notice I have also added a Debugger.Break. This will force the program to
|
|
execute a breakpoint at that location.</p>
|
|
<p>
|
|
Now let's run the Guess again. Which demo is booted is selected in Visual Studio
|
|
simply by selecting it as the startup project for the solution.</p>
|
|
<p>
|
|
<img src="SNAG-0024.jpg" style="width: 253px; height: 100px" /></p>
|
|
<p>
|
|
This time in debugger options Source and User Only is selected. Source tells the
|
|
debugger to debug C# code, rather than the lower level IL. And User Only tells
|
|
the debugger not to trace into the Cosmos Kernel or the .NET libraries. This
|
|
speeds up execution, but also lets me focus on tracing just the demo code.</p>
|
|
<p>
|
|
<img src="SNAG-0025.jpg" style="width: 743px; height: 551px" /></p>
|
|
<p>
|
|
Note that this time it did prompt us for the number yet? This is because it hit
|
|
the breakpoint. Another window will appear as well, this is the Cosmos Debugger.</p>
|
|
<p>
|
|
<img src="SNAG-0026.jpg" style="width: 720px; height: 379px" /></p>
|
|
<p>
|
|
The message and breakpoint are displayed in the trace log, and the code is
|
|
selected for the breakpoint. Breakpoints occur on the next statement after the
|
|
requested break.</p>
|
|
<p>
|
|
Now we can use the Step button (F11, just like Visual Studio) to step through
|
|
the code. Each step is recorded in the trace log and previous items can be
|
|
selected to walk backwards through the code. The trace log functions similarly
|
|
to the call stack window in Visual Studio.</p>
|
|
<p>
|
|
<img src="SNAG-0027.jpg" style="width: 683px; height: 460px" /></p>
|
|
<p>
|
|
Press continue (F5) and the code will run again until a breakpoint is
|
|
encountered in code, or requested from the debugger. After continue, a new
|
|
button will appear to that allows a forced instant break. After continue, the
|
|
code will continue and we will be prompted for the number.</p>
|
|
<p>
|
|
<img src="SNAG-0028.jpg" style="width: 743px; height: 551px" /></p>
|
|
<p>
|
|
We can also turn tracing on and off for specific sections of code using the
|
|
Cosmos.Debug namespace.</p>
|
|
<p>
|
|
<img src="SNAG-0029.jpg" style="width: 335px; height: 225px" /></p>
|
|
<p>
|
|
This will cause the trace log to be populated with all statement executions
|
|
between the TraceOn and TraceOff without needing to step through each statement
|
|
manually.</p>
|
|
<p>
|
|
<img src="SNAG-0030.jpg" style="width: 255px; height: 94px" /></p>
|
|
<p>
|
|
This time Cosmos & User is selected to show more details in the trace log.
|
|
Normally this option is only needed by developers working on Cosmos kernel
|
|
source.</p>
|
|
<p>
|
|
<img src="SNAG-0031.jpg" style="width: 764px; height: 559px" /></p>
|
|
<h3>
|
|
Conclusion</h3>
|
|
<p>
|
|
Cosmos is an open source project as included as part of its name. I hope this
|
|
article gives an easy to understand introduction. If you are interested in
|
|
operating system development I hope you will try Cosmos!</p>
|
|
|
|
</body>
|
|
</html>
|