⚠️ VeridianOS Kernel Documentation - This is low-level kernel code. All functions are unsafe unless explicitly marked otherwise. no_std

Module fbcon

Module fbcon 

Source
Expand description

Framebuffer console (fbcon) — text rendering onto a pixel framebuffer.

Renders characters using the 8x16 bitmap font onto the UEFI-provided (or ramfb-provided) pixel framebuffer. Supports cursor tracking, newlines, tab stops, backspace, scrolling, and basic ANSI color escape sequences.

§Performance architecture

Three-layer pipeline with eager rendering, glyph cache, and incremental dirty-row blitting:

  1. Text cell grid — character/color pairs in a ring buffer. Scrolling is O(cols) (advance ring pointer + clear one row of cells).
  2. RAM back-buffer — always in sync via eager rendering (each glyph rendered to pixels immediately on write). Scrolling uses a simple memmove (~1ms in RAM) and marks all rows dirty (dirty_all). A glyph cache pre-renders all 256 glyphs as u32 pixel arrays for the current color pair, making glyph rendering a copy_nonoverlapping of 32 bytes per row.
  3. Hardware framebuffer — MMIO memory. Touched once per flush() call, only for dirty rows — typically one row (~80KB) instead of the full screen (~4MB). On x86_64, write-combining (PAT) provides faster MMIO writes.

Thread-safety: The global FBCON is protected by a spinlock. Interrupt handlers must NOT call _fbcon_print (use raw serial output for diagnostics in ISRs).

Structs§

FbHwInfo
Framebuffer hardware information for the compositor.
FramebufferConsole
Framebuffer console state.

Enums§

FbPixelFormat
Pixel format of the framebuffer.

Functions§

_fbcon_print
Print formatted text to the framebuffer console.
cursor_row
Return the current text cursor row (for targeted row flushing).
disable_output
Disable fbcon text output (when switching to GUI compositor).
enable_output
Enable fbcon output. Called after boot completes (just before the shell launches) so that the hundreds of boot log lines don’t get rendered pixel-by-pixel to the framebuffer in QEMU.
flush
Blit all pending changes to the hardware framebuffer.
flush_row
Blit a single text row from back-buffer to MMIO and clear its dirty flag.
get_hw_info
Get the hardware framebuffer information.
init
Initialize the framebuffer console with the given parameters.
is_initialized
Check if the framebuffer console has been initialized.
mark_all_dirty_and_flush
Mark all rows dirty and trigger a full blit on the next flush.
update_cursor
Update the cursor overlay on the MMIO framebuffer.