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 29ed403116SRuslan Ermilov.Os FreeBSD 3064ae346bSKenneth D. Merry.Sh NAME 3164ae346bSKenneth D. Merry.Nm pci 3264ae346bSKenneth D. Merry.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 8064ae346bSKenneth D. Merrydevices matching patterns supplied by the user. 8164ae346bSKenneth D. MerryThe 8264ae346bSKenneth D. Merry.Va pci_conf_io 8364ae346bSKenneth D. Merrystructure consists of a number of fields: 8464ae346bSKenneth D. Merry.Bl -tag -width match_buf_len 8564ae346bSKenneth D. Merry.It pat_buf_len 8664ae346bSKenneth D. MerryThe length, in bytes, of the buffer filled with user-supplied patterns. 8764ae346bSKenneth D. Merry.It num_patterns 8864ae346bSKenneth D. MerryThe number of user-supplied patterns. 8964ae346bSKenneth D. Merry.It patterns 9064ae346bSKenneth D. MerryPointer to a buffer filled with user-supplied patterns. 9164ae346bSKenneth D. Merry.Va patterns 9264ae346bSKenneth D. Merryis a pointer to 9364ae346bSKenneth D. Merry.Va num_patterns 9464ae346bSKenneth D. Merry.Va pci_match_conf 9564ae346bSKenneth D. Merrystructures. The 9664ae346bSKenneth D. Merry.Va pci_match_conf 9764ae346bSKenneth D. Merrystructure consists of the following elements: 9864ae346bSKenneth D. Merry.Bl -tag -width pd_vendor 9964ae346bSKenneth D. Merry.It pc_sel 10064ae346bSKenneth D. Merry.Tn PCI 10164ae346bSKenneth D. Merrybus, slot and function. 10264ae346bSKenneth D. Merry.It pd_name 10364ae346bSKenneth D. Merry.Tn PCI 10464ae346bSKenneth D. Merrydevice driver name. 10564ae346bSKenneth D. Merry.It pd_unit 10664ae346bSKenneth D. Merry.Tn PCI 10764ae346bSKenneth D. Merrydevice driver unit number. 10864ae346bSKenneth D. Merry.It pc_vendor 10964ae346bSKenneth D. Merry.Tn PCI 11064ae346bSKenneth D. Merryvendor ID. 11164ae346bSKenneth D. Merry.It pc_device 11264ae346bSKenneth D. Merry.Tn PCI 11364ae346bSKenneth D. Merrydevice ID. 11464ae346bSKenneth D. Merry.It pc_class 11564ae346bSKenneth D. Merry.Tn PCI 11664ae346bSKenneth D. Merrydevice class. 11764ae346bSKenneth D. Merry.It flags 11864ae346bSKenneth D. MerryThe flags describe which of the fields the kernel should match against. 11964ae346bSKenneth D. MerryA device must match all specified fields in order to be returned. The 12064ae346bSKenneth D. Merrymatch flags are enumerated in the 12164ae346bSKenneth D. Merry.Va pci_getconf_flags 12264ae346bSKenneth D. Merrystructure. 12364ae346bSKenneth D. MerryHopefully the flag values are obvious enough that they don't need to 12464ae346bSKenneth D. Merrydescribed in detail. 12564ae346bSKenneth D. Merry.El 12664ae346bSKenneth D. Merry.It match_buf_len 12764ae346bSKenneth D. MerryLength of the 12864ae346bSKenneth D. Merry.Va matches 12964ae346bSKenneth D. Merrybuffer allocated by the user to hold the results of the 13064ae346bSKenneth D. Merry.Dv PCIOCGETCONF 13164ae346bSKenneth D. Merryquery. 13264ae346bSKenneth D. Merry.It num_matches 13364ae346bSKenneth D. MerryNumber of matches returned by the kernel. 13464ae346bSKenneth D. Merry.It matches 13564ae346bSKenneth D. MerryBuffer containing matching devices returned by the kernel. The items in 13664ae346bSKenneth D. Merrythis buffer are of type 13764ae346bSKenneth D. Merry.Va pci_conf , 13864ae346bSKenneth D. Merrywhich consists of the following items: 13964ae346bSKenneth D. Merry.Bl -tag -width pc_subvendor 14064ae346bSKenneth D. Merry.It pc_sel 14164ae346bSKenneth D. Merry.Tn PCI 14264ae346bSKenneth D. Merrybus, slot and function. 14364ae346bSKenneth D. Merry.It pc_hdr 14464ae346bSKenneth D. Merry.Tn PCI 14564ae346bSKenneth D. Merryheader type. 14664ae346bSKenneth D. Merry.It pc_subvendor 14764ae346bSKenneth D. Merry.Tn PCI 14864ae346bSKenneth D. Merrysubvendor ID. 14964ae346bSKenneth D. Merry.It pc_subdevice 15064ae346bSKenneth D. Merry.Tn PCI 15164ae346bSKenneth D. Merrysubdevice ID. 15264ae346bSKenneth D. Merry.It pc_vendor 15364ae346bSKenneth D. Merry.Tn PCI 15464ae346bSKenneth D. Merryvendor ID. 15564ae346bSKenneth D. Merry.It pc_device 15664ae346bSKenneth D. Merry.Tn PCI 15764ae346bSKenneth D. Merrydevice ID. 15864ae346bSKenneth D. Merry.It pc_class 15964ae346bSKenneth D. Merry.Tn PCI 16064ae346bSKenneth D. Merrydevice class. 16164ae346bSKenneth D. Merry.It pc_subclass 16264ae346bSKenneth D. Merry.Tn PCI 16364ae346bSKenneth D. Merrydevice subclass. 16464ae346bSKenneth D. Merry.It pc_progif 16564ae346bSKenneth D. Merry.Tn PCI 16664ae346bSKenneth D. Merrydevice programming interface. 16764ae346bSKenneth D. Merry.It pc_revid 16864ae346bSKenneth D. Merry.Tn PCI 16964ae346bSKenneth D. Merryrevision ID. 17064ae346bSKenneth D. Merry.It pd_name 17164ae346bSKenneth D. MerryDriver name. 17264ae346bSKenneth D. Merry.It pd_unit 17364ae346bSKenneth D. MerryDriver unit number. 17464ae346bSKenneth D. Merry.El 17564ae346bSKenneth D. Merry.It offset 17664ae346bSKenneth D. MerryThe offset is passed in by the user to tell the kernel where it should 17764ae346bSKenneth D. Merrystart traversing the device list. The value passed out by the kernel 17864ae346bSKenneth D. Merrypoints to the record immediately after the last one returned. The user may 17964ae346bSKenneth D. Merrypass the value returned by the kernel in subsequent calls to the 18064ae346bSKenneth D. Merry.Dv PCIOCGETCONF 18164ae346bSKenneth D. Merryioctl. If the user does not intend to use the offset, it must be set to 18264ae346bSKenneth D. Merryzero. 18364ae346bSKenneth D. Merry.It generation 18464ae346bSKenneth D. Merry.Tn PCI 18564ae346bSKenneth D. Merryconfiguration generation. This value only needs to be set if the offset is 18664ae346bSKenneth D. Merryset. The kernel will compare the current generation number of its internal 18764ae346bSKenneth D. Merrydevice list to the generation passed in by the user to determine whether 18864ae346bSKenneth D. Merryits device list has changed since the user last called the 18964ae346bSKenneth D. Merry.Dv PCIOCGETCONF 19064ae346bSKenneth D. Merryioctl. If the device list has changed, a status of 19164ae346bSKenneth D. Merry.Va PCI_GETCONF_LIST_CHANGED 19264ae346bSKenneth D. Merrywill be passed back. 19364ae346bSKenneth D. Merry.It status 19464ae346bSKenneth D. MerryThe status tells the user the disposition of his request for a device list. 19564ae346bSKenneth D. MerryThe possible status values are: 19664ae346bSKenneth D. Merry.Bl -ohang 19764ae346bSKenneth D. Merry.It PCI_GETCONF_LAST_DEVICE 19864ae346bSKenneth D. MerryThis means that there are no more devices in the PCI device list after the 19964ae346bSKenneth D. Merryones returned in the 20064ae346bSKenneth D. Merry.Va matches 20164ae346bSKenneth D. Merrybuffer. 20264ae346bSKenneth D. Merry.It PCI_GETCONF_LIST_CHANGED 20364ae346bSKenneth D. MerryThis status tells the user that the 20464ae346bSKenneth D. Merry.Tn PCI 20564ae346bSKenneth D. Merrydevice list has changed since his last call to the 20664ae346bSKenneth D. Merry.Dv PCIOCGETCONF 20764ae346bSKenneth D. Merryioctl and he must reset the 20864ae346bSKenneth D. Merry.Va offset 20964ae346bSKenneth D. Merryand 21064ae346bSKenneth D. Merry.Va generation 21164ae346bSKenneth D. Merryto zero to start over at the beginning of the list. 21264ae346bSKenneth D. Merry.It PCI_GETCONF_MORE_DEVS 21364ae346bSKenneth D. MerryThis tells the user that his buffer was not large enough to hold all of the 21464ae346bSKenneth D. Merryremaining devices in the device list that possibly match his criteria. It 21564ae346bSKenneth D. Merryis possible for this status to be returned, even when none of the remaining 21664ae346bSKenneth D. Merrydevices in the list would match the user's criteria. 21764ae346bSKenneth D. Merry.It PCI_GETCONF_ERROR 21864ae346bSKenneth D. MerryThis indicates a general error while servicing the user's request. A more 21964ae346bSKenneth D. Merryspecific indication of the problem may or may not be printed in the kernel 22064ae346bSKenneth D. Merrymessage buffer (and by implication, the system console). 22164ae346bSKenneth D. Merry.El 22264ae346bSKenneth D. Merry.El 22364ae346bSKenneth D. Merry.It PCIOCREAD 22464ae346bSKenneth D. MerryThis 22564ae346bSKenneth D. Merry.Xr ioctl 2 22664ae346bSKenneth D. Merryreads the 22764ae346bSKenneth D. Merry.Tn PCI 22864ae346bSKenneth D. Merryconfiguration registers specified by the passed-in 22964ae346bSKenneth D. Merry.Va pci_io 23064ae346bSKenneth D. Merrystructure. The 23164ae346bSKenneth D. Merry.Va pci_io 23264ae346bSKenneth D. Merrystructure consists of the following fields: 23364ae346bSKenneth D. Merry.Bl -tag -width pi_width 23464ae346bSKenneth D. Merry.It pi_sel 23564ae346bSKenneth D. MerryA 23664ae346bSKenneth D. Merry.Va pcisel 23764ae346bSKenneth D. Merrystructure which specifies the bus, slot and function the user would like to 23864ae346bSKenneth D. Merryquery. 23964ae346bSKenneth D. Merry.It pi_reg 24064ae346bSKenneth D. MerryThe 24164ae346bSKenneth D. Merry.Tn PCI 24264ae346bSKenneth D. Merryconfiguration register the user would like to access. 24364ae346bSKenneth D. Merry.It pi_width 24464ae346bSKenneth D. MerryThe width, in bytes, of the data the user would like to read. This value 24564ae346bSKenneth D. Merrymay be either 1, 2, or 4. 3-byte reads and reads larger than 4 bytes are 24664ae346bSKenneth D. Merrynot supported. 24764ae346bSKenneth D. Merry.It pi_data 24864ae346bSKenneth D. MerryThe data returned by the kernel. 24964ae346bSKenneth D. Merry.El 25064ae346bSKenneth D. Merry.It PCIOCWRITE 25164ae346bSKenneth D. MerryThis 25264ae346bSKenneth D. Merry.Xr ioctl 2 25364ae346bSKenneth D. Merryallows users to write to the 25464ae346bSKenneth D. Merry.Tn PCI 25564ae346bSKenneth D. Merryspecified in the passed-in 25664ae346bSKenneth D. Merry.Va pci_io 25764ae346bSKenneth D. Merrystructure. The 25864ae346bSKenneth D. Merry.Va pci_io 25964ae346bSKenneth D. Merrystructure is described above. The limitations on data width described for 26064ae346bSKenneth D. Merryreading registers, above, also apply to writing 26164ae346bSKenneth D. Merry.Tn PCI 26264ae346bSKenneth D. Merryconfiguration registers. 26364ae346bSKenneth D. Merry.El 26464ae346bSKenneth D. Merry.Sh FILES 2653136363fSRuslan Ermilov.Bl -tag -width /dev/pci -compact 26664ae346bSKenneth D. Merry.It Pa /dev/pci 26764ae346bSKenneth D. MerryCharacter device for the 2684b66483fSRuslan Ermilov.Nm 26964ae346bSKenneth D. Merrydriver. 27064ae346bSKenneth D. Merry.El 27164ae346bSKenneth D. Merry.Sh DIAGNOSTICS 27264ae346bSKenneth D. MerryNone. 27364ae346bSKenneth D. Merry.Sh SEE ALSO 27464ae346bSKenneth D. Merry.Xr pciconf 8 27564ae346bSKenneth D. Merry.Sh HISTORY 27664ae346bSKenneth D. MerryThe 2774b66483fSRuslan Ermilov.Nm 27864ae346bSKenneth D. Merrydriver (not the kernel's 27964ae346bSKenneth D. Merry.Tn PCI 28064ae346bSKenneth D. Merrysupport code) first appeared in 28164ae346bSKenneth D. Merry.Fx 2.2 , 28264ae346bSKenneth D. Merryand was written by Stefan Esser and Garrett Wollman. 28364ae346bSKenneth D. MerrySupport for device listing and matching was re-implemented by 28464ae346bSKenneth D. MerryKenneth Merry, and first appeared in 28564ae346bSKenneth D. Merry.Fx 3.0 . 28664ae346bSKenneth D. Merry.Sh AUTHORS 28764ae346bSKenneth D. Merry.An Kenneth Merry Aq ken@FreeBSD.ORG 28864ae346bSKenneth D. Merry.Sh BUGS 28964ae346bSKenneth D. MerryIt isn't possible for users to specify an accurate offset into the device 29064ae346bSKenneth D. Merrylist without calling the 29164ae346bSKenneth D. Merry.Dv PCIOCGETCONF 29264ae346bSKenneth D. Merryat least once, since they have no way of knowing the current generation 29364ae346bSKenneth D. Merrynumber otherwise. This probably isn't a serious problem, though, since 29464ae346bSKenneth D. Merryusers can easily narrow their search by specifying a pattern or patterns 29564ae346bSKenneth D. Merryfor the kernel to match against. 296