NanoKernel OS is a minimal 32-bit x86 protected-mode hobby operating system kernel loaded by GRUB via Multiboot v1.
- GRUB Multiboot v1 compatible kernel image
- VGA text mode output
- Flat 32-bit GDT setup
- IDT with exception, IRQ0, and
int 0x80entries - PIC remapping and EOI support
- PIT timer and global tick counter
- Interrupt dispatcher in C
- Multiboot module parsing for initrd
- Basic 32-bit paging (identity-mapped first 16MB)
- Syscalls via
int 0x80:SYS_WRITESYS_SLEEPSYS_GETPID
- Round-robin scheduler
- Keyboard IRQ1 driver with scancode input buffer
- Minimal shell task with commands:
help,clear,ticks,ps,about,reboot,ls,cat <file>,mem - Initrd-backed read-only virtual filesystem
- Two demo tasks that run repeatedly
- Bootable ISO image for QEMU and VirtualBox
arch/x86/boot/- Multiboot header and kernel entry point
arch/x86/- GDT/IDT load helpers, interrupt stubs, context restore, syscall wrappers
kernel/- Core kernel logic: VGA, GDT, IDT, PIC, PIT, interrupts, scheduler, tasks
include/- Public kernel headers
grub/grub.cfg- GRUB menu configuration (kernel + initrd module)
initrd/- Source text files packaged into initrd image
tools/mkinitrd.c- Host-side tool that builds
initrd.bin
- Host-side tool that builds
Recommended:
i686-elf-gcci686-elf-ldnasmgrub-mkrescuexorrisoqemu-system-i386
Fallback supported in Makefile:
- host
gcc/ld/objcopywith-m32
make all
make kernel
make isoArtifacts:
build/kernel.elfbuild/initrd.binbuild/nanokernel.iso
make runEquivalent:
qemu-system-i386 -cdrom build/nanokernel.isomake run-vboxThen follow printed steps to create a VM and attach build/nanokernel.iso as optical media.
NanoKernel v0.4 packages a simple custom initrd image and loads it via GRUB as a Multiboot module:
module /boot/initrd.binThe initrd format is intentionally small and static:
- Header:
magic,file_count - Fixed-size file table entries:
name[32],offset,size - Raw file data blobs
Kernel APIs:
fs_init(start, end)initializes the filesystem from module memory.fs_list(cb, user)enumerates files.fs_find(name)finds file metadata by name.fs_read(name, &data, &size)returns a pointer/size to file contents.
Shell integration:
lslists available initrd files.cat <filename>prints file contents.
Included sample files:
hello.txtabout.txtmotd.txt
NanoKernel v0.5 enables 32-bit paging in early boot:
paging_init()is called during kernel init after GDT setup.- A 4KB-aligned page directory and page tables are built statically.
- The first 16MB of physical memory is identity-mapped (RW, present).
- CR3 is loaded with the page directory physical address.
- CR0.PG is set to enable paging.
Current memory model:
- Kernel remains at its existing physical/load addresses (no higher-half mapping yet).
- Identity mapping keeps early boot/kernel addresses valid.
- No heap/page allocator yet; mappings are static.
Page-fault diagnostics:
- Faulting linear address from
CR2 - Error-code decoding for: present, write, user, reserved, instruction fetch (bit 4 when provided by CPU)
Shell support:
memprints paging enabled state, identity-mapped range, and linker-providedkernel_start/kernel_endaddresses.
- 32-bit x86 only
- Paging is currently static identity mapping only (first 16MB)
- No true ring3 user mode yet
- Syscalls are currently invoked from ring0 demo tasks
int 0x80ABI is implemented, but real ring3 isolation is planned- Filesystem is initrd-only and read-only
- No disk block driver
- No heap/page allocator yet
- All tasks share one address space
- Paging and higher-half kernel mapping
- Ring3 user mode and privilege separation
- ELF user program loader
- Initrd support
- Filesystem support
- Keyboard driver
- Interactive shell
- IPC primitives