xref: /freebsd/share/man/man4/io.4 (revision fa9896e082a1046ff4fbc75fcba4d18d1f2efc19)
1 e6769554SRui Paulo.\"
2 e6769554SRui Paulo.\" Copyright (c) 1996 Joerg Wunsch
3 e6769554SRui Paulo.\"
4 e6769554SRui Paulo.\" All rights reserved.
5 e6769554SRui Paulo.\"
6 e6769554SRui Paulo.\" This program is free software.
7 e6769554SRui Paulo.\"
8 e6769554SRui Paulo.\" Redistribution and use in source and binary forms, with or without
9 e6769554SRui Paulo.\" modification, are permitted provided that the following conditions
10 e6769554SRui Paulo.\" are met:
11 e6769554SRui Paulo.\" 1. Redistributions of source code must retain the above copyright
12 e6769554SRui Paulo.\"    notice, this list of conditions and the following disclaimer.
13 e6769554SRui Paulo.\" 2. Redistributions in binary form must reproduce the above copyright
14 e6769554SRui Paulo.\"    notice, this list of conditions and the following disclaimer in the
15 e6769554SRui Paulo.\"    documentation and/or other materials provided with the distribution.
16 e6769554SRui Paulo.\"
17 e6769554SRui Paulo.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
18 e6769554SRui Paulo.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 e6769554SRui Paulo.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 e6769554SRui Paulo.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
21 e6769554SRui Paulo.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 e6769554SRui Paulo.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 e6769554SRui Paulo.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 e6769554SRui Paulo.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 e6769554SRui Paulo.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 e6769554SRui Paulo.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 e6769554SRui Paulo.\"
28 *3e0efd2eSEitan Adler.Dd June 1, 2010
29 c383d55bSGavin Atkinson.Dt IO 4
30 e6769554SRui Paulo.Os
31 e6769554SRui Paulo.Sh NAME
32 e6769554SRui Paulo.Nm io
33 e6769554SRui Paulo.Nd I/O privilege file
34 e6769554SRui Paulo.Sh SYNOPSIS
35 e6769554SRui Paulo.Cd "device io"
36 31a9a22bSAttilio Rao.Pp
37 31a9a22bSAttilio Rao.In sys/types.h
38 31a9a22bSAttilio Rao.In sys/ioctl.h
39 31a9a22bSAttilio Rao.In dev/io/iodev.h
40 31a9a22bSAttilio Rao.In machine/iodev.h
41 31a9a22bSAttilio Rao.Bd -literal
42 31a9a22bSAttilio Raostruct iodev_pio_req {
43 31a9a22bSAttilio Rao	u_int access;
44 31a9a22bSAttilio Rao	u_int port;
45 31a9a22bSAttilio Rao	u_int width;
46 31a9a22bSAttilio Rao	u_int val;
47 31a9a22bSAttilio Rao};
48 a90fbe1dSUlrich Spörlein.Ed
49 e6769554SRui Paulo.Sh DESCRIPTION
50 e6769554SRui PauloThe special file
51 e6769554SRui Paulo.Pa /dev/io
52 e6769554SRui Paulois a controlled security hole that allows a process to gain I/O
53 e6769554SRui Pauloprivileges
54 e6769554SRui Paulo(which are normally reserved for kernel-internal code).
55 e6769554SRui PauloThis can be useful in order to write userland
56 e6769554SRui Pauloprograms that handle some hardware directly.
57 31a9a22bSAttilio Rao.Pp
58 31a9a22bSAttilio RaoThe usual operations on the device are to open it via the
59 31a9a22bSAttilio Rao.Xr open 2
60 31a9a22bSAttilio Raointerface and to send I/O requests to the file descriptor using the
61 31a9a22bSAttilio Rao.Xr ioctl 2
62 31a9a22bSAttilio Raosyscall.
63 31a9a22bSAttilio Rao.Pp
64 31a9a22bSAttilio RaoThe
65 31a9a22bSAttilio Rao.Xr ioctl 2
66 31a9a22bSAttilio Raorequests available for
67 31a9a22bSAttilio Rao.Pa /dev/io
68 31a9a22bSAttilio Raoare mostly platform dependent, but there are also some in common between
69 31a9a22bSAttilio Raoall of them.
70 31a9a22bSAttilio RaoThe
71 31a9a22bSAttilio Rao.Dv IODEV_PIO
72 31a9a22bSAttilio Raois used by all the architectures in order to request that an I/O operation
73 a41dcb6dSAttilio Raobe performed.
74 a41dcb6dSAttilio RaoIt takes a 'struct iodev_pio_req' argument that must be previously setup.
75 31a9a22bSAttilio Rao.Pp
76 31a9a22bSAttilio RaoThe
77 31a9a22bSAttilio Rao.Fa access
78 a41dcb6dSAttilio Raomember specifies the type of operation requested.
79 a41dcb6dSAttilio RaoIt may be:
80 31a9a22bSAttilio Rao.Bl -tag -width IODEV_PIO_WRITE
81 31a9a22bSAttilio Rao.It Dv IODEV_PIO_READ
82 a41dcb6dSAttilio RaoThe operation is an "in" type.
83 a41dcb6dSAttilio RaoA value will be read from the specified port
84 31a9a22bSAttilio Rao(retrieved from the
85 31a9a22bSAttilio Rao.Fa port
86 31a9a22bSAttilio Raomember) and the result will be stored in the
87 31a9a22bSAttilio Rao.Fa val
88 31a9a22bSAttilio Raomember.
89 31a9a22bSAttilio Rao.It Dv IODEV_PIO_WRITE
90 a41dcb6dSAttilio RaoThe operation is a "out" type.
91 a41dcb6dSAttilio RaoThe value will be fetched from the
92 31a9a22bSAttilio Rao.Fa val
93 31a9a22bSAttilio Raomember and will be written out to the specified port (defined as the
94 31a9a22bSAttilio Rao.Fa port
95 31a9a22bSAttilio Raomember).
96 31a9a22bSAttilio Rao.El
97 31a9a22bSAttilio Rao.Pp
98 31a9a22bSAttilio RaoFinally, the
99 31a9a22bSAttilio Rao.Fa width
100 31a9a22bSAttilio Raomember specifies the size of the operand to be read/written, expressed
101 31a9a22bSAttilio Raoin bytes.
102 e6769554SRui Paulo.Pp
103 e6769554SRui PauloIn addition to any file access permissions on
104 e6769554SRui Paulo.Pa /dev/io ,
105 e6769554SRui Paulothe kernel enforces that only the super-user may open this device.
106 31a9a22bSAttilio Rao.Sh LEGACY
107 31a9a22bSAttilio RaoThe
108 31a9a22bSAttilio Rao.Pa /dev/io
109 a41dcb6dSAttilio Raointerface used to be very i386 specific and worked differently.
110 a41dcb6dSAttilio RaoThe initial implementation simply raised the
111 31a9a22bSAttilio Rao.Em IOPL
112 31a9a22bSAttilio Raoof the current thread when
113 31a9a22bSAttilio Rao.Xr open 2
114 a41dcb6dSAttilio Raowas called on the device.
115 a41dcb6dSAttilio RaoThis behaviour is retained in the current implementation as legacy
116 a41dcb6dSAttilio Raosupport for both i386 and amd64 architectures.
117 e6769554SRui Paulo.Sh SEE ALSO
118 31a9a22bSAttilio Rao.Xr close 2 ,
119 e6769554SRui Paulo.Xr i386_get_ioperm 2 ,
120 e6769554SRui Paulo.Xr i386_set_ioperm 2 ,
121 31a9a22bSAttilio Rao.Xr ioctl 2 ,
122 31a9a22bSAttilio Rao.Xr open 2 ,
123 e6769554SRui Paulo.Xr mem 4
124 e6769554SRui Paulo.Sh HISTORY
125 e6769554SRui PauloThe
126 e6769554SRui Paulo.Nm
127 e6769554SRui Paulofile appeared in
128 e6769554SRui Paulo.Fx 1.0 .
129