[ repository copy of sys/pci/pci_ioctl.h to sys/sys/pciio.h happened in the
background ] Rename sys/pci/pci_ioctl.h to sys/sys/pciio.h to make it easier for userland programs to use this interface. Reformat the file, and add a BSD-style copyright to it. Add a new man page for pci(4). The PCIOCGETCONF, PCIOCREAD, and PCIOCWRITE ioctls are documented, but the PCIOCATTACHED ioctl is not documented because it is not implemented. Change includes of <pci/pci_ioctl.h> to <sys/pciio.h> or remove them altogether. In many cases, pci_ioctl.h was unused. Reviewed by: steve
This commit is contained in:
parent
7298547a1e
commit
64ae346b52
@ -7,7 +7,7 @@ MAN4= ahc.4 alpm.4 atkbd.4 atkbdc.4 blackhole.4 bpf.4 \
|
||||
icmp.4 ifmib.4 iic.4 iicbb.4 iicbus.4 iicsmb.4 \
|
||||
inet.4 intpm.4 intro.4 ip.4 ipfirewall.4 keyboard.4 kld.4 \
|
||||
lo.4 lp.4 lpbb.4 lpt.4 mem.4 mouse.4 mtio.4 natm.4 ncr.4 \
|
||||
netintro.4 null.4 ohci.4 pass.4 pcm.4 pcvt.4 \
|
||||
netintro.4 null.4 ohci.4 pass.4 pci.4 pcm.4 pcvt.4 \
|
||||
ppbus.4 ppi.4 ppp.4 psm.4 pt.4 pty.4 rl.4 \
|
||||
route.4 sa.4 screen.4 scsi.4 \
|
||||
sd.4 sf.4 si.4 sio.4 sis.4 sk.4 sl.4 smb.4 smbus.4 smp.4 snp.4 \
|
||||
|
295
share/man/man4/pci.4
Normal file
295
share/man/man4/pci.4
Normal file
@ -0,0 +1,295 @@
|
||||
.\"
|
||||
.\" Copyright (c) 1999 Kenneth D. Merry.
|
||||
.\" 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. 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 AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd October 24, 1999
|
||||
.Dt PCI 4
|
||||
.Os FreeBSD 4.0
|
||||
.Sh NAME
|
||||
.Nm pci
|
||||
.Nd Generic PCI driver
|
||||
.Sh SYNOPSYIS
|
||||
.Cd controller pci0
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm pci
|
||||
driver provides a way for userland programs to read and write
|
||||
.Tn PCI
|
||||
configuration registers. It also provides a way for userland programs to
|
||||
get a list of all
|
||||
.Tn PCI
|
||||
devices, or all
|
||||
.Tn PCI
|
||||
devices that match various patterns.
|
||||
.Pp
|
||||
Since the
|
||||
.Nm pci
|
||||
driver provides a write interface for
|
||||
.Tn PCI
|
||||
configuration registers, system administrators should exercise caution when
|
||||
granting access to the
|
||||
.Nm pci
|
||||
device. If used improperly, this driver can allow userland applications to
|
||||
crash a machine or cause data loss.
|
||||
.Sh KERNEL CONFIGURATION
|
||||
It is only necessary to specify one
|
||||
.Nm pci
|
||||
controller in the kernel. Additional
|
||||
.Tn PCI
|
||||
busses are handled automatically as they are encountered.
|
||||
.Sh IOCTLS
|
||||
The following
|
||||
.Xr ioctl 2
|
||||
calls are supported by the
|
||||
.Nm pci
|
||||
driver. They are defined in the header file
|
||||
.Aq Pa sys/pciio.h .
|
||||
.Bl -tag -width 012345678901234
|
||||
.Pp
|
||||
.It PCIOCGETCONF
|
||||
This
|
||||
.Xr ioctl 2
|
||||
takes a
|
||||
.Va pci_conf_io
|
||||
structure. It allows the user to retrieve information on all
|
||||
.Tn PCI
|
||||
devices in the system, or on
|
||||
.Tn PCI
|
||||
devices matching patterns supplied by the user.
|
||||
The
|
||||
.Va pci_conf_io
|
||||
structure consists of a number of fields:
|
||||
.Bl -tag -width match_buf_len
|
||||
.It pat_buf_len
|
||||
The length, in bytes, of the buffer filled with user-supplied patterns.
|
||||
.It num_patterns
|
||||
The number of user-supplied patterns.
|
||||
.It patterns
|
||||
Pointer to a buffer filled with user-supplied patterns.
|
||||
.Va patterns
|
||||
is a pointer to
|
||||
.Va num_patterns
|
||||
.Va pci_match_conf
|
||||
structures. The
|
||||
.Va pci_match_conf
|
||||
structure consists of the following elements:
|
||||
.Bl -tag -width pd_vendor
|
||||
.It pc_sel
|
||||
.Tn PCI
|
||||
bus, slot and function.
|
||||
.It pd_name
|
||||
.Tn PCI
|
||||
device driver name.
|
||||
.It pd_unit
|
||||
.Tn PCI
|
||||
device driver unit number.
|
||||
.It pc_vendor
|
||||
.Tn PCI
|
||||
vendor ID.
|
||||
.It pc_device
|
||||
.Tn PCI
|
||||
device ID.
|
||||
.It pc_class
|
||||
.Tn PCI
|
||||
device class.
|
||||
.It flags
|
||||
The flags describe which of the fields the kernel should match against.
|
||||
A device must match all specified fields in order to be returned. The
|
||||
match flags are enumerated in the
|
||||
.Va pci_getconf_flags
|
||||
structure.
|
||||
Hopefully the flag values are obvious enough that they don't need to
|
||||
described in detail.
|
||||
.El
|
||||
.It match_buf_len
|
||||
Length of the
|
||||
.Va matches
|
||||
buffer allocated by the user to hold the results of the
|
||||
.Dv PCIOCGETCONF
|
||||
query.
|
||||
.It num_matches
|
||||
Number of matches returned by the kernel.
|
||||
.It matches
|
||||
Buffer containing matching devices returned by the kernel. The items in
|
||||
this buffer are of type
|
||||
.Va pci_conf ,
|
||||
which consists of the following items:
|
||||
.Bl -tag -width pc_subvendor
|
||||
.It pc_sel
|
||||
.Tn PCI
|
||||
bus, slot and function.
|
||||
.It pc_hdr
|
||||
.Tn PCI
|
||||
header type.
|
||||
.It pc_subvendor
|
||||
.Tn PCI
|
||||
subvendor ID.
|
||||
.It pc_subdevice
|
||||
.Tn PCI
|
||||
subdevice ID.
|
||||
.It pc_vendor
|
||||
.Tn PCI
|
||||
vendor ID.
|
||||
.It pc_device
|
||||
.Tn PCI
|
||||
device ID.
|
||||
.It pc_class
|
||||
.Tn PCI
|
||||
device class.
|
||||
.It pc_subclass
|
||||
.Tn PCI
|
||||
device subclass.
|
||||
.It pc_progif
|
||||
.Tn PCI
|
||||
device programming interface.
|
||||
.It pc_revid
|
||||
.Tn PCI
|
||||
revision ID.
|
||||
.It pd_name
|
||||
Driver name.
|
||||
.It pd_unit
|
||||
Driver unit number.
|
||||
.El
|
||||
.It offset
|
||||
The offset is passed in by the user to tell the kernel where it should
|
||||
start traversing the device list. The value passed out by the kernel
|
||||
points to the record immediately after the last one returned. The user may
|
||||
pass the value returned by the kernel in subsequent calls to the
|
||||
.Dv PCIOCGETCONF
|
||||
ioctl. If the user does not intend to use the offset, it must be set to
|
||||
zero.
|
||||
.It generation
|
||||
.Tn PCI
|
||||
configuration generation. This value only needs to be set if the offset is
|
||||
set. The kernel will compare the current generation number of its internal
|
||||
device list to the generation passed in by the user to determine whether
|
||||
its device list has changed since the user last called the
|
||||
.Dv PCIOCGETCONF
|
||||
ioctl. If the device list has changed, a status of
|
||||
.Va PCI_GETCONF_LIST_CHANGED
|
||||
will be passed back.
|
||||
.It status
|
||||
The status tells the user the disposition of his request for a device list.
|
||||
The possible status values are:
|
||||
.Bl -ohang
|
||||
.It PCI_GETCONF_LAST_DEVICE
|
||||
This means that there are no more devices in the PCI device list after the
|
||||
ones returned in the
|
||||
.Va matches
|
||||
buffer.
|
||||
.It PCI_GETCONF_LIST_CHANGED
|
||||
This status tells the user that the
|
||||
.Tn PCI
|
||||
device list has changed since his last call to the
|
||||
.Dv PCIOCGETCONF
|
||||
ioctl and he must reset the
|
||||
.Va offset
|
||||
and
|
||||
.Va generation
|
||||
to zero to start over at the beginning of the list.
|
||||
.It PCI_GETCONF_MORE_DEVS
|
||||
This tells the user that his buffer was not large enough to hold all of the
|
||||
remaining devices in the device list that possibly match his criteria. It
|
||||
is possible for this status to be returned, even when none of the remaining
|
||||
devices in the list would match the user's criteria.
|
||||
.It PCI_GETCONF_ERROR
|
||||
This indicates a general error while servicing the user's request. A more
|
||||
specific indication of the problem may or may not be printed in the kernel
|
||||
message buffer (and by implication, the system console).
|
||||
.El
|
||||
.El
|
||||
.It PCIOCREAD
|
||||
This
|
||||
.Xr ioctl 2
|
||||
reads the
|
||||
.Tn PCI
|
||||
configuration registers specified by the passed-in
|
||||
.Va pci_io
|
||||
structure. The
|
||||
.Va pci_io
|
||||
structure consists of the following fields:
|
||||
.Bl -tag -width pi_width
|
||||
.It pi_sel
|
||||
A
|
||||
.Va pcisel
|
||||
structure which specifies the bus, slot and function the user would like to
|
||||
query.
|
||||
.It pi_reg
|
||||
The
|
||||
.Tn PCI
|
||||
configuration register the user would like to access.
|
||||
.It pi_width
|
||||
The width, in bytes, of the data the user would like to read. This value
|
||||
may be either 1, 2, or 4. 3-byte reads and reads larger than 4 bytes are
|
||||
not supported.
|
||||
.It pi_data
|
||||
The data returned by the kernel.
|
||||
.El
|
||||
.It PCIOCWRITE
|
||||
This
|
||||
.Xr ioctl 2
|
||||
allows users to write to the
|
||||
.Tn PCI
|
||||
specified in the passed-in
|
||||
.Va pci_io
|
||||
structure. The
|
||||
.Va pci_io
|
||||
structure is described above. The limitations on data width described for
|
||||
reading registers, above, also apply to writing
|
||||
.Tn PCI
|
||||
configuration registers.
|
||||
.El
|
||||
.Sh FILES
|
||||
.Bl -tag -width 01234567890 -compact
|
||||
.It Pa /dev/pci
|
||||
Character device for the
|
||||
.Nm pci
|
||||
driver.
|
||||
.El
|
||||
.Sh DIAGNOSTICS
|
||||
None.
|
||||
.Sh SEE ALSO
|
||||
.Xr pciconf 8
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Nm pci
|
||||
driver (not the kernel's
|
||||
.Tn PCI
|
||||
support code) first appeared in
|
||||
.Fx 2.2 ,
|
||||
and was written by Stefan Esser and Garrett Wollman.
|
||||
Support for device listing and matching was re-implemented by
|
||||
Kenneth Merry, and first appeared in
|
||||
.Fx 3.0 .
|
||||
.Sh AUTHORS
|
||||
.An Kenneth Merry Aq ken@FreeBSD.ORG
|
||||
.Sh BUGS
|
||||
It isn't possible for users to specify an accurate offset into the device
|
||||
list without calling the
|
||||
.Dv PCIOCGETCONF
|
||||
at least once, since they have no way of knowing the current generation
|
||||
number otherwise. This probably isn't a serious problem, though, since
|
||||
users can easily narrow their search by specifying a pattern or patterns
|
||||
for the kernel to match against.
|
@ -45,7 +45,6 @@
|
||||
#include <machine/clock.h>
|
||||
#include <pci/pcireg.h>
|
||||
#include <pci/pcivar.h>
|
||||
#include <pci/pci_ioctl.h>
|
||||
#include <alpha/pci/apecsreg.h>
|
||||
#include <alpha/pci/apecsvar.h>
|
||||
|
||||
|
@ -42,7 +42,6 @@
|
||||
#include <machine/clock.h>
|
||||
#include <pci/pcireg.h>
|
||||
#include <pci/pcivar.h>
|
||||
#include <pci/pci_ioctl.h>
|
||||
#include <alpha/pci/lcavar.h>
|
||||
|
||||
#include "sio.h"
|
||||
|
@ -60,7 +60,6 @@
|
||||
|
||||
#include <pci/pcireg.h>
|
||||
#include <pci/pcivar.h>
|
||||
#include <pci/pci_ioctl.h>
|
||||
|
||||
#include <alpha/pci/apecsreg.h>
|
||||
#include <alpha/pci/apecsvar.h>
|
||||
|
@ -42,7 +42,6 @@
|
||||
#include <machine/clock.h>
|
||||
#include <pci/pcireg.h>
|
||||
#include <pci/pcivar.h>
|
||||
#include <pci/pci_ioctl.h>
|
||||
#include <alpha/pci/ciareg.h>
|
||||
#include <alpha/pci/ciavar.h>
|
||||
|
||||
|
@ -48,7 +48,6 @@
|
||||
#include <machine/clock.h>
|
||||
#include <pci/pcireg.h>
|
||||
#include <pci/pcivar.h>
|
||||
#include <pci/pci_ioctl.h>
|
||||
#include <alpha/pci/ciareg.h>
|
||||
#include <alpha/pci/ciavar.h>
|
||||
|
||||
|
@ -41,7 +41,6 @@
|
||||
#include <machine/clock.h>
|
||||
#include <pci/pcireg.h>
|
||||
#include <pci/pcivar.h>
|
||||
#include <pci/pci_ioctl.h>
|
||||
#include <alpha/pci/tsunamireg.h>
|
||||
#include <alpha/pci/tsunamivar.h>
|
||||
|
||||
|
@ -54,7 +54,7 @@
|
||||
|
||||
#include <pci/pcireg.h>
|
||||
#include <pci/pcivar.h>
|
||||
#include <pci/pci_ioctl.h>
|
||||
#include <sys/pciio.h>
|
||||
|
||||
#ifdef APIC_IO
|
||||
#include <machine/smp.h>
|
||||
|
@ -34,7 +34,6 @@
|
||||
#define PCI_COMPAT
|
||||
#endif
|
||||
|
||||
#include <pci/pci_ioctl.h> /* XXX KDM */
|
||||
#include <sys/queue.h>
|
||||
|
||||
/* some PCI bus constants */
|
||||
|
@ -54,7 +54,7 @@
|
||||
|
||||
#include <pci/pcireg.h>
|
||||
#include <pci/pcivar.h>
|
||||
#include <pci/pci_ioctl.h>
|
||||
#include <sys/pciio.h>
|
||||
|
||||
#ifdef APIC_IO
|
||||
#include <machine/smp.h>
|
||||
|
@ -1,128 +0,0 @@
|
||||
#ifndef _PCI_IOCTL_H
|
||||
#define _PCI_IOCTL_H 1
|
||||
|
||||
#include <sys/ioccom.h>
|
||||
|
||||
|
||||
#define PCI_MAXNAMELEN 16 /* max no. of characters in a device name */
|
||||
|
||||
typedef enum {
|
||||
PCI_GETCONF_LAST_DEVICE,
|
||||
PCI_GETCONF_LIST_CHANGED,
|
||||
PCI_GETCONF_MORE_DEVS,
|
||||
PCI_GETCONF_ERROR
|
||||
} pci_getconf_status;
|
||||
|
||||
typedef enum {
|
||||
PCI_GETCONF_NO_MATCH = 0x00,
|
||||
PCI_GETCONF_MATCH_BUS = 0x01,
|
||||
PCI_GETCONF_MATCH_DEV = 0x02,
|
||||
PCI_GETCONF_MATCH_FUNC = 0x04,
|
||||
PCI_GETCONF_MATCH_NAME = 0x08,
|
||||
PCI_GETCONF_MATCH_UNIT = 0x10,
|
||||
PCI_GETCONF_MATCH_VENDOR = 0x20,
|
||||
PCI_GETCONF_MATCH_DEVICE = 0x40,
|
||||
PCI_GETCONF_MATCH_CLASS = 0x80
|
||||
} pci_getconf_flags;
|
||||
|
||||
struct pcisel {
|
||||
u_int8_t pc_bus; /* bus number */
|
||||
u_int8_t pc_dev; /* device on this bus */
|
||||
u_int8_t pc_func; /* function on this device */
|
||||
};
|
||||
|
||||
struct pci_conf {
|
||||
struct pcisel pc_sel; /* bus+slot+function */
|
||||
u_int8_t pc_hdr; /* PCI header type */
|
||||
u_int16_t pc_subvendor; /* card vendor ID */
|
||||
u_int16_t pc_subdevice; /* card device ID, assigned by
|
||||
card vendor */
|
||||
u_int16_t pc_vendor; /* chip vendor ID */
|
||||
u_int16_t pc_device; /* chip device ID, assigned by
|
||||
chip vendor */
|
||||
u_int8_t pc_class; /* chip PCI class */
|
||||
u_int8_t pc_subclass; /* chip PCI subclass */
|
||||
u_int8_t pc_progif; /* chip PCI programming interface */
|
||||
u_int8_t pc_revid; /* chip revision ID */
|
||||
char pd_name[PCI_MAXNAMELEN + 1]; /* Name of peripheral
|
||||
device */
|
||||
u_long pd_unit; /* Unit number */
|
||||
};
|
||||
|
||||
struct pci_match_conf {
|
||||
struct pcisel pc_sel; /* bus+slot+function */
|
||||
char pd_name[PCI_MAXNAMELEN + 1]; /* Name of peripheral
|
||||
device */
|
||||
u_long pd_unit; /* Unit number */
|
||||
u_int16_t pc_vendor; /* PCI Vendor ID */
|
||||
u_int16_t pc_device; /* PCI Device ID */
|
||||
u_int8_t pc_class; /* PCI class */
|
||||
pci_getconf_flags flags; /* Matching expression */
|
||||
};
|
||||
|
||||
struct pci_conf_io {
|
||||
u_int32_t pat_buf_len; /*
|
||||
* Length of buffer passed in from
|
||||
* user space.
|
||||
*/
|
||||
u_int32_t num_patterns; /*
|
||||
* Number of pci_match_conf structures
|
||||
* passed in by the user.
|
||||
*/
|
||||
struct pci_match_conf *patterns; /*
|
||||
* Patterns passed in by the user.
|
||||
*/
|
||||
u_int32_t match_buf_len;/*
|
||||
* Length of match buffer passed
|
||||
* in by the user.
|
||||
*/
|
||||
u_int32_t num_matches; /*
|
||||
* Number of matches returned by
|
||||
* the kernel.
|
||||
*/
|
||||
struct pci_conf *matches; /*
|
||||
* PCI device matches returned by
|
||||
* the kernel.
|
||||
*/
|
||||
u_int32_t offset; /*
|
||||
* Passed in by the user code to
|
||||
* indicate where the kernel should
|
||||
* start traversing the device list.
|
||||
* The value passed out by the kernel
|
||||
* points to the record immediately
|
||||
* after the last one returned.
|
||||
* i.e. this value may be passed back
|
||||
* unchanged by the user for a
|
||||
* subsequent call.
|
||||
*/
|
||||
u_int32_t generation; /*
|
||||
* PCI configuration generation.
|
||||
* This only needs to be set if the
|
||||
* offset is set. The kernel will
|
||||
* compare its current generation
|
||||
* number to the generation passed
|
||||
* in by the user to determine
|
||||
* whether the PCI device list has
|
||||
* changed since the user last
|
||||
* called the GETCONF ioctl.
|
||||
*/
|
||||
pci_getconf_status status; /*
|
||||
* Status passed back from the
|
||||
* kernel.
|
||||
*/
|
||||
};
|
||||
|
||||
struct pci_io {
|
||||
struct pcisel pi_sel; /* device to operate on */
|
||||
int pi_reg; /* configuration register to examine */
|
||||
int pi_width; /* width (in bytes) of read or write */
|
||||
u_int32_t pi_data; /* data to write or result of read */
|
||||
};
|
||||
|
||||
|
||||
#define PCIOCGETCONF _IOWR('p', 1, struct pci_conf_io)
|
||||
#define PCIOCREAD _IOWR('p', 2, struct pci_io)
|
||||
#define PCIOCWRITE _IOWR('p', 3, struct pci_io)
|
||||
#define PCIOCATTACHED _IOWR('p', 4, struct pci_io)
|
||||
|
||||
#endif /* _PCI_IOCTL_H */
|
@ -34,7 +34,6 @@
|
||||
#define PCI_COMPAT
|
||||
#endif
|
||||
|
||||
#include <pci/pci_ioctl.h> /* XXX KDM */
|
||||
#include <sys/queue.h>
|
||||
|
||||
/* some PCI bus constants */
|
||||
|
177
sys/sys/pciio.h
177
sys/sys/pciio.h
@ -1,122 +1,109 @@
|
||||
#ifndef _PCI_IOCTL_H
|
||||
#define _PCI_IOCTL_H 1
|
||||
/*-
|
||||
* Copyright (c) 1997, Stefan Esser <se@FreeBSD.ORG>
|
||||
* Copyright (c) 1997, 1998, 1999, Kenneth D. Merry <ken@FreeBSD.ORG>
|
||||
* 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 unmodified, 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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _SYS_PCIIO_H_
|
||||
#define _SYS_PCIIO_H_
|
||||
|
||||
#include <sys/ioccom.h>
|
||||
|
||||
|
||||
#define PCI_MAXNAMELEN 16 /* max no. of characters in a device name */
|
||||
#define PCI_MAXNAMELEN 16
|
||||
|
||||
typedef enum {
|
||||
PCI_GETCONF_LAST_DEVICE,
|
||||
PCI_GETCONF_LIST_CHANGED,
|
||||
PCI_GETCONF_MORE_DEVS,
|
||||
PCI_GETCONF_ERROR
|
||||
PCI_GETCONF_LAST_DEVICE,
|
||||
PCI_GETCONF_LIST_CHANGED,
|
||||
PCI_GETCONF_MORE_DEVS,
|
||||
PCI_GETCONF_ERROR
|
||||
} pci_getconf_status;
|
||||
|
||||
typedef enum {
|
||||
PCI_GETCONF_NO_MATCH = 0x00,
|
||||
PCI_GETCONF_MATCH_BUS = 0x01,
|
||||
PCI_GETCONF_MATCH_DEV = 0x02,
|
||||
PCI_GETCONF_MATCH_FUNC = 0x04,
|
||||
PCI_GETCONF_MATCH_NAME = 0x08,
|
||||
PCI_GETCONF_MATCH_UNIT = 0x10,
|
||||
PCI_GETCONF_MATCH_VENDOR = 0x20,
|
||||
PCI_GETCONF_MATCH_DEVICE = 0x40,
|
||||
PCI_GETCONF_MATCH_CLASS = 0x80
|
||||
PCI_GETCONF_NO_MATCH = 0x00,
|
||||
PCI_GETCONF_MATCH_BUS = 0x01,
|
||||
PCI_GETCONF_MATCH_DEV = 0x02,
|
||||
PCI_GETCONF_MATCH_FUNC = 0x04,
|
||||
PCI_GETCONF_MATCH_NAME = 0x08,
|
||||
PCI_GETCONF_MATCH_UNIT = 0x10,
|
||||
PCI_GETCONF_MATCH_VENDOR = 0x20,
|
||||
PCI_GETCONF_MATCH_DEVICE = 0x40,
|
||||
PCI_GETCONF_MATCH_CLASS = 0x80
|
||||
} pci_getconf_flags;
|
||||
|
||||
struct pcisel {
|
||||
u_int8_t pc_bus; /* bus number */
|
||||
u_int8_t pc_dev; /* device on this bus */
|
||||
u_int8_t pc_func; /* function on this device */
|
||||
u_int8_t pc_bus; /* bus number */
|
||||
u_int8_t pc_dev; /* device on this bus */
|
||||
u_int8_t pc_func; /* function on this device */
|
||||
};
|
||||
|
||||
struct pci_conf {
|
||||
struct pcisel pc_sel; /* bus+slot+function */
|
||||
u_int8_t pc_hdr; /* PCI header type */
|
||||
u_int16_t pc_subvendor; /* card vendor ID */
|
||||
u_int16_t pc_subdevice; /* card device ID, assigned by
|
||||
struct pcisel pc_sel; /* bus+slot+function */
|
||||
u_int8_t pc_hdr; /* PCI header type */
|
||||
u_int16_t pc_subvendor; /* card vendor ID */
|
||||
u_int16_t pc_subdevice; /* card device ID, assigned by
|
||||
card vendor */
|
||||
u_int16_t pc_vendor; /* chip vendor ID */
|
||||
u_int16_t pc_device; /* chip device ID, assigned by
|
||||
u_int16_t pc_vendor; /* chip vendor ID */
|
||||
u_int16_t pc_device; /* chip device ID, assigned by
|
||||
chip vendor */
|
||||
u_int8_t pc_class; /* chip PCI class */
|
||||
u_int8_t pc_subclass; /* chip PCI subclass */
|
||||
u_int8_t pc_progif; /* chip PCI programming interface */
|
||||
u_int8_t pc_revid; /* chip revision ID */
|
||||
char pd_name[PCI_MAXNAMELEN + 1]; /* Name of peripheral
|
||||
device */
|
||||
u_long pd_unit; /* Unit number */
|
||||
u_int8_t pc_class; /* chip PCI class */
|
||||
u_int8_t pc_subclass; /* chip PCI subclass */
|
||||
u_int8_t pc_progif; /* chip PCI programming interface */
|
||||
u_int8_t pc_revid; /* chip revision ID */
|
||||
char pd_name[PCI_MAXNAMELEN + 1]; /* device name */
|
||||
u_long pd_unit; /* device unit number */
|
||||
};
|
||||
|
||||
struct pci_match_conf {
|
||||
struct pcisel pc_sel; /* bus+slot+function */
|
||||
char pd_name[PCI_MAXNAMELEN + 1]; /* Name of peripheral
|
||||
device */
|
||||
u_long pd_unit; /* Unit number */
|
||||
u_int16_t pc_vendor; /* PCI Vendor ID */
|
||||
u_int16_t pc_device; /* PCI Device ID */
|
||||
u_int8_t pc_class; /* PCI class */
|
||||
pci_getconf_flags flags; /* Matching expression */
|
||||
struct pcisel pc_sel; /* bus+slot+function */
|
||||
char pd_name[PCI_MAXNAMELEN + 1]; /* device name */
|
||||
u_long pd_unit; /* Unit number */
|
||||
u_int16_t pc_vendor; /* PCI Vendor ID */
|
||||
u_int16_t pc_device; /* PCI Device ID */
|
||||
u_int8_t pc_class; /* PCI class */
|
||||
pci_getconf_flags flags; /* Matching expression */
|
||||
};
|
||||
|
||||
struct pci_conf_io {
|
||||
u_int32_t pat_buf_len; /*
|
||||
* Length of buffer passed in from
|
||||
* user space.
|
||||
*/
|
||||
u_int32_t num_patterns; /*
|
||||
* Number of pci_match_conf structures
|
||||
* passed in by the user.
|
||||
*/
|
||||
struct pci_match_conf *patterns; /*
|
||||
* Patterns passed in by the user.
|
||||
*/
|
||||
u_int32_t match_buf_len;/*
|
||||
* Length of match buffer passed
|
||||
* in by the user.
|
||||
*/
|
||||
u_int32_t num_matches; /*
|
||||
* Number of matches returned by
|
||||
* the kernel.
|
||||
*/
|
||||
struct pci_conf *matches; /*
|
||||
* PCI device matches returned by
|
||||
* the kernel.
|
||||
*/
|
||||
u_int32_t offset; /*
|
||||
* Passed in by the user code to
|
||||
* indicate where the kernel should
|
||||
* start traversing the device list.
|
||||
* The value passed out by the kernel
|
||||
* points to the record immediately
|
||||
* after the last one returned.
|
||||
* i.e. this value may be passed back
|
||||
* unchanged by the user for a
|
||||
* subsequent call.
|
||||
*/
|
||||
u_int32_t generation; /*
|
||||
* PCI configuration generation.
|
||||
* This only needs to be set if the
|
||||
* offset is set. The kernel will
|
||||
* compare its current generation
|
||||
* number to the generation passed
|
||||
* in by the user to determine
|
||||
* whether the PCI device list has
|
||||
* changed since the user last
|
||||
* called the GETCONF ioctl.
|
||||
*/
|
||||
pci_getconf_status status; /*
|
||||
* Status passed back from the
|
||||
* kernel.
|
||||
*/
|
||||
u_int32_t pat_buf_len; /* pattern buffer length */
|
||||
u_int32_t num_patterns; /* number of patterns */
|
||||
struct pci_match_conf *patterns; /* pattern buffer */
|
||||
u_int32_t match_buf_len; /* match buffer length */
|
||||
u_int32_t num_matches; /* number of matches returned */
|
||||
struct pci_conf *matches; /* match buffer */
|
||||
u_int32_t offset; /* offset into device list */
|
||||
u_int32_t generation; /* device list generation */
|
||||
pci_getconf_status status; /* request status */
|
||||
};
|
||||
|
||||
struct pci_io {
|
||||
struct pcisel pi_sel; /* device to operate on */
|
||||
int pi_reg; /* configuration register to examine */
|
||||
int pi_width; /* width (in bytes) of read or write */
|
||||
u_int32_t pi_data; /* data to write or result of read */
|
||||
struct pcisel pi_sel; /* device to operate on */
|
||||
int pi_reg; /* configuration register to examine */
|
||||
int pi_width; /* width (in bytes) of read or write */
|
||||
u_int32_t pi_data; /* data to write or result of read */
|
||||
};
|
||||
|
||||
|
||||
@ -125,4 +112,4 @@ struct pci_io {
|
||||
#define PCIOCWRITE _IOWR('p', 3, struct pci_io)
|
||||
#define PCIOCATTACHED _IOWR('p', 4, struct pci_io)
|
||||
|
||||
#endif /* _PCI_IOCTL_H */
|
||||
#endif /* !_SYS_PCIIO_H_ */
|
||||
|
@ -40,9 +40,7 @@ static const char rcsid[] =
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <pci/pcivar.h>
|
||||
#include <pci/pci_ioctl.h>
|
||||
#include <sys/pciio.h>
|
||||
|
||||
#include "pathnames.h"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user