Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

README.md

ccc-learn

⚠️ This learning platform is an AI-generated companion for the ccc codebase. It explains what shipped in Phases 1–3 of ccc — RISC-V emulator, bare-metal kernel, multi-process OS with filesystem and shell — through structured analyses, beginner guides, interactive demos, code-cases, quizzes, and curated reading lists. Cross-check claims against the source code before quoting them.

A from-scratch RV32 computer in Zig, taught one layer at a time.

The codebase goes from an empty repo to a working text-mode browser; this site goes from "what is a CPU register?" to "trace a single ecall through the whole stack." Topics are stacked bottom-up — each one strictly depends on the ones before it. The three Walkthroughs at the end stitch multiple topics together by following one concrete user-visible action through the entire system.

Topics

rv32-cpu-and-decode

memory-and-mmio

  • memory-and-mmio - In-Depth Analysis — Physical RAM at 0x80000000, the MMIO dispatcher (UART/CLINT/PLIC/block/halt), Sv32 page tables and translateForLoad/Store/Fetch.
  • memory-and-mmio - Beginner Guide — Why "memory-mapped I/O" is just hooks on certain addresses, what a page table is in everyday terms, and how ccc decides where each load/store goes.
  • memory-and-mmio - Interactive — A virtual-to-physical address translator: type a virtual address + a satp, watch the L1 → L0 PTE walk; an MMIO region inspector; an Sv32 PTE flag-bit decoder.
  • memory-and-mmio - Code Cases — How a UART write becomes a function call, why PLIC needs 4 MB of address space for almost no state, the kernel's first identity map, page-fault stories.
  • memory-and-mmio - Practice Quiz — MMIO dispatch, Sv32 layout, PTE flag semantics, the difference between R/W/X bits and U-bit, dirty-bit handling.
  • memory-and-mmio - Further Reading — RISC-V Privileged spec on Sv32, OSTEP paging chapter, xv6's vm.c, and notes on QEMU's softmmu.

csrs-traps-and-privilege

devices-uart-clint-plic-block

kernel-boot-and-syscalls

processes-fork-exec-wait

filesystem-internals

  • filesystem-internals - In-Depth Analysis — On-disk layout (boot + super + bitmap + inode table + data); the bufcache LRU; balloc; inode + bmap (direct + indirect, lazy alloc on for_write); dirent; namei/nameiparent; the mkfs host tool.
  • filesystem-internals - Beginner Guide — Filesystem as a library catalog; inodes as index cards; the bitmap as a "this seat is taken" board; namei as walking down hallways.
  • filesystem-internals - Interactive — On-disk layout visualizer (4 MB image broken down block by block); a namei path-walker; an inode bmap calculator with direct + indirect math.
  • filesystem-internals - Code Casese2e-persist proving writes survive emulator restart; itrunc on nlink == 0; the lazy-alloc story for bmap; how mkfs lays out an empty /tmp/.
  • filesystem-internals - Practice Quiz — How many bytes does one direct block address? What's the max file size? When does iput call itrunc? Why does bget sleep?
  • filesystem-internals - Further Reading — OSTEP file-system chapters, xv6's fs.c (the parent of ccc's FS), "Filesystem Hierarchy Standard," and notes on V6 Unix.

console-and-editor

  • console-and-editor - In-Depth Analysis — Cooked-mode line discipline (echo, backspace, ^C/^U/^D, \n commit), Raw mode for the editor, UART RX → PLIC → console.feedByte flow, ANSI escape subset, edit.zig's 16 KB buffer + redraw loop.
  • console-and-editor - Beginner Guide — "Why doesn't pressing 'a' just send 'a'?" Cooked vs raw mode in plain terms; what ^C actually does; how an ANSI cursor move works.
  • console-and-editor - Interactive — ANSI escape sandbox (type a sequence, see the cursor move on a fake terminal); cooked vs raw simulator (compare keystrokes); editor key-map cheatsheet.
  • console-and-editor - Code Casese2e-cancel proving the ^C chain; e2e-editor showing heYllo; how --input interleaves with cooked echo; the wfi/SIE-window bug story.
  • console-and-editor - Practice Quiz — When does cooked mode echo? What does ^U do? How does the editor land the cursor at byte offset N? Why is \x1b[2J\x1b[H "clear and home"?
  • console-and-editor - Further Reading — Termios docs, ANSI/VT100 escape references, notes/console.md, books on terminal-emulator internals.

shell-and-userland

  • shell-and-userland - In-Depth Analysissh.zig (line read, token split, redirect < > >>, builtins cd/pwd/exit), the fork+exec pattern, the user stdlib (_start, usys.S, printf, O_* constants), all the utilities (ls/cat/echo/mkdir/rm).
  • shell-and-userland - Beginner Guide — A shell is "a forever-loop that asks for a line, splits it into words, and runs the first word as a program." Plain explanations of redirects, builtins, exit codes.
  • shell-and-userland - Interactive — Shell pipeline visualizer: type a command, see token splits, fd dup table, fork tree; a redirect explainer; an _start register-by-register stack-tail dissector.
  • shell-and-userland - Code Casesecho hi > /tmp/x end-to-end; the init_shell fork-exec-sh-wait loop; ls calling Stat on every entry; rm's unlinkat flow.
  • shell-and-userland - Practice Quiz — Why is cd a builtin? What does init_shell do when sh exits non-zero? How does redirect > change the child's fd 1?
  • shell-and-userland - Further Reading — APUE shell + signals chapters, "Build Your Own Shell," xv6's sh.c, the System-V argv ABI doc.

Walkthroughs

journey-of-an-ecall

  • journey-of-an-ecall — Pick one syscall and trace it end-to-end: userland _startusys.Secall → trampoline → s_trap_entrys_kernel_trap_dispatchsyscall.zig → handler → return path. With annotated stack frames at each step.

what-happens-when-you-type-cat-motd

  • what-happens-when-you-type-cat-motd — Single command, full stack: keystroke through --input → UART RX FIFO → PLIC → cooked-mode echo → shell tokenize → fork → execve → namei → readi → write to fd 1 → UART TX → host stdout.

rv32-in-a-browser-tab

  • rv32-in-a-browser-tab — How the same Zig core ships as both a CLI and a browser demo: wasm32-freestanding, comptime CLINT clock branch, Web Worker chunked execution, ANSI rendering in JS, ELFs fetched at runtime not embedded.