sonald / sos

Sian's Operating System
Other
59 stars 14 forks source link
kernel operating-system os-kernel xv6

logo

sos

Sian's experimenting Operating System written in C++. it's a 32bit os kernel and runs on uniprocessor.

screenshot

BUILD

Like makefile indicated, this is a x86 kernel, and you need a i686 gcc cross compiler for building and running it. see here for the information. I think it also works under a 32bit GNU/Linux distribution. you may need to specify -Wl,--build-id=none for successful compiling. The kernel follows multiboot protocol and need a hd img with grub2 preinstalled. Here is a premade image for testing.

Refs

xv6 is a great reference implementation of a unix style kernel. linux 0.11 is also worth reading, and I learned a lot from these projects. You can find a lot of info about writing an small os kernel here.

Notes

One of the hardest as far as I can tell is memory management. I do implement my own kmalloc/kfree based on a simple algorithm. The way I choose to manage memory (both physical and virtual) makes some thing hard to implement, i.e shared memory region.

Another thing is task switch. There are many ways to do this, xv6's way or old linux way or your own method.

When design other parts of the kernel, you can stick to the unix tradition or just go bold and invent your own.

How to make a hd.img

This works under modern GNU/Linux (tested on Deepin 15). make disk image, then use parted (or fdisk to format as msdos)

dd if=/dev/zero of=hd.img bs=1M count=500
sudo parted hd.img mklabel msdos
sudo parted hd.img mkpart primary fat32 0% 100%

bind loop device (fat32 partition will be /dev/loop0p1) and mkfs

sudo losetup -f -P -v hd.img
sudo mkfs.vfat -F 32 /dev/loop0p1

then mount fat32 partition and install grub2:

sudo mount /dev/loop0p1 /mnt
sudo grub-install --modules="fat biosdisk normal part_msdos ext2 multiboot" --root-directory=/mnt /dev/loop0

TODOs

ISSUSE