This is our repository for 42's kfs (kernel from scratch) project. The aim is to build
a fully functional 32-bit kernel.
git clone git@github.com:kentucky-fried-kernel/kfs.git && cd kfssudo apt update && \
sudo apt install \
build-essential \
grub2 \
xorriso \
qemu-system-x86 \
gcc-multilib \
mtools
# For compatibility with MacPorts, the linker used by rustc
# is named i386-elf-ld (the default MacOS ld is not compatible
# with 32-bit ELF)
cp $(which ld) /bin/i386-elf-ldMacOS installation may require additional steps not documented here. Please follow any error messages encountered during setup to identify missing dependencies, and it would be highly appreciated if you open an issue about it so I can fix the docs.
Install i386-elf-gcc
sudo port install i386-elf-gccInstall QEMU
brew install qemuFor NixOs or other x86 linux systems that have the nix package manager installed just this command in the kfs directory.
nix-shellYou should be put into a nix-shell with all dependencies installed.
You can now run make run, which will run the kernel in a qemu window.
This project is separated into 10 subprojects.
- kfs-1
- Bootable via GRUB
- ASM multiboot header
- Basic kernel library
- Basic code to print stuff on the screen
- Scroll and cursor support
- I/O interface with colors support
- Handles keyboard entries
- Handles different screens with shortcuts to switch between them
- kfs-2
- Implements Global Descriptor Table (GDT)
- Kernel Code
- Kernel Data
- Kernel Stack
- User Code
- User Data
- User Stack
- GDT must be set at address 0x000008000
- Tool to print the kernel stack
- Basic shell with commands like
reboot,halt, etc.
- Implements Global Descriptor Table (GDT)
- kfs-3
- Complete memory code structure with pagination
- Read/Write operations on memory
- User Space and Kernel Space memory
- Physical and Virtual memory
- Allocators
- Kernel Panic handling
- kfs-4
- Hardware Interrupts
- Software Interrupts
- Interrup Descriptor Table (IDT)
- Signal Handling and Scheduling
- Global Panic Fault handling
- Panic & System Exit commands
- Registers cleaning
- Stack saving
- Base functions for syscalls
- Different keyboard layouts
- kfs-5
- Basic data structure for processes
- Process interconnection (signals, sockets, etc.)
- Process owner
- Process rights
- Process interruptions
- Process memory separation
- Multitasking
-
mmap - Link IDT and processes
- BSS and Data sectors in the process structure
- kfs-6
- IDE
- Read/Write/Delete an
ext2filesystem - Basic file tree (
/sys,/var,/dev,/proc) - Multiple partitions
- Users
- kfs-7
- Complete syscall table
- Complete Unix environment
- Password protection
- Inter-Process Communication socket
- Unix-like filesystem hierarchy
- Console environments
- kfs-8
- Kernel modules
- Loading modules at boot time
- Functions for communication / callback between kernel and modules
- Special memory allocator functions to create memory ring dedicated to the modules
- kfs-9
- Complete interface to read, parse and execute ELF files
- Syscalls to read ELF files and launch a process with them
- Kernel module in ELF ready to be inserted at run time
- Memory ring for the modules (built-in and run-time modules)
- kfs-x
- Fully functional binaries
-
libc - Posix Shell