Are you happy with your logging solution? Would you help us out by taking a 30-second survey? Click here

nimkernel

A small kernel written in Nim

Subscribe to updates I use nimkernel


Statistics on nimkernel

Number of watchers on Github 297
Number of open issues 1
Average time to close an issue 8 days
Main language Nimrod
Average time to merge a PR about 9 hours
Open pull requests 0+
Closed pull requests 0+
Last commit about 4 years ago
Repo Created almost 7 years ago
Repo Last Updated about 2 years ago
Size 11 KB
Organization / Authordom96
Contributors2
Page Updated
Do you use nimkernel? Leave a review!
View nimkernel activity
View on github
Fresh, new opensource launches 🚀🚀🚀
Trendy new open source projects in your inbox! View examples

Subscribe to our mailing list

Evaluating nimkernel for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)

nimkernel

This is a small 32bit (i586) kernel written using the Nim programming language.

I have been wanting to do this for a while but it wasn't until people in the #nim IRC channel inquired about Nim OS dev and the rustboot kernel inspired me that I finally did it.

It doesn't do much, but it doesn't need to. Its purpose is to provide a starting point for anyone wishing to write an OS in Nim.

It still manages to do a little more than fill a screen with a certain color. Nimkernel implements:

  • A writeString function which shows a string on screen in a specified position.
  • A rainbow function which shows a string with a rainbow-like text foreground color differentiation in a specified position.
  • Some simple error handling by implementing Nim system.nim's panic function.
  • Support for 16 colors with a brilliant type safe API!

Note: The error at the bottom is intentional, it is used to show that the error handling works properly.

Setup

You are required to have:

  • QEMU
  • a C and asm cross-compiler for i586
  • Nim 0.10.2 or higher
  • nimble (*)

* You can always grab the nake library manually from here.

Linux

I have performed this setup on a Arch Linux machine, but all other distros should work too.

Building a cross compiler

For more information take a look at the OSDev article.

You will need to download the source of binutils and gcc.

First cd into a suitable directory in which you would like to download, unzip and build the cross compiler. Then perform the following actions:

$ wget ftp://sourceware.org/pub/binutils/snapshots/binutils-2.24.51.tar.bz2
$ tar -xf binutils-2.24.51.tar.bz2
$ mkdir build
$ ./binutils-2.24.51/configure --target=i586-elf --prefix=$PWD/build/ --disable-nls
$ make -j4
$ make install

Note: I did not use the binutils suggested by the osdev article as they did not build for me, YMMV.

You may then grab the GCC source and build it:

$ wget ftp://ftp.gnu.org/gnu/gcc/gcc-4.9.2/gcc-4.9.2.tar.bz2
$ tar -xf gcc-4.9.2.tar.bz2
$ ./gcc-4.9.2/configure --target=i586-elf --prefix=$PWD/build/ --disable-nls --enable-languages=c --without-headers
$ make all-gcc -j4
$ make install-gcc

You should then have a i586-elf-gcc and i586-elf-as executable in $PWD/build/bin/ or somewhere thereabouts. You should then add it to your PATH permanently or temporarily by doing:

export PATH=$PATH:$PWD/build/bin

Nim setup

Follow the instructions in the Nim repo to bootstrap Nim and put it in your PATH.

Do the same for nimble and install nake by executing nimble install nake or alternatively just save nake into the root dir of this repo.

You can then compile the nakefile and therefore compile nimkernel:

$ nim c nakefile
$ ./nakefile run

This will automatically build and run the kernel using QEMU.

License

Nimkernel is licensed under the MIT license.

nimkernel list of languages used
More projects by dom96 View all
Other projects in Nimrod