Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 09-08-2005, 04:12 AM   #1
Registered: Sep 2003
Location: Pune, India
Distribution: Red Hat
Posts: 106

Rep: Reputation: 15
Implementing mmap

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.

Last edited by Kumar; 09-14-2005 at 06:12 AM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
mmap function professional1983 Programming 1 06-14-2005 05:23 AM
mmap() error FarAway Programming 3 03-30-2005 08:38 AM
using mmap AngryLlama Programming 1 02-09-2005 09:53 AM
kiobuf vs. mmap j4r0d Programming 8 01-10-2005 04:18 AM
mmap problem os2 Programming 4 06-21-2004 06:24 PM

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

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration