Skip to content

Repository files navigation

JanOS

JanOS is a freestanding 32-bit x86 operating system. GRUB loads only the kernel through Multiboot2. The kernel discovers the FAT16 application disk and loads the userspace services and applications from it.

The kernel currently includes higher-half paging, physical and virtual memory management, slab allocation, SMP discovery and startup, interrupts, PS/2 input, serial/VGA output, PCI, AHCI/ATA storage, FAT16, processes, static ELF loading, and a small syscall ABI. The bundled calculator runs in ring 3.

Kernel diagnostics continue to use serial independently of the userspace framebuffer service. The application disk contains `calc`, `fbserver`, `fbclient`, `pingpong`, and the PSF2 font, so disk boot displays userspace output while serial remains available for debugging and automated tests.

Build

Build the cross-toolchain once:

cd tools
./get_tools.sh

Configure and build JanOS with Meson and Ninja:

meson setup build-debug --cross-file config/i686-elf.ini \
  --buildtype=debug --prefix=/usr --libdir=lib32
meson compile -C build-debug
meson test -C build-debug --print-errorlogs
meson compile -C build-debug calc-disk iso

meson setup build-release --cross-file config/i686-elf.ini \
  --buildtype=release --prefix=/usr --libdir=lib32
meson compile -C build-release
meson test -C build-release --print-errorlogs
meson compile -C build-release calc-disk iso

Meson’s `buildtype` is the build-mode option. `debug` uses `-O0`, full `-g3` symbols, frame pointers, and disabled inlining for GDB. `release` uses the standard `-O3` optimization level. Existing build directories can be switched with `meson configure build -Dbuildtype=debug` or `-Dbuildtype=release`, but separate directories keep debug symbols and artifacts apart.

Run or debug the generated image:

meson compile -C build-debug run
meson compile -C build-debug gdb

The debug target starts QEMU paused with a GDB server on port 1234. Optional disk paths are configured with qemu_disk, qemu_sata_disk1, and qemu_sata_disk2.

Install the kernel and user SDK into a staging sysroot:

DESTDIR="$PWD/dist/sysroot" meson install -C build-release

See docs/structure.md for subsystem ownership, docs/applications.md for building client applications with the JanOS C library, docs/boot-loading.md for the disk and retained Multiboot loading paths, and docs/testing.md for the staged host and QEMU test strategy.

Kernel Navigation

Build an Emacs TAGS file containing only kernel C, header, and assembly files:

./tools/mktags.sh
meson compile -C build tags

Use the search helper for declaration-oriented lookups. Searches are restricted to kernel/include and kernel/src, so the vendored toolchain and userspace code do not add noise:

./tools/ksearch.sh function scheduler_init
./tools/ksearch.sh variable slots
./tools/ksearch.sh struct process
./tools/ksearch.sh typedef syscall_handler_t
./tools/ksearch.sh enum phy_mem_alloc_mode
./tools/ksearch.sh macro SCHEDULER_QUANTUM
./tools/ksearch.sh symbol process_current

About

Exploration project to better understend kernel dev

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages