Create Your Own Operating System - Step 0 - Introduction
One of the most challenging tasks in computer programming is developing an OS and frankly, is not for everyone except the most hard core geekheads among you.
In order to start with creating your very own OS let us start by viewing the basic definitions of what a BIOS or boot loader is and does.
An operating system (OS) is a piece of software that communicates with hardware and user input devices to give the user a platform to execute common tasks. An OS has several components, the boot loader, a system core, and various other software, from simple text and graphics editing to complex data processing and are available in various flavours and platforms.
The BIOS or basic input/output system is a skeletal OS which is in-built in every computer. The primary function of the BIOS is to load the Master Boot Record, a 512 byte section at the start of the boot media. The media to boot, whether, floppy, hard drive, or USB stick can be chosen through the BIOS interface.
An operating system has to communicate with hardware like keyboard, graphics, and network drivers and this is only achieved using machine language of 1's and 0's. Assembly Language (ASM) effectively and conveniently translates mnemonics into binary strings, like “MOV ax,30” by using a set of registers one of which is the accumulator and contains the current instruction (binary) to execute.
The boot process essentially searches for which media is bootable whether hard drive, CD-ROM, or other and loads 512 bytes of instructions from the boot sector to perform initialization and checks with CD-ROM, hard-disk, keyboard, and motherboard components.
Developing an OS with a graphical user interface (GUI) involves a lot more labour and knowledge of programming languages like C, C++, C#, Python, among others and unlike Assembly Language code these are compiled languages which means an additional tool called a compiler is needed to produce the machine language instructions in byte code. Fortunately, you don't need to know all these languages!
Creating your own OS from scratch can be done on any platform, but is easiest on the free Linux platform.
It is possible to develop a Linux based “Hello World” operating system using only a few hundred lines of ASM and C code. However, there is a catch. The GNU Compiler Collection (GCC) produces executable for the operating system it is installed on and not the operating system that is being developed. So, a cross-compiler needs to be implemented using GCC and GNU Binutils, after which an OS which only prints “Hello World” to the screen is easy enough to implement, but adding functionality is one of the hardest tasks there is.
To test your OS you can use an emulator program such as QEMU. You can also test on actual device if you create a disk image and write it to a bootable portion of the memory.
Follow the tutorials listed in the references section to get up and running with an OS of your own.
There is sample code available and the steps are roughly similar to the ones listed above – create boot disk, code functionality in a language of your choice, compile, create disk image optionally, and reboot.
Creating your own OS has become slightly easier of recent times because numerous open source implementations becoming available, such as Cosmos which uses C# and Visual Studio as build tool.
- Creating your own Hello World Operating System - https://cs.au.dk/~sortie/dopsys/osdev/
- Create Your Own Operating System! - http://www.instructables.com/id/Create-your-own-operating-system/
- Building your own operating system - https://www.codeproject.com/Articles/15843/Building-your-own-operating-system
- C# Open Source Managed Operating System - https://cosmos.codeplex.com/