Mapping kernel memory into user space

Thomas.Koenig@ciw.uni-karlsruhe.de
Tue, 16 Jul 1996 15:43:31 +0200


[I'm forwarding this for a friend, who doesn't regularly read the
kernel mailing list. I'll forward any responses to him.]

Hi,

I am writing a device driver for a PCI video capture board that writes image
data directly into the memory of the computer. As it is impossible to obtain
large contiguos memory areas in kernel space, I use blocks of 4k and program
the framegrabber's processor to write to them. To obtain fast acces to the
image data, I want to use memory mapped acces. However, I cannot figure out
how to map these 4k blocks to a contiguos area in user space memory. For
allocating the blocks I use

get_free_page();

The driver works fine when using my read(), which copies the data to user
memory via memcpy_to_fs(). In the drivers mmap() function, I tried to
subsequently map the blocks to user space via remap_page_range(). This does
not work at all, not even for the first page.

Q1: How can I map non-contiguos memory pages in kernel space to a
contiguos area in user space?

Q2: Is there a way to use shared memory, so I could use XShmPutImage()
to write to a window?

Q3: Which flags for get_free_page() insure that the pages won't be
swapped out?

Thanks in advance for your help, Hubert.