Page enable successful. Moving on to completing page fault function.

This commit is contained in:
Alexander Huddleston 2017-06-27 02:35:43 -05:00
parent 2683fd6f2f
commit ff69383462
3 changed files with 15 additions and 12 deletions

View file

@ -153,9 +153,11 @@ int main() {
PageTable pt;
pt.load();
PageTable::enable_paging();
for(;;);
Console::puts("WE TURNED ON PAGING!\n");
Console::puts("If we see this message, the page tables have been\n");
Console::puts("set up mostly correctly.\n");

View file

@ -25,15 +25,13 @@ void PageTable::init_paging(ContFramePool * _kernel_mem_pool,
PageTable::PageTable()
{
//kernel_mem_pool->get_frames(1); // Need to take one frame for page directory.
//page_directory = (unsigned long *) 0x32000; // Should be the starting address after 1st 2MB
page_directory = (unsigned long *) kernel_mem_pool->get_frames(1); // Should I get the address like this???
//unsigned long * temp_page_directory = (unsigned long *) 0x32000; // Should be the starting address after 1st 2MB
unsigned long * temp_page_directory = (unsigned long *) (4096 * kernel_mem_pool->get_frames(1)); // Should I get the address like this???
//unsigned long * page_table = (unsigned long *) 0x33000; // Should be 4kb after the page directory.
unsigned long * page_table = page_directory + 0x1000; // Might be able to just do this.
unsigned long * page_table = (unsigned long *) (4096 * kernel_mem_pool->get_frames(1)); // Might be able to just do this.
unsigned long tempaddr; // Temporary address iterator.
unsigned long tempaddr = 0; // Temporary address iterator.
// We need to map the first 4MB.
for(unsigned int i = 0; i < 1024; i++)
@ -44,14 +42,16 @@ PageTable::PageTable()
// Fill first entry of page directory.
page_directory[0] = *page_table;
page_directory[0] = page_directory[0] | 3;
temp_page_directory[0] = (unsigned long)page_table;
temp_page_directory[0] = temp_page_directory[0] | 3;
for(unsigned int j = 1; j < 1024; j++)
{
page_directory[j] = 0 | 2;
temp_page_directory[j] = 0 | 2;
}
page_directory = temp_page_directory;
current_page_table = this;
Console::puts("\nConstructed Page Table object\n");
@ -60,16 +60,16 @@ PageTable::PageTable()
void PageTable::load()
{
write_cr3(*page_directory);
write_cr3((unsigned long)page_directory);
current_page_table = this;
Console::puts("\nLoaded page table\n");
}
void PageTable::enable_paging()
{
write_cr3(*current_page_table->page_directory);
write_cr3((unsigned long)current_page_table->page_directory);
write_cr0(read_cr0() | 0x80000000);
paging_enabled = 1;
paging_enabled = read_cr0();
Console::puts("\nEnabled paging\n");
}

View file

@ -47,6 +47,7 @@ private:
static ContFramePool * kernel_mem_pool; /* Frame pool for the kernel memory */
static ContFramePool * process_mem_pool; /* Frame pool for the process memory */
static unsigned long shared_size; /* size of shared address space */
static PageTable a_page_table;
/* DATA FOR CURRENT PAGE TABLE */
unsigned long * page_directory; /* where is page directory located? */