Memory mapping in X86

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I trying to implement mmap method (And by the way I writing driver to
model adc). I had implemented as shown below. I am not getting the
result as I expected. But got some error: map pfn RAM range req
uncached-minus for 36a0e000-36a0f000, got write-back.

In user space, I call mmap as follows:  map_ptr = (signed short *)
mmap(0,ADC_USER_MEM_SIZE,PROT_READ, MAP_SHARED,fd,0);

Am I doing anything wrong here?


static int simdrv_mmap(struct file *filp,struct vm_area_struct *vma)
{
    unsigned long off	= vma->vm_pgoff << PAGE_SHIFT;
    unsigned long physical = (__pa((void *)adc_dev.adcMemoryArea) >>
PAGE_SHIFT) + off;  // adcMemory I got via
__get_free_pages(GFP_KERNEL, 1);
    unsigned long vsize = vma->vm_end - vma->vm_start;
    unsigned long psize = __pa((void *) adc_dev.adcMemoryArea) - off;

//     Module spanning too high
    if (vsize > psize)
    {
	printk(KERN_ALERT "Module spanning too high");
	return -EINVAL;
    }

    vma->vm_flags	|= VM_IO;
    vma->vm_flags	|= VM_RESERVED;
    vma->vm_page_prot	= pgprot_noncached(vma->vm_page_prot);

    if (remap_pfn_range(vma,vma->vm_start, physical,vsize,vma->vm_page_prot))
    {
        return -EAGAIN;
    }
    printk(KERN_ALERT "Sucessfully memory mapped");
    return 0;
}




-- 
Regards,
Sathishkumar D
http://flowersopenlab.weebly.com/

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux