Access physical memory with 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
User avatar
liquid.silver
Member
Member
Posts: 46
Joined: Sat Jun 30, 2007 12:07 pm
Location: South Africa
Contact:

Access physical memory with paging

Post by liquid.silver »

How do you access physical memory with paging enabled?

I know how paging works and I do have it working already, but I need to change a page structure and to change it, it must be mapped into somewhere, but I can only map anything if I can change the page structure... See my problem?

I only need to access the page structure temporarily, but many threads may be doing it at the same time too, so any solution?
Mark139
Member
Member
Posts: 39
Joined: Mon Jan 15, 2007 2:32 pm

Mapping

Post by Mark139 »

A really neat way to do this is to map the page directory to itself at the top of memory. I can't remeber the full details, but it's discussed in the forum in a few places.

You loose a little virtual memory space and it may drive you a little crazy thinking about it, but once setup it's an elegant solution
User avatar
liquid.silver
Member
Member
Posts: 46
Joined: Sat Jun 30, 2007 12:07 pm
Location: South Africa
Contact:

Post by liquid.silver »

Where would I map it? I don't want to map it to the beginning of each page cause I want memory overlapping borders of pages to be continuous.

But thanx, the principle has definitely given me a few ideas.
frank
Member
Member
Posts: 729
Joined: Sat Dec 30, 2006 2:31 pm
Location: East Coast, USA

Post by frank »

The way that most people access the page directory and the page tables is to map the last page directory entry to the page directory (so that the CPU thinks that the page directory is also the page table for the last 4mb of address space. That way you can access all of the page tables and the page directory from the last 4mb of space.

0xFFC00000 - 0xFFFFEFFF = the page tables
0xFFFFF000 - 0xFFFFFFFF = the page directory
User avatar
liquid.silver
Member
Member
Posts: 46
Joined: Sat Jun 30, 2007 12:07 pm
Location: South Africa
Contact:

Post by liquid.silver »

frank wrote:The way that most people access the page directory and the page tables is to map the last page directory entry to the page directory (so that the CPU thinks that the page directory is also the page table for the last 4mb of address space. That way you can access all of the page tables and the page directory from the last 4mb of space.

0xFFC00000 - 0xFFFFEFFF = the page tables
0xFFFFF000 - 0xFFFFFFFF = the page directory
Ah i think i see. Then you say "so that the CPU thinks...", I presume you mean to simplify the algorithm? Is that space not reserved for anything? I presume that 0xFFC00000 is the page table for virtual address 0x00000000?

Would the page directory be mapped into itself in the last PDE or what? It's quite late here and I've been drinking, so probably missing something... but could you please clarify. This method seems like a very good way of doing it though. Thanx
frank
Member
Member
Posts: 729
Joined: Sat Dec 30, 2006 2:31 pm
Location: East Coast, USA

Post by frank »

liquid.silver wrote: Ah i think i see. Then you say "so that the CPU thinks...", I presume you mean to simplify the algorithm? Is that space not reserved for anything? I presume that 0xFFC00000 is the page table for virtual address 0x00000000?
Yes 0xFFC00000 is the page table entry for virtual address 0 and 0xFFC00004 is the page table entry for virtual address 0x1000 and so on.
liquid.silver wrote: Would the page directory be mapped into itself in the last PDE or what? It's quite late here and I've been drinking, so probably missing something... but could you please clarify. This method seems like a very good way of doing it though. Thanx
Yes. That's exactly right.
User avatar
liquid.silver
Member
Member
Posts: 46
Joined: Sat Jun 30, 2007 12:07 pm
Location: South Africa
Contact:

Post by liquid.silver »

Okay got it. Thanx. :)

Off to implement it...
Post Reply