xref: /netbsd/lib/libpci/pci.3 (revision bf9ec67e)
1.\"	$NetBSD: pci.3,v 1.3 2002/02/07 07:00:51 ross Exp $
2.\"
3.\" Copyright 2001 Wasabi Systems, Inc.
4.\" All rights reserved.
5.\"
6.\" Written by Jason R. Thorpe for Wasabi Systems, Inc.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
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.
23.\"
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.
35.\"
36.Dd September 12, 2001
37.Os
38.Dt PCI 3
39.Sh NAME
40.Nm pci
41.Nd library interface for PCI bus access
42.Sh LIBRARY
43.Lb libpci
44.Sh SYNOPSIS
45.Fd #include \*[Lt]pci.h\*[Gt]
46.Ft int
47.Fn pcibus_conf_read "int pcifd" "u_int bus" "u_int dev" "u_int func" \
48"u_int reg" "pcireg_t *valp"
49.Ft int
50.Fn pcibus_conf_write "int pcifd" "u_int bus" "u_int dev" "u_int func" \
51"u_int reg" "pcireg_t val"
52.Ft int
53.Fn pcidev_conf_read "int devfd" "u_int reg" "pcireg_t *valp"
54.Ft int
55.Fn pcidev_conf_write "int devfd" "u_int reg" "pcireg_t val"
56.Ft char *
57.Fn pci_findvendor "pcireg_t id_reg"
58.Ft void
59.Fn pci_devinfo "pcireg_t id_reg" "pcireg_t class_reg" "char *devinfo"
60.Ft void
61.Fn pci_conf_print "int pcifd" "u_int bus" "u_int dev" "u_int func"
62.Sh DESCRIPTION
63The
64.Nm
65library provides support for accessing the PCI bus by user programs.
66.Pp
67These functions are available in the
68.Nm libpci
69library.
70Programs should be linked with
71.Fl lpci .
72.Sh CONFIGURATION SPACE FUNCTIONS
73The following functions are used to access PCI configuration space:
74.Bl -tag -width 4n
75.It Fn pcibus_conf_read
76Access the PCI configuration register
77.Fa reg
78on the device located at
79.Fa bus ,
80.Fa dev ,
81.Fa func ,
82and place the result in
83.Fa *valp .
84.Fa pcifd
85must be an open file descriptor to a PCI bus within the target PCI domain.
86.It Fn pcibus_conf_write
87Write the value specified by
88.Fa val
89into the PCI configuration register
90.Fa rag
91on the device located at
92.Fa bus ,
93.Fa dev ,
94.Fa func .
95.Fa pcifd
96must be an open file descriptor to a PCI bus within the target PCI domain.
97.It Fn pcidev_conf_read
98Access the PCI configuration register
99.Fa reg
100on the device associated with the open file descriptor
101.Fa devfd
102and place the result in
103.Fa *valp .
104.It Fn pcidev_conf_write
105Write the value specified by
106.Fa val
107into the PCI configuration register
108.Fa reg
109on the device associated with the open file descriptor
110.Fa devfd .
111.El
112.Sh MISCELLANEOUS FUNCTIONS
113The following miscellaneous functions are available:
114.Bl -tag -width 4n
115.It Fn pci_findvendor
116Return an ASCII description of the PCI vendor in the
117PCI ID register
118.Fa id_reg .
119.It Fn pci_devinfo
120Return an ASCII description of the PCI vendor, PCI product,
121and PCI class specified by the PCI ID register
122.Fa id_reg
123and PCI class ID register
124.Fa class_reg .
125The description is placed into the buffer pointed to by
126.Fa devinfo .
127The buffer should be at least 256 bytes long.
128.It Fn pci_conf_print
129Print the PCI configuration information for the device located
130at
131.Fa bus ,
132.Fa dev ,
133.Fa func .
134.Fa pcifd
135must be an open file descriptor to a PCI bus within the target PCI domain.
136.El
137.Sh RETURN VALUES
138The
139.Fn pcibus_conf_read ,
140.Fn pcibus_conf_write ,
141.Fn pcidev_conf_read ,
142and
143.Fn pcidev_conf_write
144functions return 0 on success and -1 on failure.
145.Pp
146The
147.Fn pci_findvendor
148function returns NULL if the PCI vendor description cannot be
149found.
150.Sh SEE ALSO
151.Xr pci 4
152.Sh HISTORY
153The
154.Fn pcibus_conf_read ,
155.Fn pcibus_conf_write ,
156.Fn pcidev_conf_read ,
157.Fn pcidev_conf_write ,
158.Fn pci_findvendor ,
159.Fn pci_devinfo ,
160and
161.Fn pci_conf_print
162functions first appeared in
163.Nx 1.6 .
164