2.5.WD_PciConfigDump()

Purpose

Reads/writes from/to the PCI configuration space of a selected PCI card or the extended configuration space of a selected PCI Express card.

[Note]
Access to the PCI Express extended configuration space is supported on target platforms that support such access (e.g., Windows and Linux). For such platforms, all PCI references in the following documentation include PCI Express as well.
Prototype
DWORD WD_PciConfigDump(
    HANDLE hWD,
    WD_PCI_CONFIG_DUMP *pConfig);
Parameters
NameTypeInput/Output
hWDHANDLEInput
pConfigWD_PCI_CONFIG_DUMP*
pciSlotWD_PCI_SLOT
*dwBusDWORDInput
*dwSlotDWORDInput
*dwFunctionDWORDInput
pBufferPVOIDInput/Output
dwOffsetDWORDInput
dwBytesDWORDInput
fIsReadDWORDInput
dwResultDWORDOutput
Description
NameDescription
hWDHandle to WinDriver's kernel-mode driver as received from WD_Open()[5.2]
pConfigPointer to a PCI configuration space information structure:
pciSlotPCI slot information structure:
*dwBusPCI bus number (0 based)
*dwSlotPCI slot number (0 based)
*dwFunctionPCI function number (0 based)
pBuffer A pointer to the data that is read from the PCI configuration space (if fIsRead is TRUE) or a pointer to the data to write to the PCI configuration space (if fIsRead is FALSE)
dwOffset The offset of the specific register(s) in the PCI configuration space to read/write from/to
dwBytesNumber of bytes to read/write
fIsRead If TRUE — read from the PCI configuration space;
If FALSE — write to the PCI configuration space
dwResult Result of the PCI configuration space read/write. Can be any of the following PCI_ACCESS_RESULT enumeration values:
PCI_ACCESS_OK — read/write succeeded
PCI_ACCESS_ERROR — read/write failed
PCI_BAD_BUS — the specified bus does not exist
PCI_BAD_SLOT — the specified slot or function does not exist
Return Value

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

Example
WD_PCI_CONFIG_DUMP pciConfig;
DWORD dwStatus;
WORD aBuffer[2];

BZERO(pciConfig);
pciConfig.pciSlot.dwBus = 0;
pciConfig.pciSlot.dwSlot = 3;
pciConfig.pciSlot.dwFunction = 0;
pciConfig.pBuffer = aBuffer;
pciConfig.dwOffset = 0;
pciConfig.dwBytes = sizeof(aBuffer);
pciConfig.fIsRead = TRUE;

dwStatus = WD_PciConfigDump(hWD, &pciConfig);
if (dwStatus)
{
    printf("WD_PciConfigDump failed: %s\n", Stat2Str(dwStatus));
}
else
{
    printf("Card in Bus 0, Slot 3, Funcion 0 has Vendor ID %x "
        "Device ID %x\n", aBuffer[0], aBuffer[1]);
}