xref: /freebsd/share/man/man4/io.4 (revision a41dcb6d1c2e52ac150895ceac6dcfe75a677b01)
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.\"
28e6769554SRui Paulo.\" $FreeBSD$
29e6769554SRui Paulo.\"
3031a9a22bSAttilio Rao.Dd June 01, 2010
31c383d55bSGavin Atkinson.Dt IO 4
32e6769554SRui Paulo.Os
33e6769554SRui Paulo.Sh NAME
34e6769554SRui Paulo.Nm io
35e6769554SRui Paulo.Nd I/O privilege file
36e6769554SRui Paulo.Sh SYNOPSIS
37e6769554SRui Paulo.Cd "device io"
3831a9a22bSAttilio Rao.Pp
3931a9a22bSAttilio Rao.In sys/types.h
4031a9a22bSAttilio Rao.In sys/ioctl.h
4131a9a22bSAttilio Rao.In dev/io/iodev.h
4231a9a22bSAttilio Rao.In machine/iodev.h
4331a9a22bSAttilio Rao.Pp
4431a9a22bSAttilio Rao.Bd -literal
4531a9a22bSAttilio Raostruct iodev_pio_req {
4631a9a22bSAttilio Rao	u_int access;
4731a9a22bSAttilio Rao	u_int port;
4831a9a22bSAttilio Rao	u_int width;
4931a9a22bSAttilio Rao	u_int val;
5031a9a22bSAttilio Rao};
51e6769554SRui Paulo.Sh DESCRIPTION
52e6769554SRui PauloThe special file
53e6769554SRui Paulo.Pa /dev/io
54e6769554SRui Paulois a controlled security hole that allows a process to gain I/O
55e6769554SRui Pauloprivileges
56e6769554SRui Paulo(which are normally reserved for kernel-internal code).
57e6769554SRui PauloThis can be useful in order to write userland
58e6769554SRui Pauloprograms that handle some hardware directly.
5931a9a22bSAttilio Rao.Pp
6031a9a22bSAttilio RaoThe usual operations on the device are to open it via the
6131a9a22bSAttilio Rao.Xr open 2
6231a9a22bSAttilio Raointerface and to send I/O requests to the file descriptor using the
6331a9a22bSAttilio Rao.Xr ioctl 2
6431a9a22bSAttilio Raosyscall.
6531a9a22bSAttilio Rao.Pp
6631a9a22bSAttilio RaoThe
6731a9a22bSAttilio Rao.Xr ioctl 2
6831a9a22bSAttilio Raorequests available for
6931a9a22bSAttilio Rao.Pa /dev/io
7031a9a22bSAttilio Raoare mostly platform dependent, but there are also some in common between
7131a9a22bSAttilio Raoall of them.
7231a9a22bSAttilio RaoThe
7331a9a22bSAttilio Rao.Dv IODEV_PIO
7431a9a22bSAttilio Raois used by all the architectures in order to request that an I/O operation
75*a41dcb6dSAttilio Raobe performed.
76*a41dcb6dSAttilio RaoIt takes a 'struct iodev_pio_req' argument that must be previously setup.
7731a9a22bSAttilio Rao.Pp
7831a9a22bSAttilio RaoThe
7931a9a22bSAttilio Rao.Fa access
80*a41dcb6dSAttilio Raomember specifies the type of operation requested.
81*a41dcb6dSAttilio RaoIt may be:
8231a9a22bSAttilio Rao.Bl -tag -width IODEV_PIO_WRITE
8331a9a22bSAttilio Rao.It Dv IODEV_PIO_READ
84*a41dcb6dSAttilio RaoThe operation is an "in" type.
85*a41dcb6dSAttilio RaoA value will be read from the specified port
8631a9a22bSAttilio Rao(retrieved from the
8731a9a22bSAttilio Rao.Fa port
8831a9a22bSAttilio Raomember) and the result will be stored in the
8931a9a22bSAttilio Rao.Fa val
9031a9a22bSAttilio Raomember.
9131a9a22bSAttilio Rao.It Dv IODEV_PIO_WRITE
92*a41dcb6dSAttilio RaoThe operation is a "out" type.
93*a41dcb6dSAttilio RaoThe value will be fetched from the
9431a9a22bSAttilio Rao.Fa val
9531a9a22bSAttilio Raomember and will be written out to the specified port (defined as the
9631a9a22bSAttilio Rao.Fa port
9731a9a22bSAttilio Raomember).
9831a9a22bSAttilio Rao.El
9931a9a22bSAttilio Rao.Pp
10031a9a22bSAttilio RaoFinally, the
10131a9a22bSAttilio Rao.Fa width
10231a9a22bSAttilio Raomember specifies the size of the operand to be read/written, expressed
10331a9a22bSAttilio Raoin bytes.
104e6769554SRui Paulo.Pp
105e6769554SRui PauloIn addition to any file access permissions on
106e6769554SRui Paulo.Pa /dev/io ,
107e6769554SRui Paulothe kernel enforces that only the super-user may open this device.
10831a9a22bSAttilio Rao.Sh LEGACY
10931a9a22bSAttilio RaoThe
11031a9a22bSAttilio Rao.Pa /dev/io
111*a41dcb6dSAttilio Raointerface used to be very i386 specific and worked differently.
112*a41dcb6dSAttilio RaoThe initial implementation simply raised the
11331a9a22bSAttilio Rao.Em IOPL
11431a9a22bSAttilio Raoof the current thread when
11531a9a22bSAttilio Rao.Xr open 2
116*a41dcb6dSAttilio Raowas called on the device.
117*a41dcb6dSAttilio RaoThis behaviour is retained in the current implementation as legacy
118*a41dcb6dSAttilio Raosupport for both i386 and amd64 architectures.
119e6769554SRui Paulo.Sh SEE ALSO
12031a9a22bSAttilio Rao.Xr close 2 ,
121e6769554SRui Paulo.Xr i386_get_ioperm 2 ,
122e6769554SRui Paulo.Xr i386_set_ioperm 2 ,
12331a9a22bSAttilio Rao.Xr ioctl 2 ,
12431a9a22bSAttilio Rao.Xr open 2 ,
125e6769554SRui Paulo.Xr mem 4
126e6769554SRui Paulo.Sh HISTORY
127e6769554SRui PauloThe
128e6769554SRui Paulo.Nm
129e6769554SRui Paulofile appeared in
130e6769554SRui Paulo.Fx 1.0 .
131