xref: /freebsd/share/man/man9/physio.9 (revision 5bf6ab83691ec9bdd8ba88e71cdbff01f891485e)
14b2502a3SMike Pritchard.\"	$NetBSD: physio.9,v 1.2 1996/11/11 00:05:12 lukem Exp $
24b2502a3SMike Pritchard.\"
34b2502a3SMike Pritchard.\" Copyright (c) 1996 The NetBSD Foundation, Inc.
44b2502a3SMike Pritchard.\" All rights reserved.
54b2502a3SMike Pritchard.\"
64b2502a3SMike Pritchard.\" This code is derived from software contributed to The NetBSD Foundation
74b2502a3SMike Pritchard.\" by Paul Kranenburg.
84b2502a3SMike Pritchard.\"
94b2502a3SMike Pritchard.\" Redistribution and use in source and binary forms, with or without
104b2502a3SMike Pritchard.\" modification, are permitted provided that the following conditions
114b2502a3SMike Pritchard.\" are met:
124b2502a3SMike Pritchard.\" 1. Redistributions of source code must retain the above copyright
134b2502a3SMike Pritchard.\"    notice, this list of conditions and the following disclaimer.
144b2502a3SMike Pritchard.\" 2. Redistributions in binary form must reproduce the above copyright
154b2502a3SMike Pritchard.\"    notice, this list of conditions and the following disclaimer in the
164b2502a3SMike Pritchard.\"    documentation and/or other materials provided with the distribution.
174b2502a3SMike Pritchard.\" 3. All advertising materials mentioning features or use of this software
184b2502a3SMike Pritchard.\"    must display the following acknowledgement:
194b2502a3SMike Pritchard.\"        This product includes software developed by the NetBSD
204b2502a3SMike Pritchard.\"        Foundation, Inc. and its contributors.
214b2502a3SMike Pritchard.\" 4. Neither the name of The NetBSD Foundation nor the names of its
224b2502a3SMike Pritchard.\"    contributors may be used to endorse or promote products derived
234b2502a3SMike Pritchard.\"    from this software without specific prior written permission.
244b2502a3SMike Pritchard.\"
254b2502a3SMike Pritchard.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
264b2502a3SMike Pritchard.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
274b2502a3SMike Pritchard.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
284b2502a3SMike Pritchard.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
294b2502a3SMike Pritchard.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
304b2502a3SMike Pritchard.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
314b2502a3SMike Pritchard.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
324b2502a3SMike Pritchard.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
334b2502a3SMike Pritchard.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
344b2502a3SMike Pritchard.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
354b2502a3SMike Pritchard.\" POSSIBILITY OF SUCH DAMAGE.
364b2502a3SMike Pritchard.\"
375bf6ab83SNik Clayton.\"     $Id$
385bf6ab83SNik Clayton.\"
394b2502a3SMike Pritchard.Dd June 15, 1996
404b2502a3SMike Pritchard.Dt PHYSIO 9
414b2502a3SMike Pritchard.Os FreeBSD
424b2502a3SMike Pritchard.Sh NAME
434b2502a3SMike Pritchard.Nm physio
444b2502a3SMike Pritchard.Nd initiate I/O on raw devices
454b2502a3SMike Pritchard.Sh SYNOPSIS
462e14815bSBruce Evans.Fd #include <sys/param.h>
472e14815bSBruce Evans.Fd #include <sys/buf.h>
484b2502a3SMike Pritchard.Ft int
492e14815bSBruce Evans.Fo physio
502e14815bSBruce Evans.Fa "void (*strategy)(struct buf *)"
514b2502a3SMike Pritchard.Fa "struct buf *bp"
524b2502a3SMike Pritchard.Fa "dev_t dev"
534b2502a3SMike Pritchard.Fa "int flags"
542e14815bSBruce Evans.Fa "u_int (*minphys)(struct buf *)"
554b2502a3SMike Pritchard.Fa "struct uio *uio"
564b2502a3SMike Pritchard.Fc
574b2502a3SMike Pritchard.Sh DESCRIPTION
584b2502a3SMike PritchardThe
594b2502a3SMike Pritchard.Fn physio
604b2502a3SMike Pritchardis a helper function typically called from character device read and write
614b2502a3SMike Pritchardroutines to start I/O on a user process buffer. It calls back on the
624b2502a3SMike Pritchardprovided
634b2502a3SMike Pritchard.Fa strategy
644b2502a3SMike Pritchardroutine one or more times to complete the transfer described by
654b2502a3SMike Pritchard.Fa uio .
664b2502a3SMike PritchardThe maximum amount of data to transfer with each call to
674b2502a3SMike Pritchard.Fa strategy
684b2502a3SMike Pritchardis determined by the
694b2502a3SMike Pritchard.Fa minphys
704b2502a3SMike Pritchardroutine. Since
714b2502a3SMike Pritchard.Fa uio
724b2502a3SMike Pritchardnormally describes user space addresses,
734b2502a3SMike Pritchard.Fn physio
744b2502a3SMike Pritchardneeds to lock the process into memory.  This is done by setting the
754b2502a3SMike Pritchard.Dv P_PHYSIO
764b2502a3SMike Pritchardflag on the process.
774b2502a3SMike Pritchard.Fn physio
784b2502a3SMike Pritchardalways awaits the completion of the entire requested transfer before
794b2502a3SMike Pritchardreturning, unless an error condition is detected earlier. In all cases,
804b2502a3SMike Pritchardthe buffer passed in
814b2502a3SMike Pritchard.Fa bp
824b2502a3SMike Pritchardis locked (marked as
834b2502a3SMike Pritchard.Dq busy )
844b2502a3SMike Pritchardfor the duration of the entire transfer.
854b2502a3SMike Pritchard.Pp
864b2502a3SMike PritchardA break-down of the arguments follows:
874b2502a3SMike Pritchard.Bl -tag -width indent
884b2502a3SMike Pritchard.It Fa strategy
894b2502a3SMike PritchardThe device strategy routine to call for each chunk of data to initiate
904b2502a3SMike Pritcharddevice I/O.
914b2502a3SMike Pritchard.It Fa bp
924b2502a3SMike PritchardThe buffer to use with the strategy routine. The buffer flags will have
934b2502a3SMike Pritchard.Dv B_BUSY ,
944b2502a3SMike Pritchardand
954b2502a3SMike Pritchard.Dv B_PHYS
964b2502a3SMike Pritchardset when passed to the strategy routine. If
974b2502a3SMike Pritchard.Dv NULL ,
984b2502a3SMike Pritcharda buffer is allocated from a system pool.
994b2502a3SMike Pritchard.It Fa dev
1004b2502a3SMike PritchardThe device number identifying the device to interact with.
1014b2502a3SMike Pritchard.It Fa flags
1024b2502a3SMike PritchardDirection of transfer; the only valid settings are
1034b2502a3SMike Pritchard.Dv B_READ
1044b2502a3SMike Pritchardor
1054b2502a3SMike Pritchard.Dv B_WRITE .
1064b2502a3SMike Pritchard.It Fa minphys
1074b2502a3SMike PritchardA device specific routine called to determine the maximum transfer size
1084b2502a3SMike Pritchardthat the device's strategy routine can handle.
1094b2502a3SMike Pritchard.It Fa uio
1104b2502a3SMike PritchardThe description of the entire transfer as requested by the user process.
1114b2502a3SMike PritchardCurrently, the results of passing a
1124b2502a3SMike Pritchard.Fa uio
1134b2502a3SMike Pritchardstructure with the
1144b2502a3SMike Pritchard.Sq uio_segflg
1154b2502a3SMike Pritchardset to anything other than
1164b2502a3SMike Pritchard.Dv UIO_USERSPACE ,
1174b2502a3SMike Pritchardare undefined.
1184b2502a3SMike Pritchard.El
1194b2502a3SMike Pritchard.Pp
1204b2502a3SMike Pritchard.Sh RETURN VALUES
1214b2502a3SMike PritchardIf successful
1224b2502a3SMike Pritchard.Fn physio
1234b2502a3SMike Pritchardreturns 0.
1244b2502a3SMike Pritchard.Er EFAULT
1254b2502a3SMike Pritchardis returned if the address range described by
1264b2502a3SMike Pritchard.Fa uio
1274b2502a3SMike Pritchardis not accessible by the requesting process.
1284b2502a3SMike Pritchard.Fn physio
1294b2502a3SMike Pritchardwill return any error resulting from calls to the device strategy routine,
1304b2502a3SMike Pritchardby examining the
1314b2502a3SMike Pritchard.Dv B_ERROR
1324b2502a3SMike Pritchardbuffer flag and the
1334b2502a3SMike Pritchard.Va b_error
1344b2502a3SMike Pritchardfield. Note that the actual transfer size may be less than requested by
1354b2502a3SMike Pritchard.Fa uio
1364b2502a3SMike Pritchardif the device signals an
1374b2502a3SMike Pritchard.Dq end of file
1384b2502a3SMike Pritchardcondition.
1394b2502a3SMike Pritchard.Sh SEE ALSO
1404b2502a3SMike Pritchard.Xr read 2 ,
1414b2502a3SMike Pritchard.Xr write 2
142