Commit 66b2c0ee by triazo

Add function to initiate a blank directory

parent 20eeaa3a
Showing with 24 additions and 4 deletions
......@@ -46,4 +46,7 @@ typedef struct
uint32_t alignment;
} elf_program_header;
// Will probably return a pointer to the PCB block eventually. Dunno though.
void load_elf(elf_header* elf_start);
#endif
......@@ -64,6 +64,7 @@ void* page_allocate()
return (void*)&_kernel_end + 0x1000 * page_number;
}
// page_free just flips the bit to say that the page has been freed
void page_free(void* page_start)
{
if (((uint32_t)page_start & 0xfff) != 0)
......@@ -143,6 +144,23 @@ page_directory_entry* mem_init_kern_tables(multiboot_memory_map* mmap, multiboot
return kern_page_dir;
}
page_directory_entry* page_new_directory()
{
page_directory_entry* pgdir = (page_directory_entry*) page_allocate();
int i;
for(i = 0; i < 1024; i++)
{
// This sets the following flags to the pages:
// Supervisor: Only kernel-mode can access them
// Write Enabled: It can be both read from and written to
// (this is the 2 bit)
// Not Present: The page table is not present
pgdir[i] = 0;
pgdir[i] |= PAGE_WRITABLE;
}
return pgdir;
}
page_directory_entry* initiate_directory()
{
// set each entry to not present
......
......@@ -34,13 +34,12 @@ extern char _kernel_end[];
void* page_allocate();
void page_free(void* page_start);
// Allocatoion of memory
// Initilization
page_directory_entry* mem_init_kern_tables(multiboot_memory_map* mmap, multiboot_memory_map* mmap_end);
// Defined in the file mem.c
page_directory_entry* initiate_directory();
// Directory handling
page_directory_entry* page_new_directory();
page_directory_entry* initiate_directory(); // DEPRECATED
// memory mark stores a counter of bytes for the most recently used
......
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