Commit b69ec898 by triazo

Add function to map a region of virtual memory to real mem

parent acf84412
Showing with 10 additions and 0 deletions
...@@ -132,6 +132,13 @@ page_directory_entry* initiate_directory() ...@@ -132,6 +132,13 @@ page_directory_entry* initiate_directory()
return page_directory; return page_directory;
} }
// Expect addr to be page aligned
void map_directory_entry(void* addr, page_directory_entry* page_dir) {
page_table_entry* new_page_table = (page_table_entry*) (malloc(2048)+1024)&0xfffffc00;
populate_page_table(new_page_table, addr & 0xffc00000, 1024, 0);
page_dir[addr >> 22] = new_page_table;
}
void* malloc(uint32_t bytes) void* malloc(uint32_t bytes)
{ {
void* old_mark = memory_mark; void* old_mark = memory_mark;
......
...@@ -31,6 +31,9 @@ extern void enablePaging(); ...@@ -31,6 +31,9 @@ extern void enablePaging();
page_directory_entry* initiate_directory(); page_directory_entry* initiate_directory();
page_directory_entry* mem_init_kern_tables(multiboot_memory_map* mmap, multiboot_memory_map* mmap_end); page_directory_entry* mem_init_kern_tables(multiboot_memory_map* mmap, multiboot_memory_map* mmap_end);
// map_directory_entry maps the real address given to a page directory at the same memory
void map_directory_entry(void*);
// memory mark stores a counter of bytes for the most recently used // memory mark stores a counter of bytes for the most recently used
// memory. Everything before it is used and all valid memory after it // memory. Everything before it is used and all valid memory after it
// is free // is free
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment