-
Notifications
You must be signed in to change notification settings - Fork 0
Home
A field guide to building a bare-metal x86 operating system from a 512-byte boot sector up to a protected-mode C system with a shell, a clock, processes, and a calculator.
This wiki is the companion reference for MyOS-Simple — a progressive,
five-stage OS tutorial. The project's README.md tells you what each stage is; this
wiki explains how and why every mechanism works, down to the byte. Every article is
checked against the actual source in this repository and cites it as path:line.
💡 Tidbit: Nothing in this project depends on an existing OS at runtime. From the first 512 bytes onward, the only thing beneath your code is the BIOS — and by Stage 2, not even that.
| If you want to… | Go to |
|---|---|
| Boot something in two minutes | Building and running |
| Follow the story stage by stage | Stage 1 → 2 → 3 → 4 → 5 |
| Understand one idea deeply | Concepts below |
| Look up a number, port, or byte | Reference below |
| Extend the OS yourself | Writing your own stage |
| # | Stage | Mode | What it adds |
|---|---|---|---|
| 1 | Assembly boot sector | 16-bit real | Boot, BIOS print, color + keyboard variant |
| 2 | C kernel in protected mode | 32-bit protected | Bootloader, GDT, real→protected switch, C kernel, direct VGA |
| 3 | Interactive shell | 32-bit protected | Polled keyboard, command interpreter (5 commands) |
| 4 | Clock, processes, calculator | 32-bit protected | CMOS RTC, process model, fixed-point calc, history/tab/aliases (20 commands) |
| 5 | The stabilized release | 32-bit protected | Consolidated command set (18), committed build artifacts |
The theory, one idea per page. Read these alongside the stage that introduces them.
Firmware & boot
- The boot process — power-on to C entry, end to end
- Real mode — 16-bit segment:offset, the 1 MiB world
-
BIOS services —
int 0x10,int 0x13,int 0x16 -
The boot sector — the 512-byte,
0xAA55contract - Disk loading with int 0x13 — CHS reads, sector counts
Into protected mode
- Protected mode — the switch, the flat model, the far jump
- The Global Descriptor Table — descriptors and selectors
- Freestanding C — life without a standard library
-
Linker scripts — placing a flat binary at
0x1000
Talking to hardware
-
VGA text mode — the framebuffer at
0xB8000 -
The 8042 PS/2 keyboard — polling ports
0x60/0x64 - Scancodes — Set 1, make/break, translation
What an OS does
- The CMOS real-time clock — wall-clock time, BCD, uptime
- Cooperative scheduling — PCBs, the ready queue (and what's only modeled)
- Fixed-point arithmetic — decimals without an FPU
Dense, authoritative lookups.
- Memory map — every address the OS touches
-
I/O ports —
0x60,0x64,0x70,0x71, and the BIOS interrupts - GDT descriptor format — the 8-byte descriptor, bit by bit
- Scancode tables — both Set-1 tables, reproduced exactly
- Command reference — every shell command across stages
- Toolchain and build — tools, flags, targets, versions
- Glossary — every term, defined and linked
The stages are a narrative; the concepts are the encyclopedia behind it. The most rewarding path is to read a stage page, then chase its links into the concept pages whenever you want the full theory, and keep the reference pages open in another tab.
💡 Tidbit: The hardest leap in the whole tutorial is not the C — it is getting the machine into a state where C can run at all. That is the entire job of Stage 2: a GDT, the protected-mode switch, and a fixed load address.
⚠️ Caveat: This is a teaching OS. The process scheduler is an instructive model — the register-level context switch is described but not performed — and several shortcuts (no A20 handling, no RTC update-race guard, fixed sector counts tuned for QEMU) are documented honestly on the relevant pages rather than hidden. Learn the shape here; learn the production details elsewhere.
Stages
- 1 · Assembly boot
- 2 · C protected mode
- 3 · Interactive shell
- 4 · Clock / processes / calc
- 5 · Stabilized release
Concepts — boot
Concepts — protected mode
Concepts — hardware
Concepts — OS services
Reference
- Memory map
- I/O ports
- GDT descriptor format
- Scancode tables
- Command reference
- Toolchain & build
- Glossary
Guides