I obtained the answers to my questions via the linux
kernel mailing list *thanks guys*. Since some
people have been asking me via e-mail for the answers,
here they are:
- How can one lock specific process pages?
Use the mlock, munlock etc. functions.
- How can one obtain the physical address of
the pages involved?
The physical address corresponding to a virtual address
'ADDRESS' of process 'PROCESS' can be obtained using the following define:
generic_virt_to_phys(ADDRESS,PROCESS)
Where the conversion is defined by:
#define generic_virt_to_phys(ADDRESS,PROCESS) \
((char*)( \
pte_page( \
*pte_offset( \
pmd_offset( \
pgd_offset(PROCESS->mm,(unsigned long)ADDRESS), \
(unsigned long) ADDRESS \
),(unsigned long) ADDRESS \
) \
) | ( ((unsigned long) ADDRESS) & (~PAGE_MASK)) ))
The define uses the page tables of the process to
translate the virtual address to a physical one.
Note that, in the kernel, the current process is
indicated by the variable `current'.
- How can one ensure that the pages involved
are DMA-able (below 16Mb)?
PCI devices can write anywhere in physical memory. Devices
connected via an ISA might have this problem.
- Is it possible to obtain a continues block of
physical memory in user space?
Yes. In that can you should mmap memory allocated by the
kernel to the user space. An example of this can be found
in the kernel sources of the `sound' device driver.
Greetings,
Marcel Boosten
|