Anonymous user
Identity Paging: Difference between revisions
Reformatted
[unchecked revision] | [unchecked revision] |
No edit summary |
(Reformatted) |
||
Line 1:
{{Convert}}
Identity Paging, Identity Mapped
For instance you may decide to use Identity Paging in the lowest 1MB, in which case vaddr <tt>00000000</tt>..<tt>00000fff</tt> are mapped to frame #00000, vaddr <tt>00001000</tt>..<tt>00001fff</tt> are mapped to frame #00001, and so on (vaddr <tt>000ff000</tt>..<tt>000fffff</tt> are mapped to frame #000ff)▼
When switching to paged protected mode, your 1:1 mapping region doesn't care of whether paging is enabled or disabled. Placing your switching code and important data such as the core page directory and a few system page tables in this region gives you an easier way to set up paging without headaches.▼
==Example==
▲
You can easily do this with a loop filling the page table:
void idpaging(dword *first_pte, vaddr from, int size){▼
from = from & 0xfffff000; // discard bits we don't want▼
for(;size;from+=4096,first_pte++){▼
*first_pte=from|1; // mark page present.▼
}▼
}▼
▲ void idpaging(dword *first_pte, vaddr from, int size){
▲==Advantages of Identity Paging==
▲ from = from & 0xfffff000; // discard bits we don't want
▲When switching to paged protected mode, your 1:1 mapping region doesn't care of whether paging is enabled or disabled. Placing your switching code and important data such as the core page directory and a few system page tables in this region gives you an easier way to set up paging without headaches.
▲ for(;size;from+=4096,first_pte++){
▲ *first_pte=from|1; // mark page present.
▲ }
▲ }
And that's all there is to it.
[[Category:Memory management]]
|