Migrated from ~/Projects/mos
  • Mojo 84.4%
  • Assembly 7.3%
  • Makefile 2.8%
  • Shell 2.8%
  • Linker Script 2.7%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-09-09 14:10:42 +01:00
.gitignore feat: big bang 2026-09-09 14:10:42 +01:00
.python-version feat: big bang 2026-09-09 14:10:42 +01:00
boot.s feat: big bang 2026-09-09 14:10:42 +01:00
build.sh feat: big bang 2026-09-09 14:10:42 +01:00
kernel.mojo feat: big bang 2026-09-09 14:10:42 +01:00
linker.ld feat: big bang 2026-09-09 14:10:42 +01:00
Makefile feat: big bang 2026-09-09 14:10:42 +01:00
pyproject.toml feat: big bang 2026-09-09 14:10:42 +01:00
README.md feat: big bang 2026-09-09 14:10:42 +01:00
run-qemu.sh feat: big bang 2026-09-09 14:10:42 +01:00
stubs.s feat: big bang 2026-09-09 14:10:42 +01:00

mos

Small x86 hobby OS experiment built from a Multiboot entry stub, a 64-bit bootstrap path, and a Mojo kernel.

What is here

  • boot.s: Multiboot header and early bootstrap that enables paging and jumps into long mode.
  • stubs.s: Runtime shims expected by the Mojo toolchain plus the inb wrapper used for keyboard input.
  • kernel.mojo: VGA plus serial-console kernel prototype with a tiny Linux-shaped process model.
  • linker.ld: Kernel linker script placing the image at 1 MiB.
  • Makefile: Rebuilds the kernel with the checked-in Mojo SDK and system assembler/linker.
  • build.sh: Shell build path using the exact commands verified in this repo.

Current behavior

The kernel:

  • enters 64-bit mode from the Multiboot loader
  • writes directly to VGA text memory at 0xb8000
  • initializes COM1 and mirrors console output to serial
  • exposes four process slots with PID, PPID, state, and tick counters
  • boots with pid 1 = init and pid 2 = kthreadd
  • models runnable, sleeping, stopped, and zombie task states
  • lets init reap zombies and reparent tasks when their parent exits

Current serial controls:

  • h: help
  • s: spawn a worker under init
  • n: select the next non-empty slot
  • t: run one scheduler tick on the selected task
  • p: toggle stop/run for the selected task
  • z: toggle sleep/wake for the selected task
  • k: terminate the selected task into zombie state
  • r: let init reap one zombie
  • 1 2 3 4: directly select a slot

This is still a prototype. It is not close to Linux feature parity: there is no memory management subsystem, userspace ABI, ELF loader, syscall layer, VFS, driver model, interrupts, or real init process execution. What exists now is a small step toward that shape, not a 1:1 Linux clone.

Existing build artifacts

This repository currently contains generated outputs from local builds:

  • boot.o
  • stubs.o
  • kernel.o
  • kernel64.bin
  • myos.bin
  • kgen.trace.json.time-events.txt
  • kgen.trace.json.time-trace

kernel64.bin is the reproducible linked ELF64 kernel image produced by the current Makefile.

myos.bin is a legacy checked-in artifact from an older flow and is not currently regenerated by the new build target.

Build

Run:

./build.sh

Or, if make is installed on the machine:

make

Both routes rebuild:

  • boot.o from boot.s
  • stubs.o from stubs.s
  • kernel.s from kernel.mojo using the checked-in Mojo SDK
  • kernel.o from kernel.s
  • kernel64.bin from the linker script plus all objects

make clean removes the generated build outputs when make is available.

Run

Best-effort QEMU launcher:

./run-qemu.sh

Notes:

  • this environment has qemu-system-x86_64
  • this environment does not have grub-mkrescue or ISO tooling
  • the direct QEMU ELF loader path is the only local option wired here
  • the kernel build is verified; the headless QEMU boot path is still experimental and may need a proper Multiboot/GRUB handoff to be fully reliable

Next useful work

  • add a real boot path with GRUB or a 32-bit Multiboot wrapper image
  • replace the fixed process slots with kernel task structs and queues
  • add interrupts, timers, and a real scheduler tick
  • introduce a syscall boundary and a genuine init userspace program