<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 9pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body class='hmmessage'>
Dear Dave,<BR>
&nbsp;<BR>
Thanks for your answer first. However I am&nbsp;very confused. It seems that I understand the memory-mapping-related functions completely wrong. Here comes more questions. <BR><BR><BR>&gt; The address you are passing to mmap is where the pointer will be mapped<BR>&gt; in virtual address space. You need to determine the DMA memory address<BR>&gt; page number down in the actual mmap call.<BR>&gt; <BR>&gt; int foo_mmap(struct file* filep, struct vm_area_struct* vma)<BR>&gt; {<BR>&gt; unsigned long dma_addr = 0x03000000;<BR>&gt; unsigned long dma_size = 0x00200000;<BR>&gt; unsigned long pfn;<BR>&gt; <BR>&gt; // convert the DMA address to page number<BR>&gt; pfn = virt_to_phys(dma_addr) &gt;&gt; PAGE_SHIFT;<BR><BR>
Shall I use virt_to_phys? dma_addr is already exactly physical address which is used to initiate DMA transfers. <BR>
&nbsp;<BR>
&gt; // remap our page frame to the vma offset<BR>&gt; remap_pfn_range(vma, vma-&gt;vm_start, pfn, <BR>&gt; dma_size, vma-&gt;vm_page_prot);<BR>&gt; }<BR>&gt; <BR>&gt; Change the address parameter from 0x03000000 to 0:<BR>&gt; <BR>&gt; lut_mem_base = (unsigned int *) mmap(0, LUT_SIZE_IN_BYTE, <BR>&gt; PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);<BR><BR>
Previously I used "remap_page_range(vma, vma-&gt;vm_start, physical_addr, vm_size, vma-&gt;vm_page_prot)" in the device driver, where physical_addr is 0x03000000. In the application program, I used "lut_mem_base = (unsigned int *) mmap(0, LUT_SIZE_IN_BYTE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);". I think it is correct but it doesn't work. I heard that in the new kernels, remap_page_range is not supported any more. However when I compile the driver, nothing was shown to complain that. I am using 2.6.10 kernel. Any hint for this?<BR>
&nbsp;<BR>
Thank you for your help to make me understand. <BR>
&nbsp;<BR>
BR<BR>
Ming<BR><br /><hr />使用新一代 Windows Live Messenger 轻松交流和共享! <a href='http://messenger.live.cn/' target='_new'>立即体验!</a></body>
</html>