LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Implementing mmap (https://www.linuxquestions.org/questions/programming-9/implementing-mmap-361342/)

Kumar 09-08-2005 03:12 AM

Implementing mmap
 
Hi,
I am trying to implement mmap in a character driver. My kernel version is 2.4.20-8 and gcc version is 3.2.2. In brief, this is what I am doing in my driver code-
1. static unsigned char *ebuffer; [This is a global variable]
2. ebuffer = (unsigned char *)kmalloc(PAGE_SIZE-1,GFP_KERNEL); [Inside init_module]
3. remap_page_range (vm, vm->vm_start, virt_to_phys(ebuffer), vm->vm_end - vm->vm_start, vm->vm_page_prot) [In my mmap function]
4. printk("Data %s",ebuffer); [In my ioctl function].


Now, In my user mode program, I open the device file(/dev/mm - created using mknod program) and do a mmap on it , followed by ioctl, the driver should dump the data which I wrote at the mapped adderss. But it is not working properly and printing some random stuff. Can anyone please tell me where I am going wrong?

Thank you.


All times are GMT -5. The time now is 10:16 AM.