Still debugging. Something wrong with writing to pages. Going to give it another go after bed.
This commit is contained in:
parent
495243854b
commit
6a466fe48d
2 changed files with 15 additions and 5 deletions
|
@ -173,7 +173,6 @@ int main() {
|
||||||
for (i=0; i<NACCESS; i++) {
|
for (i=0; i<NACCESS; i++) {
|
||||||
foo[i] = i;
|
foo[i] = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
Console::puts("DONE WRITING TO MEMORY. Now testing...\n");
|
Console::puts("DONE WRITING TO MEMORY. Now testing...\n");
|
||||||
|
|
||||||
for (i=0; i<NACCESS; i++) {
|
for (i=0; i<NACCESS; i++) {
|
||||||
|
|
|
@ -32,7 +32,13 @@ PageTable::PageTable()
|
||||||
unsigned long tempaddr = 0; // 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 < 512; i++)
|
||||||
|
{
|
||||||
|
page_table[i] = tempaddr | 3; // set bits 0 and 1 to present and read/write respectively
|
||||||
|
tempaddr += 4096; // 4096 = 4kb
|
||||||
|
}
|
||||||
|
|
||||||
|
for(unsigned int i = 512; i < 1024; i++)
|
||||||
{
|
{
|
||||||
page_table[i] = tempaddr | 3; // set bits 0 and 1 to present and read/write respectively
|
page_table[i] = tempaddr | 3; // set bits 0 and 1 to present and read/write respectively
|
||||||
tempaddr += 4096; // 4096 = 4kb
|
tempaddr += 4096; // 4096 = 4kb
|
||||||
|
@ -73,16 +79,21 @@ void PageTable::enable_paging()
|
||||||
|
|
||||||
void PageTable::handle_fault(REGS * _r)
|
void PageTable::handle_fault(REGS * _r)
|
||||||
{
|
{
|
||||||
unsigned long temp_addr = (process_mem_pool->get_frames(1));
|
unsigned long temp_addr = (kernel_mem_pool->get_frames(1));
|
||||||
|
|
||||||
((unsigned long *) ((unsigned long *) current_page_table->page_directory)[0])[temp_addr]
|
((unsigned long *) ((unsigned long *) current_page_table->page_directory)[0])[temp_addr]
|
||||||
= ((unsigned long *) ((unsigned long *) current_page_table->page_directory)[0])[temp_addr] | 3;
|
= ((unsigned long *) ((unsigned long *) current_page_table->page_directory)[0])[temp_addr] | 3;
|
||||||
|
|
||||||
Console::puts("\nerror code: ");
|
Console::puts("\nerror code: ");
|
||||||
Console::puti(_r->err_code);
|
Console::puti(_r->err_code);
|
||||||
|
|
||||||
unsigned char mask = 0x00;
|
unsigned char mask = 0x00;
|
||||||
read_cr2();
|
Console::puts("\naddress: ");
|
||||||
|
Console::puti(read_cr2());
|
||||||
|
|
||||||
|
Console::puts("\naddress: ");
|
||||||
|
Console::puti(read_cr3());
|
||||||
|
|
||||||
Console::puts("\nhandled page fault\n");
|
Console::puts("\nhandled page fault\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue