tianole/arch/x86/kernel/screen_font.c
Microindole 11a1a8234b
Some checks failed
check / build-and-boot (push) Has been cancelled
kernel: add framebuffer early console and tighten wait queues
2026-05-13 11:42:24 +08:00

82 lines
3.1 KiB
C

#include <stdint.h>
#include "screen_font.h"
struct glyph {
char ch;
uint8_t rows[SCREEN_FONT_HEIGHT];
};
static const struct glyph font[] = {
{' ', {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
{'!', {0x04, 0x04, 0x04, 0x04, 0x04, 0x00, 0x04}},
{'.', {0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x0c}},
{',', {0x00, 0x00, 0x00, 0x00, 0x0c, 0x04, 0x08}},
{':', {0x00, 0x0c, 0x0c, 0x00, 0x0c, 0x0c, 0x00}},
{'-', {0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00}},
{'_', {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f}},
{'=', {0x00, 0x00, 0x1f, 0x00, 0x1f, 0x00, 0x00}},
{'/', {0x01, 0x02, 0x04, 0x04, 0x08, 0x10, 0x10}},
{'0', {0x0e, 0x11, 0x13, 0x15, 0x19, 0x11, 0x0e}},
{'1', {0x04, 0x0c, 0x04, 0x04, 0x04, 0x04, 0x0e}},
{'2', {0x0e, 0x11, 0x01, 0x02, 0x04, 0x08, 0x1f}},
{'3', {0x1e, 0x01, 0x01, 0x0e, 0x01, 0x01, 0x1e}},
{'4', {0x02, 0x06, 0x0a, 0x12, 0x1f, 0x02, 0x02}},
{'5', {0x1f, 0x10, 0x10, 0x1e, 0x01, 0x01, 0x1e}},
{'6', {0x0e, 0x10, 0x10, 0x1e, 0x11, 0x11, 0x0e}},
{'7', {0x1f, 0x01, 0x02, 0x04, 0x08, 0x08, 0x08}},
{'8', {0x0e, 0x11, 0x11, 0x0e, 0x11, 0x11, 0x0e}},
{'9', {0x0e, 0x11, 0x11, 0x0f, 0x01, 0x01, 0x0e}},
{'A', {0x0e, 0x11, 0x11, 0x1f, 0x11, 0x11, 0x11}},
{'B', {0x1e, 0x11, 0x11, 0x1e, 0x11, 0x11, 0x1e}},
{'C', {0x0e, 0x11, 0x10, 0x10, 0x10, 0x11, 0x0e}},
{'D', {0x1e, 0x11, 0x11, 0x11, 0x11, 0x11, 0x1e}},
{'E', {0x1f, 0x10, 0x10, 0x1e, 0x10, 0x10, 0x1f}},
{'F', {0x1f, 0x10, 0x10, 0x1e, 0x10, 0x10, 0x10}},
{'G', {0x0e, 0x11, 0x10, 0x17, 0x11, 0x11, 0x0f}},
{'H', {0x11, 0x11, 0x11, 0x1f, 0x11, 0x11, 0x11}},
{'I', {0x0e, 0x04, 0x04, 0x04, 0x04, 0x04, 0x0e}},
{'J', {0x07, 0x02, 0x02, 0x02, 0x12, 0x12, 0x0c}},
{'K', {0x11, 0x12, 0x14, 0x18, 0x14, 0x12, 0x11}},
{'L', {0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x1f}},
{'M', {0x11, 0x1b, 0x15, 0x15, 0x11, 0x11, 0x11}},
{'N', {0x11, 0x19, 0x15, 0x13, 0x11, 0x11, 0x11}},
{'O', {0x0e, 0x11, 0x11, 0x11, 0x11, 0x11, 0x0e}},
{'P', {0x1e, 0x11, 0x11, 0x1e, 0x10, 0x10, 0x10}},
{'Q', {0x0e, 0x11, 0x11, 0x11, 0x15, 0x12, 0x0d}},
{'R', {0x1e, 0x11, 0x11, 0x1e, 0x14, 0x12, 0x11}},
{'S', {0x0f, 0x10, 0x10, 0x0e, 0x01, 0x01, 0x1e}},
{'T', {0x1f, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04}},
{'U', {0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x0e}},
{'V', {0x11, 0x11, 0x11, 0x11, 0x0a, 0x0a, 0x04}},
{'W', {0x11, 0x11, 0x11, 0x15, 0x15, 0x1b, 0x11}},
{'X', {0x11, 0x11, 0x0a, 0x04, 0x0a, 0x11, 0x11}},
{'Y', {0x11, 0x11, 0x0a, 0x04, 0x04, 0x04, 0x04}},
{'Z', {0x1f, 0x01, 0x02, 0x04, 0x08, 0x10, 0x1f}},
{'?', {0x0e, 0x11, 0x01, 0x02, 0x04, 0x00, 0x04}},
};
/**
* screen_font_glyph() - Return a tiny bitmap glyph for early console text.
* @ch: ASCII character requested by the early framebuffer console.
*
* The boot console keeps the font deliberately small: lowercase letters are
* folded to uppercase, and unsupported characters fall back to question mark.
*/
const uint8_t *screen_font_glyph(char ch)
{
uint32_t index;
if (ch >= 97 && ch <= 122) {
ch = (char)(ch - 97 + 65);
}
for (index = 0; index < sizeof(font) / sizeof(font[0]); index++) {
if (font[index].ch == ch) {
return font[index].rows;
}
}
return font[sizeof(font) / sizeof(font[0]) - 1].rows;
}