Expand description
Lock-free circular buffer for VGA log lines.
The kernelβs log::info! / log::warn! / etc. macros write to this buffer
instead of directly locking VGA_WRITER. A background display task (or the
panic handler) calls vgabuf_flush_to_framebuffer() to render the buffered
lines onto the actual framebuffer.
This decouples the hot logging path from the (comparatively) slow framebuffer drawing, preventing deadlocks and keeping log output fast.
StructsΒ§
- VgaSlot π
- Raw storage: each slot is a fixed-size byte buffer.
Wrapped in a newtype that is
Syncbecause we only access slots via atomically-coordinated indices (single writer per slot).
ConstantsΒ§
- FLUSH_
BATCH π - Maximum number of lines we render in one flush call (to keep frame time bounded).
- VGABUF_
CAPACITY - Maximum number of lines stored in the circular buffer. 512 gives ample headroom: at 100Hz flush Γ 30 lines/batch, the writer would need to produce >512 log messages between two reader ticks to overwrite an unread slot.
- VGABUF_
LINE_ LEN - Maximum byte length of a single log line (including trailing newline).
StaticsΒ§
- DISPLAY_
IDX π - Slot that the display task has rendered up to (exclusive).
- LENS π
- Length (in bytes) of each stored line. 0 means the slot is unused.
- STORAGE π
- TOTAL_
WRITTEN π - Total lines written since boot (for ordering / watermark).
- WRITE_
IDX π - Next slot to write into (monotonic, wraps via
% CAPACITY).
FunctionsΒ§
- vgabuf_
drain_ πdiscard - Drain all pending lines without rendering (e.g. framebuffer not available).
- vgabuf_
flush_ all - Flush all remaining lines (used by the panic handler before halting).
- vgabuf_
flush_ πall_ direct - Fallback when VGA_WRITER is locked: use the direct panic drawer. Uses a fixed-size stack buffer to avoid heap allocation in panic context.
- vgabuf_
flush_ to_ framebuffer - Read buffered lines and render them onto the framebuffer via
crate::arch::x86_64::vga::VGA_WRITER. - vgabuf_
total_ written - Return the total number of lines written since boot.
- vgabuf_
write - Write a line into the circular buffer.