Page enable successful. Moving on to completing page fault function.
This commit is contained in:
parent
2683fd6f2f
commit
ff69383462
3 changed files with 15 additions and 12 deletions
|
@ -154,8 +154,10 @@ int main() {
|
||||||
|
|
||||||
pt.load();
|
pt.load();
|
||||||
|
|
||||||
|
|
||||||
PageTable::enable_paging();
|
PageTable::enable_paging();
|
||||||
|
|
||||||
|
for(;;);
|
||||||
Console::puts("WE TURNED ON PAGING!\n");
|
Console::puts("WE TURNED ON PAGING!\n");
|
||||||
Console::puts("If we see this message, the page tables have been\n");
|
Console::puts("If we see this message, the page tables have been\n");
|
||||||
Console::puts("set up mostly correctly.\n");
|
Console::puts("set up mostly correctly.\n");
|
||||||
|
|
|
@ -25,15 +25,13 @@ void PageTable::init_paging(ContFramePool * _kernel_mem_pool,
|
||||||
|
|
||||||
PageTable::PageTable()
|
PageTable::PageTable()
|
||||||
{
|
{
|
||||||
//kernel_mem_pool->get_frames(1); // Need to take one frame for page directory.
|
//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???
|
||||||
//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 * page_table = (unsigned long *) 0x33000; // Should be 4kb after the page directory.
|
//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.
|
// We need to map the first 4MB.
|
||||||
for(unsigned int i = 0; i < 1024; i++)
|
for(unsigned int i = 0; i < 1024; i++)
|
||||||
|
@ -44,14 +42,16 @@ PageTable::PageTable()
|
||||||
|
|
||||||
|
|
||||||
// Fill first entry of page directory.
|
// Fill first entry of page directory.
|
||||||
page_directory[0] = *page_table;
|
temp_page_directory[0] = (unsigned long)page_table;
|
||||||
page_directory[0] = page_directory[0] | 3;
|
temp_page_directory[0] = temp_page_directory[0] | 3;
|
||||||
|
|
||||||
for(unsigned int j = 1; j < 1024; j++)
|
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;
|
current_page_table = this;
|
||||||
|
|
||||||
Console::puts("\nConstructed Page Table object\n");
|
Console::puts("\nConstructed Page Table object\n");
|
||||||
|
@ -60,16 +60,16 @@ PageTable::PageTable()
|
||||||
|
|
||||||
void PageTable::load()
|
void PageTable::load()
|
||||||
{
|
{
|
||||||
write_cr3(*page_directory);
|
write_cr3((unsigned long)page_directory);
|
||||||
current_page_table = this;
|
current_page_table = this;
|
||||||
Console::puts("\nLoaded page table\n");
|
Console::puts("\nLoaded page table\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void PageTable::enable_paging()
|
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);
|
write_cr0(read_cr0() | 0x80000000);
|
||||||
paging_enabled = 1;
|
paging_enabled = read_cr0();
|
||||||
Console::puts("\nEnabled paging\n");
|
Console::puts("\nEnabled paging\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,7 @@ private:
|
||||||
static ContFramePool * kernel_mem_pool; /* Frame pool for the kernel memory */
|
static ContFramePool * kernel_mem_pool; /* Frame pool for the kernel memory */
|
||||||
static ContFramePool * process_mem_pool; /* Frame pool for the process memory */
|
static ContFramePool * process_mem_pool; /* Frame pool for the process memory */
|
||||||
static unsigned long shared_size; /* size of shared address space */
|
static unsigned long shared_size; /* size of shared address space */
|
||||||
|
static PageTable a_page_table;
|
||||||
|
|
||||||
/* DATA FOR CURRENT PAGE TABLE */
|
/* DATA FOR CURRENT PAGE TABLE */
|
||||||
unsigned long * page_directory; /* where is page directory located? */
|
unsigned long * page_directory; /* where is page directory located? */
|
||||||
|
|
Reference in a new issue