Minimal device system, implement terminal device and libterminal
All checks were successful
Build documentation / build-and-deploy (push) Successful in 55s

This commit is contained in:
2026-02-12 15:49:04 +01:00
parent 4ad1519e06
commit f07e920270
40 changed files with 4664 additions and 7 deletions

44
kernel/device/terminal.c Normal file
View File

@@ -0,0 +1,44 @@
#include <Flanterm/src/flanterm.h>
#include <Flanterm/src/flanterm_backends/fb.h>
#include <device/terminal.h>
#include <libk/std.h>
#include <limine/requests.h>
#include <m/status.h>
#include <mm/liballoc.h>
#include <sys/debug.h>
struct flanterm_context* ft_ctx;
void* ft_malloc (size_t n) { return malloc (n); }
void ft_free (void* ptr, size_t size) {
(void)size;
free (ptr);
}
bool terminal_init (void* arg) {
(void)arg;
struct limine_framebuffer_response* fb_r = limine_framebuffer_request.response;
struct limine_framebuffer* fb = fb_r->framebuffers[0];
ft_ctx = flanterm_fb_init (&ft_malloc, &ft_free, fb->address, fb->width, fb->height, fb->pitch,
fb->red_mask_size, fb->red_mask_shift, fb->green_mask_size,
fb->green_mask_shift, fb->blue_mask_size, fb->blue_mask_shift, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, 1, 0, 0, 0, 0);
return true;
}
void terminal_fini (void) {}
int terminal_putstr (void* a1, void* a2, void* a3, void* a4) {
(void)a2, (void)a3, (void)a4;
char* string = (char*)a1;
size_t* len = (size_t*)a2;
flanterm_write (ft_ctx, string, *len);
return ST_OK;
}