Bootable Kernel
You'll run your own code on bare metal from a USB stick, with interrupts, two tasks on a timer, and a system call answered for a user program.
About
Everything else in this track ran on top of an operating system, so the last step is to run on nothing. You'll write a kernel in C or Rust that a bootloader like GRUB or Limine loads, print to the screen, take keyboard and timer interrupts, switch between two tasks on the timer tick, and run a user-mode program that asks you for a system call. QEMU is free and is where you'll spend most of the year, and booting on a real laptop from a USB stick is the finish line. Use a spare stick and a machine you've backed up, because a kernel with a bug can scribble on any disk it sees. The OSDev wiki is free and has everything, and this takes a year of weekends.
At a glance
- Per requirement
- 75 XP
- Completion bonus
- 1200 XP
- Requirements
- 7
- Takes
- A year of weekends
- Skill level
- Expert (what few ever do)
- Cost
- Cheap (under $10)
- Supplies
- You need some
- Where
- At home
- Other people
- On your own
Requirements
-
1
Boot a kernel that prints a line on the screen in QEMU. Use a multiboot or Limine bootloader so you don't have to write a boot sector. Write to the VGA text buffer or the framebuffer the bootloader hands you. Take a screenshot of QEMU showing your line. Photo
-
2
Set up the exception table and catch a CPU fault on purpose without rebooting. On x86 that means the GDT and IDT and a divide by zero. On ARM it means the exception vector table and a read from an unmapped address, because ARM doesn't trap on integer division. Install a handler for every vector and print the vector number and the faulting address. Take a screenshot of your handler's message instead of a triple fault or a silent reset. Photo
-
3
Take keyboard and timer interrupts and echo typed keys to the screen. Program the interrupt controller and the timer, write a scancode table for the keys you need, and acknowledge each interrupt. Film a short clip of typing in QEMU and seeing the characters appear. Video
-
4
Write a physical page allocator and turn on paging with your own page tables. Parse the memory map from the bootloader, keep a bitmap of free frames, and build page tables so your kernel runs with paging on. Map a page, write to it, unmap it, and show the page fault when you touch it again. Take a screenshot of the fault with the address. Photo
-
5
Switch between two kernel tasks on the timer tick. Each task has its own stack and saved registers, and the timer handler saves one and restores the other. Have each task print its name in a loop and watch them alternate. Film a short clip of the two tasks interleaving. Video
-
6
Run a user-mode program that makes a system call to print a string. Load a flat binary into a user page, jump to ring 3 (or EL0 on ARM), and have it trigger a syscall instruction or a software interrupt that your kernel answers. Take a screenshot of the string printed by the kernel on behalf of the user program. Photo
-
7
Boot it on real hardware from a USB stick and film it. Any old x86 laptop works, and a ten-year-old one from a thrift store is ideal; an Apple Silicon Mac won't boot it, so borrow a PC. Turn Secure Boot off in the firmware settings first or it will refuse your image. Build an ISO or a raw image and write it to a spare stick. Check the device name twice before you write the image, because dd to the wrong disk erases it. Expect something to differ from QEMU, usually the keyboard or the framebuffer. Film the machine powering on and your kernel taking keystrokes. Video