"If you want to travel around the world and be invited to speak at a lot of different places, just write a Unix operating system." ~ Linus Torvalds, creator of Linux
This repository contains the code for the operating system, KSOS, developed by the members of IIT Roorkee ACM Student Chapter. Get a prebuilt version of the latest release of KSOS here!
To know more about the development journey from the beginning, read our blog written by Suraaj. In the future, we will be releasing blogs highlighting the different core aspects of KSOS, so stay tuned!
- Introduction
- Build and Run from Source
- Changelog
- Getting Started
- Contribution Guidelines
- Potential Features
- Resources
- License
This OS is being built for an x86 architecture system using Legacy BIOS and was started from scratch in November 2019. It has been developed on a Debian-based Linux distribution. We emulate using qemu, a general-purpose CPU emulator.
We also write our very own Bootloader for Legacy BIOS. The bootloader handles the initial 16-bit CPU mode, preparing the switch to 32-bit protected mode. It also parses the filesystem and loads the kernel before passing control to it. The kernel has been implemented mostly in C.
Btw, what KSOS means shall remain a secret. 😉
This section will mainly explain how to build KSOS on a Debian-based Linux.
NOTE: If you just want to run the latest release of KSOS, you can download a prebuilt version from here. Simply run it using qemu-system-i386 disk.img
.
Make sure the following are installed before proceeding further:
- git :
sudo apt install git
- nasm (assembler):
sudo apt install nasm
- qemu (cpu emulator):
sudo apt install qemu
- make (build system):
sudo apt install make
If you are here to just try and test the OS, carry out these commands in Bash to get started:
- Clone this repository:
git clone https://github.com/acmiitr/KSOS.git
- Switch to the main directory of the repository:
cd KSOS
- If you already have a cross compiler installed, please skip this step. Run the script file for the same (only once, it takes time and around 2 gigs of memory!):
bash script.sh
- Restart the terminal.
- Do a fresh make of the OS:
make
A detailed explanation of each of the above-mentioned instructions are given below:
- Firstly, clone the repository.
- Switch to the main directory of the repository.
-
- If you already have a cross compiler installed, please skip this step!
- Ours is a 32-bit Operating System. We do not want to use your system compiler (which probably produces 64-bit binaries) and libraries to build this operating system. Hence, we build a cross compiler (we use the system compiler to make a custom compiler that produces 32-bit binaries. Yes, you read it right, we use a compiler to compile a compiler). If this went over your head, don't worry, a bash script comes along with the repository, and you just need to run the script. The script handles the rest!
- To build our cross compiler using the script, go to the directory where the script is stored and run
bash script.sh
. After this, you will have to restart the terminal. - If you don't believe that you need a cross compiler, read this and think again. Building the cross compiler will take time and around 2 GB of memory! After all, you are building an entirely new compiler.
-
- To build the OS, we need to compile the C code, assemble the assembly code, link them, make a file system on a disk, copy the kernel to the file system, make the file system bootable, and a lot more. Did you catch all that? xD
- Thankfully, all of this is done using a Makefile, which we can run using a single line:
make
. - And voila! It creates a
disk.img
file, which is the operating system. Pretty neat (it's only 1MB so far)!
-
- You can emulate KSOS using:
qemu-system-i386 disk.img
or even simplermake run
. - This results in a new window that runs KSOS. Enjoy the bright colors!
- You can emulate KSOS using:
- To run it directly on a PC without an emulator, you would need to have a Legacy BIOS system. Let's say you did have one lying around for 12+ years, follow the next instructions!
- First, we would have to copy it to a USB by plugging it into your system where you have built the OS and run:
sudo dd if=disk.img of=/dev/sdx
wheresdx
issda/sdb/sdc
depending on the output oflsblk
. - However, this would not work with UEFI systems (almost all of the systems nowadays). Porting to UEFI is something you could contribute to (see potential features).
- Then plug in your USB into the system, turn it on, and the OS boots up!
- Mini Standard Library
- User Mode
- FAT Filesystem Driver
- ATA Disk Driver
- Build System
- Interrupt Handler
- Timer
- Keyboard Driver
- Virtual Memory
- File System
- Video Driver
- Memory Manager
- Basic U/I: A Kernel Level Shell
Getting started with operating systems development is a bit tricky. Dr. Nick Blundell's book is a great resource to begin with, especially for bare-metal and bootloader programming.
BrokenThorn's OS Development series, although old, is really helpful. Most of the overall structure of the project was built from this resource.
If you have any issues, feel free to have discussions with the people at #osdev on freenode IRC, as well as the OSDev forums.
To get started with simple bare-metal programming, you can read Suraaj's blog.
Operating system development is debatably the most onerous task in programming, notably because of the complete absence of any "backend" that you can work upon. You are the complete backend. However, there is no need to be discouraged. If you want to contribute, you can look at some of the more straightforward problems that we have in the issues section.
To get started, you NEED to know how to build the OS from source. After that, it's just up to your imagination. The thing with operating systems is, you can do whatever you want. Feel free to discuss any ideas that you may have with us by opening an issue. 😃
Do not shy away from asking questions about KSOS, possible features to implement or operating systems in general on our Facebook Page.
Once you do find an issue or feature to contribute, please:
- Fork the repository.
- Create a new feature/bug branch.
- Follow the following commit guidelines: 1, 2.
- Submit a PR!
A lot of the work after v.1.0.0 release can now be done in C. Possible developments could include implementing:
- more general standard input/output functions
- file system (disk) driver
- graphics
- multitasking
- user-mode
Other major work to be done:
- Porting to UEFI OR using an existing Bootloader like GRUB
- Dr. Nick Blundell's book
- BrokenThorn's OS Development series
- The OSDev wiki
- The OSDev forums
- Official Intel Software Developer's Manual
- StackOverflow (obviously :P)
- #osdev on freenode IRC (try it, they're the best!)
This repository is licenced under MIT Licence
, see LICENCE.md.