KFS Series
This monolithic kernel will target the i386 (x86) architecture and will be developed in C and Rust, thanks to ABI compatibility, which enables interoperability between the two languages.
Summary
This documentation presents the key components and core concepts behind building this kernel. Each module is documented and available on GitHub, where versions roughly correspond to each iteration. Aimed at hobbyist to advanced programmers, it is not a step-by-step tutorial but rather a holistic overview. Many well-known OS development resources, while rich in content, tend to be heavily compartmentalized like wikis, lacking a broader perspective. This documentation fills that gap by offering a synthesized, big-picture understanding of the subject.
Boot sequence primitives: A bootable kernel loaded by GRUB, built on an assembly entry point, with a minimal library providing basic types and utility functions. It writes to VGA for screen output. We also configure and load the GDT and IDT to handle keyboard interrupts.
Memory: A complete memory code structure with pagination handling, Read and write rights on memory, User space memory and kernel space memory, Physical and virtual memory, Code helpers for physical memory like
kmalloc,kfree,ksize,kbrk, Code helpers for virtual memory likevmalloc,vfree,vsize,vbrk, Kernel panic handling.Interrupts: Hardware interrupts, Software interrupts, An interrupts descriptor table, Signal handling and scheduling, Global panic fault handling, Registers cleaning, Stack saving
Processes: Basic data structure for processes, Process interconnection such as kinship, signals, and sockets, Process owner, Rights on processes, Helpers for the following syscalls: fork, wait, _exit, getuid, signal, kill, Process interruptions, Process memory separation, Multitasking
Filesystem: A complete interface to read/write an IDE, A complete interface to read/write/delete an ext2 filesystem, A basic file tree (/sys, /var, /dev, /proc, /sys)
syscalls, sockets and env: A complete syscall table with a syscall system, A complete Unix environment, User accounts with login and password, Password protection, Inter-process communication socket, A Unix-like filesystem hierarchy
Modules: Registering kernel modules (creation/destruction), Loading modules at boot time, Implementing functions for communication/callback between the kernel and the modules
ELF: A complete interface to read, parse, store, and execute ELF files, Syscalls to read ELF files and launch a process with them, A kernel module in ELF, ready to be inserted at run time
The End: Fully functional basic binaries (/bin/*), Libc, A POSIX shell
Kernel definition
A kernel is the core of an operating system. It's the fundamental program that bridges the gap between hardware and the software you use.
The kernel manages your machine's resources without needing to know the technical details of the hardware.
The kernel runs in "privileged mode" (kernel space) with full hardware access, while applications run in "user space" with restrictions. When an app needs hardware access, it makes a "system call" to ask the kernel to handle it.
Common examples of kernels include Linux, which is open source and monolithic, Windows NT which is hybrid, and XNU which powers macOS and is based on Mach and BSD.
Below, I’m providing the definition from the famous OSDev wiki, which is interesting and more intuitive to read.
The kernel of an operating system is something you will never see. It basically enables any other programs to execute. It handles events generated by hardware (called interrupts) and software (called system calls), and manages access to resources.
The hardware event handlers (interrupt handlers) will for instance get the number of the key you just pressed, and convert it to the corresponding character stored in a buffer so some program can retrieve it.
The system calls are initiated by user-level programs, for opening files, starting other programs, etc. Each system call handler will have to check whether the arguments passed are valid, then perform the internal operation to complete the request.
Most user programs do not directly issue system calls (except for asm programs, for instance), but instead use a standard library which does the ugly job of formatting arguments as required by the kernel and generating the system call. (For example, the C function fopen() eventually calls a kernel function that actually opens the file.)
The kernel usually defines a few abstractions like files, processes, sockets, directories, etc. which correspond to an internal state it remembers about last operations, so that a program may issue a session of operation more efficiently.
References
Last updated