I'm trying to understand the Linux memory manager, so I'm hoping someone
could answer this question for me.
I'm a little confused about the difference between the virt_to_phys
function and the combination of the pgd_offset,pmd_offset, and
pte_offset functions.
The pgd/pmd/pte stuff is used, AFAIK, to obtain a physical address of a
USER SPACE virtual address, like this:
pgd = pgd_offset(current->mm, address);
pmd = pmd_offset(pgd, address);
pte = pte_offset(pmd, address);
printk("page: %08lx\n", pte_page(*pte));
(please stop me if I say something wrong)
If I try this approach on a virtual address in a driver, this won't
work, because the driver's "virtual address" are mapped directly to
physical memory, and if I want to obtain the physical address, I need to
use the virt_to_phys macro.
In short, to obtain the physical address of a user-space virtual
address, use pgd/pmd/pte_offset. To obtain the physical address of a
kernel-space virtual address, use virt_to_phys.
Is that correct?
--
Timur "too * for my code" Tabi
Remove "nospam_" from my email address when replying
Sent via Deja.com http://www.veryComputer.com/
Before you buy.