lkml.org 
[lkml]   [2000]   [Oct]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: mapping user space buffer to kernel address space
mdaljeet@in.ibm.com writes:
> I have a user buffer and i want to map it to kernel address space
> can anyone tell how to do this like in AIX we have xmattach

In 2.2, you're better off providing a fake character device driver
which allocates the memory in kernel space and lets the user mmap it.
In 2.4, you could try out kiobufs which, if my reading of the section
marked "#ifdef HACKING", "case BTTV_JUST_HACKING" and also
/* playing with kiobufs and dma-to-userspace */
is correct, goes (modulo error handling) roughly like:

struct kiobuf *iobuf;
alloc_kiovec(1, &iobuf); /* allocate a(n array of one) kiobuf */
map_user_kiobuf(READ, iobuf, va, len); /* userland vaddr and length */
/* s/READ/WRITE/ for write */
/* now you have an iobuf containing pinned down user pages */
...
lock_kiovec(1, &iobuf, 1); /* Lock pages down for I/O */
/* first 1 is vector count */
/* second means wait for lock */
.. /* do I/O on it */
free_kiovec(1, &iobuf); /* does an implicit unlock_kiovec */

It doesn't do an unmap_kiobuf(iobuf) so I don't understand where
the per-page map->count that map_user_kiobuf incremented gets
decremented again. Anyone? Lowlevel I/O on a kiovec can be done
with something like an ll_rw_kiovec which sct said was going to get
put in but since I haven't read anything more recent than
2.4.0-test5 at the moment, I can't say if it's there or what it
looks like.

--Malcolm

--
Malcolm Beattie <mbeattie@sable.ox.ac.uk>
Unix Systems Programmer
Oxford University Computing Services
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

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