xref: /freebsd/share/man/man4/pci.4 (revision 55aaf894e8a76fe780757ef6d9d1119c367946cf)
164ae346bSKenneth D. Merry.\"
264ae346bSKenneth D. Merry.\" Copyright (c) 1999 Kenneth D. Merry.
364ae346bSKenneth D. Merry.\" All rights reserved.
464ae346bSKenneth D. Merry.\"
564ae346bSKenneth D. Merry.\" Redistribution and use in source and binary forms, with or without
664ae346bSKenneth D. Merry.\" modification, are permitted provided that the following conditions
764ae346bSKenneth D. Merry.\" are met:
864ae346bSKenneth D. Merry.\" 1. Redistributions of source code must retain the above copyright
964ae346bSKenneth D. Merry.\"    notice, this list of conditions and the following disclaimer.
1064ae346bSKenneth D. Merry.\" 2. The name of the author may not be used to endorse or promote products
1164ae346bSKenneth D. Merry.\"    derived from this software without specific prior written permission.
1264ae346bSKenneth D. Merry.\"
1364ae346bSKenneth D. Merry.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1464ae346bSKenneth D. Merry.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1564ae346bSKenneth D. Merry.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1664ae346bSKenneth D. Merry.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1764ae346bSKenneth D. Merry.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1864ae346bSKenneth D. Merry.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1964ae346bSKenneth D. Merry.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2064ae346bSKenneth D. Merry.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2164ae346bSKenneth D. Merry.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2264ae346bSKenneth D. Merry.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2364ae346bSKenneth D. Merry.\" SUCH DAMAGE.
2464ae346bSKenneth D. Merry.\"
2564ae346bSKenneth D. Merry.\" $FreeBSD$
2664ae346bSKenneth D. Merry.\"
2755aaf894SMarius Strobl.Dd September 30, 2007
2864ae346bSKenneth D. Merry.Dt PCI 4
293d45e180SRuslan Ermilov.Os
3064ae346bSKenneth D. Merry.Sh NAME
3164ae346bSKenneth D. Merry.Nm pci
32eb083802SRuslan Ermilov.Nd generic PCI driver
33251c176fSRuslan Ermilov.Sh SYNOPSIS
346b713d58SJeroen Ruigrok van der Werven.Cd device pci
3564ae346bSKenneth D. Merry.Sh DESCRIPTION
3664ae346bSKenneth D. MerryThe
374b66483fSRuslan Ermilov.Nm
3864ae346bSKenneth D. Merrydriver provides a way for userland programs to read and write
3964ae346bSKenneth D. Merry.Tn PCI
40b5e7e999SRuslan Ermilovconfiguration registers.
41b5e7e999SRuslan ErmilovIt also provides a way for userland programs to get a list of all
4264ae346bSKenneth D. Merry.Tn PCI
4364ae346bSKenneth D. Merrydevices, or all
4464ae346bSKenneth D. Merry.Tn PCI
4564ae346bSKenneth D. Merrydevices that match various patterns.
4664ae346bSKenneth D. Merry.Pp
4764ae346bSKenneth D. MerrySince the
484b66483fSRuslan Ermilov.Nm
4964ae346bSKenneth D. Merrydriver provides a write interface for
5064ae346bSKenneth D. Merry.Tn PCI
5164ae346bSKenneth D. Merryconfiguration registers, system administrators should exercise caution when
5264ae346bSKenneth D. Merrygranting access to the
534b66483fSRuslan Ermilov.Nm
54b5e7e999SRuslan Ermilovdevice.
55b5e7e999SRuslan ErmilovIf used improperly, this driver can allow userland applications to
5664ae346bSKenneth D. Merrycrash a machine or cause data loss.
5764ae346bSKenneth D. Merry.Sh KERNEL CONFIGURATION
5864ae346bSKenneth D. MerryIt is only necessary to specify one
594b66483fSRuslan Ermilov.Nm
60b5e7e999SRuslan Ermilovcontroller in the kernel.
61b5e7e999SRuslan ErmilovAdditional
6264ae346bSKenneth D. Merry.Tn PCI
6364ae346bSKenneth D. Merrybusses are handled automatically as they are encountered.
6464ae346bSKenneth D. Merry.Sh IOCTLS
6564ae346bSKenneth D. MerryThe following
6664ae346bSKenneth D. Merry.Xr ioctl 2
6764ae346bSKenneth D. Merrycalls are supported by the
684b66483fSRuslan Ermilov.Nm
69b5e7e999SRuslan Ermilovdriver.
70b5e7e999SRuslan ErmilovThey are defined in the header file
71fe08efe6SRuslan Ermilov.In sys/pciio.h .
7264ae346bSKenneth D. Merry.Bl -tag -width 012345678901234
7364ae346bSKenneth D. Merry.Pp
7464ae346bSKenneth D. Merry.It PCIOCGETCONF
7564ae346bSKenneth D. MerryThis
7664ae346bSKenneth D. Merry.Xr ioctl 2
7764ae346bSKenneth D. Merrytakes a
7864ae346bSKenneth D. Merry.Va pci_conf_io
79b5e7e999SRuslan Ermilovstructure.
80b5e7e999SRuslan ErmilovIt allows the user to retrieve information on all
8164ae346bSKenneth D. Merry.Tn PCI
8264ae346bSKenneth D. Merrydevices in the system, or on
8364ae346bSKenneth D. Merry.Tn PCI
845203edcdSRuslan Ermilovdevices matching patterns supplied by the user.
855203edcdSRuslan ErmilovThe call may set
8607e3ed79SJohn-Mark Gurney.Va errno
8707e3ed79SJohn-Mark Gurneyto any value specified in either
8807e3ed79SJohn-Mark Gurney.Xr copyin 9
8907e3ed79SJohn-Mark Gurneyor
9007e3ed79SJohn-Mark Gurney.Xr copyout 9 .
9164ae346bSKenneth D. MerryThe
9264ae346bSKenneth D. Merry.Va pci_conf_io
9364ae346bSKenneth D. Merrystructure consists of a number of fields:
9464ae346bSKenneth D. Merry.Bl -tag -width match_buf_len
9564ae346bSKenneth D. Merry.It pat_buf_len
9664ae346bSKenneth D. MerryThe length, in bytes, of the buffer filled with user-supplied patterns.
9764ae346bSKenneth D. Merry.It num_patterns
9864ae346bSKenneth D. MerryThe number of user-supplied patterns.
9964ae346bSKenneth D. Merry.It patterns
10064ae346bSKenneth D. MerryPointer to a buffer filled with user-supplied patterns.
10164ae346bSKenneth D. Merry.Va patterns
10264ae346bSKenneth D. Merryis a pointer to
10364ae346bSKenneth D. Merry.Va num_patterns
10464ae346bSKenneth D. Merry.Va pci_match_conf
1055203edcdSRuslan Ermilovstructures.
1065203edcdSRuslan ErmilovThe
10764ae346bSKenneth D. Merry.Va pci_match_conf
10864ae346bSKenneth D. Merrystructure consists of the following elements:
10964ae346bSKenneth D. Merry.Bl -tag -width pd_vendor
11064ae346bSKenneth D. Merry.It pc_sel
11164ae346bSKenneth D. Merry.Tn PCI
11255aaf894SMarius Strobldomain, bus, slot and function.
11364ae346bSKenneth D. Merry.It pd_name
11464ae346bSKenneth D. Merry.Tn PCI
11564ae346bSKenneth D. Merrydevice driver name.
11664ae346bSKenneth D. Merry.It pd_unit
11764ae346bSKenneth D. Merry.Tn PCI
11864ae346bSKenneth D. Merrydevice driver unit number.
11964ae346bSKenneth D. Merry.It pc_vendor
12064ae346bSKenneth D. Merry.Tn PCI
12164ae346bSKenneth D. Merryvendor ID.
12264ae346bSKenneth D. Merry.It pc_device
12364ae346bSKenneth D. Merry.Tn PCI
12464ae346bSKenneth D. Merrydevice ID.
12564ae346bSKenneth D. Merry.It pc_class
12664ae346bSKenneth D. Merry.Tn PCI
12764ae346bSKenneth D. Merrydevice class.
12864ae346bSKenneth D. Merry.It flags
12964ae346bSKenneth D. MerryThe flags describe which of the fields the kernel should match against.
130b5e7e999SRuslan ErmilovA device must match all specified fields in order to be returned.
131b5e7e999SRuslan ErmilovThe match flags are enumerated in the
13264ae346bSKenneth D. Merry.Va pci_getconf_flags
13364ae346bSKenneth D. Merrystructure.
1340227791bSRuslan ErmilovHopefully the flag values are obvious enough that they do not need to
13564ae346bSKenneth D. Merrydescribed in detail.
13664ae346bSKenneth D. Merry.El
13764ae346bSKenneth D. Merry.It match_buf_len
13864ae346bSKenneth D. MerryLength of the
13964ae346bSKenneth D. Merry.Va matches
14064ae346bSKenneth D. Merrybuffer allocated by the user to hold the results of the
14164ae346bSKenneth D. Merry.Dv PCIOCGETCONF
14264ae346bSKenneth D. Merryquery.
14364ae346bSKenneth D. Merry.It num_matches
14464ae346bSKenneth D. MerryNumber of matches returned by the kernel.
14564ae346bSKenneth D. Merry.It matches
146b5e7e999SRuslan ErmilovBuffer containing matching devices returned by the kernel.
147b5e7e999SRuslan ErmilovThe items in this buffer are of type
14864ae346bSKenneth D. Merry.Va pci_conf ,
14964ae346bSKenneth D. Merrywhich consists of the following items:
15064ae346bSKenneth D. Merry.Bl -tag -width pc_subvendor
15164ae346bSKenneth D. Merry.It pc_sel
15264ae346bSKenneth D. Merry.Tn PCI
15355aaf894SMarius Strobldomain, bus, slot and function.
15464ae346bSKenneth D. Merry.It pc_hdr
15564ae346bSKenneth D. Merry.Tn PCI
15664ae346bSKenneth D. Merryheader type.
15764ae346bSKenneth D. Merry.It pc_subvendor
15864ae346bSKenneth D. Merry.Tn PCI
15964ae346bSKenneth D. Merrysubvendor ID.
16064ae346bSKenneth D. Merry.It pc_subdevice
16164ae346bSKenneth D. Merry.Tn PCI
16264ae346bSKenneth D. Merrysubdevice ID.
16364ae346bSKenneth D. Merry.It pc_vendor
16464ae346bSKenneth D. Merry.Tn PCI
16564ae346bSKenneth D. Merryvendor ID.
16664ae346bSKenneth D. Merry.It pc_device
16764ae346bSKenneth D. Merry.Tn PCI
16864ae346bSKenneth D. Merrydevice ID.
16964ae346bSKenneth D. Merry.It pc_class
17064ae346bSKenneth D. Merry.Tn PCI
17164ae346bSKenneth D. Merrydevice class.
17264ae346bSKenneth D. Merry.It pc_subclass
17364ae346bSKenneth D. Merry.Tn PCI
17464ae346bSKenneth D. Merrydevice subclass.
17564ae346bSKenneth D. Merry.It pc_progif
17664ae346bSKenneth D. Merry.Tn PCI
17764ae346bSKenneth D. Merrydevice programming interface.
17864ae346bSKenneth D. Merry.It pc_revid
17964ae346bSKenneth D. Merry.Tn PCI
18064ae346bSKenneth D. Merryrevision ID.
18164ae346bSKenneth D. Merry.It pd_name
18264ae346bSKenneth D. MerryDriver name.
18364ae346bSKenneth D. Merry.It pd_unit
18464ae346bSKenneth D. MerryDriver unit number.
18564ae346bSKenneth D. Merry.El
18664ae346bSKenneth D. Merry.It offset
18764ae346bSKenneth D. MerryThe offset is passed in by the user to tell the kernel where it should
188b5e7e999SRuslan Ermilovstart traversing the device list.
189b5e7e999SRuslan ErmilovThe value passed out by the kernel
190b5e7e999SRuslan Ermilovpoints to the record immediately after the last one returned.
191b5e7e999SRuslan ErmilovThe user may
19264ae346bSKenneth D. Merrypass the value returned by the kernel in subsequent calls to the
19364ae346bSKenneth D. Merry.Dv PCIOCGETCONF
194b5e7e999SRuslan Ermilovioctl.
195b5e7e999SRuslan ErmilovIf the user does not intend to use the offset, it must be set to zero.
19664ae346bSKenneth D. Merry.It generation
19764ae346bSKenneth D. Merry.Tn PCI
198b5e7e999SRuslan Ermilovconfiguration generation.
199b5e7e999SRuslan ErmilovThis value only needs to be set if the offset is set.
200b5e7e999SRuslan ErmilovThe kernel will compare the current generation number of its internal
20164ae346bSKenneth D. Merrydevice list to the generation passed in by the user to determine whether
20264ae346bSKenneth D. Merryits device list has changed since the user last called the
20364ae346bSKenneth D. Merry.Dv PCIOCGETCONF
204b5e7e999SRuslan Ermilovioctl.
205b5e7e999SRuslan ErmilovIf the device list has changed, a status of
20664ae346bSKenneth D. Merry.Va PCI_GETCONF_LIST_CHANGED
20764ae346bSKenneth D. Merrywill be passed back.
20864ae346bSKenneth D. Merry.It status
20964ae346bSKenneth D. MerryThe status tells the user the disposition of his request for a device list.
21064ae346bSKenneth D. MerryThe possible status values are:
21164ae346bSKenneth D. Merry.Bl -ohang
21264ae346bSKenneth D. Merry.It PCI_GETCONF_LAST_DEVICE
21364ae346bSKenneth D. MerryThis means that there are no more devices in the PCI device list after the
21464ae346bSKenneth D. Merryones returned in the
21564ae346bSKenneth D. Merry.Va matches
21664ae346bSKenneth D. Merrybuffer.
21764ae346bSKenneth D. Merry.It PCI_GETCONF_LIST_CHANGED
21864ae346bSKenneth D. MerryThis status tells the user that the
21964ae346bSKenneth D. Merry.Tn PCI
22064ae346bSKenneth D. Merrydevice list has changed since his last call to the
22164ae346bSKenneth D. Merry.Dv PCIOCGETCONF
22264ae346bSKenneth D. Merryioctl and he must reset the
22364ae346bSKenneth D. Merry.Va offset
22464ae346bSKenneth D. Merryand
22564ae346bSKenneth D. Merry.Va generation
22664ae346bSKenneth D. Merryto zero to start over at the beginning of the list.
22764ae346bSKenneth D. Merry.It PCI_GETCONF_MORE_DEVS
22864ae346bSKenneth D. MerryThis tells the user that his buffer was not large enough to hold all of the
229b5e7e999SRuslan Ermilovremaining devices in the device list that possibly match his criteria.
230b5e7e999SRuslan ErmilovIt is possible for this status to be returned, even when none of the remaining
23164ae346bSKenneth D. Merrydevices in the list would match the user's criteria.
23264ae346bSKenneth D. Merry.It PCI_GETCONF_ERROR
233b5e7e999SRuslan ErmilovThis indicates a general error while servicing the user's request.
234b5e7e999SRuslan ErmilovIf the
23507e3ed79SJohn-Mark Gurney.Va pat_buf_len
23607e3ed79SJohn-Mark Gurneyis not equal to
23707e3ed79SJohn-Mark Gurney.Va num_patterns
23807e3ed79SJohn-Mark Gurneytimes
239b5e7e999SRuslan Ermilov.Fn sizeof "struct pci_match_conf" ,
240b5e7e999SRuslan Ermilov.Va errno
241b5e7e999SRuslan Ermilovwill be set to
242b5e7e999SRuslan Ermilov.Er EINVAL .
24364ae346bSKenneth D. Merry.El
24464ae346bSKenneth D. Merry.El
24564ae346bSKenneth D. Merry.It PCIOCREAD
24664ae346bSKenneth D. MerryThis
24764ae346bSKenneth D. Merry.Xr ioctl 2
24864ae346bSKenneth D. Merryreads the
24964ae346bSKenneth D. Merry.Tn PCI
25064ae346bSKenneth D. Merryconfiguration registers specified by the passed-in
25164ae346bSKenneth D. Merry.Va pci_io
2525203edcdSRuslan Ermilovstructure.
2535203edcdSRuslan ErmilovThe
25464ae346bSKenneth D. Merry.Va pci_io
25564ae346bSKenneth D. Merrystructure consists of the following fields:
25664ae346bSKenneth D. Merry.Bl -tag -width pi_width
25764ae346bSKenneth D. Merry.It pi_sel
25864ae346bSKenneth D. MerryA
25964ae346bSKenneth D. Merry.Va pcisel
26055aaf894SMarius Stroblstructure which specifies the domain, bus, slot and function the user would
26155aaf894SMarius Strobllike to query.
26255aaf894SMarius StroblIf the specific bus is not found, errno will be set to ENODEV and -1 returned
26355aaf894SMarius Stroblfrom the ioctl.
26464ae346bSKenneth D. Merry.It pi_reg
26564ae346bSKenneth D. MerryThe
26664ae346bSKenneth D. Merry.Tn PCI
26764ae346bSKenneth D. Merryconfiguration register the user would like to access.
26864ae346bSKenneth D. Merry.It pi_width
269b5e7e999SRuslan ErmilovThe width, in bytes, of the data the user would like to read.
270b5e7e999SRuslan ErmilovThis value
2715203edcdSRuslan Ermilovmay be either 1, 2, or 4.
2725203edcdSRuslan Ermilov3-byte reads and reads larger than 4 bytes are
2735203edcdSRuslan Ermilovnot supported.
2745203edcdSRuslan ErmilovIf an invalid width is passed, errno will be set to EINVAL.
27564ae346bSKenneth D. Merry.It pi_data
27664ae346bSKenneth D. MerryThe data returned by the kernel.
27764ae346bSKenneth D. Merry.El
27864ae346bSKenneth D. Merry.It PCIOCWRITE
27964ae346bSKenneth D. MerryThis
28064ae346bSKenneth D. Merry.Xr ioctl 2
28164ae346bSKenneth D. Merryallows users to write to the
28264ae346bSKenneth D. Merry.Tn PCI
28364ae346bSKenneth D. Merryspecified in the passed-in
28464ae346bSKenneth D. Merry.Va pci_io
2855203edcdSRuslan Ermilovstructure.
2865203edcdSRuslan ErmilovThe
28764ae346bSKenneth D. Merry.Va pci_io
288b5e7e999SRuslan Ermilovstructure is described above.
289b5e7e999SRuslan ErmilovThe limitations on data width described for
29064ae346bSKenneth D. Merryreading registers, above, also apply to writing
29164ae346bSKenneth D. Merry.Tn PCI
29264ae346bSKenneth D. Merryconfiguration registers.
29364ae346bSKenneth D. Merry.El
29464ae346bSKenneth D. Merry.Sh FILES
2953136363fSRuslan Ermilov.Bl -tag -width /dev/pci -compact
29664ae346bSKenneth D. Merry.It Pa /dev/pci
29764ae346bSKenneth D. MerryCharacter device for the
2984b66483fSRuslan Ermilov.Nm
29964ae346bSKenneth D. Merrydriver.
30064ae346bSKenneth D. Merry.El
30164ae346bSKenneth D. Merry.Sh SEE ALSO
30264ae346bSKenneth D. Merry.Xr pciconf 8
30364ae346bSKenneth D. Merry.Sh HISTORY
30464ae346bSKenneth D. MerryThe
3054b66483fSRuslan Ermilov.Nm
30664ae346bSKenneth D. Merrydriver (not the kernel's
30764ae346bSKenneth D. Merry.Tn PCI
30864ae346bSKenneth D. Merrysupport code) first appeared in
30964ae346bSKenneth D. Merry.Fx 2.2 ,
31064ae346bSKenneth D. Merryand was written by Stefan Esser and Garrett Wollman.
31164ae346bSKenneth D. MerrySupport for device listing and matching was re-implemented by
31264ae346bSKenneth D. MerryKenneth Merry, and first appeared in
31364ae346bSKenneth D. Merry.Fx 3.0 .
31464ae346bSKenneth D. Merry.Sh AUTHORS
315c5e7e03aSRuslan Ermilov.An Kenneth Merry Aq ken@FreeBSD.org
31664ae346bSKenneth D. Merry.Sh BUGS
3170227791bSRuslan ErmilovIt is not possible for users to specify an accurate offset into the device
31864ae346bSKenneth D. Merrylist without calling the
31964ae346bSKenneth D. Merry.Dv PCIOCGETCONF
32064ae346bSKenneth D. Merryat least once, since they have no way of knowing the current generation
321b5e7e999SRuslan Ermilovnumber otherwise.
3220227791bSRuslan ErmilovThis probably is not a serious problem, though, since
32364ae346bSKenneth D. Merryusers can easily narrow their search by specifying a pattern or patterns
32464ae346bSKenneth D. Merryfor the kernel to match against.
325