Changeset View
Changeset View
Standalone View
Standalone View
head/sys/dev/pci/pci.c
Show First 20 Lines • Show All 3,974 Lines • ▼ Show 20 Lines | |||||
#undef REG | #undef REG | ||||
} | } | ||||
int | int | ||||
pci_rescan_method(device_t dev) | pci_rescan_method(device_t dev) | ||||
{ | { | ||||
#define REG(n, w) PCIB_READ_CONFIG(pcib, busno, s, f, n, w) | #define REG(n, w) PCIB_READ_CONFIG(pcib, busno, s, f, n, w) | ||||
device_t pcib = device_get_parent(dev); | device_t pcib = device_get_parent(dev); | ||||
struct pci_softc *sc; | |||||
device_t child, *devlist, *unchanged; | device_t child, *devlist, *unchanged; | ||||
int devcount, error, i, j, maxslots, oldcount; | int devcount, error, i, j, maxslots, oldcount; | ||||
int busno, domain, s, f, pcifunchigh; | int busno, domain, s, f, pcifunchigh; | ||||
uint8_t hdrtype; | uint8_t hdrtype; | ||||
/* No need to check for ARI on a rescan. */ | /* No need to check for ARI on a rescan. */ | ||||
error = device_get_children(dev, &devlist, &devcount); | error = device_get_children(dev, &devlist, &devcount); | ||||
if (error) | if (error) | ||||
return (error); | return (error); | ||||
if (devcount != 0) { | if (devcount != 0) { | ||||
unchanged = malloc(devcount * sizeof(device_t), M_TEMP, | unchanged = malloc(devcount * sizeof(device_t), M_TEMP, | ||||
M_NOWAIT | M_ZERO); | M_NOWAIT | M_ZERO); | ||||
if (unchanged == NULL) { | if (unchanged == NULL) { | ||||
free(devlist, M_TEMP); | free(devlist, M_TEMP); | ||||
return (ENOMEM); | return (ENOMEM); | ||||
} | } | ||||
} else | } else | ||||
unchanged = NULL; | unchanged = NULL; | ||||
sc = device_get_softc(dev); | |||||
domain = pcib_get_domain(dev); | domain = pcib_get_domain(dev); | ||||
busno = pcib_get_bus(dev); | busno = pcib_get_bus(dev); | ||||
maxslots = PCIB_MAXSLOTS(pcib); | maxslots = PCIB_MAXSLOTS(pcib); | ||||
for (s = 0; s <= maxslots; s++) { | for (s = 0; s <= maxslots; s++) { | ||||
/* If function 0 is not present, skip to the next slot. */ | /* If function 0 is not present, skip to the next slot. */ | ||||
f = 0; | f = 0; | ||||
if (REG(PCIR_VENDOR, 2) == 0xffff) | if (REG(PCIR_VENDOR, 2) == 0xffff) | ||||
continue; | continue; | ||||
▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | |||||
#undef REG | #undef REG | ||||
} | } | ||||
#ifdef PCI_IOV | #ifdef PCI_IOV | ||||
device_t | device_t | ||||
pci_add_iov_child(device_t bus, device_t pf, uint16_t rid, uint16_t vid, | pci_add_iov_child(device_t bus, device_t pf, uint16_t rid, uint16_t vid, | ||||
uint16_t did) | uint16_t did) | ||||
{ | { | ||||
struct pci_devinfo *pf_dinfo, *vf_dinfo; | struct pci_devinfo *vf_dinfo; | ||||
device_t pcib; | device_t pcib; | ||||
int busno, slot, func; | int busno, slot, func; | ||||
pf_dinfo = device_get_ivars(pf); | |||||
pcib = device_get_parent(bus); | pcib = device_get_parent(bus); | ||||
PCIB_DECODE_RID(pcib, rid, &busno, &slot, &func); | PCIB_DECODE_RID(pcib, rid, &busno, &slot, &func); | ||||
vf_dinfo = pci_fill_devinfo(pcib, bus, pci_get_domain(pcib), busno, | vf_dinfo = pci_fill_devinfo(pcib, bus, pci_get_domain(pcib), busno, | ||||
slot, func, vid, did); | slot, func, vid, did); | ||||
▲ Show 20 Lines • Show All 2,055 Lines • Show Last 20 Lines |