2,179
社区成员
发帖
与我相关
我的任务
分享
PRIVATE STATUS probPciDevice(UINT bus, PCI_TARGET_INFO* target)
{
UINT32 dev_vend; /* Device/Vendor identifier */
int device; /* Device location */
int function; /* Function location */
UINT8 btemp; /* Temporary holding area */
if(target==NULL)
{
PCI_PRINT(SYSLOG_LEVEL_ERROR,"NULL pointer.\n");
return ERROR;
}
/* Locate each active function on the current bus */
for (device = 0; device < PCI_MAX_DEV; device++)
{
/* Check each function until an unused one is detected */
for (function = 0; function < PCI_MAX_FUNC; function++)
{
/* Check for a valid device/vendor number */
pciConfigInLong (bus, device, function, PCI_CFG_VENDOR_ID, &dev_vend);
/* If function 0 then check next dev else check next function */
if ( ((dev_vend & 0x0000ffff) == 0xFFFF) || ((dev_vend & 0x0000ffff) == 0x0000) )
{
if (function == 0)
break; /* non-existent device, goto next device */
else
continue; /* function empty, try the next function */
}
if(((dev_vend & 0x0000ffff) == target->vendorId) || (((dev_vend>>16) & 0x0000ffff) == target->deviceId) )
{
PCI_PRINT(SYSLOG_LEVEL_DEBUG,"Found PCI device: vendorID=%04X, deviceID=%04X, bus=%d, device=%d, function=%d\n",
target->vendorId, target->deviceId, bus, device,function);
target->busNo = bus;
target->deviceNo = device;
target->funcionNo = function;
return OK;
}
/* Proceed to next device if this is a single function device */
if (function == 0)
{
pciConfigInByte (bus, device, function, PCI_CFG_HEADER_TYPE, &btemp);
if ((btemp & PCI_HEADER_MULTI_FUNC) == 0)
break;
}
}
}
return ERROR;
}