Paging: Difference between revisions

2 bytes removed ,  2 years ago
m
Fix lang source option
[unchecked revision][unchecked revision]
m (Add 5-level paging and improve code indent)
m (Fix lang source option)
Line 51:
Say the kernel is loaded to 0x100000. However, it needed to be remapped to 0xc0000000. After loading the kernel, it'll initiate paging, and set up the appropriate tables. (See [[Higher Half Kernel]]) After [[Identity Paging]] the first megabyte,it'll need to create a second table (ie. at entry #768 in the paging directory.) to map 0x100000 to 0xC0000000. The code may be like:
 
<source lang="asmASM">
mov eax, 0x0
mov ebx, 0x100000
Line 69:
Enabling paging is actually very simple. All that is needed is to load CR3 with the address of the page directory and to set the paging (PG) and protection (PE) bits of CR0. Note: setting the paging flag when the protection flag is clear causes a general-protection exception.
 
<source lang="asmASM">
mov eax, page_directory
mov cr3, eax
Line 82:
To enable PSE (4 MiB pages) the following code is required.
 
<source lang="asmASM">
mov eax, cr4
or eax, 0x00000010
Line 178:
NASM example:
 
<source lang="CASM">
invlpg [0]
</source>
 
73

edits