A Unix-like x86_64 kernel written in Ignis, booted by Limine on UEFI.
IgniOS is the first large Ignis program that lives outside the compiler. It doubles as a test bench: when the kernel hits a compiler bug, the bug is fixed in the compiler rather than worked around here. Volatile access, freestanding builds, C-layout records, C function pointers and Intel-syntax inline asm all landed in Ignis because this kernel needed them.
Early, and only tested in QEMU with OVMF.
| Area | State |
|---|---|
| Boot | Limine (base revision 6) on UEFI, higher-half ELF at 0xffffffff80000000 |
| Console | Framebuffer text console, Spleen 8x16 font, 16 ANSI colors, cursor, scrolling; mirrored to COM1 |
| CPU | Own GDT and TSS (IST stack for double faults), IDT with exception reports; x87 and SSE enabled with per-thread FXSAVE state; SMEP and SMAP on when the CPU has them; per-CPU data behind the GS base with swapgs |
| Interrupts | ACPI MADT parsed; keyboard routed through the IOAPIC to vector 0x21 with local APIC end of interrupt; 8259 remapped to 0x20-0x2F and fully masked; idle loop sleeps with sti; hlt |
| Timer | Local APIC timer calibrated against PIT channel 2, periodic 100 Hz tick on vector 0x30; uptime at the prompt prints the time since boot |
| Locks | Spinlocks with a per-CPU preemption counter and lock ranks, wait queues and a sleeping mutex; every subsystem behind them (frames, page tables, heap, console, run queue handed over across switches, process table, one VFS lock checked on every tree access, the keyboard line), per-thread system call buffers, and system calls that run with interrupts on and can be preempted halfway |
| Threads | Kernel threads with their own stacks and a guard page, a round-robin run queue, yield, sleep, exit and join, an idle thread, and preemption by the timer tick with 100 ms time slices; ps lists the threads and threads starts a demo; the boot thread runs the terminal |
| Processors | Every processor Limine reports, started through its MP feature (-smp 4 in every test target), each with its own GDT slot, TSS, per-CPU block and idle thread; one shared run queue; a reschedule IPI wakes an idle processor and a stop IPI halts the others before a panic, a reboot or a shutdown |
| Devices | PCI configuration through ports 0xCF8/0xCFC, a scan of every bus with bridges and BARs sized and mapped uncached, lspci; a modern virtio-blk driver (one virtqueue, VERSION_1 and FLUSH) that sleeps on its INTx interrupt and gives a request 30 s on the TSC before it marks the disk unusable for the rest of the boot (a host that answers an fsync late would otherwise fail a healthy disk; a timeout prints the disk, the request, the sector and the wait), disks; every test target attaches a 1 MiB scratch disk and a 64 MiB ext2 data disk seeded by mke2fs -d, checked by e2fsck -fn after every boot (DISK=0 boots without them, DISK=2 adds a disk the tests must not write, baddisktest boots with a data disk that is not ext2, checked by sha256, and journaltest with an ext2 image that has a journal); a 256-block LRU block cache that writes dirty blocks back in ascending order, sends a FLUSH after them and evicts a clean block first |
| Input | PS/2 keyboard, scancode set 1, US layout, Shift and Caps Lock, line editing at a > prompt |
| Memory | Bitmap frame allocator over the Limine memory map (4 KiB frames and 2 MiB runs, frees of unmanaged frames rejected); own 4-level page tables (kernel image per segment with W^X, direct map with 2 MiB pages, write-combining framebuffer, NX and write protection on); kernel heap in the higher half behind the compiler's allocation handlers; reference-counted frames and frame reservations (commit accounting) |
| User mode | Per-process address spaces (own PML4, shared kernel half, U/S pages, frames freed on exit); ring 3 entered with iretq, left through SYSCALL/SYSRET or an interrupt (TSS.RSP0 follows the running thread); a Linux x86_64 syscall subset (read, write, openat, close, lseek, fstat, newfstatat, getdents64, mkdirat, unlinkat, chdir, getcwd, kill, reboot, sync, fsync, fdatasync, ftruncate, mmap, munmap, exit, exit_group, getpid, sched_yield, nanosleep, clone, futex, set_tid_address, gettid, arch_prctl, getcpu, pipe, pipe2, dup, dup2, dup3, -ENOSYS for the rest) behind a per-process ABI table; every user pointer validated before use; a static ELF64 loader that starts programs from the file tree, /disk included, with argc and argv (a program's pages come from the disk when it first touches them; the native SPAWN says IO when the disk cannot give bytes of the file and INVALID for any other refusal); a fault, privileged instruction or undefined instruction in ring 3 kills only that process, and a page fault that fails because the disk could not give the page, because the page lies wholly past the end of a disk file, or because a store to a hole found the disk full ends it with SIGBUS (status 135, where a refused access is 139); waiting for a process blocks until it is gone |
| User threads | Several threads per process with Linux clone (the pthread flag set), a tid and an FS base per thread (arch_prctl, CLONE_SETTLS), futex WAIT and WAKE, join through the cleared tid; exit ends a thread and exit_group, a kill or a fault end every thread; the address space belongs to the process and is freed with its last thread; a per-process lock serializes region changes, faults and user copies; a TLB shootdown IPI before a page of a multi-thread space is freed; threadtest and a small thread library in user/lib/linux |
| Keyboard input | Programs read lines from descriptor 0: echo, Backspace, Enter, Ctrl+D for the end of input, shared with the kernel terminal |
| Files | A ustar initramfs loaded by Limine and checked at boot; an in-memory file tree seeded from it with copy on write, /dev/console, path rules as on Linux; per-process descriptor tables (16 entries growing to 256, 0 to 2 on the console unless the parent passes others) and current directories; pipes with a 4 KiB buffer, end of file when the last writer closes and status 141 for a write with no reader left; dup, dup2 and dup3 sharing the open file; an ext2 data disk, with or without the ext4 extent feature, mounted at /disk (directories read on first lookup, file pages read into the page cache, a disk file readable to its full size, programs that run from it as they do from /bin: hello and fstest are on the seeded image, and a program the shell copies there runs too), read-write unless the image has a journal the kernel does not understand or a read-only-compatible feature the kernel does not write, which mounts read-only and refuses every change with EROFS in the Linux order (the ext4 row below says which images mount how); files under /disk survive reboot and shutdown, the rest of the tree lives in memory |
| ext2 writes | Under /disk: create, write, append, truncate (also ftruncate), unlink, mkdir and rmdir, with direct, single and double indirect blocks, or with an extent tree in an inode that has one (next row). A block is allocated when write copies into its page, so a full disk is ENOSPC at the write. A page written by write or stored to through a writable MAP_SHARED mapping is dirty in the page cache and reaches the disk through sync (Linux 162, native SYNC 27, the /bin/sync program), fsync (74), fdatasync (75, the same as fsync), and the sync in reboot and shutdown, which then mark the superblock clean; the stores of a mapping reach the disk through them also after munmap and after the process ended. The cache keeps at most 8192 disk pages (32 MiB): past that it drops clean pages first, and writes a dirty page back and then drops it only when no clean page is left to drop, and it does the same when no frame is free; a page a process maps stays. A file that grows past its end reads zeros there, whatever its last block held. Images with dir_index or ext_attr work: a directory with an htree index loses its index when a record is added or removed, and unlinking a file frees its extended attribute block (or drops one of its references), and a corrupt attribute block makes rmdir, or the unlink of a file's last name, fail with EIO before the name is removed. fstat and newfstatat report i_blocks of the inode as st_blocks (a hole counts for nothing, an attribute block does), and open of a directory with O_TRUNC is EISDIR on every file system, as on Linux. Limits: a write that ends past 64 MiB is EFBIG; no rename or link; a file with more than one link is not writable and cannot be mapped for writing (EROFS); a writable shared mapping of a disk file reaches no further than 64 MiB (EFBIG) and never grows the file; there is no msync, so a mapped store waits for one of the calls above, and every sync rewrites the pages stored to while the file is still mapped for writing (once the last writable mapping goes, the next sync writes them once more and cleans them); a truncate (ftruncate, or open with O_TRUNC) that would cut a page a writable shared mapping may still store to is EBUSY and changes nothing, where Linux allows the cut and gives a bus error at the next touch; no file times; on an image without a journal (one with a journal is the ext4 journal row below) the order of writes (data pages, then metadata, the superblock last) holds in memory and at a completed sync but not at every instant on the disk, since a full block cache writes back in ascending order outside a sync, so a crash in the middle of a sync can leave the image inconsistent; no periodic writeback, only the calls above write dirty data |
| ext4 extents | The extent feature (incompatible 0x40) is read and written, in kernel/src/ext2/extents.ign. The inode decides the format, not the mount: an inode with the extents flag (i_flags 0x80000) keeps its blocks in an extent tree, one without it in indirect blocks, so an image converted with tune2fs -O extent holds both, and an indirect file there keeps its indirect map and stays writable. Every file and directory the kernel creates on an image with the feature has extents; on an image without it, none has. The tree is read at any depth up to 5, and a node is checked whole before it is trusted: a bad magic, more entries than the node holds, entries out of order or overlapping, an empty index node, a depth that is not one less per level, a block outside the file system or a node that points at one already on its path is EIO, never a panic or a loop. A hole and an unwritten extent (made by fallocate on Linux) read as zeros. A write joins the block to the extent beside it on the disk (up to 32768 blocks), else adds an extent, splits a full leaf or index node and, when the root is full, moves it into a block and grows the tree a level; a block is allocated next to its neighbours in the file, so sequential writes make long extents. truncate and unlink free the data blocks and the tree blocks and shrink the tree back towards its root. A change that cannot finish (no free block for a split) gives back what it took. i_blocks counts the tree blocks and not the root in the inode, so st_blocks of a file on an extent image has no indirect blocks. Mounts: read-write with filetype, sparse_super and extent (other compatible features such as dir_index and ext_attr as before); read-only with a journal the kernel does not understand (the journal rows below) or any read-only-compatible feature but sparse_super (huge_file, dir_nlink, extra_isize, uninit_bg and the rest), because the kernel does not write what they describe; refused with 64bit, flex_bg, meta_bg, an inode size other than 128, a journal that needs recovery and cannot be replayed (see the next row) or any other incompatible feature, so an image from a plain mke2fs -t ext4 (256-byte inodes, flex_bg, a journal) does not mount until the later phases. Limits: an unwritten extent is read as zeros and a write into one is EIO and changes nothing, since the kernel has no fallocate and would have to split the extent in three; the tree is at most 5 levels deep; a file block from 1049612 (the end of the double indirect range, for both formats) is not read, and a write ends at 64 MiB as before. make extenttest and make mixedtest run it |
| ext4 journal | The kernel writes the jbd2 journal of an image it understands (internal, version 2, 4096-byte blocks, no checksums), in kernel/src/ext2/journal.ign: the image mounts read-write and every change of its metadata is a transaction. No metadata block reaches the disk in place before its transaction is committed (Dev::Blocks::hold keeps the dirty blocks of the disk back); sync, fsync, fdatasync, the sync before power and the end of an operation that leaves 128 dirty blocks or more commit: the file data first (ordered mode: the VFS writes every dirty page of the disk), then RECOVER, the descriptor blocks and the blocks (a block that starts with the jbd2 magic escaped, 508 tags to a descriptor block) and the journal superblock, FLUSH, the commit block, FLUSH, the blocks in place with a FLUSH, the journal marked empty with the next sequence number and a FLUSH, and RECOVER cleared. A block freed in the running transaction is not allocated again before it commits unless the transaction allocated it. A transaction is at most 224 dirty blocks of the 256 the cache holds, and no operation meets that limit after it dirtied its first block: create, mkdir, write and the first store to a mapped page need room for 64 dirty blocks and truncate and remove room for 72, and a transaction that has less is committed first (Ext2::Journal::hasRoom; with a limit lowered below that the operation is IO with nothing changed). A truncation or a removal that frees more blocks than the transaction has room for does it in steps, a commit between two of them, with the inode on the orphan list (next row). An image whose journal the kernel does not understand stays read-only. make journaltest, journalextenttest, journaltwobootest, commitreplaytest, commitcrashtest and commitkilltest run it; a commit that is cut at any of its steps, or in the middle of the in-place writes, is replayed by the next mount to what e2fsck -fy makes of the same image |
| ext4 orphan list | s_last_orphan (offset 0xE8 of the ext superblock) heads a list of inodes linked through their i_dtime, the later orphan first, as Linux and e2fsck keep it: an inode with no links is a removed file whose blocks are not all freed, one with links a file cut to i_size whose blocks past it are not, in kernel/src/ext2/orphans.ign. A journaled truncate or remove (Ext2::Writer::truncateInSteps, destroyInSteps) frees blocks until the transaction has less than 72 blocks of room (Ext2::Journal::stepIsFull), puts the inode on the list in the same transaction (i_size set to the size it is cut to, link count 0 for a removal), answers MORE, and the VFS commits and calls Ext2::Orphans::resume until the last step takes the inode off the list and, for a removal, frees it. An operation that fits in one transaction never touches the list. The mount, after the journal replay and when it is read-write, finishes every inode on the list, an image made by Linux included, committing between steps and at the end (ext2: orphan list finished, T truncated, D removed, F not freed); an inode whose i_block is not a block map (a device, a fifo, a socket, a fast symlink) frees no block, as e2fsck -fy does; a list it cannot trust (a number below s_first_ino or past s_inodes_count, a loop, an unreadable inode, an inode that is not allocated in its bitmap) is left untouched before anything is written and the mount is read-only with a named reason; the list of a read-only mount is left alone. make orphantest and orphancrashtest run it |
| ext4 journal replay | An image whose jbd2 journal holds transactions (RECOVER, incompatible 0x4, set, or a journal superblock with a start block) is replayed when it mounts, in kernel/src/ext2/journal.ign, before the feature checks that used to refuse it: the scan, revoke and replay passes of jbd2 (a transaction without its commit block ends the log and is not applied, a revoke record covers the transactions up to its own sequence number, the later copy of a block wins, an escaped block gets its magic back, the log wraps from the last block to s_first), then FLUSH, the journal marked empty with the next sequence number, RECOVER cleared, FLUSH. Nothing is written before the scan has found no error. The boot log says ext2: journal recovered, N transactions, B blocks written, R blocks revoked, and the image then mounts read-write, since the kernel writes the journal it replayed. Supported: an internal journal (s_journal_inum, a regular file of at least 1024 blocks), version 2, 4096-byte blocks, the REVOKE feature, no checksums. Refused when it needs recovery and has an external journal, another incompatible feature (64BIT, ASYNC_COMMIT, CSUM_V2, CSUM_V3, FAST_COMMIT), the compat CHECKSUM feature, a bad journal superblock or inode, a committed transaction with a descriptor or revoke block that runs past its block or a block number past the file system (the same defect in a transaction without its commit block, a torn write, only ends the log there); a clean journal with such features keeps the read-only mount (with its journal reason, the image byte for byte unchanged). make replaytest runs it |
| Processes | Up to 64; each records its parent, only the parent may wait for it (WAIT or WAIT_ANY), orphans and unwaited children are freed on their own; KILL and Linux kill(2) end a process with status 137, waking it from a sleep, a wait or a keyboard read |
| Shell | /bin/sh, a user program the kernel starts after the boot: it runs programs with spawn and wait and has cd and exit; pipelines of up to 8 commands with ` |
| Commands | cat, ls, touch, mkdir, rm, rmdir, pwd, sync, reboot and shutdown in /bin, written in Ignis on the native IgniOS ABI |
| Memory mappings | lazy mmap of anonymous memory (pages get frames on first touch, from a reservation, so a granted mapping never runs out), file mappings from a page cache (MAP_PRIVATE copies a page on its first write, MAP_SHARED writes reach an in-memory file at once and a disk file at the next sync), a writable shared mapping of a disk file maps its pages read-only and the first store to each faults: the fault allocates the block of a hole (a full disk is SIGBUS, not a lost store), marks the page dirty and open, and makes it writable, with the stale entries of the other processors dropped; a page wholly past the end of a disk file is SIGBUS (status 135) for shared and private mappings, read or write, and the bytes of the last page past the end never reach the disk; mmap of a file refuses an offset plus length that overflows 64 bits with EOVERFLOW (the native TOO_LARGE; ENOMEM first when the length is more than the fixed mapping area holds and the range also wraps; Linux's ENOMEM depends on the free address space, so a length of exactly the area with a wrapping offset is EOVERFLOW here), and a writable shared mapping, after EACCES for a descriptor not open for writing, with EROFS (a disk file with more than one link), EFBIG (a range past 64 MiB) and EBUSY (a running program's file), program text and read-only data shared by every process of the same program, a stack that grows on demand up to 8 MiB, munmap that trims and splits regions, PROT_READ/PROT_WRITE/PROT_EXEC/PROT_NONE enforced by the page tables, write with execute refused; up to 1024 regions per process in a table that grows; std::alloc, a user heap on mmap behind the compiler's allocation hooks; cat reads files through mmap |
| Native ABI | A second system call ABI next to Linux, chosen per program by an IgniOS ELF note: own call numbers (28 calls: files, directories, the current directory, memory, process creation, waiting and killing, scheduling, power, pipes, sync), the status in RAX and the value in RDX, a published table of status codes, paths as pointer and length; both ABIs share descriptors and the checked transfers of Syscall::Core; hello, cat, ls, touch and mkdir are native programs, fstest and mmtest keep testing the Linux layer |
| Next | Crash tests at every point of a commit (S8), then checksums, 64-bit block numbers, flexible groups and 256-byte inodes (S9) (proposal "persistent storage with virtio-blk and ext2" in the Atlas Proposals folder) |
You need Nix with flakes. The flake provides clang, lld, Limine, QEMU, OVMF, mtools and the font.
nix develop
make runWith direnv and nix-direnv, the repository's .envrc loads the same shell when you enter the directory. Allow it once, then make run works without nix develop:
direnv allow
make runQEMU opens a window. Click it to give it the keyboard and type at the prompt: ls /, cat /etc/motd, mkdir /tmp, touch /tmp/a, ls /tmp. The prompt is /bin/sh: cd /etc, pwd, rm, rmdir work as on Unix, cat alone copies what you type until Ctrl+D. reboot boots the machine again and shutdown powers it off, which closes QEMU. The programs are in /bin, and the files you create live in memory until the next boot, except under /disk, which reboot and shutdown write to the data disk (every make run builds the disk again from build/diskroot, so a new run starts from the seeded files). The terminal shows the serial log.
The build also needs an Ignis compiler with freestanding support (Ignis main from October 2026 or later). The Makefile uses the ignis on your PATH; point elsewhere with make IGNIS=/path/to/ignis.
| Target | What it does |
|---|---|
kernel |
Builds build/kernel.elf |
user |
Builds the user programs build/user/NAME.elf from user/NAME, user/lib and the entry stub user/lib/linux/start.S |
image |
Builds build/ignios.img, a FAT32 EFI system partition with Limine, the kernel and the initramfs |
run |
Boots in QEMU with the serial console on stdio |
run-headless |
Boots without a display for HEADLESS_SECONDS (default 40, twice the slowest boot measured, SMP=1 under load) and checks the banner, the prompt and the lines of hello in build/serial.log, then e2fsck -fn and the files the tests leave on the data disk (/dir/kept, the four files of /dir/mapped that processes stored through writable shared mappings, and the seeded programs, byte for byte) |
screenshot |
Boots headless and saves the screen to build/screen.png |
keytest |
Types keys through the QEMU monitor and checks the echo |
shelltest |
Types a session of cat, ls, touch and mkdir, their errors included, a /disk session with redirections and sync, runs the programs of /disk and a copy of hello it makes there with cat, and checks every line they print; the gate then finds the trees the self-tests left as after any boot and the copy equal to the built ELF file |
powertest |
Types disktest persist and reboot, waits for the second boot, which finds the file on the disk, types shutdown and checks that QEMU exits by itself, the disk consistent and marked clean |
twobootest |
Boots QEMU twice on the same data disk: the first boot writes a tree, copies hello to /disk with the shell, stores through a writable shared mapping and ends without a sync, and shuts down; the second finds the tree and the mapped bytes, runs the copy, removes them and shuts down; e2fsck -fn returns 0 and the superblock is clean after each |
baddisktest |
Boots with a data disk that is not ext2, then with the scratch disk alone, and checks that nothing is mounted and the bad disk is unchanged |
journaltest |
Builds the seeded image with a 1024-block jbd2 journal (has_journal, its own UUID) and boots it: the kernel mounts it read-write and journals its metadata, every self-test and user program of the default image runs, including the new ones of Tests::Commit (the commit stopped after step 1 and after step 2 as the replay reads it, escape, several descriptor blocks, blocks freed in the transaction, the held disk, a transaction that does not fit, and on the mount the data on the disk and the metadata in the journal after step 1); the host requires e2fsck -fn 0, the files the tests left and an empty journal with RECOVER clear |
journalextenttest |
The same on an image made with extents and a journal (the journal inode is an extent inode too): the suites of extenttest run on it and the host requires what extenttest and journaltest require |
journaltwobootest |
Boots the journaled image twice, as twobootest does: the second boot finds an empty journal and reads back what the first wrote through transactions; e2fsck -fn 0 and an empty journal after each |
commitreplaytest |
The first boot of a journaled image changes it (a file of two pages, a directory, a removal, a cut), stops after step 2 of the commit (the transaction is in the journal and not in place) and halts; the host's logdump reads the journal, e2fsck -fy on a copy replays it, and the second boot's mount replays it: the kernel's image equals the copy block for block (but the journal's blocks and the superblock fields of the mount) and has the files |
commitcrashtest |
For each of COMMIT_CRASH_CASES (STEP:TAGS:WORKLOAD), the first boot of the journaled image commits a marker, makes the changes of commitreplaytest and stops their commit after the logged blocks (step 1), after the commit block (2), in the middle of the in-place writes (5, half of the blocks written, no FLUSH), after them (3) or after the journal is marked empty (4); the host reads the journal and the blocks in place that stop leaves (logdump, tags, descriptor blocks, the ESCAPE flag), and the second boot's mount replays it (one transaction of the logged blocks from step 2 on, none after step 1): the kernel's image equals what e2fsck -fy makes of a copy of the crashed one block for block (but the journal and the superblock fields of the mount), e2fsck -fn returns 0 with an empty journal and RECOVER clear, and the files are the committed ones (the old ones after step 1). The cases include a transaction with a logged block that starts with the jbd2 magic (the boot sector of the image does, so block 0 is escaped) and one of 8 blocks in 3 descriptor blocks (TAGS 3) |
commitkilltest |
KILL_ROUNDS (6) times on one image: the kernel, started with a second disk of serial kill, runs a workload that never ends on the journaled disk (files made, written, cut and removed in several transactions with the orphan list, directories, a sync every second round), the host kills QEMU with SIGKILL 0.15 to 3.25 s after it starts (a fixed function of the round), e2fsck -fy on a copy repairs nothing besides the journal and the orphans, and the next boot, without the second disk, mounts read-write, reads every file back and leaves an empty journal, e2fsck -fn 0 and the free counts, bitmaps and files of what e2fsck -fy made. make commitkilltest KILL_ROUNDS=40 runs more |
orphantest |
Boots, one at a time, images of scripts/journalgate.sh whose orphan list the host made with debugfs (a truncated inode and a removed one, with and without extents or a journal; a removed device node whose numbers read as a block of a live file, a fast and a slow symlink) or damaged (a head past the inodes or below the first one, a loop, a self loop, a link past the inodes, an inode whose bit is clear) or left on a mount that is read-only anyway; the host requires, for the list the kernel finishes, e2fsck -fn 0, an empty journal, /huge cut to its first 8192 bytes, /big gone and the free counts, bitmaps and files of what e2fsck -fy makes of a copy, and an image byte for byte unchanged (and a read-only mount) for the others |
orphancrashtest |
For each case, the first boot of a journaled image (indirect, or with extents) removes or cuts /huge (1280 blocks) in transactions of 100 blocks and stops the commit after step 1, 2, 3 or 4 of a chosen commit (Ext2::Journal::armStopAfter), the host reads the journal that leaves, and the second boot's mount finishes the orphan list: e2fsck -fn 0, an empty journal, and the free counts, bitmaps and files of what e2fsck -fy makes of a copy of the crashed image |
replaytest |
Boots, one at a time, the images of scripts/journalgate.sh with a pending jbd2 journal built by debugfs and by a script: five committed transactions and an unfinished one (a later copy of a block, a revoke, an escaped block), a log that wraps, a transaction torn by a power cut after a good one, two descriptor blocks, many revoke records, a replay of the inode table block the mount had cached, the same in a journal with extents, an empty log with RECOVER set, and the journals the kernel refuses (an external journal, a bad inode or superblock, unsupported features, defects in a descriptor or revoke block); the host requires e2fsck -fn 0, the logged blocks byte for byte, the revoked and unfinished ones untouched, an empty journal, an image block for block equal to a copy that e2fsck -fy replays, and an unchanged image where the kernel refuses or leaves the journal alone (an unsupported feature, an unknown read-only feature); a replayed image or a clean one is mounted read-write and differs from the copy only in the journal's blocks and the superblock fields of the mount |
compattest |
Builds an ext2 image with dir_index and ext_attr (a directory of 400 files with an htree index, files with extended attributes, some sharing an attribute block (two or three files), files whose last block holds stale bytes) and a fixed UUID (COMPAT_UUID, which the kernel's Tests::Seeded::isCompat knows), boots it, lets disktest compat unlink, create, cut and grow files there, shuts down, and requires e2fsck -fn to return 0, the free counts to agree and the names and bytes to be what the program left; then boots a second image with another UUID and a file /compat and requires that no test wrote it but for the write time and mount count of its superblock (scripts/compatgate.sh) |
extenttest |
Builds an image of the seeded tree with the extent feature (mke2fs -O extent, its own UUID) and, in /dir/extents, a file with more than 4 extents (a root that points at a leaf block), one with 2000 (a tree of depth 2) and one with unwritten extents over blocks that hold 0xEE, and boots it read-write. The kernel reads every block of those files against the layout and then writes: extent inodes made by create and mkdir, files grown to depth 2 (the leaf splits at 341 extents, the root grows at 851) and cut back, unwritten extents, corrupt trees refused, an indirect inode kept; the whole disktest suite runs on it. The host then requires e2fsck -fn to return 0, the seeded files byte for byte, the trees debugfs ex shows for the files the kernel wrote and the block counts (scripts/extentgate.sh, scripts/diskgate.sh with DISK_FORMAT=extent) |
extenttwobootest |
Builds the image of extenttest and boots it twice without rebuilding it, as twobootest does: disktest persist, the shell copy of hello and mmtest shared persist run across the boots on extent inodes. The self-tests of the second boot start from what the first left: they read /dir/ext (the depth 2 trees twoa and twob and the file seq) and /dir/kept back from the disk, check every byte and the shape of the trees, panic on a difference, and only then remove them and write them again. After each boot e2fsck -fn returns 0, the superblock is clean and the checks of extenttest hold |
mixedtest |
Builds the seeded image without extent and converts it with tune2fs -O extent, so every file is indirect and the feature is on; the kernel grows the indirect /big into the double indirect range and cuts it back, and makes /dir/mixed and /dir/mixed/new; the host requires e2fsck -fn 0, flags 0 on the files that were there and 0x80000 on the two the kernel made |
font |
Regenerates kernel/src/drivers/font_8x16.ign from the Spleen package |
clean |
Removes build/ |
Ignis compiles the whole kernel to one C unit, which clang compiles for x86_64-unknown-none with kernel flags (no red zone, no SSE in the kernel, -mcmodel=kernel). The few routines that cannot be written in Ignis are small .S files under kernel/src/arch/x86_64/: interrupt entry stubs, the code segment reload, the stack switch, the ring 3 entry and the SYSCALL stub, the per-CPU block, the fault probes, and the throwaway user programs of the boot self-tests. ld.lld links everything with kernel/linker.ld, and mtools writes the boot image. No cross GCC is involved.
User programs are Ignis projects under user/ built with std = false and the small user standard library in user/lib, shared code in common/ and one sys per system call ABI in linux/ and native/ (std::sys wraps the system calls in inline asm, std::io prints, std::args reads argv, std::alloc is a heap on mmap, std::panic is the shared panic handler; Sys::exit with a status above 255, which the kernel would cut to 8 bits, prints a line and ends with 255, and so does a main that returns one). The Makefile links each one after the entry stub user/lib/linux/start.S with user/user.ld into a static ELF64 at 0x400000 and packs it into the initramfs as /bin/NAME. The kernel runs hello one two at boot, before the keyboard line, and run hello at the prompt runs it again; run PROGRAM ARG... passes arguments.
New to the code? docs/READING.md is a reading guide in the order the code runs, with a virtual address space map and the boot log explained line by line.
The kernel is split into subsystems. Each one is a directory under kernel/src/ with a mod.ign facade, a namespace with the same name, and an import alias in ignis.toml (import Mm from "@mm"). Other subsystems import only the facade and call Mm::Pmm::allocateFrame(). The //! header of every mod.ign has the public API and the dependencies of its subsystem.
| Directory | Namespace | Alias | What is in it |
|---|---|---|---|
kernel/src/lib/ |
Lib |
@lib |
memcpy and friends, integer formatting, the scancode ring buffer |
kernel/src/arch/ |
Arch |
@arch |
CPU instructions, port I/O, GDT, IDT, PIC, PIT, context switch, ring 3 entry, the interrupt frame, x87/SSE state, SMEP/SMAP and fault probes, per-CPU data, all .S files (in arch/x86_64/) |
kernel/src/boot/ |
Boot |
@boot |
Limine requests and responses, the higher half direct map |
kernel/src/drivers/ |
Drivers |
@drivers |
COM1, the framebuffer console and its font, the PS/2 controller, the keyboard decoder |
kernel/src/acpi/ |
Acpi |
@acpi |
RSDP, XSDT/RSDT, MADT and FADT parsing, the S5 sleep type |
kernel/src/mm/ |
Mm |
@mm |
physical frames, page tables, address spaces, the kernel heap, Limine modules |
kernel/src/apic/ |
Apic |
@apic |
local APIC and IOAPIC |
kernel/src/time/ |
Time |
@time |
APIC timer calibration, the tick counter, uptime |
kernel/src/sched/ |
Sched |
@sched |
the thread table and stacks, the run queue, sleep and timer preemption, wait queues and mutexes |
kernel/src/smp/ |
Smp |
@smp |
starting the other processors |
kernel/src/pci/ |
Pci |
@pci |
configuration space through ports 0xCF8/0xCFC, the scan of every bus, BAR sizing and mapping, capability lists |
kernel/src/virtio/ |
Virtio |
@virtio |
the modern virtio PCI transport and the virtio-blk driver: one request at a time, completed by interrupt or polling, and the test hooks that fail a disk or delay a completion |
kernel/src/dev/ |
Dev |
@dev |
the 4 KiB block cache over the virtio disks: LRU, dirty blocks, write-back, sync |
kernel/src/ext2/ |
Ext2 |
@ext2 |
the ext2 reader, directory walker and writer (allocators, block map, truncate, directory records, create, mkdir, unlink, rmdir) over the block cache, the extent trees of inodes that have them (extents.ign) and the jbd2 journal: replay at mount and the transactions the kernel writes (journal.ign), and the orphan list that lets an operation take several of them (orphans.ign) |
kernel/src/fs/ |
Fs |
@fs |
the initramfs (ustar), the file tree in memory and on the ext2 data disk mounted at /disk (nodes, the page cache with dirty and open marks and eviction, sync), descriptor tables and open files, pipes, the console line editor |
kernel/src/proc/ |
Proc |
@proc |
process table, ELF loader, running a program from a path with arguments |
kernel/src/power/ |
Power |
@power |
ACPI power-off (S5) and reset |
kernel/src/syscall/ |
Syscall |
@syscall |
dispatch, the kernel operations, the Linux ABI table and handlers |
kernel/src/trap/ |
Trap |
@trap |
the interrupt dispatcher, exception reports, GDT/IDT/SYSCALL setup with their log lines |
kernel/src/shell/ |
Shell |
@shell |
the terminal loop and its commands |
kernel/src/tests/ |
Tests |
@tests |
boot self-tests |
kernel/src/main.ign |
kmain: the boot order, one call per step |
||
kernel/src/panic.ign |
the panic handler |
The dependencies run one way, and the compiler rejects an import cycle. Lib, Arch and Boot import nothing else in the kernel, and each later subsystem imports only the ones before it. The table in docs/READING.md lists what every subsystem imports and why.
kernel/linker.ld higher-half layout
user/lib/ the user standard library (entry stub, syscalls, text output, argv)
user/hello/ the first user program
user/sh/ the shell
user/cat, ls, touch, mkdir, rm, rmdir, pwd/ the commands
user/reboot, shutdown/ reset and power off
user/fstest/ ring 3 checks of the file system calls
user/disktest/ ring 3 checks of the ext2 data disk at /disk, read-write and read-only
user/sync/ the sync command
user/mmtest/ ring 3 checks of mmap, munmap and std::alloc, and of writable shared mappings of disk files (`mmtest shared`)
user/nativetest/ ring 3 checks of the native ABI
user/stress/ four processes on the file tree and memory at once
user/user.ld user program layout
initramfs/ files packed into the initramfs next to the programs in /bin
boot/limine.conf boot entry and the initramfs module
docs/READING.md reading guide: subsystem by subsystem, address space map, annotated boot log
scripts/ font generator, screenshot and key test drivers, the data disk image (with the programs `hello` and `fstest`) and its host gate, the compatibility image of `make compattest` and its gate, the extent and mixed images of `make extenttest`, `make extenttwobootest` and `make mixedtest` and their gate (`extentgate.sh`), the journal images of `make replaytest` and the journaled ones of `make journaltest`, `make journalextenttest`, `make journaltwobootest`, `make commitreplaytest`, `make commitcrashtest` and `make commitkilltest` and their gate (`journalgate.sh`)
The overall approach (Limine, one generated C unit, clang and lld, assembly entry stubs) follows Vinix, the operating system written in V.
GPL-3.0-only, the same as the Ignis compiler. See LICENSE.
The console font is Spleen 8x16 by Frederic Cambus, under the BSD 2-Clause license. See THIRD_PARTY.md and LICENSES/.
