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
cd KernOS
mkdir build && cd build
cmake ../OS
make
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
cd KernOS/build
qemu-system-i386 \
-m 128M \
-d cpu_reset,guest_errors \
-device VGA,vgamem_mb=64 \
-kernel kern.bin
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