I have a driver (this is continuation of preserving memory accross reboot) whic has some memory allocated and my application wants to write to it. Therefore in the application I (after open call) do if ((ptr = (char *) mmap(0, 4096, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0)) == NULL) { perror("error ..."); } Now I have access to memory starting at virtual location ptr for next 4096 bytes. In my driver static int ocr_mmap(struct file *file, struct vm_area_struct *vma) { unsigned long offset = vma->vm_pgoff << PAGE_SHIFT; int minor = MINOR(file->f_dentry->d_inode->i_rdev); vma->vm_flags |= VM_RESERVED; if (offset >= __pa(high_memory) || (file->f_flags & O_SYNC)) vma->vm_flags |= VM_IO; /* since this driver maps different kind of segs */ if (remap_page_range(vma->vm_start, __pa(dT[minor].addr), vma->vm_end - vma->vm_start, vma->vm_page_prot) < 0) return -EAGAIN; return(0); } Following 3 are filled by kernel vma->vm_start vma->vm_end vma->vm_start __pa(dT[minor].addr) ---> I have a kernel virtual address and __pa() gives me physical address. I hope this is helpfull. Usman --- David Stroupe <dstroupe@keyed-upsoftware.com> wrote: > Usman S. Ansari wrote: > > >No kernel is. > > > >--- David Stroupe <dstroupe@keyed-upsoftware.com> wrote: > > > >>Usman S. Ansari wrote: > >> > >>>When user process calls mmap system call, this address is setup by the kernel along with > size, > >>>this I figure is setup in some suitable place in the user process virtual space. > >>> > >>>Usman > >>> > >>But since I am the device driver writer, I am responsible for > >>this...correct? > >> > So, within my user program I do something like this: void* addy = > mmap(.....) system call. The returned variable addy can now be used in > a call to my driver as the virtual address in a remap_page_range. Of > course, this remap call would use the same size buffer etc. Once this > is completed, accesses to the buffer pointed to by addy will access the > physical memory used in my remap call? > > Thanks again > > -- > Best regards, > David Stroupe > Keyed-Up Software > > ===== Usman S. Ansari Linux OS & Device Drivers __________________________________________________ Do You Yahoo!? Yahoo! Health - your guide to health and wellness http://health.yahoo.com -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/