2.3. WD_PciGetCardInfo()

Purpose

Retrieves PCI device's resource information (i.e., Memory ranges, I/O ranges, Interrupt lines).

Prototype
DWORD WD_PciGetCardInfo(
    HANDLE hWD,
    WD_PCI_CARD_INFO *pPciCard);
Parameters
NameTypeInput/Output
hWDHANDLEInput
pPciCardWD_PCI_CARD_INFO*Input
• pciSlotWD_PCI_SLOTInput
 * dwBusDWORDInput
 * dwSlotDWORDInput
 * dwFunctionDWORDInput
• CardWD_CARDInput
 * dwItemsDWORDOutput
 * ItemWD_ITEMS[WD_CARD_ITEMS]Input
  • itemDWORDOutput
  • fNotSharableDWORDOutput
  • dwReservedDWORDN/A
  • dwOptionsDWORDN/A
  • IunionInput
   * MemstructInput
    • dwPhysicalAddrDWORDOutput
    • dwBytesDWORDOutput
    • dwTransAddrKPTRN/A
    • dwUserDirectAddrUPTRN/A
    • dwCpuPhysicalAddrDWORDN/A
    • dwBarDWORDOutput
   * IOstructInput
    • dwAddrKPTROutput
    • dwBytesDWORDOutput
    • dwBarDWORDOutput
   * IntstructInput
    • dwInterruptDWORDOutput
    • dwOptionsDWORDOutput
    • hInterruptDWORDN/A
   * BusWD_BUSInput
    • dwBusTypeWD_BUS_TYPEOutput
    • dwBusNumDWORDOutput
    • dwSlotFuncDWORDOutput
   * ValstructN/A
Description
NameDescription
hWDHandle to WinDriver's kernel-mode driver as received from WD_Open() [5.2]
pPciCardPointer to a PCI card information structure:
• pciSlotPCI slot information structure:
 * dwBusPCI bus number (0 based)
 * dwSlotPCI slot number (0 based)
 * dwFunctionPCI function number (0 based)
• CardCard information structure:
 * dwItemsNumber of items detected on the card
 * ItemCard items information structure:
  • item Type of item. Can be ITEM_MEMORY, ITEM_IO, ITEM_INTERRUPT or ITEM_BUS.
  • fNotSharable
  • 1 — Non-sharable resource; should be locked for exclusive use
  • 0 — Sharable resource
Note: You can modify the value of this field before registering the card and its resources using WD_CardRegister() [2.8].
  • ISpecific data according to the item type:
   * MemDescribes a memory item (item = ITEM_MEMORY):
    • dwPhysicalAddr First address of the physical memory range.
NOTE: For 64-bit BARs the value stored in this field may be incorrect, due to the 32-bit field size.
    • dwBytesLength of the memory range, in bytes
    • dwBarBase Address Register (BAR) number of the memory range
   * IODescribes an I/O item (item = ITEM_IO):
    • dwAddrFirst address of the I/O range
    • dwBytesLength of the I/O range, in bytes
    • dwBarBase Address Register (BAR) number for the I/O range
   * Int Describes an interrupt item (item = ITEM_INTERRUPT):
    • dwInterruptPhysical interrupt request (IRQ) number
    • dwOptions Interrupt options bit-mask, which can consist of a combination of any of the following flags for indicating the interrupt types supported by the device.
The default interrupt type, when none of the following flags is set, is legacy edge-triggered interrupts.
INTERRUPT_MESSAGE_X — Indicates that the hardware supports Extended Message-Signaled Interrupts (MSI-X).
This option is applicable only to PCI cards on Linux — see information in the WinDriver PCI Manual.
INTERRUPT_MESSAGE — On Linux, indicates that the hardware supports Message-Signaled Interrupts (MSI).
On Windows, indicates that the hardware supports MSI or MSI-X.
This option is applicable only to PCI cards on Linux and Windows Vista and higher — see information in the WinDriver PCI Manual.
INTERRUPT_LEVEL_SENSITIVE — Indicates that the hardware supports level-sensitive interrupts.
   * BusDescribes a bus item (item = ITEM_BUS):
    • dwBusType The card's bus type. For a PCI card the bus type is WD_BUS_PCI
    • dwBusNumThe card's bus number
    • dwSlotFunc A combination of the card's bus slot and function numbers: the lower three bits represent the function number and the remaining bits represent the slot number. For example: a value of 0x80 (<=> 10000000 binary) corresponds to a function number of 0 (lower 3 bits: 000) and a slot number of 0x10 (remaining bits: 10000).
Return Value

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

Remarks
  • For PCI devices, if the I/O, memory and IRQ information is available from the Plug-and-Play Manager, the information is obtained from there. Otherwise, the information is read directly from the PCI configuration registers. Note: for Windows, you must have an inf file installed.
  • If the IRQ is obtained from the Plug-and-Play Manager, it is mapped and therefore may differ from the physical IRQ.

Example
WD_PCI_CARD_INFO pciCardInfo;
WD_CARD Card;

BZERO(pciCardInfo);
pciCardInfo.pciSlot = pciSlot;
WD_PciGetCardInfo(hWD, &pciCardInfo);
if (pciCardInfo.Card.dwItems!=0) /* At least one item was found */
{
    Card = pciCardInfo.Card;
}
else
{
    printf("Failed fetching PCI card information\n");
}