42_KFS/src/memory/memory.c

19 lines
553 B
C

#include "memory.h"
#include "string.h"
extern void load_page_directory(uint32_t *);
extern void enable_paging(void);
uint32_t page_directory_entries[1024] __attribute__((aligned(4096)));
uint32_t page_table_entries[1024] __attribute__((aligned(4096)));
void init_memory(void)
{
memset(page_directory_entries, INIT_FLAGS, 1024);
for (int i = 0; i < 1024; i++)
page_table_entries[i] = (i << 12) | INIT_FLAGS;
page_directory_entries[0] = (uint32_t)page_table_entries | INIT_FLAGS;
load_page_directory(page_directory_entries);
enable_paging();
}