Atlas

i686 / x86 Bare Metal Monolithic Kernel C + NASM

Atlas OS

A hobby operating system built from scratch in two weekends.

atlas — tty0
Atlas OS
atlas :~$ help
available commands:
  clear - Clear the screen
  echo - Print arguments
  help - List all commands
  uptime - Show time since boot
  mem - Show bytes in heap
  date - Show current date and time
  beep - Beep the speaker (freq hz, duration ms)
  ps - List tasks
  kill - Kill a task by PID
atlas :~$ uptime
uptime: 0h 0m 7s
atlas :~$

Overview

Atlas is a monolithic, bare-metal operating system targeting i686 (x86 protected mode), built as a hands-on dive into low-level systems programming. It has no dependencies - no libc, no GRUB, no external libraries of any kind. It ships its own 512-byte bootloader written in NASM that loads the kernel off disk via BIOS INT 13h, sets up a GDT, switches the CPU into 32-bit protected mode, and jumps to the kernel.

From there a monolithic C kernel takes over: it initialises paging, a physical memory manager, the IDT, the PIC, a PIT-driven tick counter, a PS/2 keyboard driver, a heap allocator, a round-robin task scheduler, and an RTC reader — then drops you into an interactive shell. Everything from memset to printf-style output is implemented from scratch in kstring.c and vga.c.

Features

Custom Bootloader

A hand-written 512-byte x86 bootloader in NASM. Loads 64 sectors from disk via BIOS INT 13h into 0x1000, sets up a GDT, switches to 32-bit protected mode, and jumps directly to the kernel — no GRUB involved.

VGA Text Console

Direct memory-mapped I/O to 0xB8000. Supports newlines, backspace, forward-delete, hardware cursor sync via ports 0x3D4/0x3D5, and automatic scrolling when the screen fills.

Memory Management

A bitmap-based PMM managing 16 MB of RAM in 4 KB pages, with free pages starting at 2 MB to avoid stomping the kernel. A VMM handles page table walk, mapping, unmapping, and physical address resolution. The heap uses a first-fit linked-list allocator with block splitting and coalescing on free.

IDT, PIC & IRQ Handling

256-entry IDT with ISR stubs in NASM. The 8259 PIC is remapped to vectors 0x200x2F to avoid conflicts with CPU exceptions. IRQ0 (PIT at 1000 Hz) drives the tick counter and task scheduler; IRQ1 services the PS/2 keyboard.

Shell

Interactive shell with a command registry, argument parsing, inline cursor movement, backspace, forward-delete, and a 16-entry history navigable with arrow keys. Built-in commands: clear, echo, help, uptime, mem, date, beep, ps, kill, pmm, vmm.

Preemptive Task Scheduler

Up to 8 tasks with IRQ0-driven round-robin scheduling. Context switching is done in NASM: pusha saves registers onto the stack, the current ESP is passed to task_schedule(), and the returned ESP of the next ready task is restored with popa/iret. Tasks can sleep with task_sleep(ms) and be killed by PID.

PS/2 Keyboard

IRQ1-driven driver with a full scancode-to-ASCII map, Shift and Caps Lock handling, and extended scancode (0xE0) support for arrow keys and Delete. Characters are pushed into a 64-byte ring buffer and consumed by the shell's input loop.

PC Speaker & RTC

PIT channel 2 drives the PC speaker for arbitrary-frequency beeps via beep <hz> <ms>. The CMOS RTC is read directly over I/O ports 0x70/0x71 to get the current date and time, with BCD-to-binary conversion handled in kernel space.

Architecture

Shell + Commands clear · echo · help · uptime · mem · date · beep · ps · kill
Kernel Core VGA console · kmalloc · kstring · task scheduler · RTC
Memory Subsystem PMM (bitmap, 16 MB) · VMM (page tables) · paging
Interrupt Layer IDT (256 entries) · 8259 PIC · IRQ0 PIT 1 kHz · IRQ1 PS/2
Custom Bootloader → i686 Hardware / QEMU boot.asm · GDT · protected mode · BIOS INT 13h · os.img

Atlas is a monolithic kernel — every subsystem runs in ring 0 with a flat address space. The kernel is linked to 0x1000 by linker.ld and output as a raw binary (no ELF, no multiboot). The Makefile cats the bootloader binary and kernel binary together into a single build/os.img that QEMU or dd can boot directly.

The heap lives past the kernel's .bss section (aligned to 4 KB by the linker script), with its start address exported as heap_start. All string and memory utilities — kstrcmp, kmemset, kmemcpy, and friends — are in kstring.c. There is no libc anywhere in the build.

Build & Run

Atlas builds with a cross-compiler targeting i686-elf and runs in QEMU or on real x86 hardware. You'll need nasm, i686-elf-gcc, i686-elf-ld, and qemu-system-i386. The QEMU invocation enables PC speaker output via CoreAudio on macOS.

1

Clone the repo

git clone https://github.com/Jdrc6000/atlas.git
cd atlas
2

Build

make

Assembles boot/boot.asm to a flat binary, compiles all C and NASM kernel sources with i686-elf-gcc, links with linker.ld into build/kernel.bin, then concatenates bootloader + kernel into build/os.img.

3

Run in QEMU

make run

Boots build/os.img in qemu-system-i386 as a raw disk image with PC speaker support. The beep command produces real audio on macOS.

4

Write to real hardware (optional)

dd if=build/os.img of=/dev/sdX bs=512 status=progress

Replace /dev/sdX with your USB drive. The image is a raw disk — no partition table, no filesystem — so any x86 machine will boot it directly from BIOS.

5

Clean

make clean

Removes the build/ directory entirely.