1#- 2# Copyright (c) 1998 Doug Rabson 3# All rights reserved. 4# 5# Redistribution and use in source and binary forms, with or without 6# modification, are permitted provided that the following conditions 7# are met: 8# 1. Redistributions of source code must retain the above copyright 9# notice, this list of conditions and the following disclaimer. 10# 2. Redistributions in binary form must reproduce the above copyright 11# notice, this list of conditions and the following disclaimer in the 12# documentation and/or other materials provided with the distribution. 13# 14# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24# SUCH DAMAGE. 25# 26# $FreeBSD$ 27# 28 29#include <sys/bus.h> 30#include <dev/pci/pcivar.h> 31 32INTERFACE pci; 33 34CODE { 35 static int 36 null_msi_count(device_t dev, device_t child) 37 { 38 return (0); 39 } 40 41 static int 42 null_msix_bar(device_t dev, device_t child) 43 { 44 return (-1); 45 } 46 47 static device_t 48 null_create_iov_child(device_t bus, device_t pf, uint16_t rid, 49 uint16_t vid, uint16_t did) 50 { 51 device_printf(bus, "PCI_IOV not implemented on this bus.\n"); 52 return (NULL); 53 } 54}; 55 56HEADER { 57 struct nvlist; 58 59 enum pci_id_type { 60 PCI_ID_RID, 61 PCI_ID_MSI, 62 }; 63 64 enum pci_feature { 65 PCI_FEATURE_HP, /* Hot Plug feature */ 66 PCI_FEATURE_AER, /* Advanced Error Reporting */ 67 }; 68} 69 70 71METHOD u_int32_t read_config { 72 device_t dev; 73 device_t child; 74 int reg; 75 int width; 76}; 77 78METHOD void write_config { 79 device_t dev; 80 device_t child; 81 int reg; 82 u_int32_t val; 83 int width; 84}; 85 86METHOD int get_powerstate { 87 device_t dev; 88 device_t child; 89}; 90 91METHOD int set_powerstate { 92 device_t dev; 93 device_t child; 94 int state; 95}; 96 97METHOD int get_vpd_ident { 98 device_t dev; 99 device_t child; 100 const char **identptr; 101}; 102 103METHOD int get_vpd_readonly { 104 device_t dev; 105 device_t child; 106 const char *kw; 107 const char **vptr; 108}; 109 110METHOD int enable_busmaster { 111 device_t dev; 112 device_t child; 113}; 114 115METHOD int disable_busmaster { 116 device_t dev; 117 device_t child; 118}; 119 120METHOD int enable_io { 121 device_t dev; 122 device_t child; 123 int space; 124}; 125 126METHOD int disable_io { 127 device_t dev; 128 device_t child; 129 int space; 130}; 131 132METHOD int assign_interrupt { 133 device_t dev; 134 device_t child; 135}; 136 137METHOD int find_cap { 138 device_t dev; 139 device_t child; 140 int capability; 141 int *capreg; 142}; 143 144METHOD int find_extcap { 145 device_t dev; 146 device_t child; 147 int capability; 148 int *capreg; 149}; 150 151METHOD int find_htcap { 152 device_t dev; 153 device_t child; 154 int capability; 155 int *capreg; 156}; 157 158METHOD int alloc_msi { 159 device_t dev; 160 device_t child; 161 int *count; 162}; 163 164METHOD int alloc_msix { 165 device_t dev; 166 device_t child; 167 int *count; 168}; 169 170METHOD void enable_msi { 171 device_t dev; 172 device_t child; 173 uint64_t address; 174 uint16_t data; 175}; 176 177METHOD void enable_msix { 178 device_t dev; 179 device_t child; 180 u_int index; 181 uint64_t address; 182 uint32_t data; 183}; 184 185METHOD void disable_msi { 186 device_t dev; 187 device_t child; 188}; 189 190METHOD int remap_msix { 191 device_t dev; 192 device_t child; 193 int count; 194 const u_int *vectors; 195}; 196 197METHOD int release_msi { 198 device_t dev; 199 device_t child; 200}; 201 202METHOD int msi_count { 203 device_t dev; 204 device_t child; 205} DEFAULT null_msi_count; 206 207METHOD int msix_count { 208 device_t dev; 209 device_t child; 210} DEFAULT null_msi_count; 211 212METHOD int msix_pba_bar { 213 device_t dev; 214 device_t child; 215} DEFAULT null_msix_bar; 216 217METHOD int msix_table_bar { 218 device_t dev; 219 device_t child; 220} DEFAULT null_msix_bar; 221 222METHOD int get_id { 223 device_t dev; 224 device_t child; 225 enum pci_id_type type; 226 uintptr_t *id; 227}; 228 229METHOD struct pci_devinfo * alloc_devinfo { 230 device_t dev; 231}; 232 233METHOD void child_added { 234 device_t dev; 235 device_t child; 236}; 237 238METHOD int iov_attach { 239 device_t dev; 240 device_t child; 241 struct nvlist *pf_schema; 242 struct nvlist *vf_schema; 243 const char *name; 244}; 245 246METHOD int iov_detach { 247 device_t dev; 248 device_t child; 249}; 250 251METHOD device_t create_iov_child { 252 device_t bus; 253 device_t pf; 254 uint16_t rid; 255 uint16_t vid; 256 uint16_t did; 257} DEFAULT null_create_iov_child; 258