PCI Bus Configuration and Enumeration

PCI Bus Configuration

The PCI bus driver first configures the PCI bus if a boot loader or the system's BIOS have not previously configured PCI devices before the OS image is loaded. This step is skipped if the registry value NoConfig is set equal to dword:1 under the PCI registry key. This is useful for the CEPC because the BIOS already configures the PCI bus. Some CEPCs do not configure every possible PCI devices, such as CardBus. In order for devices to work that are not configured on a CEPC, set NoConfig equal to 1. The PCI bus driver scans the PCI bus, gathering resource information from the PCI to PCI bridges and the devices it finds. As each device is discovered, the registry is searched for a matching driver Template or Instance registry key. When the best match is found based on device identifiers such as Class, SubClass, VendorID, and so on, the corresponding registry key is examined for the presence of the ConfigEntry value. If ConfigEntry exists, the driver DLL is loaded and the configuration routine described by ConfigEntry is called to assist in allocating and placing resources.

Note   If ConfigEntry and ConfigDll values exist, then the DLL described by ConfigDll is loaded instead of the driver DLL (Dll). This mechanism is used mainly to configure non-conforming resources such as resources not in the PCI configuration registers, or to limit the resources required by the device, which is useful for systems with small PCI windows.

The Generic Device Configuration library (Gdcfg.dll) is provided as a sample. It performs the usual PCI compliant resource management and provides resource management for the expansion ROM, which is ignored by the PCI bus driver.

Once all of the resources, including memory and I/O windows, are found, the PCI bus driver places the resources within the PCI bus window. Any devices that were previously placed, such as devices used for debugging services, remain as they were, and the PCI bus driver places the resources around them. Device IRQ numbers are also allocated, using the OAL to perform the PCI IRQ to system IRQ mapping. All of the resources allocated to the devices by the PCI bus driver are requested from the I/O Resource Manager to make sure there is no overlap with other built-in devices. For more information, see IOCTL_HAL_REQUEST_SYSINTR.

PCI Bus Enumeration

The PCI bus driver then enumerates the PCI bus by re-scanning it. When a device is discovered, the registry is searched for the corresponding Template or Instance key. A best match is searched for using device identifiers such as Class, SubClass, VendorID, and so on. If an exact match is found with an Instance key, that means the device has already been configured and placed. All devices have an associated Instance key after a warm boot, or if there is registry persistence. If a best match is found with a Template key, the Template information, along with the configured resource values is copied to an Instance key for the driver. The Instance key is the key passed to the driver's entry point when the driver is loaded in the case of a non-stream driver, otherwise the Key value under the device's active key is set to the Instance key of the driver.

PCI to PCI Bridge Register Configuration

PCI to PCI bridges may need to have registers set to configure bus latencies and other board-specific parameters. There are two possibilities for configuring the PCI to PCI bridge device. These are shown in the following list:

  • The OAL can pre-enumerate, discover the bridges, and configure appropriately.

    - or -

  • Load a device driver for the bridge to do the configuration, such as through the configuration routine. The driver is unloaded after finishing the configuration.

Common PCI configuration registers can also be set in the registry for the PCI to PCI bridge device. These include Command, BridgeControl, Latency, SecondaryLatency, and NoConfig. When NoConfig is set to equal 1, the PCI bus driver does not modify the memory and I/O windows for this PCI to PCI bridge.

PCI Bus Driver Registry Enumeration

After the PCI bus is configured and enumerated, the PCI bus driver looks under the Instance key for a Dll value. This DLL, typically RegEnum.dll, enumerates the Instance key to load the device drivers for each of the device instances found on the bus. The Registry Enumerator loads the device drivers and calls their entry points according to the Order value for each driver instance. If Flags is equal to 0x0001, then the driver does not get loaded. This is useful for reserving resources, allocating resources, or both for a driver that is already loaded by the OAL, such as the Ethernet debugging adapter. For more information on other valid values Flags, see ActivateDeviceEx.

See Also

Driver Loading Process

 Last updated on Tuesday, May 18, 2004

© 1992-2003 Microsoft Corporation. All rights reserved.