1999-12-08 17:44:04 +00:00
|
|
|
.\"
|
|
|
|
.\" Copyright (c) 1999 Kenneth D. Merry.
|
|
|
|
.\" All rights reserved.
|
|
|
|
.\"
|
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
.\" modification, are permitted provided that the following conditions
|
|
|
|
.\" are met:
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
|
|
.\" 2. The name of the author may not be used to endorse or promote products
|
|
|
|
.\" derived from this software without specific prior written permission.
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
.\" SUCH DAMAGE.
|
|
|
|
.\"
|
2005-02-09 18:07:17 +00:00
|
|
|
.\" $FreeBSD$
|
1999-12-08 17:44:04 +00:00
|
|
|
.\"
|
2008-01-04 08:19:52 +00:00
|
|
|
.Dd January 3, 2008
|
1999-12-08 17:44:04 +00:00
|
|
|
.Dt PCI 4
|
2001-07-10 15:31:11 +00:00
|
|
|
.Os
|
1999-12-08 17:44:04 +00:00
|
|
|
.Sh NAME
|
|
|
|
.Nm pci
|
2001-04-18 15:54:10 +00:00
|
|
|
.Nd generic PCI driver
|
2000-11-17 11:44:16 +00:00
|
|
|
.Sh SYNOPSIS
|
2000-01-23 15:04:20 +00:00
|
|
|
.Cd device pci
|
1999-12-08 17:44:04 +00:00
|
|
|
.Sh DESCRIPTION
|
|
|
|
The
|
2000-11-20 18:41:33 +00:00
|
|
|
.Nm
|
1999-12-08 17:44:04 +00:00
|
|
|
driver provides a way for userland programs to read and write
|
|
|
|
.Tn PCI
|
2003-06-28 23:53:39 +00:00
|
|
|
configuration registers.
|
|
|
|
It also provides a way for userland programs to get a list of all
|
1999-12-08 17:44:04 +00:00
|
|
|
.Tn PCI
|
|
|
|
devices, or all
|
|
|
|
.Tn PCI
|
|
|
|
devices that match various patterns.
|
|
|
|
.Pp
|
|
|
|
Since the
|
2000-11-20 18:41:33 +00:00
|
|
|
.Nm
|
1999-12-08 17:44:04 +00:00
|
|
|
driver provides a write interface for
|
|
|
|
.Tn PCI
|
|
|
|
configuration registers, system administrators should exercise caution when
|
|
|
|
granting access to the
|
2000-11-20 18:41:33 +00:00
|
|
|
.Nm
|
2003-06-28 23:53:39 +00:00
|
|
|
device.
|
|
|
|
If used improperly, this driver can allow userland applications to
|
1999-12-08 17:44:04 +00:00
|
|
|
crash a machine or cause data loss.
|
2008-01-04 08:19:52 +00:00
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Nm
|
2008-01-05 23:21:32 +00:00
|
|
|
driver implements the
|
|
|
|
.Tn PCI
|
|
|
|
bus in the kernel.
|
|
|
|
It enumerates any devices on the
|
|
|
|
.Tn PCI
|
|
|
|
bus and gives
|
|
|
|
.Tn PCI
|
|
|
|
client drivers the chance to attach to them.
|
|
|
|
It assigns resources to children, when the BIOS does not.
|
2008-01-04 08:19:52 +00:00
|
|
|
It takes care of routing interrupts when necessary.
|
2008-01-05 23:21:32 +00:00
|
|
|
It reprobes the unattached
|
|
|
|
.Tn PCI
|
|
|
|
children when
|
|
|
|
.Tn PCI
|
|
|
|
client drivers are dynamically
|
2008-01-04 08:19:52 +00:00
|
|
|
loaded at runtime.
|
1999-12-08 17:44:04 +00:00
|
|
|
.Sh KERNEL CONFIGURATION
|
2008-01-04 08:19:52 +00:00
|
|
|
The
|
2000-11-20 18:41:33 +00:00
|
|
|
.Nm
|
2008-01-04 08:19:52 +00:00
|
|
|
device is included in the kernel as described in the SYNOPSIS section.
|
2008-01-05 23:21:32 +00:00
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
driver cannot be built as a
|
|
|
|
.Xr kld 4 .
|
1999-12-08 17:44:04 +00:00
|
|
|
.Sh IOCTLS
|
|
|
|
The following
|
|
|
|
.Xr ioctl 2
|
|
|
|
calls are supported by the
|
2000-11-20 18:41:33 +00:00
|
|
|
.Nm
|
2003-06-28 23:53:39 +00:00
|
|
|
driver.
|
|
|
|
They are defined in the header file
|
2003-09-08 19:57:22 +00:00
|
|
|
.In sys/pciio.h .
|
1999-12-08 17:44:04 +00:00
|
|
|
.Bl -tag -width 012345678901234
|
|
|
|
.Pp
|
|
|
|
.It PCIOCGETCONF
|
|
|
|
This
|
|
|
|
.Xr ioctl 2
|
|
|
|
takes a
|
|
|
|
.Va pci_conf_io
|
2003-06-28 23:53:39 +00:00
|
|
|
structure.
|
|
|
|
It allows the user to retrieve information on all
|
1999-12-08 17:44:04 +00:00
|
|
|
.Tn PCI
|
|
|
|
devices in the system, or on
|
|
|
|
.Tn PCI
|
2004-07-03 18:29:24 +00:00
|
|
|
devices matching patterns supplied by the user.
|
|
|
|
The call may set
|
2003-06-23 02:13:23 +00:00
|
|
|
.Va errno
|
|
|
|
to any value specified in either
|
|
|
|
.Xr copyin 9
|
|
|
|
or
|
|
|
|
.Xr copyout 9 .
|
1999-12-08 17:44:04 +00:00
|
|
|
The
|
|
|
|
.Va pci_conf_io
|
|
|
|
structure consists of a number of fields:
|
|
|
|
.Bl -tag -width match_buf_len
|
|
|
|
.It pat_buf_len
|
|
|
|
The length, in bytes, of the buffer filled with user-supplied patterns.
|
|
|
|
.It num_patterns
|
|
|
|
The number of user-supplied patterns.
|
|
|
|
.It patterns
|
|
|
|
Pointer to a buffer filled with user-supplied patterns.
|
|
|
|
.Va patterns
|
|
|
|
is a pointer to
|
|
|
|
.Va num_patterns
|
|
|
|
.Va pci_match_conf
|
2004-07-03 18:29:24 +00:00
|
|
|
structures.
|
|
|
|
The
|
1999-12-08 17:44:04 +00:00
|
|
|
.Va pci_match_conf
|
|
|
|
structure consists of the following elements:
|
|
|
|
.Bl -tag -width pd_vendor
|
|
|
|
.It pc_sel
|
|
|
|
.Tn PCI
|
2007-09-30 11:05:18 +00:00
|
|
|
domain, bus, slot and function.
|
1999-12-08 17:44:04 +00:00
|
|
|
.It pd_name
|
|
|
|
.Tn PCI
|
|
|
|
device driver name.
|
|
|
|
.It pd_unit
|
|
|
|
.Tn PCI
|
|
|
|
device driver unit number.
|
|
|
|
.It pc_vendor
|
|
|
|
.Tn PCI
|
|
|
|
vendor ID.
|
|
|
|
.It pc_device
|
|
|
|
.Tn PCI
|
|
|
|
device ID.
|
|
|
|
.It pc_class
|
|
|
|
.Tn PCI
|
|
|
|
device class.
|
|
|
|
.It flags
|
|
|
|
The flags describe which of the fields the kernel should match against.
|
2003-06-28 23:53:39 +00:00
|
|
|
A device must match all specified fields in order to be returned.
|
|
|
|
The match flags are enumerated in the
|
2001-07-14 19:41:16 +00:00
|
|
|
.Va pci_getconf_flags
|
1999-12-08 17:44:04 +00:00
|
|
|
structure.
|
2005-02-13 22:25:33 +00:00
|
|
|
Hopefully the flag values are obvious enough that they do not need to
|
1999-12-08 17:44:04 +00:00
|
|
|
described in detail.
|
|
|
|
.El
|
|
|
|
.It match_buf_len
|
|
|
|
Length of the
|
|
|
|
.Va matches
|
|
|
|
buffer allocated by the user to hold the results of the
|
|
|
|
.Dv PCIOCGETCONF
|
|
|
|
query.
|
|
|
|
.It num_matches
|
|
|
|
Number of matches returned by the kernel.
|
|
|
|
.It matches
|
2003-06-28 23:53:39 +00:00
|
|
|
Buffer containing matching devices returned by the kernel.
|
|
|
|
The items in this buffer are of type
|
2001-07-14 19:41:16 +00:00
|
|
|
.Va pci_conf ,
|
1999-12-08 17:44:04 +00:00
|
|
|
which consists of the following items:
|
|
|
|
.Bl -tag -width pc_subvendor
|
|
|
|
.It pc_sel
|
|
|
|
.Tn PCI
|
2007-09-30 11:05:18 +00:00
|
|
|
domain, bus, slot and function.
|
1999-12-08 17:44:04 +00:00
|
|
|
.It pc_hdr
|
|
|
|
.Tn PCI
|
|
|
|
header type.
|
|
|
|
.It pc_subvendor
|
|
|
|
.Tn PCI
|
|
|
|
subvendor ID.
|
|
|
|
.It pc_subdevice
|
|
|
|
.Tn PCI
|
|
|
|
subdevice ID.
|
|
|
|
.It pc_vendor
|
|
|
|
.Tn PCI
|
|
|
|
vendor ID.
|
|
|
|
.It pc_device
|
|
|
|
.Tn PCI
|
|
|
|
device ID.
|
|
|
|
.It pc_class
|
|
|
|
.Tn PCI
|
|
|
|
device class.
|
|
|
|
.It pc_subclass
|
|
|
|
.Tn PCI
|
|
|
|
device subclass.
|
|
|
|
.It pc_progif
|
|
|
|
.Tn PCI
|
|
|
|
device programming interface.
|
|
|
|
.It pc_revid
|
|
|
|
.Tn PCI
|
|
|
|
revision ID.
|
|
|
|
.It pd_name
|
|
|
|
Driver name.
|
|
|
|
.It pd_unit
|
|
|
|
Driver unit number.
|
|
|
|
.El
|
|
|
|
.It offset
|
|
|
|
The offset is passed in by the user to tell the kernel where it should
|
2003-06-28 23:53:39 +00:00
|
|
|
start traversing the device list.
|
|
|
|
The value passed out by the kernel
|
|
|
|
points to the record immediately after the last one returned.
|
|
|
|
The user may
|
1999-12-08 17:44:04 +00:00
|
|
|
pass the value returned by the kernel in subsequent calls to the
|
|
|
|
.Dv PCIOCGETCONF
|
2003-06-28 23:53:39 +00:00
|
|
|
ioctl.
|
|
|
|
If the user does not intend to use the offset, it must be set to zero.
|
1999-12-08 17:44:04 +00:00
|
|
|
.It generation
|
|
|
|
.Tn PCI
|
2003-06-28 23:53:39 +00:00
|
|
|
configuration generation.
|
|
|
|
This value only needs to be set if the offset is set.
|
|
|
|
The kernel will compare the current generation number of its internal
|
1999-12-08 17:44:04 +00:00
|
|
|
device list to the generation passed in by the user to determine whether
|
|
|
|
its device list has changed since the user last called the
|
|
|
|
.Dv PCIOCGETCONF
|
2003-06-28 23:53:39 +00:00
|
|
|
ioctl.
|
|
|
|
If the device list has changed, a status of
|
1999-12-08 17:44:04 +00:00
|
|
|
.Va PCI_GETCONF_LIST_CHANGED
|
|
|
|
will be passed back.
|
|
|
|
.It status
|
|
|
|
The status tells the user the disposition of his request for a device list.
|
|
|
|
The possible status values are:
|
|
|
|
.Bl -ohang
|
|
|
|
.It PCI_GETCONF_LAST_DEVICE
|
|
|
|
This means that there are no more devices in the PCI device list after the
|
|
|
|
ones returned in the
|
|
|
|
.Va matches
|
|
|
|
buffer.
|
|
|
|
.It PCI_GETCONF_LIST_CHANGED
|
|
|
|
This status tells the user that the
|
|
|
|
.Tn PCI
|
2001-07-14 19:41:16 +00:00
|
|
|
device list has changed since his last call to the
|
1999-12-08 17:44:04 +00:00
|
|
|
.Dv PCIOCGETCONF
|
|
|
|
ioctl and he must reset the
|
|
|
|
.Va offset
|
|
|
|
and
|
|
|
|
.Va generation
|
|
|
|
to zero to start over at the beginning of the list.
|
|
|
|
.It PCI_GETCONF_MORE_DEVS
|
|
|
|
This tells the user that his buffer was not large enough to hold all of the
|
2003-06-28 23:53:39 +00:00
|
|
|
remaining devices in the device list that possibly match his criteria.
|
|
|
|
It is possible for this status to be returned, even when none of the remaining
|
1999-12-08 17:44:04 +00:00
|
|
|
devices in the list would match the user's criteria.
|
|
|
|
.It PCI_GETCONF_ERROR
|
2003-06-28 23:53:39 +00:00
|
|
|
This indicates a general error while servicing the user's request.
|
|
|
|
If the
|
2003-06-23 02:13:23 +00:00
|
|
|
.Va pat_buf_len
|
|
|
|
is not equal to
|
|
|
|
.Va num_patterns
|
|
|
|
times
|
2003-06-28 23:53:39 +00:00
|
|
|
.Fn sizeof "struct pci_match_conf" ,
|
|
|
|
.Va errno
|
|
|
|
will be set to
|
|
|
|
.Er EINVAL .
|
1999-12-08 17:44:04 +00:00
|
|
|
.El
|
|
|
|
.El
|
|
|
|
.It PCIOCREAD
|
|
|
|
This
|
|
|
|
.Xr ioctl 2
|
|
|
|
reads the
|
|
|
|
.Tn PCI
|
|
|
|
configuration registers specified by the passed-in
|
|
|
|
.Va pci_io
|
2004-07-03 18:29:24 +00:00
|
|
|
structure.
|
|
|
|
The
|
1999-12-08 17:44:04 +00:00
|
|
|
.Va pci_io
|
|
|
|
structure consists of the following fields:
|
|
|
|
.Bl -tag -width pi_width
|
|
|
|
.It pi_sel
|
|
|
|
A
|
|
|
|
.Va pcisel
|
2007-09-30 11:05:18 +00:00
|
|
|
structure which specifies the domain, bus, slot and function the user would
|
|
|
|
like to query.
|
|
|
|
If the specific bus is not found, errno will be set to ENODEV and -1 returned
|
|
|
|
from the ioctl.
|
1999-12-08 17:44:04 +00:00
|
|
|
.It pi_reg
|
|
|
|
The
|
|
|
|
.Tn PCI
|
|
|
|
configuration register the user would like to access.
|
|
|
|
.It pi_width
|
2003-06-28 23:53:39 +00:00
|
|
|
The width, in bytes, of the data the user would like to read.
|
|
|
|
This value
|
2004-07-03 18:29:24 +00:00
|
|
|
may be either 1, 2, or 4.
|
|
|
|
3-byte reads and reads larger than 4 bytes are
|
|
|
|
not supported.
|
|
|
|
If an invalid width is passed, errno will be set to EINVAL.
|
1999-12-08 17:44:04 +00:00
|
|
|
.It pi_data
|
|
|
|
The data returned by the kernel.
|
|
|
|
.El
|
|
|
|
.It PCIOCWRITE
|
|
|
|
This
|
|
|
|
.Xr ioctl 2
|
|
|
|
allows users to write to the
|
|
|
|
.Tn PCI
|
|
|
|
specified in the passed-in
|
|
|
|
.Va pci_io
|
2004-07-03 18:29:24 +00:00
|
|
|
structure.
|
|
|
|
The
|
1999-12-08 17:44:04 +00:00
|
|
|
.Va pci_io
|
2003-06-28 23:53:39 +00:00
|
|
|
structure is described above.
|
|
|
|
The limitations on data width described for
|
1999-12-08 17:44:04 +00:00
|
|
|
reading registers, above, also apply to writing
|
|
|
|
.Tn PCI
|
|
|
|
configuration registers.
|
|
|
|
.El
|
|
|
|
.Sh FILES
|
2000-12-29 09:18:45 +00:00
|
|
|
.Bl -tag -width /dev/pci -compact
|
1999-12-08 17:44:04 +00:00
|
|
|
.It Pa /dev/pci
|
|
|
|
Character device for the
|
2000-11-20 18:41:33 +00:00
|
|
|
.Nm
|
1999-12-08 17:44:04 +00:00
|
|
|
driver.
|
|
|
|
.El
|
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr pciconf 8
|
|
|
|
.Sh HISTORY
|
|
|
|
The
|
2000-11-20 18:41:33 +00:00
|
|
|
.Nm
|
1999-12-08 17:44:04 +00:00
|
|
|
driver (not the kernel's
|
|
|
|
.Tn PCI
|
|
|
|
support code) first appeared in
|
|
|
|
.Fx 2.2 ,
|
|
|
|
and was written by Stefan Esser and Garrett Wollman.
|
|
|
|
Support for device listing and matching was re-implemented by
|
|
|
|
Kenneth Merry, and first appeared in
|
|
|
|
.Fx 3.0 .
|
|
|
|
.Sh AUTHORS
|
2001-08-13 16:33:00 +00:00
|
|
|
.An Kenneth Merry Aq ken@FreeBSD.org
|
1999-12-08 17:44:04 +00:00
|
|
|
.Sh BUGS
|
2005-02-13 22:25:33 +00:00
|
|
|
It is not possible for users to specify an accurate offset into the device
|
1999-12-08 17:44:04 +00:00
|
|
|
list without calling the
|
|
|
|
.Dv PCIOCGETCONF
|
|
|
|
at least once, since they have no way of knowing the current generation
|
2003-06-28 23:53:39 +00:00
|
|
|
number otherwise.
|
2005-02-13 22:25:33 +00:00
|
|
|
This probably is not a serious problem, though, since
|
1999-12-08 17:44:04 +00:00
|
|
|
users can easily narrow their search by specifying a pattern or patterns
|
|
|
|
for the kernel to match against.
|