From a5b7bd8ef23c08a8afa424ce8a5df986c9c3e73e Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Thu, 26 Nov 2020 01:30:35 +0500 Subject: [PATCH] Remove page frame allocator --- kernelmq/Makefile | 1 - kernelmq/init.c | 4 --- kernelmq/pfa.c | 86 ----------------------------------------------- kernelmq/pfa.h | 18 ---------- 4 files changed, 109 deletions(-) delete mode 100644 kernelmq/pfa.c delete mode 100644 kernelmq/pfa.h diff --git a/kernelmq/Makefile b/kernelmq/Makefile index dbd1c85..85924b3 100644 --- a/kernelmq/Makefile +++ b/kernelmq/Makefile @@ -14,7 +14,6 @@ OBJS += main.c.o OBJS += init.c.o OBJS += multiboot.c.o OBJS += panic.c.o panic.asm.cpp.o -OBJS += pfa.c.o OBJS += paging.c.o paging.asm.cpp.o OBJS += page_dir.c.o diff --git a/kernelmq/init.c b/kernelmq/init.c index 287dae1..2c6aa98 100644 --- a/kernelmq/init.c +++ b/kernelmq/init.c @@ -1,5 +1,4 @@ #include "panic.h" -#include "pfa.h" #include "protected.h" #include "paging.h" @@ -19,9 +18,6 @@ void init(const struct KernelMQ_Info *const kinfo_ptr) assert(kernelmq_info_validate_and_copy(&kinfo, kinfo_ptr), "Invalid kernel information."); - pfa_initialize(&kinfo); - pfa_print_info(); - protected_initialize(&kinfo); // Set up a new post-relocate bootstrap pagetable so that diff --git a/kernelmq/pfa.c b/kernelmq/pfa.c deleted file mode 100644 index 9e56d70..0000000 --- a/kernelmq/pfa.c +++ /dev/null @@ -1,86 +0,0 @@ -#include "pfa.h" - -#include "config.h" -#include "panic.h" -#include "logger.h" - -#include "stdlib.h" - -#define FRAMES_COUNT (PAGE_DIR_LENGTH * PAGE_TABLE_LENGTH) - -static unsigned char frames[FRAMES_COUNT]; - -static void mark_used(unsigned long base, unsigned long limit); - -void pfa_initialize(const struct KernelMQ_Info *const kinfo) -{ - logger_info_from("pfa", "Initialize page frame allocator."); - - kmemset(frames, 0, sizeof(frames)); - - mark_used(0, MEM_UPPER_BASE - 1); - - mark_used(kinfo->kernel_phys_base, kinfo->kernel_phys_limit); - - for (unsigned int i = 0; i < kinfo->modules_count; ++i) { - const struct KernelMQ_Info_Module *const module = &kinfo->modules[i]; - - mark_used(module->base, module->limit); - } - - for (unsigned int i = 0; i < kinfo->areas_count; ++i) { - const struct KernelMQ_Info_Area *const area = &kinfo->areas[i]; - - if (!area->is_available) { - mark_used(area->base, area->limit); - } - } -} - -void pfa_print_info() -{ - unsigned char started = 0; - unsigned int start = 0; - - for (unsigned int index = 0; index <= FRAMES_COUNT; ++index) { - if (frames[index]) { - if (!started) { - started = 1; - start = index; - } - } - else { - if (started) { - const unsigned int end = index - 1; - - if (start < end) { - logger_debug_from( - "pfa", - "Pages allocated: %u-%u", - start * PAGE_SIZE, - end * PAGE_SIZE - ); - } - else { - logger_debug_from( - "pfa", - "Page allocated: %u", - start * PAGE_SIZE - ); - } - } - - started = 0; - } - } -} - -void mark_used(const unsigned long base, const unsigned long limit) -{ - const unsigned int start = base / PAGE_SIZE; - const unsigned int end = limit / PAGE_SIZE; - - for (unsigned int i = start; i <= end; ++i) { - frames[i] = 0xFF; - } -} diff --git a/kernelmq/pfa.h b/kernelmq/pfa.h deleted file mode 100644 index 629c044..0000000 --- a/kernelmq/pfa.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef KERNELMQ_INCLUDED_PFA -#define KERNELMQ_INCLUDED_PFA 1 - -#include "info.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void pfa_initialize(const struct KernelMQ_Info *kinfo); - -void pfa_print_info(); - -#ifdef __cplusplus -} -#endif - -#endif