From 1a1de0b5682bf63280a0221b8e7185639c788fd7 Mon Sep 17 00:00:00 2001 From: Matheus Date: Wed, 12 Apr 2023 21:49:17 -0300 Subject: [PATCH] kernel/term.c: use pmm to allocate flanterm --- kernel-src/io/term.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/kernel-src/io/term.c b/kernel-src/io/term.c index 0ff7a14b..2b20552a 100644 --- a/kernel-src/io/term.c +++ b/kernel-src/io/term.c @@ -6,23 +6,16 @@ #include #include #include - -#define EARLY_BUFFER_SIZE (64*1024*1024) +#include +#include extern volatile struct limine_framebuffer_request fb_liminereq; -static size_t bufferused; -static uint8_t allocbuffer[EARLY_BUFFER_SIZE]; - -// TODO once the pmm is done, switch to allocating from it instead. -// right now the terminal is supposed to be initialized before true memory management is initialized. -// thus, there is a simple internal watermark allocator that allocates processor aligned chunks -// of a buffer of size EARLY_BUFFER_SIZE +// TODO make more efficient. works for now static void *internalalloc(size_t n) { - __assert(bufferused + n <= EARLY_BUFFER_SIZE) - void *ret = &allocbuffer[bufferused]; - bufferused += n + (sizeof(uintmax_t) - (n % sizeof(uintmax_t))); - return ret; + void *addr = pmm_alloc(n / PAGE_SIZE + 1, PMM_SECTION_DEFAULT); + __assert(addr); + return MAKE_HHDM(addr); } static struct flanterm_context *term_ctx;