a modular modern independent kernel
the tape-kernel is a minimal, modular, independent 32 bit kernel. it boots from bios/csm via multiboot, runs in protected mode on an i486 or better, and fits on a 1.44MB FAT12 floppy image. there is no unix, no posix, no libc—just a bump allocator, a flat file system, a shell, and a text editor.
the system has:
the entire kernel is written from scratch in c and assembly. it uses no external libraries and links against nothing—-nostdlib -nostdinc -ffreestanding.
git clone https://codeberg.org/druid520/tape-kernel.git
cd tape-kernel
make iso
make run
once booted, type help at the tape@ prompt to see available commands.
| hardware | minimum |
|---|---|
| cpu | i486 (or better) |
| ram | 3.8 MB |
| disk | 1.44 MB FAT12 image |
| display | vga text mode (80x25) |
| input | ps/2 keyboard |
| mode | 32-bit protected mode |
| firmware | bios / csm |
to build and run:
qemu-system-i386 gcc as ld make binutils coreutils git xorriso dosfstools
for development and debugging:
gdb doxygen graphviz
sudo pacman -S qemu-system-i386 gcc binutils make git xorriso dosfstools gdbsudo apt install qemu-system-x86 gcc binutils make git xorriso dosfstools gdbsudo dnf install qemu-system-i386 gcc binutils make git xorriso dosfstools gdbdoas apk add qemu-system-i386 gcc binutils make git xorriso dosfstools gdbsudo xbps-install qemu gcc binutils make git xorriso dosfstools gdbpkg install qemu gcc binutils gmake git xorriso dosfstools gdb
make build the kernel elf
make iso build the kernel and create a bootable iso
make run build the iso and run in qemu
make debug build the iso and run in qemu with gdb attached
make clean remove build artifacts
for debugging, use target remote localhost:1234 in gdb after make debug starts qemu. the makefile builds with -g so symbols are available.
commands available at the tape@ prompt:
| command | description |
|---|---|
| help | show all available commands |
| clear | clear the screen |
| ls | list all files on disk |
| read <file> | read and display a file |
| write <file> | write text to a file (opens editor) |
| rm <file> | delete a file |
| echo <text> | print text to screen |
| reboot | reboot the machine |
| alloc <n> | allocate n bytes from the heap |
| heap | show heap status |
| panic | trigger a kernel panic |
| info | show memory and cpu info |
| editor <file> | open the line-based text editor |
the editor uses hotkeys: [e] to edit a line, [w] to save, [q] to quit. it supports up to 32 lines of 80 characters each.
0x00000000 +------------------+
| ivt / bda | real-mode data
0x00001000 +------------------+
| kernel code | .text (loaded at 1M)
| kernel data | .data / .bss
| stack | 16 KB
| arena heap | bump allocator
| ... | grows upward
0x00FFFFFF +------------------+
the kernel is loaded at 1MB by the multiboot bootloader. the stack is 16KB. the heap is an arena bump allocator with no free support. allocation is 4-byte aligned with overflow checking. child arenas can be created from the parent heap via anew.
src/
boot/ multiboot header and entry point (.s)
fs/ flat file system, ide disk driver
io/ vga output, keyboard input, cursor control, port i/o
kernel/ main kernel entry, cpu detection, interrupt wrappers
lib/ string utils, math, panic handler, pit timer, types
mem/ arena allocator, memory info
usr/ shell, text editor
the tape-kernel is free software, licensed under the gpl-3.0-or-later.
contributions are welcome. follow the coding style, use the commit prefixes, and keep things simple—dont add unless needed. open an issue or pull request on codeberg.