- Notifications
You must be signed in to change notification settings - Fork3
32bit OS/kernel built from scratch with POSIX.1 compliance
License
chillancezen/ZeldaOS
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
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
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 withMakefile 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
There are two ways to launch the ZeldaOS:
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.1Copyright (c) 2018 Jie Zheng [at] VMware[Link@Hyrule.kingdom /home/zelda]# unamesysname : ZeldaOSnodename : Hyrulerelease : The Braveversion : 0.1machine : i686domain : 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 serial0FILE_TYPE_REGULAR 2000 ptm0FILE_TYPE_REGULAR 2000 ptm1FILE_TYPE_REGULAR 2000 ptm2FILE_TYPE_REGULAR 2000 ptm3FILE_TYPE_REGULAR 2000 ptm4FILE_TYPE_REGULAR 2000 ptm5FILE_TYPE_REGULAR 0 consoleFILE_TYPE_DIR 0 net./net:FILE_TYPE_MARK 0 .FILE_TYPE_REGULAR 0 Ethernet:0:3.0FILE_TYPE_REGULAR 0 Ethernet:0:4.0[Link@Hyrule.kingdom /usr/var]# tinyvm primes.vm23571113171923293137414347[Link@Hyrule.kingdom /home/zelda]# dummy0: Hello World1: Hello World^X[keyboard interrupted][Link@Hyrule.kingdom /home/zelda]#
In this case the kernel is booted by GRUB multiboot. you can burn theZelda.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):
When the kernel is fully ready, thedefault console
(which you can navigate to byAlt+F1
) is displayed, there are other 6 consoles initiated by/usr/bin/userland_init
, you can switch the console byAlt+F2 ... Alt+F7
, you will observe console as below:
- x86
- PIC, APIC will be supported inZeldaOS.x86_64.
- interrupt management.
- x86_64 64bit support.
- Symmetric multiprocessing (SMP).
- SSE/AVX context save and restore
- hypervisor to lauch a VM with Intel VT-x(VMX)
- physical memory management.
- 4K paging(No 3G barrier break) for both kernel and PL3 tasks.
- Virtual Memory Area(VMA) management(per-task VMAs and kernel VMAs).
- paging fault handling, including page non-presence and page permission fault.
- kernel memory allocator.
- multitasking (PL0 tasks and PL3 tasks).
- task signal framework.
- Elf32 executable loading.
- task exception detection(e.g. illegal instruction, #GP, paging permission violation).
- Wait queue.
- Timer.
- bottom half schedule.
- kernel panic.
- Virtual File System (VFS).
zeldafs
as initramfs in Linux.memfs
as tmpfs in Linux.devfs
to expose kernel runtime data to userland.
- net packets management.
- Ethernet device interface.
- L2 multi-bridging(VLAN+MAC learning).
- L3 multi-routing(ARP, ICMP).
- overlay support(vxlan).
- userland networking extension(LWIP).
- Legacy virtio-net ethernet device driver(with revisionid == 0).
- vmxnet3 ethernet device support.
- PS/2 keyboard management.
- Programmable Interval Timer(PIT) management.
- serial port input/output management and
serial console
. ATA/IDE drive management.- Lower level Text mode video buffer management.
pseudo terminal console
management.
- ZeldaOSruntime.
newlib
libc and libm port- dynamic programming language support
- language-level VM support: portTinyvm without modifying even one line of code.
system call list
signal list
- multipleApplications running at Privilege Level 3
About
32bit OS/kernel built from scratch with POSIX.1 compliance
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors2
Uh oh!
There was an error while loading.Please reload this page.