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?
Last edited by Kumar; 09-14-2005 at 05:12 AM.