Mapping Kernel-space to User-space

Georg v. Zezschwitz (zezschwi@kogs7.informatik.uni-hamburg.de)
Sat, 24 Jun 1995 03:46:28 +0200 (MET DST)


Hello,

I am developing (together with Alessandro Rubini) a device driver (-module)
for a laboratory interface quite popular in UK and Germany (and maybe else-
where, too (the "1401" made by Cambridge Electronic Design). It supports
such nice features like circular DMA on its ADC-channels or DMA-channels
and is capable of some simple multitasking within its processor).

Unlike most (all?) drivers the user should be able to allocate memory for
DMA-purpose within his/her user-space via a malloc-like-call, as multiple
DMA-buffers might be required, especially, if diffrent programs access the
device simultaniously.

Of cause, I'd prefer to do no changes to the actual kernel (no patching).
I found out that nowmore kmalloc supports up to 128 kB-allocation
of dma-able memory (GFP_DMA). Good! But how may I simply map this to
user space? I want to write a library routine, that is called when the
user wants to allocate memory and asks via the (character-)device-driver
for the 1401 for the memory. The device-driver should then perform
a kmalloc and map this data
to user-space and return the address of it (if it succeeds). Of cause,
the library routine could do the mapping via /dev/mem, but this would
require to run supervisor-mode and would be much slower.

*IF* I am right that no current driver performs such a task, I'd like
to hear anybodys ideas onto how to perform this task. If I am wrong
might anybody give me a hint to a driver doing such tasks?

As the driver will be GPL, if I have to do a lot of kernel modifications,
I'd like to do it in a way probably other people could use the code, too.
(A system call?).

I'd appreciate any answer very much and like to thank in advance,

Georg

Georg Zezschwitz - University of Hamburg -
zezschwi@kogs7.informatik.uni-hamburg.de