Register
Home Projects Help

Developers’ Starting Guide

On this page you’ll find a step by step guide on how to get started with development for SharpOS on Windows. (If you are using a non-Windows system, then you can probably figure out what the equivalent on your system is, but you’ll need Mono.)

Getting the tools

First you’ll need to download & install a couple of tools:

  • SVN client – to get the SharpOS code
  • A Common Language Runtime (pick at least one):
  • NAnt – for compiling SharpOS
  • An x86 virtual machine (pick at least one)
    • VMware Player – free, good performance
    • Microsoft Virtual PC – free, best performance
    • QEmu – free, supports para-virtualization
    • VirtualBox – free for personal use, excellent user interface
    • Bochs – Not supported due to a known bug in Bochs

Anything that does not come with an installer, should be completely extracted to an appropriate, non-temporary folder.

Setting up Paths in Windows

Since you’ll be using the command-line NAnt tool to compile, you’ll need to set up your Path environment variable. Here are instructions for Windows XP:

  • Right click “My Computer”
  • Select “Properties”
  • Select the Advanced tab
  • Click on “Environment Variables”
  • In the “System variables” list (the bottom one), go to PATH, click on Edit
  • In “Variable value”, add the following paths at the end, separated by ’;’ (without the quotes):
    • the mono (if installed) bin directory (for example ‘C:/Program Files/Mono-1.2.6/bin’)
    • the NAnt directory (for example ‘C:/Program Files/NAnt/’)

Getting the source code

Using vanilla Subversion on Windows/Linux: * @svn co https://sharpos.svn.sourceforge.net/svnroot/sharpos/trunk/

Using TortoiseSVN on Windows: * Create a directory (such as ‘C:/SharpOS/WorkingCopy/’) * Enter the directory and right click in the empty window * Select SVN Checkout * Enter “https://sharpos.svn.sourceforge.net/svnroot/sharpos/trunk/” in URL of repository. * Click OK

Setting up automatic End-Of-Line style property

Important: If you create a file which does not have the SVN end-of-line property, the file will suffer from line endings changes when someone on a different platform modifies the file. Make sure to set up automatic properties so that we all can develop uninterrupted.

  • Add the following to your SVN configuration file (for TortoiseSVN, click on any folder in Explorer and go to TortoiseSVN->Settings, then click ‘Edit’ for the Subversion configuration file, on Linux edit ~/.subversion/config):

[miscellany]
enable-auto-props = yes

[auto-props]
*.cs = svn:eol-style=native
*.txt = svn:eol-style=native
*.skm = svn:eol-style=native
*.xml = svn:eol-style=native
*.csproj = svn:eol-style=CRLF

Viewing the Code

SharpOS currently maintain both a Visual Studio 2005 and 2008 project. These can be loaded by Visual Studio, Sharp Develop, maybe Mono Develop(?). Visual Studio Express can also be used, but you will have to restructure the solution since it uses solution folders. If you are student though, and don’t have Visual Studio, I would suggest looking into getting a copy at the channel 8 download site.

Compiling SharpOS

  • Start a Command Prompt
    • If you are running Windows Vista, find and right-click the shortcut to Command Prompt, and select ‘Run as administrator’
  • In the command prompt, navigate to the directory where you did a Subversion check-out of SharpOS source code
  • Enter ‘nant dist’
  • Alternatively, if you installed Mono, you can enter ‘nant dist -t:mono-2.0’, to have the project built with Mono compilers

If all goes well, it should say ‘BUILD SUCCEEDED’ at the very end. If so, then the entire project has successfully been built, the kernel as been AOTed, and a floppy disk image was generated for you in ./build/distro/common/ .

(The build process has our own tool which generates the disk image in a host-independent way.)

Running SharpOS

  • Open up a Windows Explorer window
  • Navigate to your SharpOS working copy
  • Double-click on the ‘build’ subfolder
  • Double-click on the ‘distro’ subfolder
  • Double-click on the subfolder named after the emulator that you both installed and wish to use
  • Double-click on the file in that folder to launch the respective emulator

If any part of the build fails, feel free to ask questions on our mailing list or in our IRC channel.

The build process is mostly dependable from within Visual Studio as well, however the .csproj files are there for IDE convenience only, and we recommend that you do all your building with NAnt at the command-line.

Following the Code

After you have SharpOS up and working, the next step is to be able to follow what is going on in the project. The first line of code that is actually executed is located SharpOS.AOT.Core/x86/Assembly.cs::AddEntryPoint(), ~line 1103. This project is written in C#, but a runtime does not exist for the language when the operating first boots, and thus everything must be converted to machine code by the AOT (Ahead of time compiler) before it can be ran. More on this will be discussed later. But for now, lets focus on how the AOT compiles the start of the operating system.

The first thing the compiler must do is setup the stack and execute the entry method of the kernel. This is what AddEntryPoint() performs starting at line 1103 in the previously mentioned file. Now notice the line in the file “this.CALL (KERNEL_MAIN);” This transfers control to the first entry method in the kernel located at: SharpOS.Kernel.Core.EntryModule.cs::BootEntry(), ~ line 78.

Coding Style

We use the Mono coding style guidelines for SharpOS development. For details see Coding_StyleGuidelines

Patches

Once you have modified the SharpOS code and wish to contribute it to the SharpOS Project, please mail a patch to our mailing list with a brief description of your changes. We like the diff format used by ‘svn diff’ which is basically a unified diff. Make the patch from the most specific project directory that you modified. For instance if you are working on the kernel core, make the patch from either the Kernel/ or Kernel/Core/ directories.

Export to HTML, TXT