[lkml]   [1997]   [Apr]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Subjectpseudo device driver with mmap
I am trying to write a pseudo device driver for Linux.
The device driver provides a kind of smart buffer scheme for unrelated
processes. Let's call the driver buf.
The driver provides the entry points buf_open, buf_close, buf_read, buf_write,
buf_ioctl, buf_mmap.
In buf_open, a piece of kernel memory is allocated.
This piece of kernel memory is to be made available in user land by
issuing a
mmap() call into the pseudo device driver buf.
Now the problem is, what code do I need in buf_mmap to make a piece of
allocated kernel memory available to userland?

The sequence of calls in user land:
Process 1:

buf_fd = open("/dev/buf");
ioctl(buf_fd, get_address_of_allocated_kernel_buf, &kernelbufaddr)
buf = mmap(kernelbufaddr, ...)
read(buf_fd, ...) /* blocks until another proc puts something in buf */

work on buf


Process 2

buf_fd = open("/dev/buf");
write(buf_fd, ...)

The details are a bit more complicated than this, but I hope you get the idea.

I have looked at the mmap code of the mem device driver, but it seems it
doesn't do exactly what I want to accomplish. It expects a physical address
to be mapped (correct me, if I'm wrong), buf I have a virtual kernel address
from my call to kmalloc.

What code do I need in buf_mmap to map a piece of allocated kernel memory
to userland?
Any and all replies are appreciated.

K. Schuler

 \ /
  Last update: 2005-03-22 13:39    [W:0.027 / U:3.304 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site