/* * @author xamidev * @brief Framebuffer-based terminal driver * @license GPL-3.0-only */ // Terminal output /* There are a couple of bugs here and there but for now I don't care too much because this shitty implementation will be replaced one day by Flanterm (once memory management is okay: paging & kernel malloc) */ #include #include #include "term.h" #include "config.h" #include "flanterm.h" #include "flanterm_backends/fb.h" #include "mem/heap/kheap.h" #include "limine.h" extern struct flanterm_context* ft_ctx; extern struct init_status init; // Overhead that could be avoided, right? (for printf) void _putchar(char character) { // TODO: Spinlock here (terminal access) flanterm_write(ft_ctx, &character, 1); } // Debug-printing void kputs(const char* str) { size_t i=0; while (str[i] != 0) { _putchar(str[i]); i++; } _putchar('\r'); } extern struct flanterm_context* ft_ctx; extern struct boot_context boot_ctx; void flanterm_free_wrapper(void* ptr, size_t size) { (void)size; kfree(ptr); } void term_init() { uint32_t bgColor = 0x252525; ft_ctx = flanterm_fb_init( kmalloc, flanterm_free_wrapper, boot_ctx.fb->address, boot_ctx.fb->width, boot_ctx.fb->height, boot_ctx.fb->pitch, boot_ctx.fb->red_mask_size, boot_ctx.fb->red_mask_shift, boot_ctx.fb->green_mask_size, boot_ctx.fb->green_mask_shift, boot_ctx.fb->blue_mask_size, boot_ctx.fb->blue_mask_shift, NULL, NULL, NULL, &bgColor, NULL, NULL, NULL, NULL, 0, 0, 1, 0, 0, 0, 0 ); init.terminal = true; }