Module Name: src
Committed By: tls
Date: Sun Aug 10 06:52:09 UTC 2014
Modified Files:
src/lib/libpci [tls-earlyentropy]: Makefile pci.3 pci.h shlib_version
Added Files:
src/lib/libpci [tls-earlyentropy]: pci_drvname.c
Log Message:
Rebase.
To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.3.22.1 src/lib/libpci/Makefile
cvs rdiff -u -r1.7 -r1.7.22.1 src/lib/libpci/pci.3
cvs rdiff -u -r1.4 -r1.4.22.1 src/lib/libpci/pci.h
cvs rdiff -u -r0 -r1.1.2.2 src/lib/libpci/pci_drvname.c
cvs rdiff -u -r1.3 -r1.3.24.1 src/lib/libpci/shlib_version
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/lib/libpci/Makefile
diff -u src/lib/libpci/Makefile:1.3 src/lib/libpci/Makefile:1.3.22.1
--- src/lib/libpci/Makefile:1.3 Mon May 24 20:31:17 2010
+++ src/lib/libpci/Makefile Sun Aug 10 06:52:09 2014
@@ -1,10 +1,10 @@
-# $NetBSD: Makefile,v 1.3 2010/05/24 20:31:17 pgoyette Exp $
+# $NetBSD: Makefile,v 1.3.22.1 2014/08/10 06:52:09 tls Exp $
.include <bsd.own.mk>
LIB= pci
-SRCS= pci_bus.c pci_device.c pci_subr.c pci_verbose.c
+SRCS= pci_bus.c pci_device.c pci_drvname.c pci_subr.c pci_verbose.c
.PATH.c: ${NETBSDSRCDIR}/sys/dev/pci
Index: src/lib/libpci/pci.3
diff -u src/lib/libpci/pci.3:1.7 src/lib/libpci/pci.3:1.7.22.1
--- src/lib/libpci/pci.3:1.7 Fri Oct 23 15:41:58 2009
+++ src/lib/libpci/pci.3 Sun Aug 10 06:52:09 2014
@@ -1,4 +1,4 @@
-.\" $NetBSD: pci.3,v 1.7 2009/10/23 15:41:58 cegger Exp $
+.\" $NetBSD: pci.3,v 1.7.22.1 2014/08/10 06:52:09 tls Exp $
.\"
.\" Copyright 2001 Wasabi Systems, Inc.
.\" All rights reserved.
@@ -33,7 +33,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd April 24, 2004
+.Dd July 24, 2014
.Dt PCI 3
.Os
.Sh NAME
@@ -59,6 +59,8 @@
.Fn pci_devinfo "pcireg_t id_reg" "pcireg_t class_reg" "char *devinfo" "size_t len"
.Ft void
.Fn pci_conf_print "int pcifd" "u_int bus" "u_int dev" "u_int func"
+.Ft int
+.Fn pci_drvname "int pcifd" "u_int dev" "u_int func" "char *drvname" "size_t len"
.Sh DESCRIPTION
The
.Nm
@@ -134,20 +136,35 @@ at
.Fa func .
.Fa pcifd
must be an open file descriptor to a PCI bus within the target PCI domain.
+.It Fn pci_drvname
+For the PCI bus opened on
+.Fa pcifd ,
+return the driver name for
+.Fa dev
+and
+.Fa func
+into
+.Fa drvname
+using
+.Fa len
+as the buffer length.
.El
.Sh RETURN VALUES
The
.Fn pcibus_conf_read ,
.Fn pcibus_conf_write ,
.Fn pcidev_conf_read ,
+.Fn pcidev_conf_write ,
+.Fn pci_devinfo ,
and
-.Fn pcidev_conf_write
-functions return 0 on success and -1 on failure.
+.Fn pci_drvname
+functions return 0 on success and \-1 on failure.
.Pp
The
.Fn pci_findvendor
-function returns NULL if the PCI vendor description cannot be
-found.
+function returns
+.Dv NULL
+if the PCI vendor description cannot be found.
.Sh SEE ALSO
.Xr pci 4
.Sh HISTORY
@@ -162,3 +179,7 @@ and
.Fn pci_conf_print
functions first appeared in
.Nx 1.6 .
+The
+.Fn pci_drvname
+function first appeared in
+.Nx 7.0 .
Index: src/lib/libpci/pci.h
diff -u src/lib/libpci/pci.h:1.4 src/lib/libpci/pci.h:1.4.22.1
--- src/lib/libpci/pci.h:1.4 Tue May 25 08:35:47 2010
+++ src/lib/libpci/pci.h Sun Aug 10 06:52:09 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: pci.h,v 1.4 2010/05/25 08:35:47 pgoyette Exp $ */
+/* $NetBSD: pci.h,v 1.4.22.1 2014/08/10 06:52:09 tls Exp $ */
/*
* Copyright 2001 Wasabi Systems, Inc.
@@ -52,6 +52,9 @@ int pcibus_conf_write(int, u_int, u_int,
int pcidev_conf_read(int, u_int, pcireg_t *);
int pcidev_conf_write(int, u_int, pcireg_t);
+/* pci_drvname.c */
+int pci_drvname(int, u_int, u_int, char *, size_t);
+
/* pci_subr.c */
const char *pci_findvendor_real(pcireg_t);
const char *pci_findproduct_real(pcireg_t);
Index: src/lib/libpci/shlib_version
diff -u src/lib/libpci/shlib_version:1.3 src/lib/libpci/shlib_version:1.3.24.1
--- src/lib/libpci/shlib_version:1.3 Sun Jan 11 03:07:49 2009
+++ src/lib/libpci/shlib_version Sun Aug 10 06:52:09 2014
@@ -1,5 +1,5 @@
-# $NetBSD: shlib_version,v 1.3 2009/01/11 03:07:49 christos Exp $
+# $NetBSD: shlib_version,v 1.3.24.1 2014/08/10 06:52:09 tls Exp $
# Remember to update distrib/sets/lists/base/shl.* when changing
#
major=2
-minor=0
+minor=1
Added files:
Index: src/lib/libpci/pci_drvname.c
diff -u /dev/null src/lib/libpci/pci_drvname.c:1.1.2.2
--- /dev/null Sun Aug 10 06:52:10 2014
+++ src/lib/libpci/pci_drvname.c Sun Aug 10 06:52:09 2014
@@ -0,0 +1,62 @@
+/* $NetBSD: pci_drvname.c,v 1.1.2.2 2014/08/10 06:52:09 tls Exp $ */
+
+/*
+ * Copyright (c) 2014 Matthew R. Green
+ * 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. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. 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 ``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 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.
+ */
+
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: pci_drvname.c,v 1.1.2.2 2014/08/10 06:52:09 tls Exp $");
+
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <string.h>
+
+#include <pci.h>
+
+#include <dev/pci/pciio.h>
+
+/*
+ * pci_drvname:
+ *
+ * What's the driver name for a PCI device?
+ */
+int
+pci_drvname(int fd, u_int device, u_int func, char *name, size_t len)
+{
+ struct pciio_drvname drvname;
+ int rv;
+
+ drvname.device = device;
+ drvname.function = func;
+
+ rv = ioctl(fd, PCI_IOC_DRVNAME, &drvname);
+ if (rv == -1)
+ return -1;
+
+ strlcpy(name, drvname.name, len);
+ return 0;
+}