diff options
| author | mrg <mrg@NetBSD.org> | 2014-07-25 01:38:26 +0000 |
|---|---|---|
| committer | mrg <mrg@NetBSD.org> | 2014-07-25 01:38:26 +0000 |
| commit | a5c0a2d60c6f00a7a0c71dd0d08a8e42f96f150a (patch) | |
| tree | 8d674e527fcf677380a7295271538ef153cb47d6 /sys | |
| parent | 9f6a4977dfa6455dcf94372913f1755d0148bb66 (diff) | |
introduce a new pci_drvname(3) to libpci. implement it in the backend
via PCI_IOC_DRVNAME.
update manual and set lists (and remove a couple of doubled entries.)o
this will be used in libpciaccess() to implement the has_kernel_driver()
method.
Diffstat (limited to 'sys')
| -rw-r--r-- | sys/dev/pci/pci_usrreq.c | 17 | ||||
| -rw-r--r-- | sys/dev/pci/pciio.h | 19 |
2 files changed, 33 insertions, 3 deletions
diff --git a/sys/dev/pci/pci_usrreq.c b/sys/dev/pci/pci_usrreq.c index d72caf30d88..950ea30e031 100644 --- a/sys/dev/pci/pci_usrreq.c +++ b/sys/dev/pci/pci_usrreq.c @@ -1,4 +1,4 @@ -/* $NetBSD: pci_usrreq.c,v 1.26 2014/05/28 04:41:52 riastradh Exp $ */ +/* $NetBSD: pci_usrreq.c,v 1.27 2014/07/25 01:38:26 mrg Exp $ */ /* * Copyright 2001 Wasabi Systems, Inc. @@ -40,7 +40,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pci_usrreq.c,v 1.26 2014/05/28 04:41:52 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pci_usrreq.c,v 1.27 2014/07/25 01:38:26 mrg Exp $"); #include <sys/param.h> #include <sys/conf.h> @@ -74,8 +74,10 @@ static int pciioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l) { struct pci_softc *sc = device_lookup_private(&pci_cd, minor(dev)); + struct pci_child *child; struct pciio_bdf_cfgreg *bdfr; struct pciio_businfo *binfo; + struct pciio_drvname *dname; pcitag_t tag; switch (cmd) { @@ -105,6 +107,17 @@ pciioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l) binfo->maxdevs = sc->sc_maxndevs; return 0; + case PCI_IOC_DRVNAME: + dname = data; + if (dname->device >= sc->sc_maxndevs || dname->function > 7) + return EINVAL; + child = &sc->PCI_SC_DEVICESC(dname->device, dname->function); + if (!child->c_dev) + return ENXIO; + strlcpy(dname->name, device_xname(child->c_dev), + sizeof dname->name); + return 0; + default: return ENOTTY; } diff --git a/sys/dev/pci/pciio.h b/sys/dev/pci/pciio.h index 282c922c76b..a618ef5778e 100644 --- a/sys/dev/pci/pciio.h +++ b/sys/dev/pci/pciio.h @@ -1,4 +1,4 @@ -/* $NetBSD: pciio.h,v 1.3 2009/06/06 12:56:43 cegger Exp $ */ +/* $NetBSD: pciio.h,v 1.4 2014/07/25 01:38:26 mrg Exp $ */ /* * Copyright 2001 Wasabi Systems, Inc. @@ -93,4 +93,21 @@ struct pciio_businfo { #define PCI_IOC_BUSINFO _IOR('P', 4, struct pciio_businfo) +/* + * pciio_drvname: + * + * Driver info for a PCI device (autoconfiguration node) instance. + * Must be run on the correct bus. + */ + +#define PCI_IO_DRVNAME_LEN 16 +struct pciio_drvname { + u_int device; /* in: device number */ + u_int function; /* in: function number */ + char name[PCI_IO_DRVNAME_LEN]; +}; + +#define PCI_IOC_DRVNAME _IOWR('P', 5, struct pciio_drvname) + + #endif /* _DEV_PCI_PCIIO_H_ */ |
