Compartilhar via


DeviceConfig (Compact 2013)

3/26/2014

This function configures a device using a non-standard method. It is the main entry point called by the PCI bus driver.

Syntax

DWORD DeviceConfig(
  DWORD Command, 
  PPCI_DEV_INFO pInfo,
  PPCI_RSRC pRsrc1,
  PPCI_RSRC pRsrc2,
  DWORD* pMemSize,
  DWORD* pIoSize
);

Parameters

  • Command
    [in] PCI bus configuration function to call.

    The following table shows the possible values.

    Value

    Description

    PCIBUS_CONFIG_RSRC

    Calls the ConfigRsrc function to gather device resources and update the total memory and I/O size requirements.

    PCIBUS_CONFIG_SET

    Calls the ConfigSet function to set base addresses for device resources.

    PCIBUS_CONFIG_SIZE

    Calls the ConfigSize function to query device resource sizes.

    PCIBUS_CONFIG_INIT

    Calls the ConfigInit function to perform necessary device initialization procedures.

  • pRsrc1
    [in] Pointer to a PCI_RSRC structure.
  • pRsrc2
    [in] Pointer to a PCI_RSRC structure.
  • pMemSize
    [in] Pointer to a memory resource size accumulator.
  • pIoSize
    [in] Pointer to an I/O resource size accumulator.

Return Value

The following table shows return values for this function.

Return value

Description

ERROR_SUCCESS

Occurs if the call to the function specified by the flag in the Command parameter succeeds.

ERROR_GEN_FAILURE

Occurs if the call to the function specified by the flag in the Command parameter fails.

ERROR_BAD_COMMAND

Occurs if the flag specified by the Command parameter is not recognized.

Remarks

The ConfigEntry value under the device's registry key specifies the name of this function. The following registry key example shows this specification.

[HKEY_LOCAL_MACHINE\Drivers\Builtin\PCI\Template\DriverXXX]
    "ConfigDll"="DriverXXX_cfg.dll"
    "ConfigEntry"="DeviceConfig"

ConfigDll is required only if DeviceConfig is implemented in a separate DLL from the device driver. If ConfigDll is not specified, the DeviceConfig function is assumed to be implemented in the device driver DLL.

The PCI bus driver calls DeviceConfig four times in this order:

  1. When the Command parameter is equal to PCIBUS_CONFIG_RSRC during the resource information gathering stage.
    DeviceConfig is expected to return the size of the resources it requires.
  2. When the Command parameter is equal to PCIBUS_CONFIG_SET to set the base address registers (BARs) with addresses generated by the PCI bus driver.
  3. When the Command parameter is equal to PCIBUS_CONFIG_SIZE when the PCI bus driver is enumerating the bus and requesting size information of the resources it requires.
  4. When the Command parameter is equal to PCIBUS_CONFIG_INIT to allow DeviceConfig to perform any initialization steps required by the device.

Gdcfg.c shows an example of how to implement DeviceConfig so that it mimics the usual operation of the PCI bus driver. It is a good starting point for modifying your DeviceConfig routine.

Requirements

Header

gdcfg.c

Library

Gdcfg.lib

See Also

Reference

Device Configuration Functions
ConfigInit
ConfigRsrc
ConfigSet
ConfigSize
PCI_DEV_INFO
PCI_RSRC