kernel/term.c: use pmm to allocate flanterm

This commit is contained in:
Matheus
2023-04-12 21:49:17 -03:00
parent c190f0bb74
commit 1a1de0b568
+6 -13
View File
@@ -6,23 +6,16 @@
#include <printf.h> #include <printf.h>
#include <logging.h> #include <logging.h>
#include <string.h> #include <string.h>
#include <kernel/pmm.h>
#define EARLY_BUFFER_SIZE (64*1024*1024) #include <arch/mmu.h>
extern volatile struct limine_framebuffer_request fb_liminereq; extern volatile struct limine_framebuffer_request fb_liminereq;
static size_t bufferused; // TODO make more efficient. works for now
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
static void *internalalloc(size_t n) { static void *internalalloc(size_t n) {
__assert(bufferused + n <= EARLY_BUFFER_SIZE) void *addr = pmm_alloc(n / PAGE_SIZE + 1, PMM_SECTION_DEFAULT);
void *ret = &allocbuffer[bufferused]; __assert(addr);
bufferused += n + (sizeof(uintmax_t) - (n % sizeof(uintmax_t))); return MAKE_HHDM(addr);
return ret;
} }
static struct flanterm_context *term_ctx; static struct flanterm_context *term_ctx;