1
0
Fork 0
mirror of https://github.com/tailix/kernel.git synced 2024-11-20 11:16:10 -05:00

Do not allocate in lower memory

This commit is contained in:
Braiden Vasco 2017-11-05 07:32:32 +00:00
parent d45671ccda
commit 4dc79c4ee6
3 changed files with 6 additions and 3 deletions

View file

@ -1,6 +1,8 @@
#ifndef KERNELMQ_INCLUDED_CONFIG
#define KERNELMQ_INCLUDED_CONFIG 1
#define MEM_UPPER_BASE ((unsigned long)(1 * 1024 * 1024 * 1024)) // 1 MB
#define PAGE_DIR_SIZE 1024
#define PAGE_TABLE_SIZE 1024

View file

@ -14,6 +14,8 @@ void memory_initialize(const struct KernelMQ_Info *const kinfo)
{
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) {
@ -35,6 +37,7 @@ unsigned long memory_alloc_page()
{
for (unsigned int i = 0; i < FRAMES_COUNT; ++i) {
if (!frames[i]) {
frames[i] = 0xFF;
return i * PAGE_SIZE;
}
}
@ -48,6 +51,6 @@ void mark_used(const unsigned long base, const unsigned long limit)
const unsigned int end = limit / PAGE_SIZE;
for (unsigned int i = start; i <= end; ++i) {
frames[i] = 1;
frames[i] = 0xFF;
}
}

View file

@ -4,8 +4,6 @@
#include <kernelmq/stdlib.h>
#define MEM_UPPER_BASE ((unsigned long)(1 * 1024 * 1024 * 1024)) // 1 MB
// i386 paging constants
#define I386_VM_PRESENT 0x001 // Page is present
#define I386_VM_WRITE 0x002 // Read/write access allowed