# red-pepper pepperOS: "will never be done" ## Description PepperOS is a 64-bit freely-licensed monolithic kernel for x86 processors, with round-robin preemptive scheduling and 4-level paging. See the [manual](docs/MANUAL.md) for more. ## Trying the kernel in QEMU ### Debian-based distributions First, install the dependencies: `sudo apt install nasm python3 xorriso make qemu-system` Then, you can get an x86_64 toolchain for compilation. The easiest way to do that on most systems is to install it from Homebrew: ``` brew install x86_64-elf-gcc ``` If you're already on a 64-bit machine (which you probably are), and don't want to install a cross-compiler, you can just override `CC` and `LD` variables in the Makefile, like so: ``` CC := gcc LD := ld ``` Then, to compile the kernel and make an ISO image file, run: `make build-iso` To run it with QEMU, do: `make run` ## Trying the kernel on real hardware Compile the kernel and generate an ISO image like described above, then burn the image to a USB stick, `/dev/sdX` being the device name (you can get it using `lsblk`): ``` sudo dd if=pepper.iso of=/dev/sdX ``` ## Compilation options By default, PepperOS is compiled without the following features: ``` UBSAN - undefined behavior sanitization ``` These features can be activated by setting them to "true" at the end of the make command, for example: ``` make UBSAN=true ``` ## TODO The basics that I'm targeting are: ### Basic utility of what we call a "kernel" - Implement tasks, and task switching + context switching and spinlock acquire/release - Load an executable - Filesystem (TAR for read-only initfs, then maybe read-write using FAT12/16/32 or easier fs) w/ VFS layer - Getting to userspace (ring 3 switching, syscall interface) - Porting musl libc or equivalent ### Scalability/maintenance/expansion features - Documentation - SOME error handling in functions - Unit tests - Good error codes (like Linux kernel: ENOMEM, ENOENT, ...) ### Optional features In the future, maybe? - SMP support (Limine provides functionality to make this easier) - Parsing the ACPI tables and using them for something - Replacing the PIT timer with APIC ## Thanks PepperOS wouldn't be possible without the following freely-licensed software: - the [Limine](https://codeberg.org/Limine/Limine) portable bootloader - Charles Nicholson's [nanoprintf](https://github.com/charlesnicholson/nanoprintf) - Mintuski's [Flanterm](https://codeberg.org/Mintsuki/Flanterm) terminal emulator ...and without these amazing resources: - the [OSDev](https://osdev.org) wiki & forums - Intel 64 and IA-32 Architectures Software Developer's Manual - Documentation for the [GNU Compiler Collection](https://gcc.gnu.org/onlinedocs/gcc/) - dreamos82's [OSDev Notes](https://github.com/dreamportdev/Osdev-Notes/tree/master) - the [Sortix UBsan hook implementations](https://gitlab.com/sortix/sortix/-/blob/main/libc/ubsan/ubsan.c) - the [CSC 395](https://curtsinger.cs.grinnell.edu/teaching/2022S/CSC395/kernel/) Kernel Development course from Grinnell College