Identity Paging: Difference between revisions

m
Bot: Replace deprecated source tag with syntaxhighlight
[unchecked revision][unchecked revision]
No edit summary
 
m (Bot: Replace deprecated source tag with syntaxhighlight)
 
(8 intermediate revisions by 7 users not shown)
Line 1:
Identity Paging, Identity Mapped pagingPaging and 1:1 pagingPaging are terms often used on the forum to describe a design choice where a portion of [virtual addresses|Physical, Virtual, Paging, help?!?] are mapped to physical addresses that have the same value. This means that if paging is enabled with identity paging, <tt>0xb8000</tt> '''is''' <tt>0xb8000</tt>, as long as that area is identity mapped.
{{Convert}}
 
==Advantages==
Identity Paging, Identity Mapped paging and 1:1 paging are terms often used on the forum to describe a design choice where a portion of [virtual addresses|Physical, Virtual, Paging, help?!?] are mapped to physical addresses that have the same value.
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==
ForLet's instancesay you may decide to use IdentityPagingIdentity Paging in the lowest 1MB,. inIn whichthis 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)
 
You can easily do this with a loop filling the page table:
<syntaxhighlight lang="c">
<verbatim>
void idpaging(dworduint32_t *first_pte, vaddr from, int size) {
from = from & 0xfffff000; // discard bits we don't want
{
for(; size>0; from += 4096, size -= 4096, first_pte++) {
from = from & 0xfffff000; // discard bits we don't want
*first_pte = from | 1; // mark page present.
for(;size;from+=4096,first_pte++) {
}
*first_pte=from|1; // mark page present.
}
</syntaxhighlight>
}
</verbatim>
 
==See Also==
!What's the advantage of 1:1 paging
===Articles===
* [[Memory Management]]
* [[Paging]]
 
[[Category:Memory management]]
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.