Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
A single page table (and therefore a PDE) covers only a 4 MiB region. By setting the first entry in the page directory you’re mapping 0x0-0x3fffff. You should set entry 3 to the page table. I would recommend using macros to index the directory and table, for example considering the fact that VAs are 32 bits wide and directory and table indices are 10 bits wide, that means that the upper 10 bits of a va are the directory index, middle 10 are table index, lower 12 are page offset. That means that to get the directory index of a VA, do
int dirIdx = (va >> 22) & 0x3FF;
int tabIdx = (va >> 12) & 0x3FF;
I would recommend putting that either in an inline function or making a macro based off it so you don’t have to write the formula every time you want to use it.
"How did you do this?"
"It's very simple — you read the protocol and write the code." - Bill Joy
Projects: NexNix | libnex | nnpkg