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.\" 2764ae346bSKenneth D. Merry.Dd October 24, 1999 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 4064ae346bSKenneth D. Merryconfiguration registers. It also provides a way for userland programs to 4164ae346bSKenneth D. Merryget 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 5464ae346bSKenneth D. Merrydevice. If used improperly, this driver can allow userland applications to 5564ae346bSKenneth D. Merrycrash a machine or cause data loss. 5664ae346bSKenneth D. Merry.Sh KERNEL CONFIGURATION 5764ae346bSKenneth D. MerryIt is only necessary to specify one 584b66483fSRuslan Ermilov.Nm 5964ae346bSKenneth D. Merrycontroller in the kernel. Additional 6064ae346bSKenneth D. Merry.Tn PCI 6164ae346bSKenneth D. Merrybusses are handled automatically as they are encountered. 6264ae346bSKenneth D. Merry.Sh IOCTLS 6364ae346bSKenneth D. MerryThe following 6464ae346bSKenneth D. Merry.Xr ioctl 2 6564ae346bSKenneth D. Merrycalls are supported by the 664b66483fSRuslan Ermilov.Nm 6764ae346bSKenneth D. Merrydriver. They are defined in the header file 6864ae346bSKenneth D. Merry.Aq Pa sys/pciio.h . 6964ae346bSKenneth D. Merry.Bl -tag -width 012345678901234 7064ae346bSKenneth D. Merry.Pp 7164ae346bSKenneth D. Merry.It PCIOCGETCONF 7264ae346bSKenneth D. MerryThis 7364ae346bSKenneth D. Merry.Xr ioctl 2 7464ae346bSKenneth D. Merrytakes a 7564ae346bSKenneth D. Merry.Va pci_conf_io 7664ae346bSKenneth D. Merrystructure. It allows the user to retrieve information on all 7764ae346bSKenneth D. Merry.Tn PCI 7864ae346bSKenneth D. Merrydevices in the system, or on 7964ae346bSKenneth D. Merry.Tn PCI 8007e3ed79SJohn-Mark Gurneydevices matching patterns supplied by the user. The call may set 8107e3ed79SJohn-Mark Gurney.Va errno 8207e3ed79SJohn-Mark Gurneyto any value specified in either 8307e3ed79SJohn-Mark Gurney.Xr copyin 9 8407e3ed79SJohn-Mark Gurneyor 8507e3ed79SJohn-Mark Gurney.Xr copyout 9 . 8664ae346bSKenneth D. MerryThe 8764ae346bSKenneth D. Merry.Va pci_conf_io 8864ae346bSKenneth D. Merrystructure consists of a number of fields: 8964ae346bSKenneth D. Merry.Bl -tag -width match_buf_len 9064ae346bSKenneth D. Merry.It pat_buf_len 9164ae346bSKenneth D. MerryThe length, in bytes, of the buffer filled with user-supplied patterns. 9264ae346bSKenneth D. Merry.It num_patterns 9364ae346bSKenneth D. MerryThe number of user-supplied patterns. 9464ae346bSKenneth D. Merry.It patterns 9564ae346bSKenneth D. MerryPointer to a buffer filled with user-supplied patterns. 9664ae346bSKenneth D. Merry.Va patterns 9764ae346bSKenneth D. Merryis a pointer to 9864ae346bSKenneth D. Merry.Va num_patterns 9964ae346bSKenneth D. Merry.Va pci_match_conf 10064ae346bSKenneth D. Merrystructures. The 10164ae346bSKenneth D. Merry.Va pci_match_conf 10264ae346bSKenneth D. Merrystructure consists of the following elements: 10364ae346bSKenneth D. Merry.Bl -tag -width pd_vendor 10464ae346bSKenneth D. Merry.It pc_sel 10564ae346bSKenneth D. Merry.Tn PCI 10664ae346bSKenneth D. Merrybus, slot and function. 10764ae346bSKenneth D. Merry.It pd_name 10864ae346bSKenneth D. Merry.Tn PCI 10964ae346bSKenneth D. Merrydevice driver name. 11064ae346bSKenneth D. Merry.It pd_unit 11164ae346bSKenneth D. Merry.Tn PCI 11264ae346bSKenneth D. Merrydevice driver unit number. 11364ae346bSKenneth D. Merry.It pc_vendor 11464ae346bSKenneth D. Merry.Tn PCI 11564ae346bSKenneth D. Merryvendor ID. 11664ae346bSKenneth D. Merry.It pc_device 11764ae346bSKenneth D. Merry.Tn PCI 11864ae346bSKenneth D. Merrydevice ID. 11964ae346bSKenneth D. Merry.It pc_class 12064ae346bSKenneth D. Merry.Tn PCI 12164ae346bSKenneth D. Merrydevice class. 12264ae346bSKenneth D. Merry.It flags 12364ae346bSKenneth D. MerryThe flags describe which of the fields the kernel should match against. 12464ae346bSKenneth D. MerryA device must match all specified fields in order to be returned. The 12564ae346bSKenneth D. Merrymatch flags are enumerated in the 12664ae346bSKenneth D. Merry.Va pci_getconf_flags 12764ae346bSKenneth D. Merrystructure. 12864ae346bSKenneth D. MerryHopefully the flag values are obvious enough that they don't need to 12964ae346bSKenneth D. Merrydescribed in detail. 13064ae346bSKenneth D. Merry.El 13164ae346bSKenneth D. Merry.It match_buf_len 13264ae346bSKenneth D. MerryLength of the 13364ae346bSKenneth D. Merry.Va matches 13464ae346bSKenneth D. Merrybuffer allocated by the user to hold the results of the 13564ae346bSKenneth D. Merry.Dv PCIOCGETCONF 13664ae346bSKenneth D. Merryquery. 13764ae346bSKenneth D. Merry.It num_matches 13864ae346bSKenneth D. MerryNumber of matches returned by the kernel. 13964ae346bSKenneth D. Merry.It matches 14064ae346bSKenneth D. MerryBuffer containing matching devices returned by the kernel. The items in 14164ae346bSKenneth D. Merrythis buffer are of type 14264ae346bSKenneth D. Merry.Va pci_conf , 14364ae346bSKenneth D. Merrywhich consists of the following items: 14464ae346bSKenneth D. Merry.Bl -tag -width pc_subvendor 14564ae346bSKenneth D. Merry.It pc_sel 14664ae346bSKenneth D. Merry.Tn PCI 14764ae346bSKenneth D. Merrybus, slot and function. 14864ae346bSKenneth D. Merry.It pc_hdr 14964ae346bSKenneth D. Merry.Tn PCI 15064ae346bSKenneth D. Merryheader type. 15164ae346bSKenneth D. Merry.It pc_subvendor 15264ae346bSKenneth D. Merry.Tn PCI 15364ae346bSKenneth D. Merrysubvendor ID. 15464ae346bSKenneth D. Merry.It pc_subdevice 15564ae346bSKenneth D. Merry.Tn PCI 15664ae346bSKenneth D. Merrysubdevice ID. 15764ae346bSKenneth D. Merry.It pc_vendor 15864ae346bSKenneth D. Merry.Tn PCI 15964ae346bSKenneth D. Merryvendor ID. 16064ae346bSKenneth D. Merry.It pc_device 16164ae346bSKenneth D. Merry.Tn PCI 16264ae346bSKenneth D. Merrydevice ID. 16364ae346bSKenneth D. Merry.It pc_class 16464ae346bSKenneth D. Merry.Tn PCI 16564ae346bSKenneth D. Merrydevice class. 16664ae346bSKenneth D. Merry.It pc_subclass 16764ae346bSKenneth D. Merry.Tn PCI 16864ae346bSKenneth D. Merrydevice subclass. 16964ae346bSKenneth D. Merry.It pc_progif 17064ae346bSKenneth D. Merry.Tn PCI 17164ae346bSKenneth D. Merrydevice programming interface. 17264ae346bSKenneth D. Merry.It pc_revid 17364ae346bSKenneth D. Merry.Tn PCI 17464ae346bSKenneth D. Merryrevision ID. 17564ae346bSKenneth D. Merry.It pd_name 17664ae346bSKenneth D. MerryDriver name. 17764ae346bSKenneth D. Merry.It pd_unit 17864ae346bSKenneth D. MerryDriver unit number. 17964ae346bSKenneth D. Merry.El 18064ae346bSKenneth D. Merry.It offset 18164ae346bSKenneth D. MerryThe offset is passed in by the user to tell the kernel where it should 18264ae346bSKenneth D. Merrystart traversing the device list. The value passed out by the kernel 18364ae346bSKenneth D. Merrypoints to the record immediately after the last one returned. The user may 18464ae346bSKenneth D. Merrypass the value returned by the kernel in subsequent calls to the 18564ae346bSKenneth D. Merry.Dv PCIOCGETCONF 18664ae346bSKenneth D. Merryioctl. If the user does not intend to use the offset, it must be set to 18764ae346bSKenneth D. Merryzero. 18864ae346bSKenneth D. Merry.It generation 18964ae346bSKenneth D. Merry.Tn PCI 19064ae346bSKenneth D. Merryconfiguration generation. This value only needs to be set if the offset is 19164ae346bSKenneth D. Merryset. The kernel will compare the current generation number of its internal 19264ae346bSKenneth D. Merrydevice list to the generation passed in by the user to determine whether 19364ae346bSKenneth D. Merryits device list has changed since the user last called the 19464ae346bSKenneth D. Merry.Dv PCIOCGETCONF 19564ae346bSKenneth D. Merryioctl. If the device list has changed, a status of 19664ae346bSKenneth D. Merry.Va PCI_GETCONF_LIST_CHANGED 19764ae346bSKenneth D. Merrywill be passed back. 19864ae346bSKenneth D. Merry.It status 19964ae346bSKenneth D. MerryThe status tells the user the disposition of his request for a device list. 20064ae346bSKenneth D. MerryThe possible status values are: 20164ae346bSKenneth D. Merry.Bl -ohang 20264ae346bSKenneth D. Merry.It PCI_GETCONF_LAST_DEVICE 20364ae346bSKenneth D. MerryThis means that there are no more devices in the PCI device list after the 20464ae346bSKenneth D. Merryones returned in the 20564ae346bSKenneth D. Merry.Va matches 20664ae346bSKenneth D. Merrybuffer. 20764ae346bSKenneth D. Merry.It PCI_GETCONF_LIST_CHANGED 20864ae346bSKenneth D. MerryThis status tells the user that the 20964ae346bSKenneth D. Merry.Tn PCI 21064ae346bSKenneth D. Merrydevice list has changed since his last call to the 21164ae346bSKenneth D. Merry.Dv PCIOCGETCONF 21264ae346bSKenneth D. Merryioctl and he must reset the 21364ae346bSKenneth D. Merry.Va offset 21464ae346bSKenneth D. Merryand 21564ae346bSKenneth D. Merry.Va generation 21664ae346bSKenneth D. Merryto zero to start over at the beginning of the list. 21764ae346bSKenneth D. Merry.It PCI_GETCONF_MORE_DEVS 21864ae346bSKenneth D. MerryThis tells the user that his buffer was not large enough to hold all of the 21964ae346bSKenneth D. Merryremaining devices in the device list that possibly match his criteria. It 22064ae346bSKenneth D. Merryis possible for this status to be returned, even when none of the remaining 22164ae346bSKenneth D. Merrydevices in the list would match the user's criteria. 22264ae346bSKenneth D. Merry.It PCI_GETCONF_ERROR 22307e3ed79SJohn-Mark GurneyThis indicates a general error while servicing the user's request. If the 22407e3ed79SJohn-Mark Gurney.Va pat_buf_len 22507e3ed79SJohn-Mark Gurneyis not equal to 22607e3ed79SJohn-Mark Gurney.Va num_patterns 22707e3ed79SJohn-Mark Gurneytimes 22807e3ed79SJohn-Mark Gurney.Va sizeof(struct pci_match_conf) , errno 22907e3ed79SJohn-Mark Gurneywill be set to EINVAL. 23064ae346bSKenneth D. Merry.El 23164ae346bSKenneth D. Merry.El 23264ae346bSKenneth D. Merry.It PCIOCREAD 23364ae346bSKenneth D. MerryThis 23464ae346bSKenneth D. Merry.Xr ioctl 2 23564ae346bSKenneth D. Merryreads the 23664ae346bSKenneth D. Merry.Tn PCI 23764ae346bSKenneth D. Merryconfiguration registers specified by the passed-in 23864ae346bSKenneth D. Merry.Va pci_io 23964ae346bSKenneth D. Merrystructure. The 24064ae346bSKenneth D. Merry.Va pci_io 24164ae346bSKenneth D. Merrystructure consists of the following fields: 24264ae346bSKenneth D. Merry.Bl -tag -width pi_width 24364ae346bSKenneth D. Merry.It pi_sel 24464ae346bSKenneth D. MerryA 24564ae346bSKenneth D. Merry.Va pcisel 24664ae346bSKenneth D. Merrystructure which specifies the bus, slot and function the user would like to 24707e3ed79SJohn-Mark Gurneyquery. If the specific bus is not found, errno will be set to ENODEV and -1 returned from the ioctl. 24864ae346bSKenneth D. Merry.It pi_reg 24964ae346bSKenneth D. MerryThe 25064ae346bSKenneth D. Merry.Tn PCI 25164ae346bSKenneth D. Merryconfiguration register the user would like to access. 25264ae346bSKenneth D. Merry.It pi_width 25364ae346bSKenneth D. MerryThe width, in bytes, of the data the user would like to read. This value 25464ae346bSKenneth D. Merrymay be either 1, 2, or 4. 3-byte reads and reads larger than 4 bytes are 25507e3ed79SJohn-Mark Gurneynot supported. If an invalid width is passed, errno will be set to EINVAL. 25664ae346bSKenneth D. Merry.It pi_data 25764ae346bSKenneth D. MerryThe data returned by the kernel. 25864ae346bSKenneth D. Merry.El 25964ae346bSKenneth D. Merry.It PCIOCWRITE 26064ae346bSKenneth D. MerryThis 26164ae346bSKenneth D. Merry.Xr ioctl 2 26264ae346bSKenneth D. Merryallows users to write to the 26364ae346bSKenneth D. Merry.Tn PCI 26464ae346bSKenneth D. Merryspecified in the passed-in 26564ae346bSKenneth D. Merry.Va pci_io 26664ae346bSKenneth D. Merrystructure. The 26764ae346bSKenneth D. Merry.Va pci_io 26864ae346bSKenneth D. Merrystructure is described above. The limitations on data width described for 26964ae346bSKenneth D. Merryreading registers, above, also apply to writing 27064ae346bSKenneth D. Merry.Tn PCI 27164ae346bSKenneth D. Merryconfiguration registers. 27264ae346bSKenneth D. Merry.El 27364ae346bSKenneth D. Merry.Sh FILES 2743136363fSRuslan Ermilov.Bl -tag -width /dev/pci -compact 27564ae346bSKenneth D. Merry.It Pa /dev/pci 27664ae346bSKenneth D. MerryCharacter device for the 2774b66483fSRuslan Ermilov.Nm 27864ae346bSKenneth D. Merrydriver. 27964ae346bSKenneth D. Merry.El 28064ae346bSKenneth D. Merry.Sh DIAGNOSTICS 28164ae346bSKenneth D. MerryNone. 28264ae346bSKenneth D. Merry.Sh SEE ALSO 28364ae346bSKenneth D. Merry.Xr pciconf 8 28464ae346bSKenneth D. Merry.Sh HISTORY 28564ae346bSKenneth D. MerryThe 2864b66483fSRuslan Ermilov.Nm 28764ae346bSKenneth D. Merrydriver (not the kernel's 28864ae346bSKenneth D. Merry.Tn PCI 28964ae346bSKenneth D. Merrysupport code) first appeared in 29064ae346bSKenneth D. Merry.Fx 2.2 , 29164ae346bSKenneth D. Merryand was written by Stefan Esser and Garrett Wollman. 29264ae346bSKenneth D. MerrySupport for device listing and matching was re-implemented by 29364ae346bSKenneth D. MerryKenneth Merry, and first appeared in 29464ae346bSKenneth D. Merry.Fx 3.0 . 29564ae346bSKenneth D. Merry.Sh AUTHORS 296c5e7e03aSRuslan Ermilov.An Kenneth Merry Aq ken@FreeBSD.org 29764ae346bSKenneth D. Merry.Sh BUGS 29864ae346bSKenneth D. MerryIt isn't possible for users to specify an accurate offset into the device 29964ae346bSKenneth D. Merrylist without calling the 30064ae346bSKenneth D. Merry.Dv PCIOCGETCONF 30164ae346bSKenneth D. Merryat least once, since they have no way of knowing the current generation 30264ae346bSKenneth D. Merrynumber otherwise. This probably isn't a serious problem, though, since 30364ae346bSKenneth D. Merryusers can easily narrow their search by specifying a pattern or patterns 30464ae346bSKenneth D. Merryfor the kernel to match against. 305