chillancezen / ZeldaOS

32bit OS/kernel built from scratch with POSIX.1 compliance
BSD 3-Clause "New" or "Revised" License
28 stars 2 forks source link
32bit kernel

ZeldaOS

Written in C&inline assembly from scratch, ZeldaOS is an unix-like 32bit monolithic kernel which is designed to comform to POSIX.1 interface. At present, it's only able to run on any x86 and x86_64 processors. The name Zelda is from Nintendo video game: The Legend of Zelda asciicast

How to Build The Project ?

To build the project, we need a 64bit Linux host (I used a CentOS 7.3) and GCC suite(my GCC version is 4.8.5, other versioned gcc are supposed to work), in order to package a bootable ISO image, I also install rpm package: #yum install -y xorriso. the compilation tools will automatically generate 32bit elf objects with Makefile and Linker script

To build the image and ISO image(imagine the project top directory is /root/ZeldaOS/):

#ZELDA=/root/ZeldaOS/ make runtime_install
#ZELDA=/root/ZeldaOS/ make app_install
#ZELDA=/root/ZeldaOS/ make drive
#ZELDA=/root/ZeldaOS/ make

To clean the built objects:

#ZELDA=/root/ZeldaOS/ make runtime_clean
#ZELDA=/root/ZeldaOS/ make app_clean
#ZELDA=/root/ZeldaOS/ make clean

How to Launch the OS/kernel ?

There are two ways to launch the ZeldaOS:

(a) Launch ZeldaOS via the Zelda.bin raw kernel image.

this is the most usual way I did when I was debuging the code. you need to install qemu software beforehand, a typical command is given like:

#/usr/bin/qemu-system-x86_64 -serial tcp::4444,server -m 3024 -kernel Zelda.bin \
-monitor null -nographic -vnc :100 -netdev tap,id=demonet0,ifname=demotap0,script=no,downscript=no \
-device virtio-net-pci,netdev=demonet0,mac=52:53:54:55:56:00 \
-netdev tap,id=demonet1,ifname=demotap1,script=no,downscript=no \
-device virtio-net-pci,netdev=demonet1 -gdb tcp::5070

you can specify more different -serial parameter(qemu mannual) to observe the output or input. right here you can use the shell by telnet to local qemu serial endpoint:

#telnet localhost 4444
....(omitted)
Welcome to ZeldaOS Version 0.1
Copyright (c) 2018 Jie Zheng [at] VMware

[Link@Hyrule.kingdom /home/zelda]# uname
sysname  : ZeldaOS
nodename : Hyrule
release  : The Brave
version  : 0.1
machine  : i686
domain   : kingdom
[Link@Hyrule.kingdom /home/zelda]#
[Link@Hyrule.kingdom /home/zelda]# ps
    0 PL0:0x1060f6   kernel_idle_task          running                   /
    1 PL3:0x40000c27 /usr/bin/userland_init    interruptible             /
    2 PL0:0x104664   wq:ethernet_rx            interruptible             /
    3 PL3:0x400013c8 /usr/bin/shelld           interruptible             /home/zelda
    4 PL3:0x400013c8 /usr/bin/shelld           interruptible             /home/zelda
    5 PL3:0x400013c8 /usr/bin/shelld           interruptible             /home/zelda
    6 PL3:0x400013c8 /usr/bin/shelld           interruptible             /home/zelda
    7 PL3:0x400013c8 /usr/bin/shelld           interruptible             /home/zelda
    8 PL3:0x400013c8 /usr/bin/shelld           interruptible             /home/zelda
    9 PL3:0x400013c8 /usr/bin/shelld           interruptible             /home/zelda
   10 PL3:0x40000b24 ps                        running                   /home/zelda
[Link@Hyrule.kingdom /dev]# ls -la ./ ./net
./:
FILE_TYPE_MARK        0        .
FILE_TYPE_REGULAR     0        serial0
FILE_TYPE_REGULAR     2000     ptm0
FILE_TYPE_REGULAR     2000     ptm1
FILE_TYPE_REGULAR     2000     ptm2
FILE_TYPE_REGULAR     2000     ptm3
FILE_TYPE_REGULAR     2000     ptm4
FILE_TYPE_REGULAR     2000     ptm5
FILE_TYPE_REGULAR     0        console
FILE_TYPE_DIR         0        net

./net:
FILE_TYPE_MARK        0        .
FILE_TYPE_REGULAR     0        Ethernet:0:3.0
FILE_TYPE_REGULAR     0        Ethernet:0:4.0
[Link@Hyrule.kingdom /usr/var]# tinyvm primes.vm
2
3
5
7
11
13
17
19
23
29
31
37
41
43
47
[Link@Hyrule.kingdom /home/zelda]# dummy
0: Hello World
1: Hello World
^X
[keyboard interrupted]
[Link@Hyrule.kingdom /home/zelda]#

(b) Launch ZeldaOS via the Zelda.iso bootable image or hard drive.

In this case the kernel is booted by GRUB multiboot. you can burn the Zelda.iso into a udisk drive or hard drive from which you can boot the kernel. we have the splash window when the kernel boots(grub draws it): image_of_splash

When the kernel is fully ready, the default console (which you can navigate to by Alt+F1) is displayed, there are other 6 consoles initiated by /usr/bin/userland_init, you can switch the console by Alt+F2 ... Alt+F7, you will observe console as below:

image_of_console0

Feature inventory

Archeticture Features: