xref: /freebsd-src/share/man/man4/io.4 (revision fa9896e082a1046ff4fbc75fcba4d18d1f2efc19)
1e6769554SRui Paulo.\"
2e6769554SRui Paulo.\" Copyright (c) 1996 Joerg Wunsch
3e6769554SRui Paulo.\"
4e6769554SRui Paulo.\" All rights reserved.
5e6769554SRui Paulo.\"
6e6769554SRui Paulo.\" This program is free software.
7e6769554SRui Paulo.\"
8e6769554SRui Paulo.\" Redistribution and use in source and binary forms, with or without
9e6769554SRui Paulo.\" modification, are permitted provided that the following conditions
10e6769554SRui Paulo.\" are met:
11e6769554SRui Paulo.\" 1. Redistributions of source code must retain the above copyright
12e6769554SRui Paulo.\"    notice, this list of conditions and the following disclaimer.
13e6769554SRui Paulo.\" 2. Redistributions in binary form must reproduce the above copyright
14e6769554SRui Paulo.\"    notice, this list of conditions and the following disclaimer in the
15e6769554SRui Paulo.\"    documentation and/or other materials provided with the distribution.
16e6769554SRui Paulo.\"
17e6769554SRui Paulo.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
18e6769554SRui Paulo.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19e6769554SRui Paulo.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20e6769554SRui Paulo.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
21e6769554SRui Paulo.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22e6769554SRui Paulo.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23e6769554SRui Paulo.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24e6769554SRui Paulo.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25e6769554SRui Paulo.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26e6769554SRui Paulo.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27e6769554SRui Paulo.\"
28*3e0efd2eSEitan Adler.Dd June 1, 2010
29c383d55bSGavin Atkinson.Dt IO 4
30e6769554SRui Paulo.Os
31e6769554SRui Paulo.Sh NAME
32e6769554SRui Paulo.Nm io
33e6769554SRui Paulo.Nd I/O privilege file
34e6769554SRui Paulo.Sh SYNOPSIS
35e6769554SRui Paulo.Cd "device io"
3631a9a22bSAttilio Rao.Pp
3731a9a22bSAttilio Rao.In sys/types.h
3831a9a22bSAttilio Rao.In sys/ioctl.h
3931a9a22bSAttilio Rao.In dev/io/iodev.h
4031a9a22bSAttilio Rao.In machine/iodev.h
4131a9a22bSAttilio Rao.Bd -literal
4231a9a22bSAttilio Raostruct iodev_pio_req {
4331a9a22bSAttilio Rao	u_int access;
4431a9a22bSAttilio Rao	u_int port;
4531a9a22bSAttilio Rao	u_int width;
4631a9a22bSAttilio Rao	u_int val;
4731a9a22bSAttilio Rao};
48a90fbe1dSUlrich Spörlein.Ed
49e6769554SRui Paulo.Sh DESCRIPTION
50e6769554SRui PauloThe special file
51e6769554SRui Paulo.Pa /dev/io
52e6769554SRui Paulois a controlled security hole that allows a process to gain I/O
53e6769554SRui Pauloprivileges
54e6769554SRui Paulo(which are normally reserved for kernel-internal code).
55e6769554SRui PauloThis can be useful in order to write userland
56e6769554SRui Pauloprograms that handle some hardware directly.
5731a9a22bSAttilio Rao.Pp
5831a9a22bSAttilio RaoThe usual operations on the device are to open it via the
5931a9a22bSAttilio Rao.Xr open 2
6031a9a22bSAttilio Raointerface and to send I/O requests to the file descriptor using the
6131a9a22bSAttilio Rao.Xr ioctl 2
6231a9a22bSAttilio Raosyscall.
6331a9a22bSAttilio Rao.Pp
6431a9a22bSAttilio RaoThe
6531a9a22bSAttilio Rao.Xr ioctl 2
6631a9a22bSAttilio Raorequests available for
6731a9a22bSAttilio Rao.Pa /dev/io
6831a9a22bSAttilio Raoare mostly platform dependent, but there are also some in common between
6931a9a22bSAttilio Raoall of them.
7031a9a22bSAttilio RaoThe
7131a9a22bSAttilio Rao.Dv IODEV_PIO
7231a9a22bSAttilio Raois used by all the architectures in order to request that an I/O operation
73a41dcb6dSAttilio Raobe performed.
74a41dcb6dSAttilio RaoIt takes a 'struct iodev_pio_req' argument that must be previously setup.
7531a9a22bSAttilio Rao.Pp
7631a9a22bSAttilio RaoThe
7731a9a22bSAttilio Rao.Fa access
78a41dcb6dSAttilio Raomember specifies the type of operation requested.
79a41dcb6dSAttilio RaoIt may be:
8031a9a22bSAttilio Rao.Bl -tag -width IODEV_PIO_WRITE
8131a9a22bSAttilio Rao.It Dv IODEV_PIO_READ
82a41dcb6dSAttilio RaoThe operation is an "in" type.
83a41dcb6dSAttilio RaoA value will be read from the specified port
8431a9a22bSAttilio Rao(retrieved from the
8531a9a22bSAttilio Rao.Fa port
8631a9a22bSAttilio Raomember) and the result will be stored in the
8731a9a22bSAttilio Rao.Fa val
8831a9a22bSAttilio Raomember.
8931a9a22bSAttilio Rao.It Dv IODEV_PIO_WRITE
90a41dcb6dSAttilio RaoThe operation is a "out" type.
91a41dcb6dSAttilio RaoThe value will be fetched from the
9231a9a22bSAttilio Rao.Fa val
9331a9a22bSAttilio Raomember and will be written out to the specified port (defined as the
9431a9a22bSAttilio Rao.Fa port
9531a9a22bSAttilio Raomember).
9631a9a22bSAttilio Rao.El
9731a9a22bSAttilio Rao.Pp
9831a9a22bSAttilio RaoFinally, the
9931a9a22bSAttilio Rao.Fa width
10031a9a22bSAttilio Raomember specifies the size of the operand to be read/written, expressed
10131a9a22bSAttilio Raoin bytes.
102e6769554SRui Paulo.Pp
103e6769554SRui PauloIn addition to any file access permissions on
104e6769554SRui Paulo.Pa /dev/io ,
105e6769554SRui Paulothe kernel enforces that only the super-user may open this device.
10631a9a22bSAttilio Rao.Sh LEGACY
10731a9a22bSAttilio RaoThe
10831a9a22bSAttilio Rao.Pa /dev/io
109a41dcb6dSAttilio Raointerface used to be very i386 specific and worked differently.
110a41dcb6dSAttilio RaoThe initial implementation simply raised the
11131a9a22bSAttilio Rao.Em IOPL
11231a9a22bSAttilio Raoof the current thread when
11331a9a22bSAttilio Rao.Xr open 2
114a41dcb6dSAttilio Raowas called on the device.
115a41dcb6dSAttilio RaoThis behaviour is retained in the current implementation as legacy
116a41dcb6dSAttilio Raosupport for both i386 and amd64 architectures.
117e6769554SRui Paulo.Sh SEE ALSO
11831a9a22bSAttilio Rao.Xr close 2 ,
119e6769554SRui Paulo.Xr i386_get_ioperm 2 ,
120e6769554SRui Paulo.Xr i386_set_ioperm 2 ,
12131a9a22bSAttilio Rao.Xr ioctl 2 ,
12231a9a22bSAttilio Rao.Xr open 2 ,
123e6769554SRui Paulo.Xr mem 4
124e6769554SRui Paulo.Sh HISTORY
125e6769554SRui PauloThe
126e6769554SRui Paulo.Nm
127e6769554SRui Paulofile appeared in
128e6769554SRui Paulo.Fx 1.0 .
129