Date: Mon, 1 Dec 1997 15:42:35 -0500 (EST) From: "John S. Dyson" <toor@dyson.iquest.net> To: templin@erg.sri.com (Fred L. Templin) Cc: freebsd-hackers@freebsd.org, templin@erg.sri.com Subject: Re: copyout()/copyin() Message-ID: <199712012042.PAA00811@dyson.iquest.net> In-Reply-To: <199712011952.LAA10723@grayling.erg.sri.com> from "Fred L. Templin" at "Dec 1, 97 11:52:28 am"
next in thread | previous in thread | raw e-mail | index | archive | help
Fred L. Templin said: > Hi, > > I'm designing an interface in which I need to move data directly between > user and kernel buffers using copyout() and copyin(). The interface works > fine when called synchronously within process context (e.g. the user process > calls ioctl(), giving the address of a buffer, and the kernel calls copyout() > or copyin() to move the data). But, what I really want is an *asynchronous* > interface in which the kernel can move data to/from the user buffers from > within an interrupt service routine - and it's my understanding that copyout() > and copyin() aren't suited for this. Am I wrong about this? If not, are there > alternatives to copyout()/copyin() which can be used to implement such an > interface? > Two ways (off the top of my head) to do it: 1) Queue it to a buffer representation while a process is waiting for the I/O to complete. Transfer the data using read or somesuch in process context, after waking the process up. (This is how read generally works.) One usually ends up using copyin/copyout here directly or indirectly by using uiomove. You have to have a process context active for copyin or copyout to work. (That includes their friends suword, fuword, etc.) 2) Lock the process virtual memory into physical space. Then, map that memory into kernel space. (This is how raw I/O generally works.) Once the memory is wired and mapped into the kernel, no special copyin/copyout is needed, you can just bcopy or use the virtual memory for anything. (Look at kern_physio.c.) Each of the schemes has it's own set of problems. There are probably other ways, I just haven't thought of them here and now. -- John dyson@freebsd.org jdyson@nc.com
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199712012042.PAA00811>