xref: /dragonfly/share/man/man9/physio.9 (revision c03f08f3)
1.\"
2.\" Copyright (c) 2005 The DragonFly Project.  All rights reserved.
3.\"
4.\" This code is derived from software contributed to The DragonFly Project
5.\" by Hiten Pandya <hmp@backplane.com>.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\"    notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\"    notice, this list of conditions and the following disclaimer in
15.\"    the documentation and/or other materials provided with the
16.\"    distribution.
17.\" 3. Neither the name of The DragonFly Project nor the names of its
18.\"    contributors may be used to endorse or promote products derived
19.\"    from this software without specific, prior written permission.
20.\"
21.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24.\" FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
25.\" COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26.\" INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
27.\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29.\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31.\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32.\" SUCH DAMAGE.
33.\"
34.\"	$NetBSD: physio.9,v 1.2 1996/11/11 00:05:12 lukem Exp $
35.\"
36.\" Copyright (c) 1996 The NetBSD Foundation, Inc.
37.\" All rights reserved.
38.\"
39.\" This code is derived from software contributed to The NetBSD Foundation
40.\" by Paul Kranenburg.
41.\"
42.\" Redistribution and use in source and binary forms, with or without
43.\" modification, are permitted provided that the following conditions
44.\" are met:
45.\" 1. Redistributions of source code must retain the above copyright
46.\"    notice, this list of conditions and the following disclaimer.
47.\" 2. Redistributions in binary form must reproduce the above copyright
48.\"    notice, this list of conditions and the following disclaimer in the
49.\"    documentation and/or other materials provided with the distribution.
50.\" 3. All advertising materials mentioning features or use of this software
51.\"    must display the following acknowledgement:
52.\"        This product includes software developed by the NetBSD
53.\"        Foundation, Inc. and its contributors.
54.\" 4. Neither the name of The NetBSD Foundation nor the names of its
55.\"    contributors may be used to endorse or promote products derived
56.\"    from this software without specific prior written permission.
57.\"
58.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
59.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
60.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
61.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
62.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
63.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
64.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
65.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
66.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
68.\" POSSIBILITY OF SUCH DAMAGE.
69.\"
70.\" $FreeBSD: src/share/man/man9/physio.9,v 1.6.2.4 2001/12/17 11:30:18 ru Exp $
71.\" $DragonFly: src/share/man/man9/physio.9,v 1.4 2007/06/30 19:03:52 swildner Exp $
72.\"
73.Dd July 31, 2005
74.Dt PHYSIO 9
75.Os
76.Sh NAME
77.Nm physio
78.Nd initiate I/O on raw devices
79.Sh SYNOPSIS
80.In sys/param.h
81.In sys/systm.h
82.In sys/buf.h
83.Ft int
84.Fn physio "dev_t dev" "struct uio *uio" "int ioflag"
85.Sh DESCRIPTION
86The
87.Fn physio
88is a helper function typically called from character device read and write
89routines to start I/O on a user process buffer.
90It will call the
91.Xr BUF_STRATEGY 9
92routine one or more times depending on the size of transfer which is
93described by the
94.Fa uio
95argument.
96.Pp
97The maximum amount of data transferable in one iteration of the
98.Nm
99function is determined by the maximum I/O size supported by the device
100.Fa dev ,
101otherwise the value of
102.Dv DFLTPHYS
103is used.
104Until the I/O operation is complete, the calling process or thread is
105put to sleep with the wait message set to
106.Ql "physstr" .
107.Pp
108The
109.Nm
110function always awaits the completion of the entire requested transfer
111before returning, unless an error condition is detected earlier.
112.Pp
113A break-down of the arguments follow:
114.Bl -tag -width indent
115.It Fa dev
116The device to interact with by using it as with the
117.Xr BUF_STRATEGY 9
118routine in order to initiate I/O.
119.It Fa uio
120The description of the entire transfer as requested by the user process.
121.It Fa ioflag
122Direction of transfer; the only valid settings are
123.Dv B_READ
124or
125.Dv B_WRITE .
126.El
127.Sh RETURN VALUES
128If successful
129.Nm
130will return 0.
131.Pp
132The
133.Va errno
134value
135.Er EFAULT
136will be returned if the address range described by
137.Fa uio
138is not accessible by the calling process or thread.
139.Pp
140Note that the actual transfer size may be less than requested by
141.Fa uio
142if the device signals an
143.Dq end of file
144condition.
145.Sh SEE ALSO
146.Xr read 2 ,
147.Xr write 2
148