Bus Enumerator (Windows CE 5.0)

Send Feedback

The bus enumerator, BusEnum.dll, exports the Init and Deinit functions. It finds new devices by reading entries from the registry. The Device Manager can call the bus enumerator again while a previous invocation is still active. Because the bus enumerator supports hierarchical usage, it can load itself over a different registry key. When the bus enumerator is unloaded, it unloads anything it directly loaded.

The bus enumerator loads built-in drivers at boot time and eventually loads PCI drivers. It exposes a bus interface to support driver unloading and reloading. The bus enumerator provides bus names for the drivers that it loads. Because the bus enumerator does not support bus power management, built-in devices require power management support from the OAL.

The base bus name is a bus enumerator parameter, which, if absent, suppresses bus naming. This is because the bus enumerator also loads services.

The Device Manager loads the bus enumerator by checking HKEY_LOCAL_MACHINE\Drivers\RootKey to determine where to start the driver loading process. The default value of RootKey is Drivers. The Device Manager loads the driver indicated by that key, which is typically BusEnum.dll.

The bus enumerator examines its root key, which is the registry key passed to it, by looking for subkeys that describe drivers to load. The following list shows the subkeys these keys contain:

  • Built-in or native devices
  • ISA devices
  • The PCI bus
  • Virtual devices, such as the Network Driver Interface Specification (NDIS)
  • Optional protocol elements, such as Simple Network Management Protocol (SNMP) or Point-to-Point Protocol (PPP)
  • Other non-enumerable operating system (OS) components.

BusEnum.dll examines the first level of keys just below the key passed to it, according to the Order registry subkey. It invokes ActivateDeviceEx on each subkey it finds. The bus enumerator generally runs with the DEVFLAGS_UNLOAD flag.

Each subkey can have any values typically interpreted by ActivateDeviceEx or by the driver ultimately loaded. Additionally, each subkey can have an Order value between 0 and 255. The smallest Order value gets loaded first. If there is no Order value, the driver gets loaded after drivers with defined Order values.

Entry points of drivers that expose the stream interface are constructed from the Prefix value. If the registry entry for the driver does not contain a Prefix value, the entry points do not have a prefix. For example, a serial driver with Prefix equal to COM has an entry point of COM_Init. If there is no Prefix value, then the entry point is Init. The bus enumerator driver does all of its work in its Init entry point and the Device Manager can unload it when Init returns.

As the bus enumerator initializes the system, it traverses the subkeys of HKEY_LOCAL_MACHINE\Drivers\BuiltIn or wherever the HKEY_LOCAL_MACHINE\Drivers\RootKey value points. The bus enumerator traverses the subkeys one by one, initializing a driver for each subkey. It loads the DLL indicated by the DLL value, and then creates a subkey for the driver under HKEY_LOCAL_MACHINE\Drivers\Active. Then, it calls the Init function or the driver's entry point and passes in a string containing that subkey.

Using the string it gets in return, the XXX_Init routine should call RegOpenKeyEx to get a handle for this key, and then call RegQueryValueEx to look up the key value, which contains the string corresponding to the registry key that Device Manager originally encountered under HKEY_LOCAL_MACHINE\Drivers\BuiltIn.

It is common for device driver writers to include other values in their registry keys. These values can indicate the I/O port address, the IRQ setting, the DMA settings, or any additional information needed.

The following registry key example shows the generic registry key format for a device called Sample. You can find other examples in Platform.reg files or registry files in directories that contain device drivers.

[HKEY_LOCAL_MACHINE\Drivers\BuiltIn\Sample]
    "Dll" = "sampledev.dll"
    "Prefix" = "SMP"
    "Index" = dword:1
    "Order" = dword:0
    "FriendlyName" = "Sample Controller"
    "Ioctl" = dword:0

Using the above registry settings, the Device Manager creates a new key. Then, it calls SMP_Init and passes in a pointer to the new key. SMP_Init then calls RegOpenKeyEx to get a handle for the key. Then, it calls RegQueryValueEx to get the string "\Drivers\BuiltIn\Sample". XXX_Init can then use this string to open that key and access other information placed there. For non-stream drivers, if there is no Prefix value, Init is the assumed entry point.

See Also

ActivateDeviceEx | PCI Bus Driver

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.