• Stars
    star
    604
  • Rank 71,680 (Top 2 %)
  • Language
    Nim
  • License
    Other
  • Created almost 11 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A small kernel written in Nim

nimkernel

This is a small 32bit (i686) 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 i686
  • Nim 1.6.0 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 https://ftp.gnu.org/gnu/binutils/binutils-2.37.tar.xz
$ tar -xJf binutils-2.37.tar.xz
$ cd binutils-2.37
$ mkdir build && cd build
$ ../configure --target=i686-elf --prefix=$HOME/cross-tools/ --with-sysroot --disable-nls --disable-werror
$ make -j$(nproc)
$ make install

You may then grab the GCC source and build it:

$ wget https://ftp.gnu.org/gnu/gcc/gcc-11.2.0/gcc-11.2.0.tar.xz
$ tar -xJf gcc-11.2.0.tar.xz
$ cd gcc-11.2.0
$ mkdir build && cd build
$ ../configure --target=i686-elf --prefix=$HOME/cross-tools/ --disable-nls --enable-languages=c --without-headers
$ make all-gcc -j$(nproc)
$ make all-target-libgcc -j$(nproc)
$ make install-gcc
$ make install-target-libgcc

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

export PATH=$PATH:$HOME/cross-tools/bin

Downloading cross compiler binaries

If for some reason you either can't or don't want to build your own toolchain you can grab binaries from https://github.com/lordmilko/i686-elf-tools/releases

Please note that these are a bit outdated but they are confirmed to work.

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.

More Repositories

1

jester

A sinatra-like web framework for Nim.
Nim
1,539
star
2

choosenim

Tool for easily installing and managing multiple versions of the Nim programming language.
Nim
662
star
3

httpbeast

A highly performant, multi-threaded HTTP 1.1 server written in Nim.
Nim
435
star
4

Aporia

IDE/Advanced text editor mainly focusing on support for the Nim programming language.
Nim
383
star
5

snake

A little snake game in Nim
Nim
203
star
6

nim-in-action-code

Nim in Action code samples
Nim
193
star
7

deauther

An interactive command-line deauther for macOS.
Nim
71
star
8

nim-opencv

Nim OpenCV wrapper
Nim
55
star
9

ipsumgenera

Static blog generator written in Nim
Nim
50
star
10

webdriver

Nim
46
star
11

gamelight

A set of simple modules for writing 2D games targeting JS/Android/iOS in Nim.
Nim
41
star
12

SimpleIRC

IRC Library for Haskell
Haskell
36
star
13

nimbox

Fork of https://notabug.org/vktec/nimbox
Nim
30
star
14

untar

Nim library for decompressing tar.gz files.
Nim
29
star
15

nael

Stack-based language similar to Factor.
Nim
26
star
16

prometheus

Prometheus instrumentation library for Nim
Nim
26
star
17

binary_size

Shell
21
star
18

irc

Nim IRC module
Nim
21
star
19

notifications

A small library for displaying notifications
Nim
17
star
20

gbemulator

GameBoy emulator written in Nim
Nim
16
star
21

pycloud

Experimental Pyodide fork which works in Cloudflare Workers
JavaScript
14
star
22

ElysiaBot

Modular Haskell IRC Bot
Haskell
12
star
23

nimbuild

Nim's build farm
Nim
12
star
24

sass

Nim bindings to the libsass C++ library
Nim
12
star
25

texttospeech

A Nim client for the Google Cloud Text to Speech API.
Nim
11
star
26

osinfo

Modules providing information about the OS for Nim
Nim
10
star
27

nim-jsonrpc

Nim
9
star
28

webasmio

A prototype library for selectively compiling Nim functions into Web Assembly
Nim
9
star
29

aoc2019

Advent of Code 2019 in Nim
Nim
7
star
30

analytics

A Google Analytics reporting library for Nim
Nim
7
star
31

tictactoe-rs

Tic Tac Toe in Rust
Rust
6
star
32

chirper.picheta.me

Browser extension which integrates Mastodon with Twitter.
HTML
6
star
33

xchat-exaile-script

A script which announces the currently played song in exaile. For xchat.
Python
5
star
34

stock_notifier

Nim
4
star
35

pwned

A client for the Pwned passwords API.
Nim
4
star
36

GeneticAlgorithms

Genetic algorithm experiments
Python
3
star
37

andromeda

ogame clone written in haskell
3
star
38

nyx

Old Python GTK IRC Client
Python
3
star
39

pb

Simple command line pastebin app.
Haskell
3
star
40

c4hbot

An IRC bot which lets you play Card Against Humanity. Written in Nim.
Nim
3
star
41

DynreckIRC

Lightweight, efficient and fast Python IRC Library
Python
2
star
42

vec

Nim
2
star
43

nim-urbanterror

Nimrod module for communicating with Urban Terror servers over UDP.
Nim
2
star
44

ld43

Nim
2
star
45

ld40

Nim
2
star
46

geckodriver-travis

Barebones example showing how to test a Jester app on Travis with Gecko driver.
Nim
2
star
47

MDSBot

Modular IRC Bot made in Python
Python
2
star
48

himari

My crappy toy OS
C
2
star
49

radiotap

Nim
2
star
50

dom96.github.com

2
star
51

adventofcode

Nim
2
star
52

nimrod-on-android

Attempt to run nimrod on the android platform
C
2
star
53

tinyrenderer.nim

C++
2
star
54

libclang

Nim
1
star
55

turingsim

Turing simulator written in Nim. Inspired by QUB's CSC2005.
Nim
1
star
56

qub-university-codesmash

http://shopkeep.github.io/qub-university-codesmash
Ruby
1
star
57

futurehack

It's a game thing.
C++
1
star
58

AELC

AEL(Awesome Esoteric Language) Interpreter
1
star
59

arduino

Messy repo with various Arduino experiments.
C++
1
star
60

oui

Parser for the official OUI file.
Nim
1
star
61

log2html

Tool for gathering information from HTTP server access logs.
1
star
62

corewlan

Nim
1
star
63

CSC-Java

Java
1
star
64

RPNCalc

A Reverse Polish Notation calculator made in various languages
Haskell
1
star
65

relnotesgen

Release notes generator
Nim
1
star
66

pyodide-worker-hello-world

Template to run Python via Pyodide on Cloudflare Workers
JavaScript
1
star