Paging: Difference between revisions

Jump to navigation Jump to search
[unchecked revision][unchecked revision]
Content deleted Content added
m →‎Page Table: grammar
No edit summary
Line 68: Line 68:


== Enabling ==
== Enabling ==
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 bit of CR0.
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="asm">
<source lang="asm">
Line 75: Line 75:
mov eax, cr0
mov eax, cr0
or eax, 0x80000000
or eax, 0x80000001
mov cr0, eax
mov cr0, eax
</source>
</source>


If you want to set pages as read-only for both userspace and supervisor, replace 0x80000000 above with 0x80010000, which also sets the WP bit.
If you want to set pages as read-only for both userspace and supervisor, replace 0x80000001 above with 0x80010001, which also sets the WP bit.


To enable PSE (4 MiB pages) the following code is required.
To enable PSE (4 MiB pages) the following code is required.