Master the fundamental concepts of build a mini kernel through this focused micro-challenge.
You have read the whole brief, and the concepts above stay free on every task. Writing and running the code needs a plan.
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
Every task includes starter code, theory, and hidden tests so you can implement and verify locally in the browser.
How it worksVGA text mode maps an 80x25 array of character/attribute pairs at 0xB8000. Writing 0x0741 stores white-on-black A without a graphics driver.
Each cell:
For example, row 2 col 5 lives at index (2 * 80 + 5) * 2 bytes from 0xB8000.
Writing directly to the VGA buffer at physical address 0xB8000 is exactly how BIOS, GRUB, DOS, and the early Linux console all rendered text for decades before framebuffer graphics took over. Forgetting to handle scrolling when the cursor passes row 24 is a classic bug that causes new kernel output to silently disappear off the bottom of the screen instead of appearing.
Before you call the implementation done, walk failure modes on purpose. Test empty structures, single-element edge cases, maximum concurrency, and errno paths that must not crash the program. OS code usually fails in production when happy-path tests pass but invariants break under contention or memory pressure.
Keep structures small and name fields after kernel counterparts when possible. That lets you read man pages and kernel source side by side while you work. Print observable events during development; remove noisy logs once tests pass reliably.
You will implement cursor movement, newline scroll, and colored kprintf output. The task asks you to wrap long lines without corrupting attribute bytes.
Write a VGA text-mode console. The screen is an array of 16-bit cells at physical address 0xB8000. Each cell holds the character in its low byte and an attribute in its high byte: the foreground colour in bits 0-3 and the background colour in bits 4-7. The console tracks a cursor, handles \n, \t and \b, wraps long lines, scrolls when it runs off the bottom, and programs the hardware cursor through the CRT controller.
cLoading…
Colours 0-15: black blue green cyan red magenta brown light-grey dark-grey light-blue light-green light-cyan light-red pink yellow white. The start-up attribute is 0x07 (light-grey on black).
row * W + col with the current attribute, and the cursor then advances. Writing to the last column wraps the cursor to the next row.\n moves to column 0 of the next row. \t writes spaces up to the next multiple of 8 columns (at least one). \b moves back one column and blanks that cell, but does nothing at column 0.row * W + col. Write register 0x0f (low byte) and then 0x0e (high byte) through index port 0x3d4 and data port 0x3d5.screen WxH: unsupported, color FG BG: unknown colour, cursor R C: off screen, and cell R C: off screen.cLoading…
If the background colour is 8 or higher, color adds (bit 7 set: blinks on real hardware). dump draws a border W dashes wide, with the cursor and scroll count on the top line, and then every row between | characters.
Input:
cLoading…
Output:
cLoading…
uint16_t array indexed by row * W + col, and build entries as c | attr << 8.memmove of W * (H - 1) cells.Hidden tests cover backspace at and away from column 0, clear with a coloured attribute, bright backgrounds, unknown colours and off-screen coordinates, text that scrolls several times, and a hardware cursor position that needs the high byte on the default 80x25 screen.