Minimal device system, implement terminal device and libterminal
All checks were successful
Build documentation / build-and-deploy (push) Successful in 55s
All checks were successful
Build documentation / build-and-deploy (push) Successful in 55s
This commit is contained in:
44
kernel/device/terminal.c
Normal file
44
kernel/device/terminal.c
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user