1 .\" $NetBSD: pci.3,v 1.10 2014/12/16 13:38:36 msaitoh Exp $
3 .\" Copyright 2001 Wasabi Systems, Inc.
4 .\" All rights reserved.
6 .\" Written by Jason R. Thorpe for Wasabi Systems, Inc.
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\" notice, this list of conditions and the following disclaimer.
13 .\" 2. Redistributions in binary form must reproduce the above copyright
14 .\" notice, this list of conditions and the following disclaimer in the
15 .\" documentation and/or other materials provided with the distribution.
16 .\" 3. All advertising materials mentioning features or use of this software
17 .\" must display the following acknowledgement:
18 .\" This product includes software developed for the NetBSD Project by
19 .\" Wasabi Systems, Inc.
20 .\" 4. The name of Wasabi Systems, Inc. may not be used to endorse
21 .\" or promote products derived from this software without specific prior
22 .\" written permission.
24 .\" THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
25 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
26 .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
27 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
28 .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 .\" POSSIBILITY OF SUCH DAMAGE.
41 .Nd library interface for PCI bus access
47 .Fn pcibus_conf_read "int pcifd" "u_int bus" "u_int dev" "u_int func" \
48 "u_int reg" "pcireg_t *valp"
50 .Fn pcibus_conf_write "int pcifd" "u_int bus" "u_int dev" "u_int func" \
51 "u_int reg" "pcireg_t val"
53 .Fn pcidev_conf_read "int devfd" "u_int reg" "pcireg_t *valp"
55 .Fn pcidev_conf_write "int devfd" "u_int reg" "pcireg_t val"
57 .Fn pci_findvendor "pcireg_t id_reg"
59 .Fn pci_devinfo "pcireg_t id_reg" "pcireg_t class_reg" "int showclass" "char *devinfo" "size_t len"
61 .Fn pci_conf_print "int pcifd" "u_int bus" "u_int dev" "u_int func"
63 .Fn pci_drvname "int pcifd" "u_int dev" "u_int func" "char *drvname" "size_t len"
67 library provides support for accessing the PCI bus by user programs.
69 These functions are available in the
72 Programs should be linked with
74 .Sh CONFIGURATION SPACE FUNCTIONS
75 The following functions are used to access PCI configuration space:
77 .It Fn pcibus_conf_read
78 Access the PCI configuration register
80 on the device located at
84 and place the result in
87 must be an open file descriptor to a PCI bus within the target PCI domain.
88 .It Fn pcibus_conf_write
89 Write the value specified by
91 into the PCI configuration register
93 on the device located at
98 must be an open file descriptor to a PCI bus within the target PCI domain.
99 .It Fn pcidev_conf_read
100 Access the PCI configuration register
102 on the device associated with the open file descriptor
104 and place the result in
106 .It Fn pcidev_conf_write
107 Write the value specified by
109 into the PCI configuration register
111 on the device associated with the open file descriptor
114 .Sh MISCELLANEOUS FUNCTIONS
115 The following miscellaneous functions are available:
117 .It Fn pci_findvendor
118 Return an ASCII description of the PCI vendor in the
122 Return an ASCII description of the PCI vendor, PCI product,
123 and PCI class specified by the PCI ID register
125 and PCI class ID register
127 The description is placed into the buffer pointed to by
129 the size of that buffer is specified in
133 is not 0, the class, subclass and interface are added into the buffer.
134 .It Fn pci_conf_print
135 Print the PCI configuration information for the device located
141 must be an open file descriptor to a PCI bus within the target PCI domain.
143 For the PCI bus opened on
145 return the driver name for
153 as the buffer length.
157 .Fn pcibus_conf_read ,
158 .Fn pcibus_conf_write ,
159 .Fn pcidev_conf_read ,
160 .Fn pcidev_conf_write ,
164 functions return 0 on success and \-1 on failure.
170 if the PCI vendor description cannot be found.
175 .Fn pcibus_conf_read ,
176 .Fn pcibus_conf_write ,
177 .Fn pcidev_conf_read ,
178 .Fn pcidev_conf_write ,
183 functions first appeared in
187 function first appeared in