C# Open Source Managed Operating System (Cosmos) is a
toolkit
A toolkit is an assembly of tools; set of basic building units for user interfaces.
The word toolkit may refer to:
* Abstract Window Toolkit
* Accessibility Toolkit
* Adventure Game Toolkit
* B-Toolkit
* Cheminformatics toolkits
* Dojo Toolk ...
for building
GUI and command-line based
operating system
An operating system (OS) is system software that manages computer hardware and software resources, and provides common daemon (computing), services for computer programs.
Time-sharing operating systems scheduler (computing), schedule tasks for ...
s, written mostly in the programming language
C# and small amounts of a high-level
assembly language
In computing, assembly language (alternatively assembler language or symbolic machine code), often referred to simply as assembly and commonly abbreviated as ASM or asm, is any low-level programming language with a very strong correspondence bet ...
named X#. ''Cosmos'' is a
backronym
A backronym is an acronym formed from an already existing word by expanding its letters into the words of a phrase. Backronyms may be invented with either serious or humorous intent, or they may be a type of false etymology or folk etymology. The ...
,
[Cosmos website: project repository at GitHub](_blank)
/ref> in that the acronym
An acronym is a type of abbreviation consisting of a phrase whose only pronounced elements are the initial letters or initial sounds of words inside that phrase. Acronyms are often spelled with the initial Letter (alphabet), letter of each wor ...
was chosen before the meaning. It is open-source software
Open-source software (OSS) is Software, computer software that is released under a Open-source license, license in which the copyright holder grants users the rights to use, study, change, and Software distribution, distribute the software an ...
released under a BSD license
BSD licenses are a family of permissive free software licenses, imposing minimal restrictions on the use and distribution of covered software. This is in contrast to copyleft licenses, which have share-alike requirements. The original BSD lic ...
.
, Cosmos encompasses an ahead-of-time (AOT) compiler named IL2CPU to translate Common Intermediate Language
Common Intermediate Language (CIL), formerly called Microsoft Intermediate Language (MSIL) or Intermediate Language (IL), is the intermediate language binary instruction set defined within the Common Language Infrastructure (CLI) specification. ...
(CIL) into native instructions. Cosmos compiles user-made programs and associated libraries
A library is a collection of Book, books, and possibly other Document, materials and Media (communication), media, that is accessible for use by its members and members of allied institutions. Libraries provide physical (hard copies) or electron ...
using IL2CPU to create a bootable
In computing, booting is the process of starting a computer as initiated via hardware such as a physical button on the computer or by a software command. After it is switched on, a computer's central processing unit (CPU) has no software in ...
native executable that can run independently. The resulting output can be booted from a USB flash drive
A flash drive (also thumb drive, memory stick, and pen drive/pendrive) is a data storage device that includes flash memory with an integrated USB interface. A typical USB drive is removable, rewritable, and smaller than an optical disc, and u ...
, CD-ROM
A CD-ROM (, compact disc read-only memory) is a type of read-only memory consisting of a pre-pressed optical compact disc that contains computer data storage, data computers can read, but not write or erase. Some CDs, called enhanced CDs, hold b ...
, over a network via Preboot Execution Environment
In computing, the Preboot eXecution Environment (PXE; often pronounced as ''pixie''), often called PXE boot (''pixie boot''), is a specification describing a standardized client–server environment that boots a software assembly, retrieved ...
(PXE), or inside a virtual machine
In computing, a virtual machine (VM) is the virtualization or emulator, emulation of a computer system. Virtual machines are based on computer architectures and provide the functionality of a physical computer. Their implementations may involve ...
. Recent releases also allow deploying to certain x86
x86 (also known as 80x86 or the 8086 family) is a family of complex instruction set computer (CISC) instruction set architectures initially developed by Intel, based on the 8086 microprocessor and its 8-bit-external-bus variant, the 8088. Th ...
embedded devices over Universal Serial Bus (USB
Universal Serial Bus (USB) is an industry standard, developed by USB Implementers Forum (USB-IF), for digital data transmission and power delivery between many types of electronics. It specifies the architecture, in particular the physical ...
). While C# is the primary language used by developers (both on the backend and by end user
In product development, an end user (sometimes end-user) is a person who ultimately uses or is intended to ultimately use a product. The end user stands in contrast to users who support or maintain the product, such as sysops, system administrato ...
s of Cosmos), many CLI languages
CLI languages are computer programming languages that are used to produce libraries and programs that conform to the Common Language Infrastructure (CLI) specifications. With some notable exceptions, most CLI languages compile entirely to the Com ...
can be used, provided they compile to pure CIL without the use of Platform Invocation Services (P/Invokes). Cosmos is mainly intended for use with .NET
The .NET platform (pronounced as "''dot net"'') is a free and open-source, managed code, managed computer software framework for Microsoft Windows, Windows, Linux, and macOS operating systems. The project is mainly developed by Microsoft emplo ...
.
Cosmos does not aim to become a full operating system, but rather a toolkit
A toolkit is an assembly of tools; set of basic building units for user interfaces.
The word toolkit may refer to:
* Abstract Window Toolkit
* Accessibility Toolkit
* Adventure Game Toolkit
* B-Toolkit
* Cheminformatics toolkits
* Dojo Toolk ...
to allow other developers to simply and easily build their own operating systems using .NET. It also functions as an abstraction layer
In computing, an abstraction layer or abstraction level is a way of hiding the working details of a subsystem. Examples of software models that use layers of abstraction include the OSI model for network protocols, OpenGL, and other graphics libra ...
, hiding much of the inner workings of the hardware from the eventual developer.
Older versions of Cosmos were released in ''Milestones'', with the last being Milestone 5 (released August 2010). More recently, the project switched to simply naming new releases after the latest commit number.
Releases of Cosmos are divided into two types: the ''Userkit'', and the ''Devkit''. The Userkit is a pre-packaged release that is updated irregularly, as new and improved features are added. Userkits are generally considered stable, but do not include recent changes and may lack features. The Devkits, which refers to the source code
In computing, source code, or simply code or source, is a plain text computer program written in a programming language. A programmer writes the human readable source code to control the behavior of a computer.
Since a computer, at base, only ...
of Cosmos, are usually stable but may have some bugs. They can be acquired on GitHub
GitHub () is a Proprietary software, proprietary developer platform that allows developers to create, store, manage, and share their code. It uses Git to provide distributed version control and GitHub itself provides access control, bug trackin ...
and must be built manually. Git is used for source control management.
Most work on Cosmos is currently aimed at improving debugger
A debugger is a computer program used to test and debug other programs (the "target" programs). Common features of debuggers include the ability to run or halt the target program using breakpoints, step through code line by line, and display ...
functionality and Microsoft Visual Studio
Visual Studio is an integrated development environment (IDE) developed by Microsoft. It is used to develop computer programs including websites, web apps, web services and mobile apps. Visual Studio uses Microsoft software development platforms ...
integration. Kernel
Kernel may refer to:
Computing
* Kernel (operating system), the central component of most operating systems
* Kernel (image processing), a matrix used for image convolution
* Compute kernel, in GPGPU programming
* Kernel method, in machine learnin ...
work is focused on implementing file systems, memory management
Memory management (also dynamic memory management, dynamic storage allocation, or dynamic memory allocation) is a form of Resource management (computing), resource management applied to computer memory. The essential requirement of memory manag ...
, and developing a reliable network interface. Limine serves as the project's bootloader
A bootloader, also spelled as boot loader or called bootstrap loader, is a computer program that is responsible for booting a computer and booting an operating system. If it also provides an interactive menu with multiple boot choices then it's o ...
; in older versions of the toolkit, GRUB
GNU GRUB (short for GNU GRand Unified Bootloader, commonly referred to as GRUB) is a boot loader package from the GNU Project. GRUB is the reference implementation of the Free Software Foundation's Multiboot Specification, which provides a use ...
was used instead.
Origin
The idea for Cosmos was created by Chad Hower and was initially co-developed by Hower and Matthijs ter Woord. Over time, Cosmos has been maintained and improved by many other individuals.
Developing with Cosmos
Cosmos has many facilities to improve the experience of developing operating systems, and is designed to make the process as fast and painless as possible. Knowledge of assembly language
In computing, assembly language (alternatively assembler language or symbolic machine code), often referred to simply as assembly and commonly abbreviated as ASM or asm, is any low-level programming language with a very strong correspondence bet ...
is not required to use Cosmos.
Visual Studio integration
A key feature of Cosmos, which separates it from other operating systems of its type, is its tight integration with Microsoft Visual Studio
Visual Studio is an integrated development environment (IDE) developed by Microsoft. It is used to develop computer programs including websites, web apps, web services and mobile apps. Visual Studio uses Microsoft software development platforms ...
. Code can be written, compiled, debugged, and run entirely through Visual Studio
Visual Studio is an integrated development environment (IDE) developed by Microsoft. It is used to develop computer programs including web site, websites, web apps, web services and mobile apps. Visual Studio uses Microsoft software development ...
, with only a few keypresses. Cosmos no longer supports Visual Studio 2015
Visual Studio is an integrated development environment (IDE) developed by Microsoft. It is used to develop computer programs including websites, web apps, web services and mobile apps. Visual Studio uses Microsoft software development platforms ...
, Visual Studio 2017
Visual Studio is an integrated development environment (IDE) developed by Microsoft. It is used to develop computer programs including websites, web apps, web services and mobile apps. Visual Studio uses Microsoft software development platforms ...
, or Visual Studio 2019
Visual Studio is an integrated development environment (IDE) developed by Microsoft. It is used to develop computer programs including web site, websites, web apps, web services and mobile apps. Visual Studio uses Microsoft software development ...
, only supporting Visual Studio 2022.
Debugging
Cosmos can be seamlessly debugged through Visual Studio
Visual Studio is an integrated development environment (IDE) developed by Microsoft. It is used to develop computer programs including web site, websites, web apps, web services and mobile apps. Visual Studio uses Microsoft software development ...
when running over PXE or in a virtual machine
In computing, a virtual machine (VM) is the virtualization or emulator, emulation of a computer system. Virtual machines are based on computer architectures and provide the functionality of a physical computer. Their implementations may involve ...
. Many standard debugging
In engineering, debugging is the process of finding the Root cause analysis, root cause, workarounds, and possible fixes for bug (engineering), bugs.
For software, debugging tactics can involve interactive debugging, control flow analysis, Logf ...
features are present, such as breakpoints, tracing, and logging. Also, debugging can be done via serial cables, if running on physical hardware. When running in VMWare, Cosmos supports stepping and breakpoints, even while an operating system is running.
Running
Cosmos uses virtualisation to help speed development by allowing developers to test their operating systems without having to restart their computers as often. By default, VMware Player is used, due to its ease of use in terms of integration with the project. Other virtualisation environments are supported as well, such as Bochs
Bochs (pronounced "box") is a portable IA-32 and x86-64 IBM PC compatible emulator and debugger mostly written in C++ and distributed as free software under the GNU Lesser General Public License. It supports emulation of the processor(s) (includ ...
and Hyper-V
Hyper-V is a native hypervisor developed by Microsoft; it can create virtual machines on x86-64 systems running Windows. It is included in Pro and Enterprise editions of Windows (since Windows 8) as an optional feature to be manually enabled. A ...
. An ISO disk image may also be generated that can be burned to a USB flash drive
A flash drive (also thumb drive, memory stick, and pen drive/pendrive) is a data storage device that includes flash memory with an integrated USB interface. A typical USB drive is removable, rewritable, and smaller than an optical disc, and u ...
, CD-ROM
A CD-ROM (, compact disc read-only memory) is a type of read-only memory consisting of a pre-pressed optical compact disc that contains computer data storage, data computers can read, but not write or erase. Some CDs, called enhanced CDs, hold b ...
, or similar media.
PXE booting is also supported, allowing for remote machines to run Cosmos over a network connection.
IDE support
Cosmos does not strictly require Visual Studio. Projects can be created by running the command below, given you have the template installed:
dotnet new cosmosCSKernel -n MyCOSMOSProject
Code can be written in other editors and IDEs, such as JetBrains Rider
JetBrains Společnost s ručením omezeným, s.r.o. (formerly IntelliJ Software s.r.o.) is a Czech Republic, Czech software development private limited company which makes tools for software developers and project managers. The company has its ...
, Visual Studio Code
Visual Studio Code, commonly referred to as VS Code, is an integrated development environment developed by Microsoft for Windows, Linux, macOS and web browsers. Features include support for debugging, syntax highlighting, intelligent code comp ...
, Neovim
Vim (;
: "Vim is pronounced as one word, like Jim, not vi-ai-em. It's written with a capital, since it's a name, again like Jim." ...
and GNU Nano
GNU nano is a text editor for Unix-like computing systems or operating environments using a command line interface. It emulates the Pico text editor, part of the Pine email client, and also provides additional functionality. Unlike Pico, nano i ...
. One downside of this is that debugging
In engineering, debugging is the process of finding the Root cause analysis, root cause, workarounds, and possible fixes for bug (engineering), bugs.
For software, debugging tactics can involve interactive debugging, control flow analysis, Logf ...
may be difficult without the Visual Studio debugger. COSMOS will also not automatically launch your virtualisation software on build. If you would like to use QEMU
The Quick Emulator (QEMU) is a free and open-source emulator that uses dynamic binary translation to emulate a computer's processor; that is, it translates the emulated binary codes to an equivalent binary format which is executed by the mach ...
, for instance, you can run this command after build:
qemu-system-x86_64 -cdrom ./bin/Debug/net6.0/MyCOSMOSProject.iso
Compile process
IL2CPU
To compile .NET CIL into assembly language, Cosmos developers created an ahead-of-time compiler named IL2CPU, designed to parse CIL and output x86
x86 (also known as 80x86 or the 8086 family) is a family of complex instruction set computer (CISC) instruction set architectures initially developed by Intel, based on the 8086 microprocessor and its 8-bit-external-bus variant, the 8088. Th ...
opcode
In computing, an opcode (abbreviated from operation code) is an enumerated value that specifies the operation to be performed. Opcodes are employed in hardware devices such as arithmetic logic units (ALUs), central processing units (CPUs), and ...
s. (IL To CPU) is an AOT compiler that is written using a Common Intermediate Language
Common Intermediate Language (CIL), formerly called Microsoft Intermediate Language (MSIL) or Intermediate Language (IL), is the intermediate language binary instruction set defined within the Common Language Infrastructure (CLI) specification. ...
compliant language ( C#). It translates Common Intermediate Language
Common Intermediate Language (CIL), formerly called Microsoft Intermediate Language (MSIL) or Intermediate Language (IL), is the intermediate language binary instruction set defined within the Common Language Infrastructure (CLI) specification. ...
to machine code
In computer programming, machine code is computer code consisting of machine language instructions, which are used to control a computer's central processing unit (CPU). For conventional binary computers, machine code is the binaryOn nonb ...
.
X#
''X#'' is a low-level programming language
A programming language is a system of notation for writing computer programs.
Programming languages are described in terms of their Syntax (programming languages), syntax (form) and semantics (computer science), semantics (meaning), usually def ...
designed for the x86
x86 (also known as 80x86 or the 8086 family) is a family of complex instruction set computer (CISC) instruction set architectures initially developed by Intel, based on the 8086 microprocessor and its 8-bit-external-bus variant, the 8088. Th ...
processor architecture as part of Cosmos operating system. It aims to simplify operating system development by incorporating C-like language syntax
In linguistics, syntax ( ) is the study of how words and morphemes combine to form larger units such as phrases and sentences. Central concerns of syntax include word order, grammatical relations, hierarchical sentence structure (constituenc ...
to assembly language
In computing, assembly language (alternatively assembler language or symbolic machine code), often referred to simply as assembly and commonly abbreviated as ASM or asm, is any low-level programming language with a very strong correspondence bet ...
. Initially, X# was used for debugging services in Cosmos. The X# compiler is an open source
Open source is source code that is made freely available for possible modification and redistribution. Products include permission to use and view the source code, design documents, or content of the product. The open source model is a decentrali ...
command-line interface
A command-line interface (CLI) is a means of interacting with software via command (computing), commands each formatted as a line of text. Command-line interfaces emerged in the mid-1960s, on computer terminals, as an interactive and more user ...
(console) program that parses code lines into tokens, compares them with patterns, and translates matched patterns to intel syntax
x86 assembly language is a family of low-level programming languages that are used to produce object code for the x86 class of processors. These languages provide backward compatibility with CPUs dating back to the Intel 8008 microprocessor, in ...
x86 assembly, typically for the YASM assembler. Early versions of X# operated mostly 1:1 with assembly code, but this is no longer the case.
Syntax
The syntax of X# is straightforward but stricter compared to C.
Comments
X# supports only single-line comments in the C++ style, starting with - //
.
Constants
X# allows the definition of named constants declared outside functions. Numeric constants are defined similarly to C++; for example: const i = 0. Referencing them elsewhere requires a #
before the name; for example: - "#i"
.
* String
String or strings may refer to:
*String (structure), a long flexible structure made from threads twisted together, which is used to tie, bind, or hang other objects
Arts, entertainment, and media Films
* ''Strings'' (1991 film), a Canadian anim ...
constant use single quotes (''
). To include a single quote in a string constant, use a backslash (e.g.,'I\'m so happy'
). X# strings are null terminated.
* Hexadecimal constants are prefixed with a dollar sign ($
), followed by the constant. ($B8000
).
* Decimal constants are not prefixed but cannot start with 0
.
* Binary and octal constants aren't supported yet.
Labels
Labels in X# function similarly to labels in other assembly languages. The goto
mnemonic is used to jump to a label instead of the conventional jump
or jmp
mnemonic.
CodeLabel1:
goto CodeLabel2:
Namespaces
X# program files must start with a namespace directive. X# lacks a namespace hierarchy, so the current namespace changes with each directive until the file ends. Variables or constants in different namespaces can have the same name, as the namespace is prefixed to the member's name in the assembly output. Namespaces cannot reference each other except through low-level operations.
namespace FIRST
// Everything variable or constant name will be prefixed with FIRST and an underscore. Hence the true full name of the below variable
// is FIRST_aVar.
var aVar
namespace SECOND
// It's not a problem to name another variable aVar. Its true name is SECOND_aVar.
var aVar
namespace FIRST
// This code is now back to the FIRST namespace until the file ends.
Functions
All X# executive code should be placed in functions defined by the 'function' keyword. Unlike C, X# does not support any formal parameter declaration in the header of the functions, so the conventional parentheses after the function name are omitted. Because line-fixed patterns are specified in syntax implemented in code parser, the opening curly bracket can't be placed on the next line, unlike in many other C-style languages.
function xSharpFunction
Because X# is a low-level language, there are no stack frame
In computer science, a call stack is a stack data structure that stores information about the active subroutines and inline blocks of a computer program. This type of stack is also known as an execution stack, program stack, control stack, run- ...
s inserted, so by default, the return EIP address should be on the top of the stack. X# function calls do contain arguments enclosed in parentheses, unlike in function headers. Arguments passed to functions can be registers, addresses, or constants. These arguments are pushed onto the stack in reverse order. Note that the stack on x86 platforms cannot push or pop one-byte registers.
function xSharpFunction
function anotherFunction
The return
keyword returns execution to the return EIP address saved in the stack.
Arithmetic and bitwise operations
X# can work with three low-level data structures: the registers, the stack
Stack may refer to:
Places
* Stack Island, an island game reserve in Bass Strait, south-eastern Australia, in Tasmania’s Hunter Island Group
* Blue Stack Mountains, in Co. Donegal, Ireland
People
* Stack (surname) (including a list of people ...
and the memory
Memory is the faculty of the mind by which data or information is encoded, stored, and retrieved when needed. It is the retention of information over time for the purpose of influencing future action. If past events could not be remembe ...
, on different ports. The registers are the base of all normal operations for X#. A register can be copied to another by writing DST = SRC
as opposed to mov
or load/store instructions. Registers can be incremented or decremented just as easily. Arithmetic operations (add, subtract, multiply, divide) are written as dest op src
where src
is a constant, variable, or register, and dest
is both an operand and the location where the result is stored.
Examples of assignment and arithmetic operations are shown below.
ESI = 12345 // assign 12345 to ESI
EDX = #constantForEDX // assign #ConstantForEDX to EDX
EAX = EBX // move EBX to EAX => mov eax, ebx
EAX-- // decrement EAX => dec eax
EAX++ // increment EAX => inc eax
EAX + 2 // add 2 to eax => add eax, 2
EAX - $80 // subtract 0x80 from eax => sub eax, 0x80
BX * CX // multiply BX by CX => mul cx -- division, multiplication and modulo should preserve registers
CX / BX // divide CX by BX => div bx
CX mod BX // remainder of CX/BX to BX => div bx
Register shifting and rolling is similar to C.
DX << 10 // shift left by 10 bits
CX >> 8 // shift right by 8 bits
EAX <~ 6 // rotate left by 6 bits
EAX ~> 4 // rotate right by 4 bits
Other bitwise operations are similar to arithmetic operations.
DL & $08 // perform bitwise AND on DL with 0x08 and store the result in DL
CX , 1 // set the lowest bit of CX to 1 (make it odd)
EAX = ~ECX // perform bitwise NOT on ECX and store the result in EAX
EAX ^ EAX // erase EAX by XORing it with itself
Stack
Stack manipulation in X# is performed using +
and -
prefixes, where +
pushes a register, value, constant or all registers onto the stack and -
pops a value to some register. All constants are pushed on stack as double words, unless stated otherwise (pushing single bytes is not supported).
+ESI // push esi
-EDI // pop into edi
+All // save all registers => pushad
-All // load all registers => popad
+$1badboo2 // push 0x1badboo2 on the stack
+$cafe as word // \/
+$babe as word // push 0xcafebabe
+#VideoMemory // push value of constant VideoMemory
Variables
Variables
Variable may refer to:
Computer science
* Variable (computer science), a symbolic name associated with a value and whose associated value may be changed
Mathematics
* Variable (mathematics), a symbol that represents a quantity in a mathemat ...
are defined within namespaces using the var
keyword. Arrays
An array is a systematic arrangement of similar objects, usually in rows and columns.
Things called an array include:
{{TOC right
Music
* In twelve-tone and serial composition, the presentation of simultaneous twelve-tone sets such that the ...
are defined by specifying the type and size. Variables and arrays are zeroed by default. To reference a variable's value, use a dot ('.'), and to reference its address, use @
.
namespace XSharpVariables
var zeroVar // variable will be assigned zero
var myVar1 = $f000beef // variable will be assigned 0xf000beef
var someString = 'Hello XSharp!' // variable will be assigned 'Hello XSharp!\0',
var buffer byte 024 // variable of size 1024 bytes will be assigned 1024 zero bytes
...
EAX = .myVar1 // moves value of myVar1 (0xf000beef) to EAX
ESI = @.someString // moves address of someString to ESI
CL = .someString // moves first character of someString ('H') to CL
.zeroVar = EAX // assigns zeroVar to value of EAX
X# can access an address with a specified offset using square brackets:
var someString = 'Hello XSharp!' //variable will be assigned to 'Hello XSharp!\0'
...
ESI = @.someString // load address of someString to ESI
CL = 'B' // set CL to 'B' (rewrite 'H' on the start)
CH = ESI // move second character ('E') from string to CH
ESI = $00 // end string
//Value of someString will be 'Bell' (or 'Bell\0 XSharp!\0')
Comparison
There are two ways to compare values in X#: pure comparison and if-comparison.
*Pure comparison leaves the result in FLAGS, which can be used in native assembly or with the if
keyword without specifying comparison members.
*If comparison directly compares two members after an if
keyword.
Here are two ways of writing a (slow) X# string length (strlen
)function:
// Method 1: using pure comparison
function strlen {
ESI = ESP // get pointer to string passed as first argument
ECX ^ ECX // clear ECX
Loop:
AL = ESI CX/ get next character
AL ?= 0 // is it 0? save to FLAGS
if = return // if ZF is set, return
ECX++ // else increment ECX
goto Loop // loop...
//Way 2: using if
function strlen {
ESI = ESP // get pointer to string passed as first argument
ECX ^ ECX // clear ECX
Loop:
AL = ESI CX if AL = 0 return// AL = 0? return
ECX++
goto Loop // loop....
}
There are six available comparison operators: < > = <= >= !=
. These operators can be used in both comparisons and loops. Note that there's also a bitwise AND
In computer programming, a bitwise operation operates on a bit string, a bit array or a binary numeral (considered as a bit string) at the level of its individual bits. It is a fast and simple action, basic to the higher-level arithmetic operat ...
operator which tests bits:
AL ?& $80 // test AL MSB
if = return // if ZF is 0, test instruction resulted in 0 and MSB is not set.
Writing Cosmos code
An operating system built with Cosmos is developed in a similar fashion to any .NET C# console program. Additional references are made in the start of the program which give access to the Cosmos libraries.
User Kit and Visual Studio
The Cosmos User Kit is a part of Cosmos designed to make Cosmos easier to use for developers using Microsoft Visual Studio
Visual Studio is an integrated development environment (IDE) developed by Microsoft. It is used to develop computer programs including websites, web apps, web services and mobile apps. Visual Studio uses Microsoft software development platforms ...
. When installed, the user kit adds a new project type to Visual Studio
Visual Studio is an integrated development environment (IDE) developed by Microsoft. It is used to develop computer programs including web site, websites, web apps, web services and mobile apps. Visual Studio uses Microsoft software development ...
, called a Cosmos Project. This is a modified version of a console application, with the Cosmos compiler
In computing, a compiler is a computer program that Translator (computing), translates computer code written in one programming language (the ''source'' language) into another language (the ''target'' language). The name "compiler" is primaril ...
and bootup stub code already added.
Compiling a project
Once the code is complete, it may be compiled using Roslyn, the .NET
The .NET platform (pronounced as "''dot net"'') is a free and open-source, managed code, managed computer software framework for Microsoft Windows, Windows, Linux, and macOS operating systems. The project is mainly developed by Microsoft emplo ...
compiler, either via Microsoft Visual Studio
Visual Studio is an integrated development environment (IDE) developed by Microsoft. It is used to develop computer programs including websites, web apps, web services and mobile apps. Visual Studio uses Microsoft software development platforms ...
or the .NET command-line tools (dotnet).
This converts the application from the original source code ( C# or otherwise) into Common Intermediate Language
Common Intermediate Language (CIL), formerly called Microsoft Intermediate Language (MSIL) or Intermediate Language (IL), is the intermediate language binary instruction set defined within the Common Language Infrastructure (CLI) specification. ...
(CIL), the native intermediate language of .NET.
The build process then invokes the IL2CPU compiler which systematically scans through all of the application's CIL code (excluding the Cosmos compiler code), converting it into assembly language
In computing, assembly language (alternatively assembler language or symbolic machine code), often referred to simply as assembly and commonly abbreviated as ASM or asm, is any low-level programming language with a very strong correspondence bet ...
for the selected processor architecture. , only the x86
x86 (also known as 80x86 or the 8086 family) is a family of complex instruction set computer (CISC) instruction set architectures initially developed by Intel, based on the 8086 microprocessor and its 8-bit-external-bus variant, the 8088. Th ...
architecture is supported. Next, Cosmos invokes the selected assembler to convert this assembly language code into native central processing unit
A central processing unit (CPU), also called a central processor, main processor, or just processor, is the primary Processor (computing), processor in a given computer. Its electronic circuitry executes Instruction (computing), instructions ...
(CPU) opcode
In computing, an opcode (abbreviated from operation code) is an enumerated value that specifies the operation to be performed. Opcodes are employed in hardware devices such as arithmetic logic units (ALUs), central processing units (CPUs), and ...
. Finally, the desired output option is activated, be it starting a virtual machine, starting a PXE PXE may refer to:
Science and technology
* Pentium Extreme Edition, a variant of the Pentium D microprocessor
* Preboot Execution Environment, booting computers via a network
* Pseudoxanthoma elasticum, a genetic disease
Other uses
* Proof and Exp ...
engine, or producing an ISO disk image
A disk image is a snapshot of a storage device's content typically stored in a file on another storage device.
Traditionally, a disk image was relatively large because it was a bit-by-bit copy of every storage location of a device (i.e. every ...
file.
Debug options
Cosmos offers several options as to how to deploy the resulting OS and how to debug
In engineering, debugging is the process of finding the root cause, workarounds, and possible fixes for bugs.
For software, debugging tactics can involve interactive debugging, control flow analysis, log file analysis, monitoring at the ap ...
the output.
Virtualization
Cosmos allows users to boot the operating system
An operating system (OS) is system software that manages computer hardware and software resources, and provides common daemon (computing), services for computer programs.
Time-sharing operating systems scheduler (computing), schedule tasks for ...
in an emulated environment using a virtual machine
In computing, a virtual machine (VM) is the virtualization or emulator, emulation of a computer system. Virtual machines are based on computer architectures and provide the functionality of a physical computer. Their implementations may involve ...
. This lets developers test the system on their own computer without having to reboot, giving the advantages of not requiring extra hardware or that developers exit their integrated development environment
An integrated development environment (IDE) is a Application software, software application that provides comprehensive facilities for software development. An IDE normally consists of at least a source-code editor, build automation tools, an ...
(IDE). VMware is the primary virtualisation method, however others are supported such as QEMU
The Quick Emulator (QEMU) is a free and open-source emulator that uses dynamic binary translation to emulate a computer's processor; that is, it translates the emulated binary codes to an equivalent binary format which is executed by the mach ...
and Hyper-V.
Disk images
This option writes the operating system to a disk image
A disk image is a snapshot of a storage device's content typically stored in a file on another storage device.
Traditionally, a disk image was relatively large because it was a bit-by-bit copy of every storage location of a device (i.e. every ...
(ISO image
An optical disc image (or ISO image, from the ISO 9660 file system used with CD-ROM media) is a disk image that contains everything that would be written to an optical disc, disk sector by disc sector, including the optical disc file system. IS ...
) file, which can be loaded into some emulators (such as Bochs
Bochs (pronounced "box") is a portable IA-32 and x86-64 IBM PC compatible emulator and debugger mostly written in C++ and distributed as free software under the GNU Lesser General Public License. It supports emulation of the processor(s) (includ ...
, QEMU
The Quick Emulator (QEMU) is a free and open-source emulator that uses dynamic binary translation to emulate a computer's processor; that is, it translates the emulated binary codes to an equivalent binary format which is executed by the mach ...
or more commonly VMware) or written to a USB flash drive
A flash drive (also thumb drive, memory stick, and pen drive/pendrive) is a data storage device that includes flash memory with an integrated USB interface. A typical USB drive is removable, rewritable, and smaller than an optical disc, and u ...
and booted on physical hardware.
PXE network boot
This option allows the operating system to boot on physical hardware. The data is sent via a local area network
A local area network (LAN) is a computer network that interconnects computers within a limited area such as a residence, campus, or building, and has its network equipment and interconnects locally managed. LANs facilitate the distribution of da ...
(LAN) to the client
Client(s) or The Client may refer to:
* Client (business)
* Client (computing), hardware or software that accesses a remote service on another computer
* Customer or client, a recipient of goods or services in return for monetary or other valuable ...
machine. This requires two computers: one as the client machine (on which the OS is booted) and one as the server (usually the development machine). It also requires a network connecting the two computers, a client machine with a network card
A network interface controller (NIC, also known as a network interface card, network adapter, LAN adapter and physical network interface) is a computer hardware component that connects a computer to a computer network.
Early network interface ...
, and a Basic Input/Output System (BIOS
In computing, BIOS (, ; Basic Input/Output System, also known as the System BIOS, ROM BIOS, BIOS ROM or PC BIOS) is a type of firmware used to provide runtime services for operating systems and programs and to perform hardware initialization d ...
) that can boot with PXE. , debugging over a network is no longer supported.
See also
* IL2CPU
* .NET
The .NET platform (pronounced as "''dot net"'') is a free and open-source, managed code, managed computer software framework for Microsoft Windows, Windows, Linux, and macOS operating systems. The project is mainly developed by Microsoft emplo ...
* SharpOS
* Singularity (operating system)
Singularity is an experimental operating system developed by Microsoft Research between July 9, 2003, and February 7, 2015. It was designed as a high dependability OS in which the kernel, device drivers, and application software were all writte ...
* Phantom OS
Phantom OS is an Persistence_(computer_science)#Orthogonal_or_transparent_persistence, orthogonally persistent managed code general-purpose operating system. It is based on a concept of persistent virtual memory, and executes bytecode in a virt ...
References
External links
*
*
Cosmos Overview article at CodeProject
Cosmos Dev Yahoo Group
Cosmos Fan Page on Facebook
News coverage
Mary Jo Foley on ZDNet - Cosmos: An open-source .Net-based microkernel OS is born
Scott Hanselman: Tiny Managed Operating System Edition
{{Operating systems
Embedded operating systems
Operating system kernels
Free software operating systems
Beta software
X86 operating systems
.NET
Software using the BSD license