Files
AirlysOS/drivers/font.c
T
Adam Eehan da3f0788d0 fix(baremetal): 512GB identity paging, early GOP splash, dual-output console & COM1/RTC timeout guards
- arch/x86_64/boot.s: Map 8GB..512GB using 1GB huge pages in PDPT; set Multiboot2 FB tag to required native 32bpp
- drivers/serial.c: Add scratch register hardware probe & 50k timeout guard to prevent infinite polling hang on modern AMD chipsets
- drivers/rtc.c: Add timeout guard to CMOS status register polling
- drivers/vga.c: Bypass legacy 0x3D4/0x3D5 CRT ports in GOP mode; mirror all characters to active hardware framebuffer
- drivers/vbe.c: Implement vbe_early_boot_splash, direct front-buffer console rendering & dynamic backbuffer allocation
- kernel/kmain.c: Initialize GOP linear framebuffer at Step 0 for instant physical screen illumination; use pause+counter in render loop
- scripts/build_iso.sh: Support universal GOP/VBE/VGA multi-resolution auto-detect for both bare metal and VirtualBox
2026-10-24 01:21:00 +05:30

149 lines
11 KiB
C

#include <airlys/font.h>
#include <airlys/vbe.h>
/* Standard embedded 8x16 monochrome bitmap font table (ASCII 32..126) */
static const uint8_t s_font8x16[95][16] = {
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, /* ' ' */
{0x00,0x00,0x18,0x3C,0x3C,0x3C,0x18,0x18,0x18,0x00,0x18,0x18,0x00,0x00,0x00,0x00}, /* '!' */
{0x00,0x66,0x66,0x66,0x24,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, /* '"' */
{0x00,0x00,0x6C,0x6C,0xFE,0x6C,0x6C,0x6C,0xFE,0x6C,0x6C,0x00,0x00,0x00,0x00,0x00}, /* '#' */
{0x18,0x18,0x7C,0xC6,0xC2,0xC0,0x7C,0x06,0x06,0x86,0xC6,0x7C,0x18,0x18,0x00,0x00}, /* '$' */
{0x00,0x00,0x00,0xC2,0xC6,0x0C,0x18,0x30,0x60,0xC6,0x86,0x00,0x00,0x00,0x00,0x00}, /* '%' */
{0x00,0x00,0x38,0x6C,0x64,0x30,0x76,0xCC,0xCC,0xCC,0x76,0x00,0x00,0x00,0x00,0x00}, /* '&' */
{0x00,0x30,0x30,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, /* ''' */
{0x00,0x0C,0x18,0x30,0x30,0x60,0x60,0x60,0x30,0x30,0x18,0x0C,0x00,0x00,0x00,0x00}, /* '(' */
{0x00,0x30,0x18,0x0C,0x0C,0x06,0x06,0x06,0x0C,0x0C,0x18,0x30,0x00,0x00,0x00,0x00}, /* ')' */
{0x00,0x00,0x00,0x66,0x3C,0xFF,0x3C,0x66,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, /* '*' */
{0x00,0x00,0x00,0x18,0x18,0x7E,0x18,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, /* '+' */
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x18,0x30,0x00,0x00,0x00}, /* ',' */
{0x00,0x00,0x00,0x00,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, /* '-' */
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x00,0x00}, /* '.' */
{0x00,0x00,0x02,0x06,0x0C,0x18,0x30,0x60,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00}, /* '/' */
{0x00,0x00,0x7C,0xC6,0xCE,0xD6,0xE6,0xC6,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00,0x00}, /* '0' */
{0x00,0x00,0x18,0x38,0x78,0x18,0x18,0x18,0x18,0x18,0x7E,0x00,0x00,0x00,0x00,0x00}, /* '1' */
{0x00,0x00,0x7C,0xC6,0x06,0x0C,0x18,0x30,0x60,0xC0,0xFE,0x00,0x00,0x00,0x00,0x00}, /* '2' */
{0x00,0x00,0x7C,0xC6,0x06,0x1C,0x06,0x06,0x06,0xC6,0x7C,0x00,0x00,0x00,0x00,0x00}, /* '3' */
{0x00,0x00,0x0C,0x1C,0x3C,0x6C,0xCC,0xFE,0x0C,0x0C,0x1E,0x00,0x00,0x00,0x00,0x00}, /* '4' */
{0x00,0x00,0xFE,0xC0,0xC0,0xFC,0x06,0x06,0x06,0xC6,0x7C,0x00,0x00,0x00,0x00,0x00}, /* '5' */
{0x00,0x00,0x38,0x60,0xC0,0xFC,0xC6,0xC6,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00,0x00}, /* '6' */
{0x00,0x00,0xFE,0xC6,0x06,0x0C,0x18,0x30,0x30,0x30,0x30,0x00,0x00,0x00,0x00,0x00}, /* '7' */
{0x00,0x00,0x7C,0xC6,0xC6,0x7C,0xC6,0xC6,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00,0x00}, /* '8' */
{0x00,0x00,0x7C,0xC6,0xC6,0xC6,0x7E,0x06,0x06,0x0C,0x78,0x00,0x00,0x00,0x00,0x00}, /* '9' */
{0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, /* ':' */
{0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x18,0x18,0x30,0x00,0x00,0x00,0x00,0x00,0x00}, /* ';' */
{0x00,0x06,0x0C,0x18,0x30,0x60,0x30,0x18,0x0C,0x06,0x00,0x00,0x00,0x00,0x00,0x00}, /* '<' */
{0x00,0x00,0x00,0x7E,0x00,0x00,0x7E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, /* '=' */
{0x00,0x60,0x30,0x18,0x0C,0x06,0x0C,0x18,0x30,0x60,0x00,0x00,0x00,0x00,0x00,0x00}, /* '>' */
{0x00,0x00,0x7C,0xC6,0x06,0x0C,0x18,0x18,0x00,0x18,0x18,0x00,0x00,0x00,0x00,0x00}, /* '?' */
{0x00,0x00,0x7C,0xC6,0xDE,0xDE,0xDE,0xC0,0xC0,0xC6,0x7C,0x00,0x00,0x00,0x00,0x00}, /* '@' */
{0x00,0x00,0x18,0x3C,0x66,0xC3,0xC3,0xFF,0xC3,0xC3,0xC3,0x00,0x00,0x00,0x00,0x00}, /* 'A' */
{0x00,0x00,0xFC,0x66,0x66,0x7C,0x66,0x66,0x66,0x66,0xFC,0x00,0x00,0x00,0x00,0x00}, /* 'B' */
{0x00,0x00,0x3C,0x66,0xC3,0xC0,0xC0,0xC0,0xC3,0x66,0x3C,0x00,0x00,0x00,0x00,0x00}, /* 'C' */
{0x00,0x00,0xF8,0x6C,0x66,0x66,0x66,0x66,0x66,0x6C,0xF8,0x00,0x00,0x00,0x00,0x00}, /* 'D' */
{0x00,0x00,0xFE,0x62,0x60,0x7C,0x60,0x60,0x62,0x62,0xFE,0x00,0x00,0x00,0x00,0x00}, /* 'E' */
{0x00,0x00,0xFE,0x62,0x60,0x7C,0x60,0x60,0x60,0x60,0xF0,0x00,0x00,0x00,0x00,0x00}, /* 'F' */
{0x00,0x00,0x3C,0x66,0xC3,0xC0,0xC0,0xCF,0xC3,0x66,0x3E,0x00,0x00,0x00,0x00,0x00}, /* 'G' */
{0x00,0x00,0xC3,0xC3,0xC3,0xFF,0xC3,0xC3,0xC3,0xC3,0xC3,0x00,0x00,0x00,0x00,0x00}, /* 'H' */
{0x00,0x00,0x7E,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x7E,0x00,0x00,0x00,0x00,0x00}, /* 'I' */
{0x00,0x00,0x1E,0x06,0x06,0x06,0x06,0x06,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00,0x00}, /* 'J' */
{0x00,0x00,0xC6,0xCC,0xD8,0xF0,0xE0,0xD8,0xCC,0xC6,0xC3,0x00,0x00,0x00,0x00,0x00}, /* 'K' */
{0x00,0x00,0xF0,0x60,0x60,0x60,0x60,0x60,0x62,0x66,0xFE,0x00,0x00,0x00,0x00,0x00}, /* 'L' */
{0x00,0x00,0xC3,0xE7,0xFF,0xDB,0xC3,0xC3,0xC3,0xC3,0xC3,0x00,0x00,0x00,0x00,0x00}, /* 'M' */
{0x00,0x00,0xC3,0xE3,0xF3,0xDB,0xCF,0xC7,0xC3,0xC3,0xC3,0x00,0x00,0x00,0x00,0x00}, /* 'N' */
{0x00,0x00,0x7C,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00,0x00}, /* 'O' */
{0x00,0x00,0xFC,0x66,0x66,0x66,0x7C,0x60,0x60,0x60,0xF0,0x00,0x00,0x00,0x00,0x00}, /* 'P' */
{0x00,0x00,0x7C,0xC6,0xC6,0xC6,0xC6,0xC6,0xD6,0xCC,0x7A,0x06,0x00,0x00,0x00,0x00}, /* 'Q' */
{0x00,0x00,0xFC,0x66,0x66,0x66,0x7C,0x6C,0x66,0x66,0xE3,0x00,0x00,0x00,0x00,0x00}, /* 'R' */
{0x00,0x00,0x7C,0xC6,0xC0,0x78,0x0C,0x06,0x06,0xC6,0x7C,0x00,0x00,0x00,0x00,0x00}, /* 'S' */
{0x00,0x00,0xFF,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x00,0x00,0x00,0x00,0x00}, /* 'T' */
{0x00,0x00,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0x7E,0x00,0x00,0x00,0x00,0x00}, /* 'U' */
{0x00,0x00,0xC3,0xC3,0xC3,0xC3,0xC3,0x66,0x66,0x3C,0x18,0x00,0x00,0x00,0x00,0x00}, /* 'V' */
{0x00,0x00,0xC3,0xC3,0xC3,0xC3,0xDB,0xFF,0x66,0x66,0x66,0x00,0x00,0x00,0x00,0x00}, /* 'W' */
{0x00,0x00,0xC3,0x66,0x3C,0x18,0x18,0x3C,0x66,0xC3,0xC3,0x00,0x00,0x00,0x00,0x00}, /* 'X' */
{0x00,0x00,0xC3,0xC3,0x66,0x3C,0x18,0x18,0x18,0x18,0x3C,0x00,0x00,0x00,0x00,0x00}, /* 'Y' */
{0x00,0x00,0xFF,0x03,0x06,0x0C,0x18,0x30,0x60,0xC0,0xFF,0x00,0x00,0x00,0x00,0x00}, /* 'Z' */
{0x00,0x3C,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x3C,0x00,0x00,0x00,0x00,0x00}, /* '[' */
{0x00,0x00,0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01,0x00,0x00,0x00,0x00,0x00,0x00}, /* '\' */
{0x00,0x3C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x3C,0x00,0x00,0x00,0x00,0x00}, /* ']' */
{0x00,0x18,0x3C,0x66,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, /* '^' */
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00}, /* '_' */
{0x00,0x30,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, /* '`' */
{0x00,0x00,0x00,0x00,0x78,0x0C,0x7C,0xCC,0xCC,0xCC,0x76,0x00,0x00,0x00,0x00,0x00}, /* 'a' */
{0x00,0x00,0xE0,0x60,0x60,0x7C,0x66,0x66,0x66,0x66,0xDC,0x00,0x00,0x00,0x00,0x00}, /* 'b' */
{0x00,0x00,0x00,0x00,0x78,0xCC,0xC0,0xC0,0xC0,0xCC,0x78,0x00,0x00,0x00,0x00,0x00}, /* 'c' */
{0x00,0x00,0x1C,0x0C,0x0C,0x7C,0xCC,0xCC,0xCC,0xCC,0x76,0x00,0x00,0x00,0x00,0x00}, /* 'd' */
{0x00,0x00,0x00,0x00,0x78,0xCC,0xFE,0xC0,0xC0,0xCC,0x78,0x00,0x00,0x00,0x00,0x00}, /* 'e' */
{0x00,0x00,0x1C,0x36,0x30,0x7C,0x30,0x30,0x30,0x30,0x78,0x00,0x00,0x00,0x00,0x00}, /* 'f' */
{0x00,0x00,0x00,0x00,0x76,0xCC,0xCC,0xCC,0xCC,0x7C,0x0C,0xCC,0x78,0x00,0x00,0x00}, /* 'g' */
{0x00,0x00,0xE0,0x60,0x60,0x6C,0x76,0x66,0x66,0x66,0xE6,0x00,0x00,0x00,0x00,0x00}, /* 'h' */
{0x00,0x00,0x18,0x18,0x00,0x38,0x18,0x18,0x18,0x18,0x3C,0x00,0x00,0x00,0x00,0x00}, /* 'i' */
{0x00,0x00,0x0C,0x0C,0x00,0x1C,0x0C,0x0C,0x0C,0x0C,0x0C,0xCC,0x78,0x00,0x00,0x00}, /* 'j' */
{0x00,0x00,0xE0,0x60,0x60,0x66,0x6C,0x78,0x78,0x6C,0xE6,0x00,0x00,0x00,0x00,0x00}, /* 'k' */
{0x00,0x00,0x78,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x3C,0x00,0x00,0x00,0x00,0x00}, /* 'l' */
{0x00,0x00,0x00,0x00,0xEC,0xFE,0xD6,0xD6,0xD6,0xD6,0xD6,0x00,0x00,0x00,0x00,0x00}, /* 'm' */
{0x00,0x00,0x00,0x00,0xDC,0x66,0x66,0x66,0x66,0x66,0x66,0x00,0x00,0x00,0x00,0x00}, /* 'n' */
{0x00,0x00,0x00,0x00,0x78,0xCC,0xCC,0xCC,0xCC,0xCC,0x78,0x00,0x00,0x00,0x00,0x00}, /* 'o' */
{0x00,0x00,0x00,0x00,0xDC,0x66,0x66,0x66,0x66,0x7C,0x60,0x60,0xF0,0x00,0x00,0x00}, /* 'p' */
{0x00,0x00,0x00,0x00,0x76,0xCC,0xCC,0xCC,0xCC,0x7C,0x0C,0x0C,0x1E,0x00,0x00,0x00}, /* 'q' */
{0x00,0x00,0x00,0x00,0xDC,0x76,0x60,0x60,0x60,0x60,0xF0,0x00,0x00,0x00,0x00,0x00}, /* 'r' */
{0x00,0x00,0x00,0x00,0x7C,0xC0,0x78,0x0C,0x0C,0xC6,0x7C,0x00,0x00,0x00,0x00,0x00}, /* 's' */
{0x00,0x00,0x30,0x30,0x7C,0x30,0x30,0x30,0x30,0x34,0x18,0x00,0x00,0x00,0x00,0x00}, /* 't' */
{0x00,0x00,0x00,0x00,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0x76,0x00,0x00,0x00,0x00,0x00}, /* 'u' */
{0x00,0x00,0x00,0x00,0xC6,0xC6,0xC6,0xC6,0x6C,0x38,0x10,0x00,0x00,0x00,0x00,0x00}, /* 'v' */
{0x00,0x00,0x00,0x00,0xC6,0xC6,0xD6,0xD6,0xFE,0x6C,0x6C,0x00,0x00,0x00,0x00,0x00}, /* 'w' */
{0x00,0x00,0x00,0x00,0xC6,0x6C,0x38,0x10,0x38,0x6C,0xC6,0x00,0x00,0x00,0x00,0x00}, /* 'x' */
{0x00,0x00,0x00,0x00,0xC6,0xC6,0xC6,0xC6,0x7E,0x06,0x0C,0x78,0x00,0x00,0x00,0x00}, /* 'y' */
{0x00,0x00,0x00,0x00,0xFE,0x0C,0x18,0x30,0x60,0xC0,0xFE,0x00,0x00,0x00,0x00,0x00}, /* 'z' */
{0x00,0x0E,0x18,0x18,0x18,0x70,0x18,0x18,0x18,0x18,0x0E,0x00,0x00,0x00,0x00,0x00}, /* '{' */
{0x00,0x18,0x18,0x18,0x18,0x00,0x18,0x18,0x18,0x18,0x18,0x00,0x00,0x00,0x00,0x00}, /* '|' */
{0x00,0x70,0x18,0x18,0x18,0x0E,0x18,0x18,0x18,0x18,0x70,0x00,0x00,0x00,0x00,0x00}, /* '}' */
{0x00,0x76,0xDC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00} /* '~' */
};
const uint8_t* font_get_glyph(char c) {
if (c < 32 || c > 126) c = '?';
return s_font8x16[(uint8_t)c - 32];
}
void font_draw_char(uint32_t x, uint32_t y, char c, uint32_t color) {
if (c < 32 || c > 126) c = '?';
const uint8_t* glyph = s_font8x16[(uint8_t)c - 32];
for (uint32_t row = 0; row < 16; row++) {
uint8_t line = glyph[row];
for (uint32_t col = 0; col < 8; col++) {
if ((line >> (7 - col)) & 1) {
vbe_putpixel(x + col, y + row, color);
}
}
}
}
void font_draw_string(uint32_t x, uint32_t y, const char* str, uint32_t color) {
if (!str) return;
uint32_t cur_x = x;
uint32_t cur_y = y;
while (*str) {
if (*str == '\n') {
cur_x = x;
cur_y += FONT_CHAR_HEIGHT;
str++;
continue;
}
font_draw_char(cur_x, cur_y, *str, color);
cur_x += FONT_CHAR_WIDTH;
str++;
}
}
void font_draw_string_glow(uint32_t x, uint32_t y, const char* str, uint32_t color, uint32_t glow_color) {
/* Draw soft halo around string */
font_draw_string(x - 1, y, str, glow_color);
font_draw_string(x + 1, y, str, glow_color);
font_draw_string(x, y - 1, str, glow_color);
font_draw_string(x, y + 1, str, glow_color);
/* Draw foreground string */
font_draw_string(x, y, str, color);
}