1 #ifndef _PCI_IOCTL_H 2 #define _PCI_IOCTL_H 1 3 4 #include <sys/ioccom.h> 5 6 7 #define PCI_MAXNAMELEN 16 /* max no. of characters in a device name */ 8 9 typedef enum { 10 PCI_GETCONF_LAST_DEVICE, 11 PCI_GETCONF_LIST_CHANGED, 12 PCI_GETCONF_MORE_DEVS, 13 PCI_GETCONF_ERROR 14 } pci_getconf_status; 15 16 typedef enum { 17 PCI_GETCONF_NO_MATCH = 0x00, 18 PCI_GETCONF_MATCH_BUS = 0x01, 19 PCI_GETCONF_MATCH_DEV = 0x02, 20 PCI_GETCONF_MATCH_FUNC = 0x04, 21 PCI_GETCONF_MATCH_NAME = 0x08, 22 PCI_GETCONF_MATCH_UNIT = 0x10, 23 PCI_GETCONF_MATCH_VENDOR = 0x20, 24 PCI_GETCONF_MATCH_DEVICE = 0x40, 25 PCI_GETCONF_MATCH_CLASS = 0x80 26 } pci_getconf_flags; 27 28 struct pcisel { 29 u_int8_t pc_bus; /* bus number */ 30 u_int8_t pc_dev; /* device on this bus */ 31 u_int8_t pc_func; /* function on this device */ 32 }; 33 34 struct pci_conf { 35 struct pcisel pc_sel; /* bus+slot+function */ 36 u_int8_t pc_hdr; /* PCI header type */ 37 u_int16_t pc_subvendor; /* card vendor ID */ 38 u_int16_t pc_subdevice; /* card device ID, assigned by 39 card vendor */ 40 u_int16_t pc_vendor; /* chip vendor ID */ 41 u_int16_t pc_device; /* chip device ID, assigned by 42 chip vendor */ 43 u_int8_t pc_class; /* chip PCI class */ 44 u_int8_t pc_subclass; /* chip PCI subclass */ 45 u_int8_t pc_progif; /* chip PCI programming interface */ 46 u_int8_t pc_revid; /* chip revision ID */ 47 char pd_name[PCI_MAXNAMELEN + 1]; /* Name of peripheral 48 device */ 49 u_long pd_unit; /* Unit number */ 50 }; 51 52 struct pci_match_conf { 53 struct pcisel pc_sel; /* bus+slot+function */ 54 char pd_name[PCI_MAXNAMELEN + 1]; /* Name of peripheral 55 device */ 56 u_long pd_unit; /* Unit number */ 57 u_int16_t pc_vendor; /* PCI Vendor ID */ 58 u_int16_t pc_device; /* PCI Device ID */ 59 u_int8_t pc_class; /* PCI class */ 60 pci_getconf_flags flags; /* Matching expression */ 61 }; 62 63 struct pci_conf_io { 64 u_int32_t pat_buf_len; /* 65 * Length of buffer passed in from 66 * user space. 67 */ 68 u_int32_t num_patterns; /* 69 * Number of pci_match_conf structures 70 * passed in by the user. 71 */ 72 struct pci_match_conf *patterns; /* 73 * Patterns passed in by the user. 74 */ 75 u_int32_t match_buf_len;/* 76 * Length of match buffer passed 77 * in by the user. 78 */ 79 u_int32_t num_matches; /* 80 * Number of matches returned by 81 * the kernel. 82 */ 83 struct pci_conf *matches; /* 84 * PCI device matches returned by 85 * the kernel. 86 */ 87 u_int32_t offset; /* 88 * Passed in by the user code to 89 * indicate where the kernel should 90 * start traversing the device list. 91 * The value passed out by the kernel 92 * points to the record immediately 93 * after the last one returned. 94 * i.e. this value may be passed back 95 * unchanged by the user for a 96 * subsequent call. 97 */ 98 u_int32_t generation; /* 99 * PCI configuration generation. 100 * This only needs to be set if the 101 * offset is set. The kernel will 102 * compare its current generation 103 * number to the generation passed 104 * in by the user to determine 105 * whether the PCI device list has 106 * changed since the user last 107 * called the GETCONF ioctl. 108 */ 109 pci_getconf_status status; /* 110 * Status passed back from the 111 * kernel. 112 */ 113 }; 114 115 struct pci_io { 116 struct pcisel pi_sel; /* device to operate on */ 117 int pi_reg; /* configuration register to examine */ 118 int pi_width; /* width (in bytes) of read or write */ 119 u_int32_t pi_data; /* data to write or result of read */ 120 }; 121 122 123 #define PCIOCGETCONF _IOWR('p', 1, struct pci_conf_io) 124 #define PCIOCREAD _IOWR('p', 2, struct pci_io) 125 #define PCIOCWRITE _IOWR('p', 3, struct pci_io) 126 #define PCIOCATTACHED _IOWR('p', 4, struct pci_io) 127 128 #endif /* _PCI_IOCTL_H */ 129