mirror of
https://github.com/tailix/kernel.git
synced 2025-09-04 22:42:59 -04:00
Do not allocate in lower memory
This commit is contained in:
parent
d45671ccda
commit
4dc79c4ee6
3 changed files with 6 additions and 3 deletions
|
@ -1,6 +1,8 @@
|
||||||
#ifndef KERNELMQ_INCLUDED_CONFIG
|
#ifndef KERNELMQ_INCLUDED_CONFIG
|
||||||
#define KERNELMQ_INCLUDED_CONFIG 1
|
#define KERNELMQ_INCLUDED_CONFIG 1
|
||||||
|
|
||||||
|
#define MEM_UPPER_BASE ((unsigned long)(1 * 1024 * 1024 * 1024)) // 1 MB
|
||||||
|
|
||||||
#define PAGE_DIR_SIZE 1024
|
#define PAGE_DIR_SIZE 1024
|
||||||
#define PAGE_TABLE_SIZE 1024
|
#define PAGE_TABLE_SIZE 1024
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,8 @@ void memory_initialize(const struct KernelMQ_Info *const kinfo)
|
||||||
{
|
{
|
||||||
kmemset(frames, 0, sizeof(frames));
|
kmemset(frames, 0, sizeof(frames));
|
||||||
|
|
||||||
|
mark_used(0, MEM_UPPER_BASE - 1);
|
||||||
|
|
||||||
mark_used(kinfo->kernel_phys_base, kinfo->kernel_phys_limit);
|
mark_used(kinfo->kernel_phys_base, kinfo->kernel_phys_limit);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < kinfo->modules_count; ++i) {
|
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) {
|
for (unsigned int i = 0; i < FRAMES_COUNT; ++i) {
|
||||||
if (!frames[i]) {
|
if (!frames[i]) {
|
||||||
|
frames[i] = 0xFF;
|
||||||
return i * PAGE_SIZE;
|
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;
|
const unsigned int end = limit / PAGE_SIZE;
|
||||||
|
|
||||||
for (unsigned int i = start; i <= end; ++i) {
|
for (unsigned int i = start; i <= end; ++i) {
|
||||||
frames[i] = 1;
|
frames[i] = 0xFF;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,8 +4,6 @@
|
||||||
|
|
||||||
#include <kernelmq/stdlib.h>
|
#include <kernelmq/stdlib.h>
|
||||||
|
|
||||||
#define MEM_UPPER_BASE ((unsigned long)(1 * 1024 * 1024 * 1024)) // 1 MB
|
|
||||||
|
|
||||||
// i386 paging constants
|
// i386 paging constants
|
||||||
#define I386_VM_PRESENT 0x001 // Page is present
|
#define I386_VM_PRESENT 0x001 // Page is present
|
||||||
#define I386_VM_WRITE 0x002 // Read/write access allowed
|
#define I386_VM_WRITE 0x002 // Read/write access allowed
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue