Implementing mmap

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

 



Hello
	I've written a simple character device driver ( that only reads and writes
from a buffer  ).  I'm trying to implement mmap. The code is below.  The
open, release, read, write all are defined and work ok.  I'm trying to map
kernel virtual address to a logical address. Only the mmap code gives
problems.

-----------< mmap >-------------------------


static int mids_mmap ( struct file * file, struct vm_area_struct *vmas )
{
	unsigned long size;
	if ( vmas->vm_pgoff )
		return -EINVAL;
	size = vmas->vm_end - vmas->vm_start;
	if ( size != PAGE_SIZE )
		return -EINVAL;

	/* mids_buffer is defined as static char * mids_buffer and
	    allocated PAGE_SIZE memory in init_module()
	    using vmalloc()
	*/
	if ( remap_page_range( vmas->vm_start, virt_to_phys(mids_buffer),
				size,vmas->vm_page_prot ))
		return -EAGAIN;
	return 0;
}

Whatever be the contents of the buffer ( i can do that using read and write
implementations ), I always get the output in the userspace code as a funny
character - ASCII value 255 ( I passed it through od ). There is no other
error.

	What am I doing wrong ?

regards
Sridhar




--
Anyone can do any amount of work provided it isn't the work he is supposed to
be doing
		-- Murphy's Laws on Work
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[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