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
32 .Nd generic PCI driver
38 driver provides a way for userland programs to read and write
40 configuration registers.
41 It also provides a way for userland programs to get a list of all
45 devices that match various patterns.
49 driver provides a write interface for
51 configuration registers, system administrators should exercise caution when
52 granting access to the
55 If used improperly, this driver can allow userland applications to
56 crash a machine or cause data loss.
63 It enumerates any devices on the
67 client drivers the chance to attach to them.
68 It assigns resources to children, when the BIOS does not.
69 It takes care of routing interrupts when necessary.
70 It reprobes the unattached
74 client drivers are dynamically
76 .Sh KERNEL CONFIGURATION
79 device is included in the kernel as described in the SYNOPSIS section.
82 driver cannot be built as a
87 calls are supported by the
90 They are defined in the header file
92 .Bl -tag -width 012345678901234
99 It allows the user to retrieve information on all
101 devices in the system, or on
103 devices matching patterns supplied by the user.
106 to any value specified in either
112 structure consists of a number of fields:
113 .Bl -tag -width match_buf_len
115 The length, in bytes, of the buffer filled with user-supplied patterns.
117 The number of user-supplied patterns.
119 Pointer to a buffer filled with user-supplied patterns.
127 structure consists of the following elements:
128 .Bl -tag -width pd_vendor
131 domain, bus, slot and function.
137 device driver unit number.
148 The flags describe which of the fields the kernel should match against.
149 A device must match all specified fields in order to be returned.
150 The match flags are enumerated in the
151 .Va pci_getconf_flags
153 Hopefully the flag values are obvious enough that they do not need to
159 buffer allocated by the user to hold the results of the
163 Number of matches returned by the kernel.
165 Buffer containing matching devices returned by the kernel.
166 The items in this buffer are of type
168 which consists of the following items:
169 .Bl -tag -width pc_subvendor
172 domain, bus, slot and function.
196 device programming interface.
206 The offset is passed in by the user to tell the kernel where it should
207 start traversing the device list.
208 The value passed out by the kernel
209 points to the record immediately after the last one returned.
211 pass the value returned by the kernel in subsequent calls to the
214 If the user does not intend to use the offset, it must be set to zero.
217 configuration generation.
218 This value only needs to be set if the offset is set.
219 The kernel will compare the current generation number of its internal
220 device list to the generation passed in by the user to determine whether
221 its device list has changed since the user last called the
224 If the device list has changed, a status of
225 .Va PCI_GETCONF_LIST_CHANGED
228 The status tells the user the disposition of his request for a device list.
229 The possible status values are:
231 .It PCI_GETCONF_LAST_DEVICE
232 This means that there are no more devices in the PCI device list matching
233 the specified criteria after the
237 .It PCI_GETCONF_LIST_CHANGED
238 This status tells the user that the
240 device list has changed since his last call to the
242 ioctl and he must reset the
246 to zero to start over at the beginning of the list.
247 .It PCI_GETCONF_MORE_DEVS
248 This tells the user that his buffer was not large enough to hold all of the
249 remaining devices in the device list that match his criteria.
250 .It PCI_GETCONF_ERROR
251 This indicates a general error while servicing the user's request.
257 .Fn sizeof "struct pci_match_conf" ,
268 configuration registers specified by the passed-in
273 structure consists of the following fields:
274 .Bl -tag -width pi_width
278 structure which specifies the domain, bus, slot and function the user would
280 If the specific bus is not found, errno will be set to ENODEV and -1 returned
285 configuration register the user would like to access.
287 The width, in bytes, of the data the user would like to read.
289 may be either 1, 2, or 4.
290 3-byte reads and reads larger than 4 bytes are
292 If an invalid width is passed, errno will be set to EINVAL.
294 The data returned by the kernel.
299 allows users to write to the
301 specified in the passed-in
306 structure is described above.
307 The limitations on data width described for
308 reading registers, above, also apply to writing
310 configuration registers.
313 .Bl -tag -width /dev/pci -compact
315 Character device for the
324 driver (not the kernel's
326 support code) first appeared in
328 and was written by Stefan Esser and Garrett Wollman.
329 Support for device listing and matching was re-implemented by
330 Kenneth Merry, and first appeared in
333 .An Kenneth Merry Aq ken@FreeBSD.org
335 It is not possible for users to specify an accurate offset into the device
336 list without calling the
338 at least once, since they have no way of knowing the current generation
340 This probably is not a serious problem, though, since
341 users can easily narrow their search by specifying a pattern or patterns
342 for the kernel to match against.