xref: /freebsd/share/man/man9/physio.9 (revision 22cf89c938886d14f5796fc49f9f020c23ea8eaf)
1.\"	$NetBSD: physio.9,v 1.2 1996/11/11 00:05:12 lukem Exp $
2.\"
3.\" Copyright (c) 1996 The NetBSD Foundation, Inc.
4.\" All rights reserved.
5.\"
6.\" This code is derived from software contributed to The NetBSD Foundation
7.\" by Paul Kranenburg.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\" 1. Redistributions of source code must retain the above copyright
13.\"    notice, this list of conditions and the following disclaimer.
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\"    notice, this list of conditions and the following disclaimer in the
16.\"    documentation and/or other materials provided with the distribution.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
22.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28.\" POSSIBILITY OF SUCH DAMAGE.
29.\"
30.Dd January 19, 2012
31.Dt PHYSIO 9
32.Os
33.Sh NAME
34.Nm physio
35.Nd initiate I/O on raw devices
36.Sh SYNOPSIS
37.In sys/param.h
38.In sys/systm.h
39.In sys/bio.h
40.In sys/buf.h
41.Ft int
42.Fn physio "struct cdev *dev" "struct uio *uio" "int ioflag"
43.Sh DESCRIPTION
44The
45.Fn physio
46is a helper function typically called from character device
47.Fn read
48and
49.Fn write
50routines to start I/O on a user process buffer.
51The maximum amount of data to transfer with each call
52is determined by
53.Fa dev->si_iosize_max .
54The
55.Fn physio
56call converts the I/O request into a
57.Fn strategy
58request and passes the new request to the driver's
59.Fn strategy
60routine for processing.
61.Pp
62Since
63.Fa uio
64normally describes user space addresses,
65.Fn physio
66needs to lock those pages into memory.
67This is done by calling
68.Fn vmapbuf
69for the appropriate pages.
70.Fn physio
71always awaits the completion of the entire requested transfer before
72returning, unless an error condition is detected earlier.
73.Pp
74A break-down of the arguments follows:
75.Bl -tag -width indent
76.It Fa dev
77The device number identifying the device to interact with.
78.It Fa uio
79The description of the entire transfer as requested by the user process.
80Currently, the results of passing a
81.Fa uio
82structure with the
83.Va uio_segflg
84set to anything other than
85.Dv UIO_USERSPACE
86are undefined.
87.It Fa ioflag
88The ioflag argument from the
89.Fn read
90or
91.Fn write
92function calling
93.Fn physio .
94.El
95.Sh RETURN VALUES
96If successful
97.Fn physio
98returns 0.
99.Er EFAULT
100is returned if the address range described by
101.Fa uio
102is not accessible by the requesting process.
103.Fn physio
104will return any error resulting from calls to the device strategy routine,
105by examining the
106.Dv B_ERROR
107buffer flag and the
108.Va b_error
109field.
110Note that the actual transfer size may be less than requested by
111.Fa uio
112if the device signals an
113.Dq "end of file"
114condition.
115.Sh SEE ALSO
116.Xr read 2 ,
117.Xr write 2
118.Sh HISTORY
119The
120.Nm
121manual page is originally from
122.Nx
123with minor changes for applicability with
124.Fx .
125.Pp
126The
127.Nm
128call has been completely re-written for providing higher
129I/O and paging performance.
130