Selective page binding when enabling paging

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.
Post Reply
stonedzealot

Selective page binding when enabling paging

Post by stonedzealot »

That's an awfully complex title for a simple concept. Essentially, I'm just binding whatever pages I actually need before enabling paging rather than using the whole first 4MB shotgun approach.

This is how I've got it set up: I bind

0x9B000 -> 0x9D000 <- 3 pages (1 for misc, kernel's page directory and first page table)

0x100000 -> 0x11B000 <- Kernel loaded at 1MB with a ridiculous (for now) amount of memory allotted to it.

0x300000 -> ~0x305000 <- I say around because it's based off of a variable but it comes out to 0x305000 in bochs. This is used for the stacks of memory addresses.

The kernel binds these all just fine (judging from the entries in the page directory and table) but bochs dies when paging is enabled. This leads me to wonder what section of memory I'm missing.

Also, to note, I'm confident in my pagebind function because when I actually was using the top 4MB shotgun approach I made a for loop like this:

for (i=0, i<1024, i++)
pagebind (i * 4096, i * 4096, pagedirectory);

and proceeded to enable paging successfully. (pagebind(physaddress, virtualaddress, pagedirectory))

EDIT: I've been doing a little trial and error searching and found that I can leave all of the pages >0x9b000 unmapped except 0xf000, anyone know the significance of this page?

ANOTHER EDIT: I give up. Finding holes that need to be paged is much more cumbersome (and less portable, I'd imagine) than just covering the first 4MB. Oh well, it was nice thought.
Post Reply