enable configuration space accesses and return data port address */
| 205 | |
| 206 | /* enable configuration space accesses and return data port address */ |
| 207 | static int |
| 208 | pci_cfgenable(unsigned bus, unsigned slot, unsigned func, int reg, int bytes) |
| 209 | { |
| 210 | int dataport = 0; |
| 211 | |
| 212 | if (bus <= PCI_BUSMAX |
| 213 | && slot < devmax |
| 214 | && func <= PCI_FUNCMAX |
| 215 | && (unsigned)reg <= PCI_REGMAX |
| 216 | && bytes != 3 |
| 217 | && (unsigned)bytes <= 4 |
| 218 | && (reg & (bytes - 1)) == 0) { |
| 219 | switch (cfgmech) { |
| 220 | case CFGMECH_PCIE: |
| 221 | case CFGMECH_1: |
| 222 | outl(CONF1_ADDR_PORT, (1U << 31) |
| 223 | | (bus << 16) | (slot << 11) |
| 224 | | (func << 8) | (reg & ~0x03)); |
| 225 | dataport = CONF1_DATA_PORT + (reg & 0x03); |
| 226 | break; |
| 227 | case CFGMECH_2: |
| 228 | outb(CONF2_ENABLE_PORT, 0xf0 | (func << 1)); |
| 229 | outb(CONF2_FORWARD_PORT, bus); |
| 230 | dataport = 0xc000 | (slot << 8) | reg; |
| 231 | break; |
| 232 | } |
| 233 | } |
| 234 | return (dataport); |
| 235 | } |
| 236 | |
| 237 | /* disable configuration space accesses */ |
| 238 | static void |
no test coverage detected