xref: /minix3/lib/libpci/pci.3 (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc.\"	$NetBSD: pci.3,v 1.10 2014/12/16 13:38:36 msaitoh Exp $
27eb99bdaSLionel Sambuc.\"
37eb99bdaSLionel Sambuc.\" Copyright 2001 Wasabi Systems, Inc.
47eb99bdaSLionel Sambuc.\" All rights reserved.
57eb99bdaSLionel Sambuc.\"
67eb99bdaSLionel Sambuc.\" Written by Jason R. Thorpe for Wasabi Systems, Inc.
77eb99bdaSLionel Sambuc.\"
87eb99bdaSLionel Sambuc.\" Redistribution and use in source and binary forms, with or without
97eb99bdaSLionel Sambuc.\" modification, are permitted provided that the following conditions
107eb99bdaSLionel Sambuc.\" are met:
117eb99bdaSLionel Sambuc.\" 1. Redistributions of source code must retain the above copyright
127eb99bdaSLionel Sambuc.\"    notice, this list of conditions and the following disclaimer.
137eb99bdaSLionel Sambuc.\" 2. Redistributions in binary form must reproduce the above copyright
147eb99bdaSLionel Sambuc.\"    notice, this list of conditions and the following disclaimer in the
157eb99bdaSLionel Sambuc.\"    documentation and/or other materials provided with the distribution.
167eb99bdaSLionel Sambuc.\" 3. All advertising materials mentioning features or use of this software
177eb99bdaSLionel Sambuc.\"    must display the following acknowledgement:
187eb99bdaSLionel Sambuc.\"	This product includes software developed for the NetBSD Project by
197eb99bdaSLionel Sambuc.\"	Wasabi Systems, Inc.
207eb99bdaSLionel Sambuc.\" 4. The name of Wasabi Systems, Inc. may not be used to endorse
217eb99bdaSLionel Sambuc.\"    or promote products derived from this software without specific prior
227eb99bdaSLionel Sambuc.\"    written permission.
237eb99bdaSLionel Sambuc.\"
247eb99bdaSLionel Sambuc.\" THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
257eb99bdaSLionel Sambuc.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
267eb99bdaSLionel Sambuc.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
277eb99bdaSLionel Sambuc.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
287eb99bdaSLionel Sambuc.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
297eb99bdaSLionel Sambuc.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
307eb99bdaSLionel Sambuc.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
317eb99bdaSLionel Sambuc.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
327eb99bdaSLionel Sambuc.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
337eb99bdaSLionel Sambuc.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
347eb99bdaSLionel Sambuc.\" POSSIBILITY OF SUCH DAMAGE.
357eb99bdaSLionel Sambuc.\"
36*0a6a1f1dSLionel Sambuc.Dd December 16, 2014
377eb99bdaSLionel Sambuc.Dt PCI 3
387eb99bdaSLionel Sambuc.Os
397eb99bdaSLionel Sambuc.Sh NAME
407eb99bdaSLionel Sambuc.Nm pci
417eb99bdaSLionel Sambuc.Nd library interface for PCI bus access
427eb99bdaSLionel Sambuc.Sh LIBRARY
437eb99bdaSLionel Sambuc.Lb libpci
447eb99bdaSLionel Sambuc.Sh SYNOPSIS
457eb99bdaSLionel Sambuc.In pci.h
467eb99bdaSLionel Sambuc.Ft int
477eb99bdaSLionel Sambuc.Fn pcibus_conf_read "int pcifd" "u_int bus" "u_int dev" "u_int func" \
487eb99bdaSLionel Sambuc"u_int reg" "pcireg_t *valp"
497eb99bdaSLionel Sambuc.Ft int
507eb99bdaSLionel Sambuc.Fn pcibus_conf_write "int pcifd" "u_int bus" "u_int dev" "u_int func" \
517eb99bdaSLionel Sambuc"u_int reg" "pcireg_t val"
527eb99bdaSLionel Sambuc.Ft int
537eb99bdaSLionel Sambuc.Fn pcidev_conf_read "int devfd" "u_int reg" "pcireg_t *valp"
547eb99bdaSLionel Sambuc.Ft int
557eb99bdaSLionel Sambuc.Fn pcidev_conf_write "int devfd" "u_int reg" "pcireg_t val"
567eb99bdaSLionel Sambuc.Ft char *
577eb99bdaSLionel Sambuc.Fn pci_findvendor "pcireg_t id_reg"
587eb99bdaSLionel Sambuc.Ft void
59*0a6a1f1dSLionel Sambuc.Fn pci_devinfo "pcireg_t id_reg" "pcireg_t class_reg" "int showclass" "char *devinfo" "size_t len"
607eb99bdaSLionel Sambuc.Ft void
617eb99bdaSLionel Sambuc.Fn pci_conf_print "int pcifd" "u_int bus" "u_int dev" "u_int func"
62*0a6a1f1dSLionel Sambuc.Ft int
63*0a6a1f1dSLionel Sambuc.Fn pci_drvname "int pcifd" "u_int dev" "u_int func" "char *drvname" "size_t len"
647eb99bdaSLionel Sambuc.Sh DESCRIPTION
657eb99bdaSLionel SambucThe
667eb99bdaSLionel Sambuc.Nm
677eb99bdaSLionel Sambuclibrary provides support for accessing the PCI bus by user programs.
687eb99bdaSLionel Sambuc.Pp
697eb99bdaSLionel SambucThese functions are available in the
707eb99bdaSLionel Sambuc.Nm libpci
717eb99bdaSLionel Sambuclibrary.
727eb99bdaSLionel SambucPrograms should be linked with
737eb99bdaSLionel Sambuc.Fl lpci .
747eb99bdaSLionel Sambuc.Sh CONFIGURATION SPACE FUNCTIONS
757eb99bdaSLionel SambucThe following functions are used to access PCI configuration space:
767eb99bdaSLionel Sambuc.Bl -tag -width 4n
777eb99bdaSLionel Sambuc.It Fn pcibus_conf_read
787eb99bdaSLionel SambucAccess the PCI configuration register
797eb99bdaSLionel Sambuc.Fa reg
807eb99bdaSLionel Sambucon the device located at
817eb99bdaSLionel Sambuc.Fa bus ,
827eb99bdaSLionel Sambuc.Fa dev ,
837eb99bdaSLionel Sambuc.Fa func ,
847eb99bdaSLionel Sambucand place the result in
857eb99bdaSLionel Sambuc.Fa *valp .
867eb99bdaSLionel Sambuc.Fa pcifd
877eb99bdaSLionel Sambucmust be an open file descriptor to a PCI bus within the target PCI domain.
887eb99bdaSLionel Sambuc.It Fn pcibus_conf_write
897eb99bdaSLionel SambucWrite the value specified by
907eb99bdaSLionel Sambuc.Fa val
917eb99bdaSLionel Sambucinto the PCI configuration register
927eb99bdaSLionel Sambuc.Fa reg
937eb99bdaSLionel Sambucon the device located at
947eb99bdaSLionel Sambuc.Fa bus ,
957eb99bdaSLionel Sambuc.Fa dev ,
967eb99bdaSLionel Sambuc.Fa func .
977eb99bdaSLionel Sambuc.Fa pcifd
987eb99bdaSLionel Sambucmust be an open file descriptor to a PCI bus within the target PCI domain.
997eb99bdaSLionel Sambuc.It Fn pcidev_conf_read
1007eb99bdaSLionel SambucAccess the PCI configuration register
1017eb99bdaSLionel Sambuc.Fa reg
1027eb99bdaSLionel Sambucon the device associated with the open file descriptor
1037eb99bdaSLionel Sambuc.Fa devfd
1047eb99bdaSLionel Sambucand place the result in
1057eb99bdaSLionel Sambuc.Fa *valp .
1067eb99bdaSLionel Sambuc.It Fn pcidev_conf_write
1077eb99bdaSLionel SambucWrite the value specified by
1087eb99bdaSLionel Sambuc.Fa val
1097eb99bdaSLionel Sambucinto the PCI configuration register
1107eb99bdaSLionel Sambuc.Fa reg
1117eb99bdaSLionel Sambucon the device associated with the open file descriptor
1127eb99bdaSLionel Sambuc.Fa devfd .
1137eb99bdaSLionel Sambuc.El
1147eb99bdaSLionel Sambuc.Sh MISCELLANEOUS FUNCTIONS
1157eb99bdaSLionel SambucThe following miscellaneous functions are available:
1167eb99bdaSLionel Sambuc.Bl -tag -width 4n
1177eb99bdaSLionel Sambuc.It Fn pci_findvendor
1187eb99bdaSLionel SambucReturn an ASCII description of the PCI vendor in the
1197eb99bdaSLionel SambucPCI ID register
1207eb99bdaSLionel Sambuc.Fa id_reg .
1217eb99bdaSLionel Sambuc.It Fn pci_devinfo
1227eb99bdaSLionel SambucReturn an ASCII description of the PCI vendor, PCI product,
1237eb99bdaSLionel Sambucand PCI class specified by the PCI ID register
1247eb99bdaSLionel Sambuc.Fa id_reg
1257eb99bdaSLionel Sambucand PCI class ID register
1267eb99bdaSLionel Sambuc.Fa class_reg .
1277eb99bdaSLionel SambucThe description is placed into the buffer pointed to by
1287eb99bdaSLionel Sambuc.Fa devinfo ;
1297eb99bdaSLionel Sambucthe size of that buffer is specified in
1307eb99bdaSLionel Sambuc.Fa len .
131*0a6a1f1dSLionel SambucIf
132*0a6a1f1dSLionel Sambuc.Fa showclass
133*0a6a1f1dSLionel Sambucis not 0, the class, subclass and interface are added into the buffer.
1347eb99bdaSLionel Sambuc.It Fn pci_conf_print
1357eb99bdaSLionel SambucPrint the PCI configuration information for the device located
1367eb99bdaSLionel Sambucat
1377eb99bdaSLionel Sambuc.Fa bus ,
1387eb99bdaSLionel Sambuc.Fa dev ,
1397eb99bdaSLionel Sambuc.Fa func .
1407eb99bdaSLionel Sambuc.Fa pcifd
1417eb99bdaSLionel Sambucmust be an open file descriptor to a PCI bus within the target PCI domain.
142*0a6a1f1dSLionel Sambuc.It Fn pci_drvname
143*0a6a1f1dSLionel SambucFor the PCI bus opened on
144*0a6a1f1dSLionel Sambuc.Fa pcifd ,
145*0a6a1f1dSLionel Sambucreturn the driver name for
146*0a6a1f1dSLionel Sambuc.Fa dev
147*0a6a1f1dSLionel Sambucand
148*0a6a1f1dSLionel Sambuc.Fa func
149*0a6a1f1dSLionel Sambucinto
150*0a6a1f1dSLionel Sambuc.Fa drvname
151*0a6a1f1dSLionel Sambucusing
152*0a6a1f1dSLionel Sambuc.Fa len
153*0a6a1f1dSLionel Sambucas the buffer length.
1547eb99bdaSLionel Sambuc.El
1557eb99bdaSLionel Sambuc.Sh RETURN VALUES
1567eb99bdaSLionel SambucThe
1577eb99bdaSLionel Sambuc.Fn pcibus_conf_read ,
1587eb99bdaSLionel Sambuc.Fn pcibus_conf_write ,
1597eb99bdaSLionel Sambuc.Fn pcidev_conf_read ,
160*0a6a1f1dSLionel Sambuc.Fn pcidev_conf_write ,
161*0a6a1f1dSLionel Sambuc.Fn pci_devinfo ,
1627eb99bdaSLionel Sambucand
163*0a6a1f1dSLionel Sambuc.Fn pci_drvname
164*0a6a1f1dSLionel Sambucfunctions return 0 on success and \-1 on failure.
1657eb99bdaSLionel Sambuc.Pp
1667eb99bdaSLionel SambucThe
1677eb99bdaSLionel Sambuc.Fn pci_findvendor
168*0a6a1f1dSLionel Sambucfunction returns
169*0a6a1f1dSLionel Sambuc.Dv NULL
170*0a6a1f1dSLionel Sambucif the PCI vendor description cannot be found.
1717eb99bdaSLionel Sambuc.Sh SEE ALSO
1727eb99bdaSLionel Sambuc.Xr pci 4
1737eb99bdaSLionel Sambuc.Sh HISTORY
1747eb99bdaSLionel SambucThe
1757eb99bdaSLionel Sambuc.Fn pcibus_conf_read ,
1767eb99bdaSLionel Sambuc.Fn pcibus_conf_write ,
1777eb99bdaSLionel Sambuc.Fn pcidev_conf_read ,
1787eb99bdaSLionel Sambuc.Fn pcidev_conf_write ,
1797eb99bdaSLionel Sambuc.Fn pci_findvendor ,
1807eb99bdaSLionel Sambuc.Fn pci_devinfo ,
1817eb99bdaSLionel Sambucand
1827eb99bdaSLionel Sambuc.Fn pci_conf_print
1837eb99bdaSLionel Sambucfunctions first appeared in
1847eb99bdaSLionel Sambuc.Nx 1.6 .
185*0a6a1f1dSLionel SambucThe
186*0a6a1f1dSLionel Sambuc.Fn pci_drvname
187*0a6a1f1dSLionel Sambucfunction first appeared in
188*0a6a1f1dSLionel Sambuc.Nx 7.0 .
189