2.2  WD_PciScanCards

PURPOSE
• Detects PCI devices installed on the PCI bus, which conform to the input criteria (vendor ID and/or card ID), and returns the number and location (bus, slot and function) of the detected devices.
PROTOTYPE
DWORD WD_PciScanCards(
    HANDLE hWD,
    WD_PCI_SCAN_CARDS *pPciScan);
PARAMETERS
NameTypeInput/Output
hWDHANDLEInput
pPciScanWD_PCI_SCAN_CARDS* 
• searchIdWD_PCI_ID 
 * dwVendorIdDWORDInput
 * dwDeviceIdDWORDInput
• dwCardsDWORDOutput
• cardIdWD_PCI_ID[WD_PCI_CARDS] 
 * dwVendorIdDWORDOutput
 * dwDeviceIdDWORDOutput
• cardSlotWD_PCI_SLOT[WD_PCI_CARDS] 
 * dwBusDWORDOutput
 * dwSlotDWORDOutput
 * dwFunctionDWORDOutput
• dwOptionsDWORDInput
DESCRIPTION
NameDescription
hWDHandle to WinDriver's kernel-mode driver as received from WD_Open [5.2]
pPciScanPointer to a PCI bus scan information structure:
• searchIdPCI card ID information structure:
 * dwVendorIdThe vendor ID of the PCI cards to detect. If 0, the function will search for all PCI card vendor IDs.
 * dwDeviceIdThe card ID of the PCI cards to detect. If 0, the function will search for all PCI card IDs.
If both dwVendorId and dwDeviceId are set to 0 the function will return information regarding all connected PCI cards.
• dwCardsNumber of cards detected for the specified search criteria set in the searchId field
• cardIdArray of PCI card ID information structures for the detected PCI cards that match the search criteria set in the searchId field:
 * dId.dwVendorIdVendor ID
 * dId.dwDeviceIdCard ID
• cardSlotArray of PCI slot information structures for the detected PCI cards that match the search criteria set in the searchId field:
 * dwBusBus number (0 based)
 * dwSlotSlot number (0 based)
 * dwFunctionFunction number (0 based)
• dwOptionsPCI bus scan options. Can be either of the following:
WD_PCI_SCAN_DEFAULT: Scan all PCI buses and slots.
This is the default scan option.
WD_PCI_SCAN_BY_TOPOLOGY: Scan the PCI bus by topology.
RETURN VALUE
Returns WD_STATUS_SUCCESS(0) on success, or an appropriate error code otherwise [A].
EXAMPLE
WD_PCI_SCAN_CARDS pciScan;
DWORD cards_found;
WD_PCI_SLOT pciSlot;

BZERO(pciScan);
pciScan.searchId.dwVendorId = 0x12bc;
pciScan.searchId.dwDeviceId = 0x1;
WD_PciScanCards(hWD, &pciScan);
if (pciScan.dwCards>0) /* Found at least one device */
    pciSlot = pciScan.cardSlot[0]; /* Use the first card found */
else
    printf("No matching PCI devices found\n");