ºìÁªLinuxÃÅ»§
Linux°ïÖú

LinuxÏ°ÑIO¿Õ¼äÓ³Éäµ½Óû§½ø³Ì¿Õ¼ä

·¢²¼Ê±¼ä:2007-01-12 01:20:46À´Ô´:ºìÁª×÷Õß:disney
¡¡¡¡ÆäʵÊǸöÂù¼òµ¥µÄÎÊÌâ¡£ÔÚLDD3µÄµÚ15ÕÂÉÏÓÐд£¨¼û¡°Remapping Specific I/O Regions¡±ÕâÒ»½Ú£©¡£²»¹ýµ±Ê±×÷ÕßÑ¡ÔñÁËÒ»¸ö´íÎóµÄ×ö·¨£ºÏÈ°ÑÕâ¿éIO¿Õ¼äÓÃioremapÓ³Éäµ½ÁËÄں˿ռ䣬ȻºóÔÚÓû§½ø³Ì·ÃÎʱ»Ó³ÉäµÄµØÖ·Ëù²úÉúµÄȱҳÖжÏÀÓÃvmalloc_to_pageµÃµ½page£¬·µ»Ø¸øÓû§½ø³Ì¡£

¡¡¡¡È»¶ø£¬vmalloc_to_pageû·¨ÓÃÔÚioremapËùµÃµ½µÄµØÖ·ÉÏ£¬ÒòΪIO¿Õ¼ä¸ù±¾¾ÍûÓжÔÓ¦µÄPage½á¹¹£¬·µ»ØµÄpageÖ¸Õë×ÔÈ»ÊDz»¶ÔµÄ¡£

¡¡¡¡ÕýÈ·µÄ×ö·¨ÊÇÔÚmmapº¯ÊýÀʹÓÃremap_pfn_rangeº¯Êý¡£´úÂëÈçÏ¡£×¢ÒâÒªÉèÖÃÒ»ÏÂvma->vm_pgoffΪÄãÒªmapµÄio¿Õ¼äµÄÎïÀíµØÖ·¶ÔÓ¦µÄÒ³¡£

ÒýÓÃ:
static int filter_mmap(struct file *filp, struct vm_area_struct *vma)
{
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
vma->vm_pgoff = ( (u32)map_start >> PAGE_SHIFT);

if (remap_pfn_range(vma,
vma->vm_start,
vma->vm_pgoff,
vma->vm_end-vma->vm_start,
vma->vm_page_prot))
return -EAGAIN;
return 0;
}
ÎÄÕÂÆÀÂÛ

¹²ÓÐ 0 ÌõÆÀÂÛ