paging code - crazy bug (again)
Posted: Thu Nov 24, 2005 1:45 pm
Ok, I'm re-writing my paging set-up code, and it gives me a page fault every time I run it. Well, chances are I'm missing something obvious, but I really am stumped on this one!
Here's the current code (I'm not posting other functions and header files just yet - it might needlessly clutter up the post if they aren't needed):
Thanks in advance for your help,
OScoder
Here's the current code (I'm not posting other functions and header files just yet - it might needlessly clutter up the post if they aren't needed):
Code: Select all
/* Copyright (c) 2005 Tim Saunders - see license.txt file for the license
* SCIOX - Basic Page Handler: Sets up address spaces and provides functions for managing them
*/
#include "..\..\include\config.h"
#include "..\..\include\defs.h"
#include "..\include\system\paging.h"
#include "..\include\asm.h"
void paging_init()
{
unsigned long counter;
unsigned long temp;
unsigned long (*page_directory) [PAGE_TABLE_SIZE-1]; /*First Page Directory (4096 bytes)*/
unsigned long (*page_table_kernel) [PAGE_TABLE_SIZE-1]; /*Maps in the kernel*/
/*Set up our page tables and directories to their physical addresses: - warning - incompatible assignment types*/
page_directory= (long *)0x00110000;
page_table_kernel= (long *)0x00111000;
/*Fill up all tables and directories:*/
for(counter=0; counter<1024; counter++)
{*page_directory[counter]=0 | 2;
*page_table_kernel[counter]=((counter*4096) | 3);}
*page_directory[0]=0x00111000 | 3;
*page_directory[512]=0x00110000 | 3;
/*Enable paging:*/
write_cr3(0x00110000);
get_cr0(temp);
write_cr0((temp | 0x80000000));
asm("hlt");
}
OScoder