MCPcopy Create free account
hub / github.com/F-Stack/f-stack / pci_cfgenable

Function pci_cfgenable

freebsd/i386/pci/pci_cfgreg.c:207–235  ·  view source on GitHub ↗

enable configuration space accesses and return data port address */

Source from the content-addressed store, hash-verified

205
206/* enable configuration space accesses and return data port address */
207static int
208pci_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 */
238static void

Callers 3

pcireg_cfgreadFunction · 0.70
pcireg_cfgwriteFunction · 0.70
pci_cfgcheckFunction · 0.70

Calls 2

outlFunction · 0.50
outbFunction · 0.50

Tested by

no test coverage detected