Paging: self mapping
Posted: Mon Feb 10, 2003 6:08 am
I mapped the page directory into itself like this:
This means that I can access the page directory at address (4GB - 4MB), right? So I use two macros for getting the PTE and PDE of a virtual address. But when I try to access the PDE, I get a page fault:
Any idea what might be wrong?
Code: Select all
extern addr_t *pdir;
pdir[1023] = pdir | 0x003;
Code: Select all
#define PG_TABLE_SIZE 4096
#define PTE_SIZE 4
#define PG_DIR_START(0xFFFFFFFF - 0x400000) /* 4GB - 4MB */
#define ADDR_TO_PDE(virt) (PG_DIR_START + (virt >> 22) * PG_TABLE_SIZE)
#define ADDR_TO_PTE(virt) (PG_DIR_START + ((virt >> 12) &0xFFFFF) * PTE_SIZE)
void foo(addr_t virt)
{
addr_t *pde;
pde = (addr_t*) ADDR_TO_PDE(virt);
if ((*pde & IS_PRESENT) == 0) /* that's where I get the page fault */
...
...
}