misc: Updates for Flanterm rebrand

This commit is contained in:
mintsuki 2023-03-29 22:43:06 +02:00
parent 034b5cca50
commit 7a3e1f7773
11 changed files with 84 additions and 84 deletions

2
.gitignore vendored
View File

@ -4,7 +4,7 @@
/limine-efi /limine-efi
/freestanding-headers /freestanding-headers
/libgcc-binaries /libgcc-binaries
/common/term /common/flanterm
/common/stb/stb_image.h /common/stb/stb_image.h
/ovmf* /ovmf*
*.o *.o

View File

@ -287,7 +287,7 @@ dist:
cp -r '$(call SHESCAPE,$(SRCDIR))'/.git '$(call SHESCAPE,$(BUILDDIR))'/"limine-$(LIMINE_VERSION)"/ cp -r '$(call SHESCAPE,$(SRCDIR))'/.git '$(call SHESCAPE,$(BUILDDIR))'/"limine-$(LIMINE_VERSION)"/
cd '$(call SHESCAPE,$(BUILDDIR))'/"limine-$(LIMINE_VERSION)" && git checkout . cd '$(call SHESCAPE,$(BUILDDIR))'/"limine-$(LIMINE_VERSION)" && git checkout .
cd '$(call SHESCAPE,$(BUILDDIR))'/"limine-$(LIMINE_VERSION)" && ./bootstrap cd '$(call SHESCAPE,$(BUILDDIR))'/"limine-$(LIMINE_VERSION)" && ./bootstrap
rm -rf '$(call SHESCAPE,$(BUILDDIR))'/"limine-$(LIMINE_VERSION)/common/term/.git" rm -rf '$(call SHESCAPE,$(BUILDDIR))'/"limine-$(LIMINE_VERSION)/common/flanterm/.git"
rm -rf '$(call SHESCAPE,$(BUILDDIR))'/"limine-$(LIMINE_VERSION)/freestanding-headers/.git" rm -rf '$(call SHESCAPE,$(BUILDDIR))'/"limine-$(LIMINE_VERSION)/freestanding-headers/.git"
rm -rf '$(call SHESCAPE,$(BUILDDIR))'/"limine-$(LIMINE_VERSION)/libgcc-binaries/.git" rm -rf '$(call SHESCAPE,$(BUILDDIR))'/"limine-$(LIMINE_VERSION)/libgcc-binaries/.git"
rm -rf '$(call SHESCAPE,$(BUILDDIR))'/"limine-$(LIMINE_VERSION)/libgcc-binaries/.gitignore" rm -rf '$(call SHESCAPE,$(BUILDDIR))'/"limine-$(LIMINE_VERSION)/libgcc-binaries/.gitignore"
@ -322,7 +322,7 @@ distclean: clean
.PHONY: maintainer-clean .PHONY: maintainer-clean
maintainer-clean: distclean maintainer-clean: distclean
cd '$(call SHESCAPE,$(SRCDIR))' && rm -rf common/term common/stb/stb_image.h freestanding-headers libgcc-binaries limine-efi freestanding-toolchain configure build-aux *'~' autom4te.cache *.tar.xz *.tar.gz cd '$(call SHESCAPE,$(SRCDIR))' && rm -rf common/flanterm common/stb/stb_image.h freestanding-headers libgcc-binaries limine-efi freestanding-toolchain configure build-aux *'~' autom4te.cache *.tar.xz *.tar.gz
.PHONY: common-uefi-x86-64 .PHONY: common-uefi-x86-64
common-uefi-x86-64: common-uefi-x86-64:

View File

@ -7,7 +7,7 @@ test -z "$srcdir" && srcdir=.
cd "$srcdir" cd "$srcdir"
[ -d common/term ] || git clone https://github.com/limine-bootloader/terminal.git common/term --depth=1 [ -d common/flanterm ] || git clone https://github.com/mintsuki/flanterm.git common/flanterm --depth=1
[ -f common/stb/stb_image.h ] || ( curl -Lo common/stb/stb_image.h https://github.com/nothings/stb/raw/master/stb_image.h && patch -p0 < common/stb_image.patch ) [ -f common/stb/stb_image.h ] || ( curl -Lo common/stb/stb_image.h https://github.com/nothings/stb/raw/master/stb_image.h && patch -p0 < common/stb_image.patch )
[ -f freestanding-toolchain ] || ( curl -Lo freestanding-toolchain https://github.com/mintsuki/freestanding-toolchain/raw/trunk/freestanding-toolchain && chmod +x freestanding-toolchain ) [ -f freestanding-toolchain ] || ( curl -Lo freestanding-toolchain https://github.com/mintsuki/freestanding-toolchain/raw/trunk/freestanding-toolchain && chmod +x freestanding-toolchain )
[ -d freestanding-headers ] || git clone https://github.com/mintsuki/freestanding-headers.git --depth=1 [ -d freestanding-headers ] || git clone https://github.com/mintsuki/freestanding-headers.git --depth=1

View File

@ -18,24 +18,24 @@ static void draw_cursor(struct textmode_context *ctx) {
ctx->video_mem[ctx->cursor_offset + 1] = ((pal & 0xf0) >> 4) | ((pal & 0x0f) << 4); ctx->video_mem[ctx->cursor_offset + 1] = ((pal & 0xf0) >> 4) | ((pal & 0x0f) << 4);
} }
static void text_save_state(struct term_context *_ctx) { static void text_save_state(struct flanterm_context *_ctx) {
struct textmode_context *ctx = (void *)_ctx; struct textmode_context *ctx = (void *)_ctx;
ctx->saved_state_text_palette = ctx->text_palette; ctx->saved_state_text_palette = ctx->text_palette;
ctx->saved_state_cursor_offset = ctx->cursor_offset; ctx->saved_state_cursor_offset = ctx->cursor_offset;
} }
static void text_restore_state(struct term_context *_ctx) { static void text_restore_state(struct flanterm_context *_ctx) {
struct textmode_context *ctx = (void *)_ctx; struct textmode_context *ctx = (void *)_ctx;
ctx->text_palette = ctx->saved_state_text_palette; ctx->text_palette = ctx->saved_state_text_palette;
ctx->cursor_offset = ctx->saved_state_cursor_offset; ctx->cursor_offset = ctx->saved_state_cursor_offset;
} }
static void text_swap_palette(struct term_context *_ctx) { static void text_swap_palette(struct flanterm_context *_ctx) {
struct textmode_context *ctx = (void *)_ctx; struct textmode_context *ctx = (void *)_ctx;
ctx->text_palette = (ctx->text_palette << 4) | (ctx->text_palette >> 4); ctx->text_palette = (ctx->text_palette << 4) | (ctx->text_palette >> 4);
} }
static void text_scroll(struct term_context *_ctx) { static void text_scroll(struct flanterm_context *_ctx) {
struct textmode_context *ctx = (void *)_ctx; struct textmode_context *ctx = (void *)_ctx;
// move the text up by one row // move the text up by one row
@ -51,7 +51,7 @@ static void text_scroll(struct term_context *_ctx) {
} }
} }
static void text_revscroll(struct term_context *_ctx) { static void text_revscroll(struct flanterm_context *_ctx) {
struct textmode_context *ctx = (void *)_ctx; struct textmode_context *ctx = (void *)_ctx;
// move the text up by one row // move the text up by one row
@ -69,7 +69,7 @@ static void text_revscroll(struct term_context *_ctx) {
} }
} }
static void text_clear(struct term_context *_ctx, bool move) { static void text_clear(struct flanterm_context *_ctx, bool move) {
struct textmode_context *ctx = (void *)_ctx; struct textmode_context *ctx = (void *)_ctx;
for (size_t i = 0; i < VIDEO_BOTTOM; i += 2) { for (size_t i = 0; i < VIDEO_BOTTOM; i += 2) {
@ -81,7 +81,7 @@ static void text_clear(struct term_context *_ctx, bool move) {
} }
} }
static void text_full_refresh(struct term_context *_ctx) { static void text_full_refresh(struct flanterm_context *_ctx) {
struct textmode_context *ctx = (void *)_ctx; struct textmode_context *ctx = (void *)_ctx;
for (size_t i = 0; i < VD_ROWS * VD_COLS; i++) { for (size_t i = 0; i < VD_ROWS * VD_COLS; i++) {
@ -95,7 +95,7 @@ static void text_full_refresh(struct term_context *_ctx) {
} }
} }
static void text_double_buffer_flush(struct term_context *_ctx) { static void text_double_buffer_flush(struct flanterm_context *_ctx) {
struct textmode_context *ctx = (void *)_ctx; struct textmode_context *ctx = (void *)_ctx;
if (_ctx->cursor_enabled) { if (_ctx->cursor_enabled) {
@ -125,14 +125,14 @@ static void text_double_buffer_flush(struct term_context *_ctx) {
} }
} }
static void text_get_cursor_pos(struct term_context *_ctx, size_t *x, size_t *y) { static void text_get_cursor_pos(struct flanterm_context *_ctx, size_t *x, size_t *y) {
struct textmode_context *ctx = (void *)_ctx; struct textmode_context *ctx = (void *)_ctx;
*x = (ctx->cursor_offset % VD_COLS) / 2; *x = (ctx->cursor_offset % VD_COLS) / 2;
*y = ctx->cursor_offset / VD_COLS; *y = ctx->cursor_offset / VD_COLS;
} }
static void text_move_character(struct term_context *_ctx, size_t new_x, size_t new_y, size_t old_x, size_t old_y) { static void text_move_character(struct flanterm_context *_ctx, size_t new_x, size_t new_y, size_t old_x, size_t old_y) {
struct textmode_context *ctx = (void *)_ctx; struct textmode_context *ctx = (void *)_ctx;
if (old_x >= VD_COLS / 2 || old_y >= VD_ROWS if (old_x >= VD_COLS / 2 || old_y >= VD_ROWS
@ -143,7 +143,7 @@ static void text_move_character(struct term_context *_ctx, size_t new_x, size_t
ctx->back_buffer[new_y * VD_COLS + new_x * 2] = ctx->back_buffer[old_y * VD_COLS + old_x * 2]; ctx->back_buffer[new_y * VD_COLS + new_x * 2] = ctx->back_buffer[old_y * VD_COLS + old_x * 2];
} }
static void text_set_cursor_pos(struct term_context *_ctx, size_t x, size_t y) { static void text_set_cursor_pos(struct flanterm_context *_ctx, size_t x, size_t y) {
struct textmode_context *ctx = (void *)_ctx; struct textmode_context *ctx = (void *)_ctx;
if (x >= VD_COLS / 2) { if (x >= VD_COLS / 2) {
@ -165,57 +165,57 @@ static void text_set_cursor_pos(struct term_context *_ctx, size_t x, size_t y) {
static uint8_t ansi_colours[] = { 0, 4, 2, 6, 1, 5, 3, 7 }; static uint8_t ansi_colours[] = { 0, 4, 2, 6, 1, 5, 3, 7 };
static void text_set_text_fg(struct term_context *_ctx, size_t fg) { static void text_set_text_fg(struct flanterm_context *_ctx, size_t fg) {
struct textmode_context *ctx = (void *)_ctx; struct textmode_context *ctx = (void *)_ctx;
ctx->text_palette = (ctx->text_palette & 0xf0) | ansi_colours[fg]; ctx->text_palette = (ctx->text_palette & 0xf0) | ansi_colours[fg];
} }
static void text_set_text_bg(struct term_context *_ctx, size_t bg) { static void text_set_text_bg(struct flanterm_context *_ctx, size_t bg) {
struct textmode_context *ctx = (void *)_ctx; struct textmode_context *ctx = (void *)_ctx;
ctx->text_palette = (ctx->text_palette & 0x0f) | (ansi_colours[bg] << 4); ctx->text_palette = (ctx->text_palette & 0x0f) | (ansi_colours[bg] << 4);
} }
static void text_set_text_fg_bright(struct term_context *_ctx, size_t fg) { static void text_set_text_fg_bright(struct flanterm_context *_ctx, size_t fg) {
struct textmode_context *ctx = (void *)_ctx; struct textmode_context *ctx = (void *)_ctx;
ctx->text_palette = (ctx->text_palette & 0xf0) | (ansi_colours[fg] | (1 << 3)); ctx->text_palette = (ctx->text_palette & 0xf0) | (ansi_colours[fg] | (1 << 3));
} }
static void text_set_text_bg_bright(struct term_context *_ctx, size_t bg) { static void text_set_text_bg_bright(struct flanterm_context *_ctx, size_t bg) {
struct textmode_context *ctx = (void *)_ctx; struct textmode_context *ctx = (void *)_ctx;
ctx->text_palette = (ctx->text_palette & 0x0f) | ((ansi_colours[bg] | (1 << 3)) << 4); ctx->text_palette = (ctx->text_palette & 0x0f) | ((ansi_colours[bg] | (1 << 3)) << 4);
} }
static void text_set_text_fg_rgb(struct term_context *ctx, uint32_t n) { static void text_set_text_fg_rgb(struct flanterm_context *ctx, uint32_t n) {
(void)ctx; (void)ctx;
(void)n; (void)n;
} }
static void text_set_text_bg_rgb(struct term_context *ctx, uint32_t n) { static void text_set_text_bg_rgb(struct flanterm_context *ctx, uint32_t n) {
(void)ctx; (void)ctx;
(void)n; (void)n;
} }
static void text_set_text_fg_default(struct term_context *_ctx) { static void text_set_text_fg_default(struct flanterm_context *_ctx) {
struct textmode_context *ctx = (void *)_ctx; struct textmode_context *ctx = (void *)_ctx;
ctx->text_palette = (ctx->text_palette & 0xf0) | 7; ctx->text_palette = (ctx->text_palette & 0xf0) | 7;
} }
static void text_set_text_bg_default(struct term_context *_ctx) { static void text_set_text_bg_default(struct flanterm_context *_ctx) {
struct textmode_context *ctx = (void *)_ctx; struct textmode_context *ctx = (void *)_ctx;
ctx->text_palette &= 0x0f; ctx->text_palette &= 0x0f;
} }
static void text_set_text_fg_default_bright(struct term_context *_ctx) { static void text_set_text_fg_default_bright(struct flanterm_context *_ctx) {
struct textmode_context *ctx = (void *)_ctx; struct textmode_context *ctx = (void *)_ctx;
ctx->text_palette = (ctx->text_palette & 0xf0) | (7 | (1 << 3)); ctx->text_palette = (ctx->text_palette & 0xf0) | (7 | (1 << 3));
} }
static void text_set_text_bg_default_bright(struct term_context *_ctx) { static void text_set_text_bg_default_bright(struct flanterm_context *_ctx) {
struct textmode_context *ctx = (void *)_ctx; struct textmode_context *ctx = (void *)_ctx;
ctx->text_palette = (ctx->text_palette & 0x0f) | ((1 << 3) << 4); ctx->text_palette = (ctx->text_palette & 0x0f) | ((1 << 3) << 4);
} }
static void text_putchar(struct term_context *_ctx, uint8_t c) { static void text_putchar(struct flanterm_context *_ctx, uint8_t c) {
struct textmode_context *ctx = (void *)_ctx; struct textmode_context *ctx = (void *)_ctx;
ctx->back_buffer[ctx->cursor_offset] = c; ctx->back_buffer[ctx->cursor_offset] = c;
@ -233,7 +233,7 @@ static void text_putchar(struct term_context *_ctx, uint8_t c) {
} }
} }
static void text_deinit(struct term_context *_ctx, void (*_free)(void *, size_t)) { static void text_deinit(struct flanterm_context *_ctx, void (*_free)(void *, size_t)) {
struct textmode_context *ctx = (void *)_ctx; struct textmode_context *ctx = (void *)_ctx;
if (ctx->back_buffer != NULL) { if (ctx->back_buffer != NULL) {
@ -269,7 +269,7 @@ void vga_textmode_init(bool managed) {
terms[0] = ext_mem_alloc(sizeof(struct textmode_context)); terms[0] = ext_mem_alloc(sizeof(struct textmode_context));
struct term_context *term = terms[0]; struct flanterm_context *term = terms[0];
struct textmode_context *ctx = (void *)term; struct textmode_context *ctx = (void *)term;
if (ctx->back_buffer == NULL) { if (ctx->back_buffer == NULL) {
@ -348,7 +348,7 @@ void vga_textmode_init(bool managed) {
term->in_bootloader = true; term->in_bootloader = true;
term_context_reinit(term); flanterm_context_reinit(term);
if (!managed) { if (!managed) {
term->cursor_enabled = false; term->cursor_enabled = false;

View File

@ -6,13 +6,13 @@
#include <stdint.h> #include <stdint.h>
#include <stddef.h> #include <stddef.h>
#include <stdbool.h> #include <stdbool.h>
#include <term/term.h> #include <flanterm/flanterm.h>
#define VD_COLS (80 * 2) #define VD_COLS (80 * 2)
#define VD_ROWS 25 #define VD_ROWS 25
struct textmode_context { struct textmode_context {
struct term_context term; struct flanterm_context term;
volatile uint8_t *video_mem; volatile uint8_t *video_mem;

View File

@ -9,8 +9,8 @@
#include <lib/fb.h> #include <lib/fb.h>
#include <lib/image.h> #include <lib/image.h>
#include <mm/pmm.h> #include <mm/pmm.h>
#include <term/term.h> #include <flanterm/flanterm.h>
#include <term/backends/framebuffer.h> #include <flanterm/backends/fb.h>
#include <lib/term.h> #include <lib/term.h>
// Builtin font originally taken from: // Builtin font originally taken from:
@ -693,7 +693,7 @@ bool gterm_init(struct fb_info **_fbs, size_t *_fbs_count,
size_t font_width = 8; size_t font_width = 8;
size_t font_height = 16; size_t font_height = 16;
size_t font_size = (font_width * font_height * FBTERM_FONT_GLYPHS) / 8; size_t font_size = (font_width * font_height * FLANTERM_FB_FONT_GLYPHS) / 8;
#define FONT_MAX 16384 #define FONT_MAX 16384
uint8_t *font = ext_mem_alloc(FONT_MAX); uint8_t *font = ext_mem_alloc(FONT_MAX);
@ -706,7 +706,7 @@ bool gterm_init(struct fb_info **_fbs, size_t *_fbs_count,
if (menu_font_size != NULL) { if (menu_font_size != NULL) {
parse_resolution(&tmp_font_width, &tmp_font_height, NULL, menu_font_size); parse_resolution(&tmp_font_width, &tmp_font_height, NULL, menu_font_size);
size_t tmp_font_size = (tmp_font_width * tmp_font_height * FBTERM_FONT_GLYPHS) / 8; size_t tmp_font_size = (tmp_font_width * tmp_font_height * FLANTERM_FB_FONT_GLYPHS) / 8;
if (tmp_font_size > FONT_MAX) { if (tmp_font_size > FONT_MAX) {
print("Font would be too large (%u bytes, %u bytes allowed). Not loading.\n", tmp_font_size, FONT_MAX); print("Font would be too large (%u bytes, %u bytes allowed). Not loading.\n", tmp_font_size, FONT_MAX);
@ -782,7 +782,7 @@ no_load_font:;
generate_canvas(fb); generate_canvas(fb);
terms[terms_i] = fbterm_init(ext_mem_alloc, terms[terms_i] = flanterm_fb_init(ext_mem_alloc,
(void *)(uintptr_t)fb->framebuffer_addr, (void *)(uintptr_t)fb->framebuffer_addr,
fb->framebuffer_width, fb->framebuffer_height, fb->framebuffer_pitch, fb->framebuffer_width, fb->framebuffer_height, fb->framebuffer_pitch,
bg_canvas, bg_canvas,
@ -814,7 +814,7 @@ no_load_font:;
} }
for (size_t i = 0; i < terms_i; i++) { for (size_t i = 0; i < terms_i; i++) {
struct term_context *term = terms[i]; struct flanterm_context *term = terms[i];
if (serial) { if (serial) {
term->cols = term->cols > 80 ? 80 : term->cols; term->cols = term->cols > 80 ? 80 : term->cols;
@ -826,7 +826,7 @@ no_load_font:;
size_t min_rows = (size_t)-1; size_t min_rows = (size_t)-1;
for (size_t i = 0; i < terms_i; i++) { for (size_t i = 0; i < terms_i; i++) {
struct term_context *term = terms[i]; struct flanterm_context *term = terms[i];
if (term->cols < min_cols) { if (term->cols < min_cols) {
min_cols = term->cols; min_cols = term->cols;
@ -838,14 +838,14 @@ no_load_font:;
} }
for (size_t i = 0; i < terms_i; i++) { for (size_t i = 0; i < terms_i; i++) {
struct term_context *term = terms[i]; struct flanterm_context *term = terms[i];
term->cols = min_cols; term->cols = min_cols;
term->rows = min_rows; term->rows = min_rows;
term->in_bootloader = true; term->in_bootloader = true;
term_context_reinit(term); flanterm_context_reinit(term);
} }
term_backend = GTERM; term_backend = GTERM;

View File

@ -222,7 +222,7 @@ out:
#if defined (BIOS) #if defined (BIOS)
if (stage3_loaded) { if (stage3_loaded) {
#endif #endif
FOR_TERM(term_write(TERM, print_buf, print_buf_i)); FOR_TERM(flanterm_write(TERM, print_buf, print_buf_i));
#if defined (BIOS) #if defined (BIOS)
} else { } else {
s2_print(print_buf, print_buf_i); s2_print(print_buf, print_buf_i);

View File

@ -6,20 +6,20 @@
#include <lib/misc.h> #include <lib/misc.h>
#include <mm/pmm.h> #include <mm/pmm.h>
#include <drivers/vga_textmode.h> #include <drivers/vga_textmode.h>
#include <term/backends/framebuffer.h> #include <flanterm/backends/fb.h>
#if defined (BIOS) #if defined (BIOS)
int current_video_mode = -1; int current_video_mode = -1;
#endif #endif
struct term_context **terms = NULL; struct flanterm_context **terms = NULL;
size_t terms_i = 0; size_t terms_i = 0;
int term_backend = _NOT_READY; int term_backend = _NOT_READY;
void term_notready(void) { void term_notready(void) {
for (size_t i = 0; i < terms_i; i++) { for (size_t i = 0; i < terms_i; i++) {
struct term_context *term = terms[i]; struct flanterm_context *term = terms[i];
term->deinit(term, pmm_free); term->deinit(term, pmm_free);
} }
@ -35,17 +35,17 @@ void term_notready(void) {
// --- fallback --- // --- fallback ---
#if defined (BIOS) #if defined (BIOS)
static void fallback_raw_putchar(struct term_context *ctx, uint8_t c) { static void fallback_raw_putchar(struct flanterm_context *ctx, uint8_t c) {
(void)ctx; (void)ctx;
struct rm_regs r = {0}; struct rm_regs r = {0};
r.eax = 0x0e00 | c; r.eax = 0x0e00 | c;
rm_int(0x10, &r, &r); rm_int(0x10, &r, &r);
} }
static void fallback_set_cursor_pos(struct term_context *ctx, size_t x, size_t y); static void fallback_set_cursor_pos(struct flanterm_context *ctx, size_t x, size_t y);
static void fallback_get_cursor_pos(struct term_context *ctx, size_t *x, size_t *y); static void fallback_get_cursor_pos(struct flanterm_context *ctx, size_t *x, size_t *y);
static void fallback_clear(struct term_context *ctx, bool move) { static void fallback_clear(struct flanterm_context *ctx, bool move) {
(void)ctx; (void)ctx;
size_t x, y; size_t x, y;
fallback_get_cursor_pos(NULL, &x, &y); fallback_get_cursor_pos(NULL, &x, &y);
@ -72,7 +72,7 @@ static void fallback_clear(struct term_context *ctx, bool move) {
fallback_set_cursor_pos(NULL, x, y); fallback_set_cursor_pos(NULL, x, y);
} }
static void fallback_set_cursor_pos(struct term_context *ctx, size_t x, size_t y) { static void fallback_set_cursor_pos(struct flanterm_context *ctx, size_t x, size_t y) {
(void)ctx; (void)ctx;
struct rm_regs r = {0}; struct rm_regs r = {0};
r.eax = 0x0200; r.eax = 0x0200;
@ -81,7 +81,7 @@ static void fallback_set_cursor_pos(struct term_context *ctx, size_t x, size_t y
rm_int(0x10, &r, &r); rm_int(0x10, &r, &r);
} }
static void fallback_get_cursor_pos(struct term_context *ctx, size_t *x, size_t *y) { static void fallback_get_cursor_pos(struct flanterm_context *ctx, size_t *x, size_t *y) {
(void)ctx; (void)ctx;
struct rm_regs r = {0}; struct rm_regs r = {0};
r.eax = 0x0300; r.eax = 0x0300;
@ -91,7 +91,7 @@ static void fallback_get_cursor_pos(struct term_context *ctx, size_t *x, size_t
*y = r.edx >> 8; *y = r.edx >> 8;
} }
static void fallback_scroll(struct term_context *ctx) { static void fallback_scroll(struct flanterm_context *ctx) {
(void)ctx; (void)ctx;
size_t x, y; size_t x, y;
fallback_get_cursor_pos(NULL, &x, &y); fallback_get_cursor_pos(NULL, &x, &y);
@ -104,7 +104,7 @@ static void fallback_scroll(struct term_context *ctx) {
static size_t cursor_x = 0, cursor_y = 0; static size_t cursor_x = 0, cursor_y = 0;
static void fallback_scroll(struct term_context *ctx) { static void fallback_scroll(struct flanterm_context *ctx) {
(void)ctx; (void)ctx;
gST->ConOut->SetCursorPosition(gST->ConOut, ctx->cols - 1, ctx->rows - 1); gST->ConOut->SetCursorPosition(gST->ConOut, ctx->cols - 1, ctx->rows - 1);
CHAR16 string[2]; CHAR16 string[2];
@ -114,7 +114,7 @@ static void fallback_scroll(struct term_context *ctx) {
gST->ConOut->SetCursorPosition(gST->ConOut, cursor_x, cursor_y); gST->ConOut->SetCursorPosition(gST->ConOut, cursor_x, cursor_y);
} }
static void fallback_raw_putchar(struct term_context *ctx, uint8_t c) { static void fallback_raw_putchar(struct flanterm_context *ctx, uint8_t c) {
if (!ctx->scroll_enabled && cursor_x == ctx->cols - 1 && cursor_y == ctx->rows - 1) { if (!ctx->scroll_enabled && cursor_x == ctx->cols - 1 && cursor_y == ctx->rows - 1) {
return; return;
} }
@ -132,7 +132,7 @@ static void fallback_raw_putchar(struct term_context *ctx, uint8_t c) {
gST->ConOut->SetCursorPosition(gST->ConOut, cursor_x, cursor_y); gST->ConOut->SetCursorPosition(gST->ConOut, cursor_x, cursor_y);
} }
static void fallback_clear(struct term_context *ctx, bool move) { static void fallback_clear(struct flanterm_context *ctx, bool move) {
(void)ctx; (void)ctx;
gST->ConOut->ClearScreen(gST->ConOut); gST->ConOut->ClearScreen(gST->ConOut);
if (move) { if (move) {
@ -141,7 +141,7 @@ static void fallback_clear(struct term_context *ctx, bool move) {
gST->ConOut->SetCursorPosition(gST->ConOut, cursor_x, cursor_y); gST->ConOut->SetCursorPosition(gST->ConOut, cursor_x, cursor_y);
} }
static void fallback_set_cursor_pos(struct term_context *ctx, size_t x, size_t y) { static void fallback_set_cursor_pos(struct flanterm_context *ctx, size_t x, size_t y) {
(void)ctx; (void)ctx;
if (x >= ctx->cols || y >= ctx->rows) { if (x >= ctx->cols || y >= ctx->rows) {
return; return;
@ -151,7 +151,7 @@ static void fallback_set_cursor_pos(struct term_context *ctx, size_t x, size_t y
cursor_y = y; cursor_y = y;
} }
static void fallback_get_cursor_pos(struct term_context *ctx, size_t *x, size_t *y) { static void fallback_get_cursor_pos(struct flanterm_context *ctx, size_t *x, size_t *y) {
(void)ctx; (void)ctx;
*x = cursor_x; *x = cursor_x;
*y = cursor_y; *y = cursor_y;
@ -172,9 +172,9 @@ void term_fallback(void) {
terms = ext_mem_alloc(sizeof(void *)); terms = ext_mem_alloc(sizeof(void *));
terms_i = 1; terms_i = 1;
terms[0] = ext_mem_alloc(sizeof(struct term_context)); terms[0] = ext_mem_alloc(sizeof(struct flanterm_context));
struct term_context *term = terms[0]; struct flanterm_context *term = terms[0];
fallback_clear(NULL, true); fallback_clear(NULL, true);
@ -210,7 +210,7 @@ void term_fallback(void) {
term->rows = 25; term->rows = 25;
#endif #endif
term_backend = FALLBACK; term_backend = FALLBACK;
term_context_reinit(term); flanterm_context_reinit(term);
term->in_bootloader = true; term->in_bootloader = true;
#if defined (UEFI) #if defined (UEFI)
@ -227,15 +227,15 @@ extern void set_cursor_pos_helper(size_t x, size_t y);
static uint8_t xfer_buf[TERM_XFER_CHUNK]; static uint8_t xfer_buf[TERM_XFER_CHUNK];
#endif #endif
static uint64_t context_size(struct term_context *term) { static uint64_t context_size(struct flanterm_context *term) {
switch (term_backend) { switch (term_backend) {
#if defined (BIOS) #if defined (BIOS)
case TEXTMODE: case TEXTMODE:
return sizeof(struct textmode_context) + (VD_ROWS * VD_COLS) * 2; return sizeof(struct textmode_context) + (VD_ROWS * VD_COLS) * 2;
#endif #endif
case GTERM: { case GTERM: {
struct fbterm_context *ctx = (void *)term; struct flanterm_fb_context *ctx = (void *)term;
return sizeof(struct fbterm_context) + return sizeof(struct flanterm_fb_context) +
ctx->font_bits_size + ctx->font_bits_size +
ctx->font_bool_size + ctx->font_bool_size +
ctx->canvas_size + ctx->canvas_size +
@ -248,7 +248,7 @@ static uint64_t context_size(struct term_context *term) {
} }
} }
static void context_save(struct term_context *term, uint64_t buf) { static void context_save(struct flanterm_context *term, uint64_t buf) {
switch (term_backend) { switch (term_backend) {
#if defined (BIOS) #if defined (BIOS)
case TEXTMODE: { case TEXTMODE: {
@ -263,9 +263,9 @@ static void context_save(struct term_context *term, uint64_t buf) {
} }
#endif #endif
case GTERM: { case GTERM: {
struct fbterm_context *ctx = (void *)term; struct flanterm_fb_context *ctx = (void *)term;
memcpy32to64(buf, (uintptr_t)ctx, sizeof(struct fbterm_context)); memcpy32to64(buf, (uintptr_t)ctx, sizeof(struct flanterm_fb_context));
buf += sizeof(struct fbterm_context); buf += sizeof(struct flanterm_fb_context);
memcpy32to64(buf, (uintptr_t)ctx->font_bits, ctx->font_bits_size); memcpy32to64(buf, (uintptr_t)ctx->font_bits, ctx->font_bits_size);
buf += ctx->font_bits_size; buf += ctx->font_bits_size;
memcpy32to64(buf, (uintptr_t)ctx->font_bool, ctx->font_bool_size); memcpy32to64(buf, (uintptr_t)ctx->font_bool, ctx->font_bool_size);
@ -283,7 +283,7 @@ static void context_save(struct term_context *term, uint64_t buf) {
} }
} }
static void context_restore(struct term_context *term, uint64_t buf) { static void context_restore(struct flanterm_context *term, uint64_t buf) {
switch (term_backend) { switch (term_backend) {
#if defined (BIOS) #if defined (BIOS)
case TEXTMODE: { case TEXTMODE: {
@ -298,9 +298,9 @@ static void context_restore(struct term_context *term, uint64_t buf) {
} }
#endif #endif
case GTERM: { case GTERM: {
struct fbterm_context *ctx = (void *)term; struct flanterm_fb_context *ctx = (void *)term;
memcpy32to64((uintptr_t)ctx, buf, sizeof(struct fbterm_context)); memcpy32to64((uintptr_t)ctx, buf, sizeof(struct flanterm_fb_context));
buf += sizeof(struct fbterm_context); buf += sizeof(struct flanterm_fb_context);
memcpy32to64((uintptr_t)ctx->font_bits, buf, ctx->font_bits_size); memcpy32to64((uintptr_t)ctx->font_bits, buf, ctx->font_bits_size);
buf += ctx->font_bits_size; buf += ctx->font_bits_size;
memcpy32to64((uintptr_t)ctx->font_bool, buf, ctx->font_bool_size); memcpy32to64((uintptr_t)ctx->font_bool, buf, ctx->font_bool_size);
@ -318,7 +318,7 @@ static void context_restore(struct term_context *term, uint64_t buf) {
} }
} }
void _term_write(struct term_context *term, uint64_t buf, uint64_t count) { void _term_write(struct flanterm_context *term, uint64_t buf, uint64_t count) {
switch (count) { switch (count) {
case TERM_OOB_OUTPUT_GET: { case TERM_OOB_OUTPUT_GET: {
memcpy32to64(buf, (uint64_t)(uintptr_t)&term->oob_output, sizeof(uint64_t)); memcpy32to64(buf, (uint64_t)(uintptr_t)&term->oob_output, sizeof(uint64_t));
@ -360,7 +360,7 @@ void _term_write(struct term_context *term, uint64_t buf, uint64_t count) {
if (term->in_bootloader || native) { if (term->in_bootloader || native) {
const char *s = (const char *)(uintptr_t)buf; const char *s = (const char *)(uintptr_t)buf;
term_write(term, s, count); flanterm_write(term, s, count);
} else { } else {
#if defined (__i386__) #if defined (__i386__)
while (count != 0) { while (count != 0) {
@ -373,7 +373,7 @@ void _term_write(struct term_context *term, uint64_t buf, uint64_t count) {
memcpy32to64((uint64_t)(uintptr_t)xfer_buf, buf, chunk); memcpy32to64((uint64_t)(uintptr_t)xfer_buf, buf, chunk);
term_write(term, (const char *)xfer_buf, chunk); flanterm_write(term, (const char *)xfer_buf, chunk);
count -= chunk; count -= chunk;
buf += chunk; buf += chunk;

View File

@ -4,7 +4,7 @@
#include <stddef.h> #include <stddef.h>
#include <stdint.h> #include <stdint.h>
#include <lib/print.h> #include <lib/print.h>
#include <term/term.h> #include <flanterm/flanterm.h>
enum { enum {
_NOT_READY, _NOT_READY,
@ -17,7 +17,7 @@ enum {
extern int current_video_mode; extern int current_video_mode;
#endif #endif
extern struct term_context **terms; extern struct flanterm_context **terms;
extern size_t terms_i; extern size_t terms_i;
extern int term_backend; extern int term_backend;
@ -31,7 +31,7 @@ extern int term_backend;
#define FOR_TERM(...) do { \ #define FOR_TERM(...) do { \
for (size_t FOR_TERM_i = 0; FOR_TERM_i < terms_i; FOR_TERM_i++) { \ for (size_t FOR_TERM_i = 0; FOR_TERM_i < terms_i; FOR_TERM_i++) { \
struct term_context *TERM = terms[FOR_TERM_i]; \ struct flanterm_context *TERM = terms[FOR_TERM_i]; \
__VA_ARGS__ \ __VA_ARGS__ \
; \ ; \
} \ } \
@ -39,10 +39,10 @@ extern int term_backend;
inline void reset_term(void) { inline void reset_term(void) {
for (size_t i = 0; i < terms_i; i++) { for (size_t i = 0; i < terms_i; i++) {
struct term_context *term = terms[i]; struct flanterm_context *term = terms[i];
print("\e[2J\e[H"); print("\e[2J\e[H");
term_context_reinit(term); flanterm_context_reinit(term);
term->in_bootloader = true; term->in_bootloader = true;
term->cursor_enabled = true; term->cursor_enabled = true;
term->double_buffer_flush(term); term->double_buffer_flush(term);
@ -55,6 +55,6 @@ inline void set_cursor_pos_helper(size_t x, size_t y) {
void term_notready(void); void term_notready(void);
void term_fallback(void); void term_fallback(void);
void _term_write(struct term_context *term, uint64_t buf, uint64_t count); void _term_write(struct flanterm_context *term, uint64_t buf, uint64_t count);
#endif #endif

View File

@ -40,7 +40,7 @@ SECTIONS
full_map = .; full_map = .;
getchar = .; getchar = .;
menu = .; menu = .;
term_write = .; flanterm_write = .;
term_backend = .; term_backend = .;
term_fallback = .; term_fallback = .;
term_notready = .; term_notready = .;

View File

@ -18,7 +18,7 @@
#include <sys/gdt.h> #include <sys/gdt.h>
#include <lib/fb.h> #include <lib/fb.h>
#include <lib/term.h> #include <lib/term.h>
#include <term/backends/framebuffer.h> #include <flanterm/backends/fb.h>
#include <sys/pic.h> #include <sys/pic.h>
#include <sys/lapic.h> #include <sys/lapic.h>
#include <sys/idt.h> #include <sys/idt.h>
@ -285,7 +285,7 @@ void limine_term_callback(uint64_t, uint64_t, uint64_t, uint64_t, uint64_t);
static uint64_t term_arg; static uint64_t term_arg;
static void (*actual_callback)(uint64_t, uint64_t, uint64_t, uint64_t, uint64_t); static void (*actual_callback)(uint64_t, uint64_t, uint64_t, uint64_t, uint64_t);
static void callback_shim(struct term_context *ctx, uint64_t a, uint64_t b, uint64_t c, uint64_t d) { static void callback_shim(struct flanterm_context *ctx, uint64_t a, uint64_t b, uint64_t c, uint64_t d) {
(void)ctx; (void)ctx;
actual_callback(term_arg, a, b, c, d); actual_callback(term_arg, a, b, c, d);
} }
@ -816,7 +816,7 @@ term_fail:
#endif #endif
term_fb_ptr = &terminal->framebuffer; term_fb_ptr = &terminal->framebuffer;
term_fb_addr = reported_addr((void *)(((struct fbterm_context *)terms[0])->framebuffer)); term_fb_addr = reported_addr((void *)(((struct flanterm_fb_context *)terms[0])->framebuffer));
terminal->columns = terms[0]->cols; terminal->columns = terms[0]->cols;
terminal->rows = terms[0]->rows; terminal->rows = terms[0]->rows;
@ -1132,7 +1132,7 @@ FEAT_START
FEAT_END FEAT_END
// Clear terminal for kernels that will use the Limine terminal // Clear terminal for kernels that will use the Limine terminal
FOR_TERM(term_write(TERM, "\e[2J\e[H", 7)); FOR_TERM(flanterm_write(TERM, "\e[2J\e[H", 7));
FOR_TERM(TERM->in_bootloader = false); FOR_TERM(TERM->in_bootloader = false);
#if defined (__x86_64__) || defined (__i386__) #if defined (__x86_64__) || defined (__i386__)