2 .\" Copyright (c) 1999 Kenneth D. Merry.
3 .\" All rights reserved.
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
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.
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
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.3 2006/05/26 19:39:39 swildner Exp $
33 .Nd generic PCI driver
39 driver provides a way for userland programs to read and write
41 configuration registers. It also provides a way for userland programs to
46 devices that match various patterns.
50 driver provides a write interface for
52 configuration registers, system administrators should exercise caution when
53 granting access to the
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
60 controller in the kernel. Additional
62 busses are handled automatically as they are encountered.
66 calls are supported by the
68 driver. They are defined in the header file
70 .Bl -tag -width 012345678901234
77 structure. It allows the user to retrieve information on all
79 devices in the system, or on
81 devices matching patterns supplied by the user.
84 structure consists of a number of fields:
85 .Bl -tag -width match_buf_len
87 The length, in bytes, of the buffer filled with user-supplied patterns.
89 The number of user-supplied patterns.
91 Pointer to a buffer filled with user-supplied patterns.
98 structure consists of the following elements:
99 .Bl -tag -width pd_vendor
102 bus, slot and function.
108 device driver unit number.
119 The flags describe which of the fields the kernel should match against.
120 A device must match all specified fields in order to be returned. The
121 match flags are enumerated in the
122 .Va pci_getconf_flags
124 Hopefully the flag values are obvious enough that they don't need to
130 buffer allocated by the user to hold the results of the
134 Number of matches returned by the kernel.
136 Buffer containing matching devices returned by the kernel. The items in
137 this buffer are of type
139 which consists of the following items:
140 .Bl -tag -width pc_subvendor
143 bus, slot and function.
167 device programming interface.
177 The offset is passed in by the user to tell the kernel where it should
178 start traversing the device list. The value passed out by the kernel
179 points to the record immediately after the last one returned. The user may
180 pass the value returned by the kernel in subsequent calls to the
182 ioctl. If the user does not intend to use the offset, it must be set to
186 configuration generation. This value only needs to be set if the offset is
187 set. The kernel will compare the current generation number of its internal
188 device list to the generation passed in by the user to determine whether
189 its device list has changed since the user last called the
191 ioctl. If the device list has changed, a status of
192 .Va PCI_GETCONF_LIST_CHANGED
195 The status tells the user the disposition of his request for a device list.
196 The possible status values are:
198 .It PCI_GETCONF_LAST_DEVICE
199 This means that there are no more devices in the PCI device list after the
203 .It PCI_GETCONF_LIST_CHANGED
204 This status tells the user that the
206 device list has changed since his last call to the
208 ioctl and he must reset the
212 to zero to start over at the beginning of the list.
213 .It PCI_GETCONF_MORE_DEVS
214 This tells the user that his buffer was not large enough to hold all of the
215 remaining devices in the device list that possibly match his criteria. It
216 is possible for this status to be returned, even when none of the remaining
217 devices in the list would match the user's criteria.
218 .It PCI_GETCONF_ERROR
219 This indicates a general error while servicing the user's request. A more
220 specific indication of the problem may or may not be printed in the kernel
221 message buffer (and by implication, the system console).
229 configuration registers specified by the passed-in
233 structure consists of the following fields:
234 .Bl -tag -width pi_width
238 structure which specifies the bus, slot and function the user would like to
243 configuration register the user would like to access.
245 The width, in bytes, of the data the user would like to read. This value
246 may be either 1, 2, or 4. 3-byte reads and reads larger than 4 bytes are
249 The data returned by the kernel.
254 allows users to write to the
256 specified in the passed-in
260 structure is described above. The limitations on data width described for
261 reading registers, above, also apply to writing
263 configuration registers.
266 .Bl -tag -width /dev/pci -compact
268 Character device for the
279 driver (not the kernel's
281 support code) first appeared in
283 and was written by Stefan Esser and Garrett Wollman.
284 Support for device listing and matching was re-implemented by
285 Kenneth Merry, and first appeared in
288 .An Kenneth Merry Aq ken@FreeBSD.org
290 It isn't possible for users to specify an accurate offset into the device
291 list without calling the
293 at least once, since they have no way of knowing the current generation
294 number otherwise. This probably isn't a serious problem, though, since
295 users can easily narrow their search by specifying a pattern or patterns
296 for the kernel to match against.