Ok, here I am, I am now ready to start on paging, I can setup a basic PMode environment. Now I need to setup paging.
Ok, I understand that the page directory holds 1024 32bit page table descriptors (dont know if they are called descriptors, but that sounds good enough), and a page table holds 1024 32bit page descriptors, to map the entire 4GB it takes 4MB of memory, 4KB for the directory, and 4KB for each of the 1024 tables. Now I know nothing, I know about the directory address going into cr3, but how does it work from here?
How do I reference a memory location?
I have seen the docs from the popular reference sites, but I would like some kind of clear example code, if anyone has some that they are willing to part with. lol
Thanks.
Page World!!
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Page World!!
In paged mode, each 4k of memory addresses can virtually map any 4K physical page frame in memory. Here's the design i've used personnally for my own OS.
[table][tr]
[td]0..4M[/td][td]microkernel[/td][td]maps 0..4M physical addresses: convenient for initialization & drivers (you're sure contiguous addresses means contiguous physical locations). All processes map this place identically, thus it is shared among everything[/td][/tr]
[tr][td]4M..4G-8M[/td][td]private[/td][td] free mapping, depending on the running process. These pages are usually allocated on demand (first access to a page will select a free frame and give it to the process for that page)[/td][/tr]
[tr][td]4G-8M..4G-4M[/td][td]directory[/td][td] the 1022th entry of the page directory refers to the directory itself, thus you can easily access to any page table of the current process by using directory[address>>12].[/td][/tr]
[tr][td]4G-4M..4G[/td][td]page frame viewer[/td][td] this is a special shared system place where a process in kernel mode can map any physical page frame it wants. I also use it to keep a map of pages references count (for copy-on-write implementation)[/td]
[/tr]
[/table]
[table][tr]
[td]0..4M[/td][td]microkernel[/td][td]maps 0..4M physical addresses: convenient for initialization & drivers (you're sure contiguous addresses means contiguous physical locations). All processes map this place identically, thus it is shared among everything[/td][/tr]
[tr][td]4M..4G-8M[/td][td]private[/td][td] free mapping, depending on the running process. These pages are usually allocated on demand (first access to a page will select a free frame and give it to the process for that page)[/td][/tr]
[tr][td]4G-8M..4G-4M[/td][td]directory[/td][td] the 1022th entry of the page directory refers to the directory itself, thus you can easily access to any page table of the current process by using directory[address>>12].[/td][/tr]
[tr][td]4G-4M..4G[/td][td]page frame viewer[/td][td] this is a special shared system place where a process in kernel mode can map any physical page frame it wants. I also use it to keep a map of pages references count (for copy-on-write implementation)[/td]
[/tr]
[/table]