Sweep over our manual pages and remove .Pp before a .Bd or .Bl without
[dragonfly.git] / share / man / man4 / pci.4
1 .\"
2 .\" Copyright (c) 1999 Kenneth D. Merry.
3 .\" All rights reserved.
4 .\"
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
7 .\" are met:
8 .\" 1. Redistributions of source code must retain the above copyright
9 .\"    notice, this list of conditions and the following disclaimer.
10 .\" 2. The name of the author may not be used to endorse or promote products
11 .\"    derived from this software without specific prior written permission.
12 .\"
13 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 .\" SUCH DAMAGE.
24 .\"
25 .\"     $FreeBSD: src/share/man/man4/pci.4,v 1.3.2.5 2001/08/17 13:08:39 ru Exp $
26 .\"     $DragonFly: src/share/man/man4/pci.4,v 1.4 2008/05/02 02:05:05 swildner Exp $
27 .\"
28 .Dd October 24, 1999
29 .Dt PCI 4
30 .Os
31 .Sh NAME
32 .Nm pci
33 .Nd generic PCI driver
34 .Sh SYNOPSIS
35 .Cd device pci
36 .Sh DESCRIPTION
37 The
38 .Nm
39 driver provides a way for userland programs to read and write
40 .Tn PCI
41 configuration registers.  It also provides a way for userland programs to
42 get a list of all
43 .Tn PCI
44 devices, or all
45 .Tn PCI
46 devices that match various patterns.
47 .Pp
48 Since the
49 .Nm
50 driver provides a write interface for
51 .Tn PCI
52 configuration registers, system administrators should exercise caution when
53 granting access to the
54 .Nm
55 device.  If used improperly, this driver can allow userland applications to
56 crash a machine or cause data loss.
57 .Sh KERNEL CONFIGURATION
58 It is only necessary to specify one
59 .Nm
60 controller in the kernel.  Additional
61 .Tn PCI
62 busses are handled automatically as they are encountered.
63 .Sh IOCTLS
64 The following
65 .Xr ioctl 2
66 calls are supported by the
67 .Nm
68 driver.  They are defined in the header file
69 .In sys/pciio.h .
70 .Bl -tag -width 012345678901234
71 .It PCIOCGETCONF
72 This
73 .Xr ioctl 2
74 takes a
75 .Va pci_conf_io
76 structure.  It allows the user to retrieve information on all
77 .Tn PCI
78 devices in the system, or on
79 .Tn PCI
80 devices matching patterns supplied by the user.
81 The
82 .Va pci_conf_io
83 structure consists of a number of fields:
84 .Bl -tag -width match_buf_len
85 .It pat_buf_len
86 The length, in bytes, of the buffer filled with user-supplied patterns.
87 .It num_patterns
88 The number of user-supplied patterns.
89 .It patterns
90 Pointer to a buffer filled with user-supplied patterns.
91 .Va patterns
92 is a pointer to
93 .Va num_patterns
94 .Va pci_match_conf
95 structures.  The
96 .Va pci_match_conf
97 structure consists of the following elements:
98 .Bl -tag -width pd_vendor
99 .It pc_sel
100 .Tn PCI
101 bus, slot and function.
102 .It pd_name
103 .Tn PCI
104 device driver name.
105 .It pd_unit
106 .Tn PCI
107 device driver unit number.
108 .It pc_vendor
109 .Tn PCI
110 vendor ID.
111 .It pc_device
112 .Tn PCI
113 device ID.
114 .It pc_class
115 .Tn PCI
116 device class.
117 .It flags
118 The flags describe which of the fields the kernel should match against.
119 A device must match all specified fields in order to be returned.  The
120 match flags are enumerated in the
121 .Va pci_getconf_flags
122 structure.
123 Hopefully the flag values are obvious enough that they don't need to
124 described in detail.
125 .El
126 .It match_buf_len
127 Length of the
128 .Va matches
129 buffer allocated by the user to hold the results of the
130 .Dv PCIOCGETCONF
131 query.
132 .It num_matches
133 Number of matches returned by the kernel.
134 .It matches
135 Buffer containing matching devices returned by the kernel.  The items in
136 this buffer are of type
137 .Va pci_conf ,
138 which consists of the following items:
139 .Bl -tag -width pc_subvendor
140 .It pc_sel
141 .Tn PCI
142 bus, slot and function.
143 .It pc_hdr
144 .Tn PCI
145 header type.
146 .It pc_subvendor
147 .Tn PCI
148 subvendor ID.
149 .It pc_subdevice
150 .Tn PCI
151 subdevice ID.
152 .It pc_vendor
153 .Tn PCI
154 vendor ID.
155 .It pc_device
156 .Tn PCI
157 device ID.
158 .It pc_class
159 .Tn PCI
160 device class.
161 .It pc_subclass
162 .Tn PCI
163 device subclass.
164 .It pc_progif
165 .Tn PCI
166 device programming interface.
167 .It pc_revid
168 .Tn PCI
169 revision ID.
170 .It pd_name
171 Driver name.
172 .It pd_unit
173 Driver unit number.
174 .El
175 .It offset
176 The offset is passed in by the user to tell the kernel where it should
177 start traversing the device list.  The value passed out by the kernel
178 points to the record immediately after the last one returned.  The user may
179 pass the value returned by the kernel in subsequent calls to the
180 .Dv PCIOCGETCONF
181 ioctl.  If the user does not intend to use the offset, it must be set to
182 zero.
183 .It generation
184 .Tn PCI
185 configuration generation.  This value only needs to be set if the offset is
186 set.  The kernel will compare the current generation number of its internal
187 device list to the generation passed in by the user to determine whether
188 its device list has changed since the user last called the
189 .Dv PCIOCGETCONF
190 ioctl.  If the device list has changed, a status of
191 .Va PCI_GETCONF_LIST_CHANGED
192 will be passed back.
193 .It status
194 The status tells the user the disposition of his request for a device list.
195 The possible status values are:
196 .Bl -ohang
197 .It PCI_GETCONF_LAST_DEVICE
198 This means that there are no more devices in the PCI device list after the
199 ones returned in the
200 .Va matches
201 buffer.
202 .It PCI_GETCONF_LIST_CHANGED
203 This status tells the user that the
204 .Tn PCI
205 device list has changed since his last call to the
206 .Dv PCIOCGETCONF
207 ioctl and he must reset the
208 .Va offset
209 and
210 .Va generation
211 to zero to start over at the beginning of the list.
212 .It PCI_GETCONF_MORE_DEVS
213 This tells the user that his buffer was not large enough to hold all of the
214 remaining devices in the device list that possibly match his criteria.  It
215 is possible for this status to be returned, even when none of the remaining
216 devices in the list would match the user's criteria.
217 .It PCI_GETCONF_ERROR
218 This indicates a general error while servicing the user's request.  A more
219 specific indication of the problem may or may not be printed in the kernel
220 message buffer (and by implication, the system console).
221 .El
222 .El
223 .It PCIOCREAD
224 This
225 .Xr ioctl 2
226 reads the
227 .Tn PCI
228 configuration registers specified by the passed-in
229 .Va pci_io
230 structure.  The
231 .Va pci_io
232 structure consists of the following fields:
233 .Bl -tag -width pi_width
234 .It pi_sel
235 A
236 .Va pcisel
237 structure which specifies the bus, slot and function the user would like to
238 query.
239 .It pi_reg
240 The
241 .Tn PCI
242 configuration register the user would like to access.
243 .It pi_width
244 The width, in bytes, of the data the user would like to read.  This value
245 may be either 1, 2, or 4.  3-byte reads and reads larger than 4 bytes are
246 not supported.
247 .It pi_data
248 The data returned by the kernel.
249 .El
250 .It PCIOCWRITE
251 This
252 .Xr ioctl 2
253 allows users to write to the
254 .Tn PCI
255 specified in the passed-in
256 .Va pci_io
257 structure.  The
258 .Va pci_io
259 structure is described above.  The limitations on data width described for
260 reading registers, above, also apply to writing
261 .Tn PCI
262 configuration registers.
263 .El
264 .Sh FILES
265 .Bl -tag -width /dev/pci -compact
266 .It Pa /dev/pci
267 Character device for the
268 .Nm
269 driver.
270 .El
271 .Sh DIAGNOSTICS
272 None.
273 .Sh SEE ALSO
274 .Xr pciconf 8
275 .Sh HISTORY
276 The
277 .Nm
278 driver (not the kernel's
279 .Tn PCI
280 support code) first appeared in
281 .Fx 2.2 ,
282 and was written by Stefan Esser and Garrett Wollman.
283 Support for device listing and matching was re-implemented by
284 Kenneth Merry, and first appeared in
285 .Fx 3.0 .
286 .Sh AUTHORS
287 .An Kenneth Merry Aq ken@FreeBSD.org
288 .Sh BUGS
289 It isn't possible for users to specify an accurate offset into the device
290 list without calling the
291 .Dv PCIOCGETCONF
292 at least once, since they have no way of knowing the current generation
293 number otherwise.  This probably isn't a serious problem, though, since
294 users can easily narrow their search by specifying a pattern or patterns
295 for the kernel to match against.