> Hi,
>
> is there a simple hack for Linux 2.0.X that the kernel allocates a
> contigous 64k area of memory which then can be mmaped by a user program
> which is going to use this as DMA buffer then ?
>
> using a full kernel driver is no option (at least right now for first tests)
> and having this 64k locked, contiguous area seems to be enough for now
> (it's a PCI card, so there is no need for <16MB addresses).
Take a look at the sound driver (linux/drivers/sound/soundcard.c). It
allocates 64k of physically contiguous pages in (sound_alloc_dmap()) using
__get_free_pages() and marks them reserved. Then in sound_mmap() this
memory is mapped to user program's space. The mmap_test.c program in
ftp://ftp.4front-tech.com/ossfree shows how the user process side works.
In practice you should implement a simple loadable device driver with just
open, close and mmap calls. Allocate the memory in init_module() and free
it in cleanup_module(). Freeing mmapped memory in the close routine seems
to cause serious problems in some cases.
Best regards,
Hannu
------
Hannu Savolainen (hannu@voxware.pp.fi, hannu@4front-tech.com)
http://www.4Front-Tech.com/oss.html (Open Sound System (OSS))
http://personal.eunet.fi/pp/voxware (OSS Free/TASD/VoxWare)