An operating system written in C17 (gnu17), for x86_64
, aarch64
, and riscv64
.
loongarch64
is supported 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;
uart8250
on x86_64, riscv64 andpl011
on aarch64 - Full abstract virtual memory manager with large page support.
- Implements
kmalloc()
using a slab allocator. - Keeps time with RTC (
google,goldfish-rtc
on riscv64) andLocal-APIC
Timer,HPET
on 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
It's recommended that LLVM/Clang be used as the toolchain and compiler, GCC may not be able to build this project.
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
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
and sgdisk
are only required to build the hdd
targets.
The GNUmakefile provides the following targets to use with make
for building:
all
target builds the system for the given architecture inARCH
, creating a bootable .iso image containing the built system.all-hdd
target builds a flat hard disk/USB image instead.install
target 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
,loongarch64
as inputs to run the project on the respective architecture.CC=
,LD=
detail the compiler and linker used to build the kernel. Default isCC=cc
LD=ld
.
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-bios
Makefile targets are equivalent to their non-bios
counterparts except that they boot QEMU using the defaultSeaBIOS
firmware 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 is4G
SMP=
to configure amount of cpus. Default is4
DEBUG=
to build in debug mode and to start in QEMU in debugger mode. Default is0
RELEASE=
to build in release mode with full optimizations (thoughubsan
is still enabled). Default is0
CONSOLE=
to start in QEMU's console mode. Default is0
DISABLE_ACPI=
to start QEMU's machine without ACPI, relying exclusively on the DTB (Flattened Device Tree). Default is0
DISABLE_FLANTERM=
to disable flanterm, the terminal emulator used in this project. This option helps improve bootup performance. Default is0
DRIVE_KIND=
to specify what drives are available from QEMU. Default isscsi
for riscv64, andnvme
for all other archs. Available options are:block
which provides the defaultcdrom
/hda
access from QEMUscsi
which providesVirtIO
to access drives through thevirtio-scsi
interfacenvme
which provides nvme drives instead
NVME_MAX_QUEUE_COUNT=
to set nvme's max queue count. Only available whenDRIVE_KIND
is nvme. Default is64
TRACE=
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 is0
DEBUG_LOCKS=
to enable pervasive lock integrity checks. Default is0