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:
 * dwVendorId The vendor ID of the PCI cards to detect. If 0, the function will search for all PCI card vendor IDs.
 * dwDeviceId The 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.
• dwCards Number of cards detected for the specified search criteria set in the searchId field
• cardId Array 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
• cardSlot Array 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)
• dwOptions PCI bus scan options. Can be set to any of the WD_PCI_SCAN_OPTIONS flags:
  • 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.
  • WD_PCI_SCAN_REGISTERED — Scan all PCI buses and slots but only look for devices that have been registered to work with WinDriver.
Return Value

Returns WD_STATUS_SUCCESS (0) on success, or an appropriate error code otherwise [A].

Example
WD_PCI_SCAN_CARDS pciScan;
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");