diff --git a/arch/config.h b/arch/config.h index 2080693..21e1568 100644 --- a/arch/config.h +++ b/arch/config.h @@ -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 diff --git a/arch/memory.c b/arch/memory.c index 1012d1e..e655464 100644 --- a/arch/memory.c +++ b/arch/memory.c @@ -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; } } diff --git a/arch/paging.c b/arch/paging.c index 5ba2ad8..acf0a2f 100644 --- a/arch/paging.c +++ b/arch/paging.c @@ -4,8 +4,6 @@ #include -#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