Paging initialization:

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.
distantvoices
Member
Member
Posts: 1600
Joined: Wed Oct 18, 2006 11:59 am
Location: Vienna/Austria
Contact:

Re:Paging initialization:

Post 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
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Paging initialization:

Post 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.
distantvoices
Member
Member
Posts: 1600
Joined: Wed Oct 18, 2006 11:59 am
Location: Vienna/Austria
Contact:

Re:Paging initialization:

Post 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.
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Paging initialization:

Post 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 ...
distantvoices
Member
Member
Posts: 1600
Joined: Wed Oct 18, 2006 11:59 am
Location: Vienna/Austria
Contact:

Re:Paging initialization:

Post 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.
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
FlashBurn

Re:Paging initialization:

Post 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?
RicoSanchez

Re:Paging initialization:

Post 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?
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Paging initialization:

Post 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 ...
FlashBurn

Re:Paging initialization:

Post 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!
Post Reply