mirror of
https://github.com/tailix/kernel.git
synced 2024-12-11 11:35:39 -05:00
Remove page frame allocator
This commit is contained in:
parent
ecb719af13
commit
a5b7bd8ef2
4 changed files with 0 additions and 109 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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
|
Loading…
Reference in a new issue