summaryrefslogtreecommitdiff
path: root/static/freebsd/man4/io.4 3.html
blob: d26e4c65f4ecd3d23d2f2c2e862a0fe204a105bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<table class="head">
  <tr>
    <td class="head-ltitle">IO(4)</td>
    <td class="head-vol">Device Drivers Manual</td>
    <td class="head-rtitle">IO(4)</td>
  </tr>
</table>
<div class="manual-text">
<section class="Sh">
<h1 class="Sh" id="NAME"><a class="permalink" href="#NAME">NAME</a></h1>
<p class="Pp"><code class="Nm">io</code> &#x2014; <span class="Nd">I/O privilege
    file</span></p>
</section>
<section class="Sh">
<h1 class="Sh" id="SYNOPSIS"><a class="permalink" href="#SYNOPSIS">SYNOPSIS</a></h1>
<p class="Pp"><code class="Cd">device io</code></p>
<p class="Pp">
  <br/>
  <code class="In">#include &lt;<a class="In">sys/types.h</a>&gt;</code>
  <br/>
  <code class="In">#include &lt;<a class="In">sys/ioctl.h</a>&gt;</code>
  <br/>
  <code class="In">#include &lt;<a class="In">dev/io/iodev.h</a>&gt;</code>
  <br/>
  <code class="In">#include &lt;<a class="In">machine/iodev.h</a>&gt;</code></p>
<div class="Bd Pp Li">
<pre>struct iodev_pio_req {
	u_int access;
	u_int port;
	u_int width;
	u_int val;
};</pre>
</div>
</section>
<section class="Sh">
<h1 class="Sh" id="DESCRIPTION"><a class="permalink" href="#DESCRIPTION">DESCRIPTION</a></h1>
<p class="Pp">The special file <span class="Pa">/dev/io</span> is a controlled
    security hole that allows a process to gain I/O privileges (which are
    normally reserved for kernel-internal code). This can be useful in order to
    write userland programs that handle some hardware directly.</p>
<p class="Pp">The usual operations on the device are to open it via the
    <a class="Xr">open(2)</a> interface and to send I/O requests to the file
    descriptor using the <a class="Xr">ioctl(2)</a> syscall.</p>
<p class="Pp">The <a class="Xr">ioctl(2)</a> requests available for
    <span class="Pa">/dev/io</span> are mostly platform dependent, but there are
    also some in common between all of them. The
    <code class="Dv">IODEV_PIO</code> is used by all the architectures in order
    to request that an I/O operation be performed. It takes a 'struct
    iodev_pio_req' argument that must be previously setup.</p>
<p class="Pp">The <var class="Fa">access</var> member specifies the type of
    operation requested. It may be:</p>
<dl class="Bl-tag">
  <dt id="IODEV_PIO_READ"><a class="permalink" href="#IODEV_PIO_READ"><code class="Dv">IODEV_PIO_READ</code></a></dt>
  <dd>The operation is an &quot;in&quot; type. A value will be read from the
      specified port (retrieved from the <var class="Fa">port</var> member) and
      the result will be stored in the <var class="Fa">val</var> member.</dd>
  <dt id="IODEV_PIO_WRITE"><a class="permalink" href="#IODEV_PIO_WRITE"><code class="Dv">IODEV_PIO_WRITE</code></a></dt>
  <dd>The operation is a &quot;out&quot; type. The value will be fetched from
      the <var class="Fa">val</var> member and will be written out to the
      specified port (defined as the <var class="Fa">port</var> member).</dd>
</dl>
<p class="Pp">Finally, the <var class="Fa">width</var> member specifies the size
    of the operand to be read/written, expressed in bytes.</p>
<p class="Pp">In addition to any file access permissions on
    <span class="Pa">/dev/io</span>, the kernel enforces that only the
    super-user may open this device.</p>
</section>
<section class="Sh">
<h1 class="Sh" id="LEGACY"><a class="permalink" href="#LEGACY">LEGACY</a></h1>
<p class="Pp">The <span class="Pa">/dev/io</span> interface used to be very i386
    specific and worked differently. The initial implementation simply raised
    the <a class="permalink" href="#IOPL"><i class="Em" id="IOPL">IOPL</i></a>
    of the current thread when <a class="Xr">open(2)</a> was called on the
    device. This behaviour is retained in the current implementation as legacy
    support for both i386 and amd64 architectures.</p>
</section>
<section class="Sh">
<h1 class="Sh" id="SEE_ALSO"><a class="permalink" href="#SEE_ALSO">SEE
  ALSO</a></h1>
<p class="Pp"><a class="Xr">close(2)</a>, <a class="Xr">i386_get_ioperm(2)</a>,
    <a class="Xr">i386_set_ioperm(2)</a>, <a class="Xr">ioctl(2)</a>,
    <a class="Xr">open(2)</a>, <a class="Xr">mem(4)</a></p>
</section>
<section class="Sh">
<h1 class="Sh" id="HISTORY"><a class="permalink" href="#HISTORY">HISTORY</a></h1>
<p class="Pp">The <code class="Nm">io</code> file appeared in
    <span class="Ux">FreeBSD 1.0</span>.</p>
</section>
</div>
<table class="foot">
  <tr>
    <td class="foot-date">June 1, 2010</td>
    <td class="foot-os">FreeBSD 15.0</td>
  </tr>
</table>