Page 2 of 2
Re:Paging initialization:
Posted: Tue Feb 18, 2003 3:30 am
by distantvoices
and now, the bugs drive me to insanity *ig*
I have some feeling as if the Adresses, I hand over to the page directory, aren't correct, because the cr2 register shows a location in my idt which is reserved for the page fault handler , AND this exception is fired off directly after this instruction: mov cr0,eax. (in eax,i modify the msw to set the paging enable bit).
Well, letz look forward, what else I find out. My feeling says that there are some misled pointers in the page directory so that no page entries can be found.
Question: the adress handed over to cr3 has to be a physical one: in nasm I would extract this by lea [page_dir] where page_dir is a variable defined in the bss section of my kernel thing. Is this right?
other question: the adresses entered in the page table stand for 4 k page frames. The index to the page frames indicates their physical adress. Is this right?
stay safe folks
Re:Paging initialization:
Posted: Tue Feb 18, 2003 7:44 am
by Pype.Clicker
The CR3 indeed holds an absolute physical address (directly sent to the memory chips, without any paging or segmentation translation of any kind). It will be lea [directory] iff your data segment is 0-based and iff directory is aligned on a 4K boundary (i think 12 lowest bits of CR3 are ignored by the hardware, but i wouldn't gamble my life on that ...)
The page directory entries (as well as page table entries) contains the "frame number" for the referred object (either page table or data/code page). absolute_address = frame_number*4096. As the frame number is stored in bits 12..31 of the table entries, just applying an AND mask 0xFFFFF000 to the entry give you the start of the frame as an absolute address (once again, this is directly useable iff your data segment has a base = 0)
Both page directory and page tables must be 4K aligned, and both PDE and PTE entries must have their "present" bit set in order to have a page readable.
Re:Paging initialization:
Posted: Tue Feb 18, 2003 1:07 pm
by distantvoices
SUCH A SHAME:
so long I needed to get it working.
I tried just some VERY simple code I imagined that it should do the job at last, and bang, it did! Nothing complicated, nothing excessively twisted did the job, but a simple for-loop to fill in that page table. *lol*
thanks for help and patience.
it took my forward a big step.
Re:Paging initialization:
Posted: Wed Feb 19, 2003 2:05 am
by Pype.Clicker
don't be ashamed ... it took me about 2 monthes to have a working paged environment ... and i still found bugz in it as long as i decided to rewrote it in C and - design - it ...
programming should always start at the Ultimate Integrated Design Tool : the sheet of paper ...
Re:Paging initialization:
Posted: Wed Feb 19, 2003 4:27 am
by distantvoices
It is always good to write down the intention. to give them a picture.
I sometimes take a sheet of paper and a calculator just to figure out how some algorithm would run or what I get after certain bit shifts. It helps a lot to keep these braindumps.
I often make sketches of the program run ... to imagine how it shall run... I am none of those who are able to code out of the head. I need to visualize it first, think about it and then do the actual coding. Everything else leads to negative entropy.
Re:Paging initialization:
Posted: Sat Mar 22, 2003 4:27 am
by FlashBurn
OK, I think I should post my problem in this thread!
When I enable paging on newer machines (>P2) then my code works. But when I enable it on older machines I get a page fault and the address points to my print function before paging is enabled!
Why is it working on newer, but not on older machines?
Re:Paging initialization:
Posted: Sat Mar 22, 2003 9:16 am
by RicoSanchez
FlashBurn wrote:
OK, I think I should post my problem in this thread!
When I enable paging on newer machines (>P2) then my code works. But when I enable it on older machines I get a page fault and the address points to my print function before paging is enabled!
Why is it working on newer, but not on older machines?
Ehhhm. You get a page fault before paging is enabled?
Re:Paging initialization:
Posted: Sat Mar 22, 2003 3:50 pm
by Pype.Clicker
FlashBurn wrote:
OK, I think I should post my problem in this thread!
This is a soooo old thread. You should better have started a new one ... well. It will be for the next time
When I enable paging on newer machines (>P2) then my code works. But when I enable it on older machines I get a page fault and the address points to my print function before paging is enabled!
I would definitely say "check the code that tell you where the bug is" ... No processor (even the 80386) will send you a page fault before paging is enabled ... maybe the previous message just didn't print out correctly ...
Why is it working on newer, but not on older machines?
The main reason i envision would be the difference in memory size ... or maybe do you use some extensions that aren't available in older processors like Page Size Extensions ...
Re:Paging initialization:
Posted: Sun Mar 23, 2003 4:09 am
by FlashBurn
I don?t use the page size extension. The page fault address points to the call of my print function. And thius call is before the call of my page init call! But I wont search for this bug now. Maybe later, because it is working on newer machines!