An operating system written in C17 (gnu17), for x86_64, aarch64, and riscv64.
loongarch64 is being worked on but isn't currently functional.
x86_64 is the most feature complete, while aarch64 and riscv64 are catching up
Migrated from older repository: https://github.com/suhas-pai/operating-system-old Check older repository for full commit history
The project has the implemented all of the following:
- Has serial UART drivers;
uart8250on x86_64, riscv64 andpl011on aarch64 - Full abstract virtual memory manager with large page support.
- Implements
kmalloc()using a slab allocator. - Keeps time with RTC (
google,goldfish-rtcon riscv64) andLocal-APICTimer,HPETon x86_64 - Discovers devices in ACPI Tables and Device Tree (when available)
- Finds and Initializes PCI(e) Devices.
And more
The following is currently being thought out and worked on.
- IDE, AHCI, SATA, NVME controllers to read disks
- VirtIO drivers
- Virtual File System (VFS)
- Full SMP support with scheduler
- User processes and threads
LLVM/Clang are recommended as the toolchain and compiler to build this project, GCC will likely be able to build this project. These instructions will build with LLVM/Clang
The kernel GitHub Workflow follows the steps detailed below on both macOS and
Ubuntu (Linux) to build this project.
Run the following command to install the required packages from Homebrew.
brew install llvm make nasm xorriso coreutils mtools gptfdisk lld
Note that mtools and gptfdisk are only required to build the hdd targets.
Per the installation instructions of llvm, make, and coreutils, add the following
paths to your $PATH environment variable:
/opt/homebrew/opt/llvm/bin
/opt/homebrew/opt/make/libexec/gnubin
/usr/local/opt/coreutils/libexec/gnubin
Install the latest version of LLVM available. The best option is from llvm.org. The llvm version available in your system's package manager may be too old to build this project.
This project also requires installing nasm, xorriso, sgdisk, and mtools.
Make sure to add llvm's installation folder to your $PATH environment variable.
Note that mtools are only required to build the hdd targets. sgdisk is only
required to build x86_64 and hdd targets
The GNUmakefile provides the following targets to use with make for building:
alltarget builds the system for the given architecture inARCH, creating a bootable .iso image containing the built system.all-hddtarget builds a flat hard disk/USB image instead.installtarget can install the system into a directory provided by the variableDESTDIR.
Several variables are available to configure how the project is built:
ARCH=specifies the architecture the project is built for. Default isx86_64, but also acceptsaarch64,riscv64,loongarch64as inputs to run the project on the respective architecture.CC=,LD=detail the compiler and linker used to build the kernel. Default isCC=ccLD=ld, though these are unlikely to be able to build this project.
This project uses the Makefile build system. To run the project (In QEMU), use the following command:
make run ARCH=x86_64 CC=clang LD=ld.lld
To run from a built raw HDD image (creating if necessary), rather than a bootable ISO, run the following command instead:
make run-hdd ARCH=x86_64 CC=clang LD=ld.lld
On x86_64, additional options are available:
run-bios,run-hdd-biosMakefile targets are equivalent to their non-bioscounterparts except that they boot QEMU using the defaultSeaBIOSfirmware instead ofOVMF.
Several variables are also available to configure the system provided by QEMU. If not provided, they are given a default value that is detailed below:
MEM=to configure memory size (in QEMU units). Default is4GSMP=to configure amount of cpus. Default is4DEBUG=to build in debug mode and to start in QEMU in debugger mode. Default is0RELEASE=to build in release mode with full optimizations (thoughubsanis still enabled). Default is0CONSOLE=to start in QEMU's console mode. Default is0DISABLE_ACPI=to start QEMU's machine without ACPI, relying exclusively on the DTB (Flattened Device Tree). Default is0DISABLE_FLANTERM=to disable flanterm, the terminal emulator used in this project. This option helps improve bootup performance. Default is0DRIVE_KIND=to specify what drives are available from QEMU. Default isscsifor riscv64, andnvmefor all other archs. Available options are:blockwhich provides the defaultcdrom/hdaaccess from QEMUscsiwhich providesVirtIOto access drives through thevirtio-scsiinterfacenvmewhich provides nvme drives instead
NVME_MAX_QUEUE_COUNT=to set nvme's max queue count. Only available whenDRIVE_KINDis nvme. Default is64TRACE=to trace certain logs in qemu tolog.txt. Takes a space separated string and provides qemu with the list in the correct format. Default is""CHECK_SLABS=to enable pervasive slab checks inkmalloc()and other slab allocators. Default is0DEBUG_LOCKS=to enable pervasive lock integrity checks. Default is0CONFIG_UACPI=to use uACPI, an implementation of ACPI necessary for full device driver and hardware support. Default is1