Skip to content

kernyan/KernOS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KernOS logo

KernOS

Table of contents

Project goal

To have a working well-documented Operating System code that lets the reader quickly find code implementation of a specific topic. Ultimately to have KernOS be programmable on RISCV FPGA softcore, and perform a wget. Thereby completing geohot's transistor to internet challenge

Documented topics

The doxygen documentation below is a good place to start exploring

For specific topics, use links below,

Status

Currently only supports

  • C++
  • x86 architecture

Milestones

2020 11 01 - Task switching

alt text

Currently working on supporting DMA/PIO disk access on PCI SATA. Next to port Fat32 filesystem prototyped in python to the OS.

Toolchain and qemu

Build i686-elf toolchain as below

cd Toolchain
./BuildToolchain.sh

Add path to ~/.profile or ~/.bashrc by

PATH="$HOME/opt/cross/bin:$PATH"

Get qemu from package manager. Or build from below if need to debug qemu, e.g. using rr

cd Qemu
./BuildQemu.sh

Build and run

Build kern.bin

# build kern.bin
mkdir build
pushd build
cmake ../OS
make -j$(nproc)

# build disk image
../Scripts/build-image-qemu.sh   # builds _disk_image and mount at mnt/
sudo ../Scripts/build-root-filesystem.sh  # upload content in KernOS/Disk to mnt/
popd

The kernel is still far from being deployable to actual hardware, but feel free to try. Disclaimer: do so at your own risk

Otherwise, here's the script to running it in qemu. Note that we are mounting _disk_image as AHCI SATA

cd build
qemu-system-i386 \
  -gdb tcp::1234 -S \
  -m 128M \
  -d cpu_reset,guest_errors \
  -device VGA,vgamem_mb=64 \
  -drive id=disk,file=_disk_image,if=none,format=raw \
  -device ahci,id=ahci\
  -device ide-hd,drive=disk,bus=ahci.0 \
  -kernel ../build/kern.bin

Or use

cd build
../Scripts/Mount

Test

Testing framework setup is unorthodox as

  1. I wanted access to standard libraries, and
  2. gtest required different toolchain

This led to a separate CMakeLists.txt in the Test directory.

To build and run test

cd KernOS/Test
mkdir build && cd build
cmake ../Tests
make && ctest

Debugging

Debugging requires running qemu with -S command to prevent CPU from starting, and exposing a port for gdb to attach to.

Here's the script to launch qemu for debug

cd KernOS/build
qemu-system-i386 \
-gdb tcp::1234 -S \
-m 128M \
-d cpu_reset,guest_errors \
-device VGA,vgamem_mb=64 \
-kernel kern.bin

and to attach from gdb

file kern.bin
target remote localhost:1234
break kernel_main
continue

About

Minimal feature educational operating system

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published