Doubt on paging...
Posted: Wed Apr 13, 2011 1:03 am
Dear All,
Currently I am go throughing OSDev Wiki page for "PAGING". In this page http://wiki.osdev.org/Paging, I have found a function definition to convert virtual address to physical address.
In the above code, they have used two hex address 0xFFFFF000 (assigned to unsigned long * pd) and 0xFFC00000 (assigned to unsigned long * pt), from where these hex values are comes in to an account ?
Actually the *pd value should be taken from the register CR3 and *pt value should taken from the *pd along with the offset.
Can you explain it better ? why they have used these two hex values ?
Currently I am go throughing OSDev Wiki page for "PAGING". In this page http://wiki.osdev.org/Paging, I have found a function definition to convert virtual address to physical address.
Code: Select all
void * get_physaddr(void * virtualaddr)
{
unsigned long pdindex = (unsigned long)virtualaddr >> 22;
unsigned long ptindex = (unsigned long)virtualaddr >> 12 & 0x03FF;
unsigned long * pd = (unsigned long *)0xFFFFF000; //=====> ?????????????????
// Here you need to check whether the PD entry is present.
unsigned long * pt = ((unsigned long *)0xFFC00000) + (0x400 * pdindex); //=====> ?????????????????
// Here you need to check whether the PT entry is present.
return (void *)((pt[ptindex] & ~0xFFF) + ((unsigned long)virtualaddr & 0xFFF));
}
Actually the *pd value should be taken from the register CR3 and *pt value should taken from the *pd along with the offset.
Can you explain it better ? why they have used these two hex values ?