mmap: how do i do it ????

Mauro Condarelli (mc5686@mclink.it)
Fri, 3 Nov 1995 01:09:24 +0000


Hi,
I'm again looking for informations about thee innards of the kernel.

I've written a peripheral driver for a frame grabbing board.
It seems to work nicely using the standard open/read paradigm, which
implies copying the whole image from a buffer in kernel memory to
user memory.

Aside from the fact i lose time to copy, i have a memory usage
problem, since the frame buffers can be up to 752*582*4=1750656 (!)
bytes each.

What i wanted to do is to allow the user mode program to mmap the
buffer which already holds the image.
I'm sorry to say that i'm lost.

The KHG doesn't to hold the informations i need, it's either too
generic or goes too deep in detail (i don't belive i have to
manipulate directly page tables and other low level structures!).
I usually can read the kernel code without too much trouble, but the
memory management routines are defying me :-(
There are just too many seemingly similar routines with similar
names and (i suspect) very different semantics (comments, when
existing at all, are perplexing to say the least).

What i need to do seems quite simple:
I have a buffer in kernel memory (guaranteed physically contiguous)
and i have to handle a mmap call so that the user can access it.

Can someone point to me the Right_Way(tm) to do it?

Since we are on the subject:
Is there any (approved) way for the kernel to call a user space
routine? Some kind of callback routine is required to handle the
sigaction() calls, is it necessary to go through that stuff or is
there some shortcut possible (user could call some ioctl() to register
a callbaack routine for certain driver-known events).

In general all this part is quite fuzzy in my mind, so, if someone
can help me to understand a little more...

Thanks in advance.
\_____ Mauro Condarelli (mc5686@mclink.it)