Setting Up Paging: Difference between revisions

Jump to navigation Jump to search
[unchecked revision][unchecked revision]
Content deleted Content added
Line 24: Line 24:
If you know where the end of your kernel is, then you can put the page directory right after it.
If you know where the end of your kernel is, then you can put the page directory right after it.


Note that all of your paging structures need to be at page aligned addresses, so it's probably a good idea to make a page allocator first and have that dish out pages for your paging code.
Note that all of your paging structures need to be at page aligned addresses, so it's probably a good idea to make a page allocator first and have that dish out pages for your paging code. Until you create a proper page allocator though, simply finding the first free page-aligned address after the kernel will be fine.


<pre>
<pre>
//the page directory comes right after the kernel - NOTE: make sure the address is page aligned!
//the page directory comes right after the kernel - NOTE: make sure the address is page aligned!
unsigned int *page_directory = (unsigned int*)end;
unsigned int page_aligned_end = (((unsigned int*)end) & 0xFFFFF000) + 0x1000;
unsigned int *page_directory = (unsigned int*)page_aligned_end;
</pre>
</pre>


Line 35: Line 36:
<pre>
<pre>
//this is only a temporary solution. Find out where your kernel ends!
//this is only a temporary solution. Find out where your kernel ends!
unsigned int *page_directory = (unsigned int*) 0x9C000;
unsigned int *page_directory = (unsigned int*) 0x9C000;//Make sure that this address is properly page aligned
</pre>
</pre>