IBNOS
|
IBNOS is a research operating system written by Michael Müller and Sebstian Lackner to demonstrate how the basics of x86 operating systems work. The focus of the development lies on the kernel which is still in its early beta stage but already supports the following features:
The aim is to provide easy to understand and extendable code - not reaching the best performance or to compete with real-world operating systems. Although the feature set is still quite limited, the kernel already has some unique features, for example all handles are represented as an object for which you can wait. This makes it possible to write programs in a very efficient way as you can wait for threads, pipes, keyboard input or processes with just a single syscall.
To make testing easier IBNOS also contains a user land part consisting of a C library, some wrappers for syscalls and a tiny shell. This should make it easier to port POSIX applications in the future.
To be able to build the kernel and the userland you need a cross compiler. As this might be a bit complicated for someone starting with OS development, we also provide a prepared VM image with all required tools directly for download. Alternatively you can also follow the instructions for installing and compiling everything on your own. The instructions are targeting Debian based systems like Ubuntu / Linux Mint, but should also apply to any other linux distribution, you just need to replace the package names and package manager command.
We provide a hard disk image for VirtualBox which you can download here. It contains a Lubuntu 14.04 installation with all required utilities and files. The username and password is "ibnos", though you will only need it if you want to install additional software.
To use the image in VirtualBox simply create a new VM and select Ubuntu as Operating System. When VirtualBox asks you whether you want to create a new harddisk, select the downloaded image file (after extracting it) and leave everything else to its default values.
When you start the VM, you should get directly to the desktop of Lubuntu. Now open a terminal, change to the "ibnos" folder with "cd" and type the following commands to update the code to the newest version, create the iso image and start the OS in a VM:
git pull make boch -f bochs.cfg
You should now see IBNOS doing its work. For more information about these commands take a look at the following sections.
IBNOS is split across several files which represent self-containing units of the OS like threads or memory. We therefore recommend to use an editor which shows a list of files in the sidebar so that you can easily switch between them. One example for such an editor is Geany (which is already preinstalled), but feel free to use a different one.
Before you can start you need to install some basic build utilities like gcc or make plus the build dependencies for the cross compiler itself. After you've successfully build your compiler, you also need some tools like doxygen for creating a html documentation or mkisofs to create a bootable iso file. We also recommend to download the source code of the OS via git. On Debian based systems you can install the necessary packages with the following command:
sudo apt-get install build-essential bison flex libgmp-dev libmpfr-dev libmpc-dev git doxygen genisoimage
Now simply execute the following commands (don't copy&paste multiple lines at the same time!) to compile and install gcc to your home directory:
export PREFIX="$HOME/opt/cross" export TARGET=i586-elf export PATH="$PREFIX/bin:$PATH" # Create working directory mkdir cross cd cross # Binutils wget http://ftp.gnu.org/gnu/binutils/binutils-2.24.tar.gz tar -xf binutils-2.24.tar.gz mkdir build-binutils cd build-binutils ../binutils-2.24/configure --target=$TARGET --prefix="$PREFIX" --disable-nls make make install cd .. # GCC wget ftp://ftp.fu-berlin.de/unix/languages/gcc/releases/gcc-4.8.2/gcc-4.8.2.tar.bz2 tar -xf gcc-4.8.2.tar.bz2 mkdir build-gcc cd build-gcc ../gcc-4.8.2/configure --target=$TARGET --prefix="$PREFIX" --disable-nls --enable-languages=c,c++ --without-headers make all-gcc -j4 make all-target-libgcc -j4 make install-gcc make install-target-libgcc cd ../..
If everything worked as expected you can delete the "cross" directory. The compiled files should now be placed under ~/opt/cross inside your home directory. Whenever you want to use the compiler, i.e when building the OS, you must first execute:
export PATH="$HOME/opt/cross/bin:$PATH"
Alternatively, you can also add the command to your .bashrc.
The next step is to download the source code for the operating system itself. The easiest way is to use git to clone our repository and you have everything you need:
git clone https://bitbucket.org/mmueller2012/ibnos.git
Now change to the ibnos directory and run "make". After some seconds you should get a file called ibnos.iso which can be booted in a VM. You can use the "make" command at any time if you have changed something and want to rebuild the VM image.
The generated ISO file can now be plugged into a VM or a real machine. We recommend to test it in a VM, as it is (although extremely unlikely) not impossible to destroy your hardware by sending malformed data to it.
There are a lot of different x86 emulators out there, but Bochs and Qemu are better suited for OS development then the usual ones (Virtualbox, VMware, ...) since they support emulating a x86 CPU in software. This gives additional debugging possibilities and moreover Bochs shows some additional information when you manage to trigger a fatal error.
On Debian based systems you can install both programs with the following commands:
sudo apt-get install bochs-sdl qemu-system
These programs are already preinstalled in the ready-to-use VM.
Now you can use the following commands to start IBNOS in a VM (You must be inside the source directory!):
Bochs:
bochs -f bochs.cfg
Qemu:
qemu-system-i386 -m 128 -cdrom ibnos.iso -boot c
After pressing enter / return in the Bootloader the OS should start.
The Kernel will perform the following steps when the system is booted
For more information about these steps and the rest of the OS, please take a look at the according modules:
Afterwards the main purpose of this (and also any other) operating system is to provide a set of syscalls, which allows user mode applications to interact with the hardware in an abstract way. User mode applications don't have to care about the total amount of memory in the system or how to isolate different tasks from each other - this is all done transparently by the operating system.
The concepts currently available for usermode applications are:
For a more complete list, take a look at the modules page!
IBNOS uses a system to automatically generate Makefiles from within the Makefile itself. This makes it possible to add new files or includes without worrying about changing Makefile entries. A simple call to "make" should always create an up to date iso file (or "make doc" to update the html documentation). If you want to add a new directory, simply copy a Makefile from a different directory with the same directory depth (or correct the path to the config.mk file manually). Now you should know everything you need to add files and start altering the kernel. In case you never worked on an OS so far, here are some things you need to pay attention to:
This said, we wish you much fun hacking on our code :-)