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
The doxygen documentation below is a good place to start exploring
For specific topics, use links below,
- linking kernel
- VGA display
- Global constructor
- Kernel memory allocator
- Streaming SIMD extension initialization
- Global descriptor table
- Exception and interrupt handler
- Paging
- Task switching
- PCI - SATA (in progress)
- Unit testing
Currently only supports
- C++
- x86 architecture
2020 11 01 - Task switching
Currently working on supporting DMA/PIO disk access on PCI SATA. Next to port Fat32 filesystem prototyped in python to the OS.
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 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
Testing framework setup is unorthodox as
- I wanted access to standard libraries, and
- 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 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