Skip to main content

strat9_kernel/arch/x86_64/vga/
mod.rs

1/*
2 * This file is part of strat9-os.
3 *
4 * strat9-os is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * strat9-os is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with strat9-os. If not, see <https://www.gnu.org/licenses/>.
16 *
17 * Website: https://www.strat9-os.org
18 * Repository: https://github.com/strat9-os/strat9-os
19 *
20 * Copyright (C) 2023-26 Guillaume Gielly
21 */
22
23//! Framebuffer text console (UEFI bootloader framebuffer + PSF font).
24//! https://en.wikipedia.org/wiki/PC_Screen_Font
25//!
26//! Keeps the existing `vga_print!` / `vga_println!` API but renders text into
27//! the graphical framebuffer when available. Falls back to serial otherwise.
28//!
29//! # Module structure
30//!
31//! - `types`    : Color, RgbColor, UiTheme, layout types, terminal widget
32//! - `font`     : PSF font parsing (PSF1/PSF2 + unicode map)
33//! - `writer`   : `VgaWriter` struct: glyph rendering, scrollback, cursors,
34//!                double-buffering, dirty-rect tracking, present
35//! - `canvas`   : `Canvas` convenience drawing API
36//! - `api`      : Public free functions, `VGA_WRITER` static, `init()`
37//! - `panic_screen` : Lock-free panic framebuffer drawing
38//! - `debug_overlay` : Live debug overlay (bypasses VGA_WRITER)
39//! - `status_line` : Status bar kthread and rendering
40
41mod api;
42pub mod boot_progress;
43mod canvas;
44mod console_mode;
45mod cursor;
46mod debug_overlay;
47pub(crate) mod fastfb;
48mod font;
49mod panic_screen;
50mod scrollback;
51pub(crate) mod status_line;
52mod types;
53mod writer;
54
55// Re-export everything that was previously public from the old monolithic vga.rs.
56pub use api::*;
57pub use canvas::Canvas;
58pub use console_mode::{
59    current as console_mode, is_lite, is_serial, present_min_ticks, select as select_console_mode,
60    ConsoleMode,
61};
62pub use types::*;
63pub use writer::VgaWriter;
64
65pub use status_line::{
66    draw_system_status_line, maybe_refresh_system_status_line, set_status_hostname, set_status_ip,
67    status_line_task_main, ui_draw_status_bar,
68};
69
70pub use debug_overlay::{vga_debug_init, vga_debug_write, vga_debug_writeln};
71pub use panic_screen::{init_panic_fb_globals, panic_draw_direct};
72
73/// Print to framebuffer console (falls back to serial when unavailable).
74#[macro_export]
75macro_rules! vga_print {
76    ($($arg:tt)*) => {
77        if !$crate::debug_cfg::is_quiet() && $crate::vasistas_state::kernel_fb_allowed() {
78            $crate::arch::x86_64::vga::_print(format_args!($($arg)*));
79        }
80    };
81}
82
83/// Print line to framebuffer console (falls back to serial when unavailable).
84/// Flushes to screen after each line.
85#[macro_export]
86macro_rules! vga_println {
87    () => {
88        if !$crate::debug_cfg::is_quiet() && $crate::vasistas_state::kernel_fb_allowed() {
89            $crate::vga_print!("\n");
90            $crate::arch::x86_64::vga::flush_display();
91        }
92    };
93    ($($arg:tt)*) => {
94        if !$crate::debug_cfg::is_quiet() && $crate::vasistas_state::kernel_fb_allowed() {
95            $crate::vga_print!("{}\n", format_args!($($arg)*));
96            $crate::arch::x86_64::vga::flush_display();
97        }
98    };
99}