Writing an HCD Module

To support USB on a Windows CE–based platform, OEMs must customize the HCD module included with the Platform Builder. Microsoft provides a sample HCD module that works with OHCD-compliant USB host controllers. The sample OHCD is designed for a Windows CE–based platform. OEMs must port the sample OHCD to their platforms as part of their OAL implementations.

To ease the porting effort, the OHCD is divided into two parts: a platform-independent MDD and a small PDD. This is similar to the MDD/PDD device driver model used by Windows CE–based native device drivers. As with the native device driver model, OEMs need to port only the PDD part. Furthermore, because the specifications for OHC interface and UHC interface hardware explicitly define the behavior of such hardware, the PDD layer does very little. The PDD layer for most HCD modules merely has to locate the hardware address of the host controller within memory and provide the MDD layer with the hardware address and a pointer to a shared memory area.

However, the MDD and PDD layers in the HCD module interact more than the MDD and PDD layers in most native device drivers. For example, in the majority of native device drivers, the MDD layer calls DDSI functions exposed by the PDD layer. In the HCD module, the MDD layer not only calls the DDSI functions, but also exposes a set of functions that the PDD layer must call at specific times during initialization.

OEMs must create a registry key within HKEY_LOCAL_MACHINE\Drivers\Builtin\ so that the Device Manager loads the HCD module when the platform starts. Device drivers that the Device Manager loads must expose some of the stream interface functions. Therefore, the PDD layer is required to include some additional DDSI functions, such as OhcdPdd_Open and OhcdPdd_IoControl, even though the HCD module is not a stream interface driver. The benefit of this approach is that the Device Manager calls the HCD module’s OhcdPdd_Init function, which in turn enables the HCD module to call the required MDD functions. The following example shows the registry key for the HCD module; it should contain the same values as other stream interface driver keys.

[HKEY_LOCAL_MACHINE\Drivers\Builtin\OHCI]
  “Prefix”=“HCD”
  “Dll”=“ohci.dll”
  “Index”=dword:1
  “Order”=dword:1

The following table shows the MDD functions that the PDD layer must call.

OhcdMdd_CreateMemoryObject
OhcdMdd_DestroyMemoryObject
OhcdMdd_CreateOhcdObject
OhcdMdd_DestroyOhcdObject
OhcdMdd_PowerUp
OhcdMdd_PowerDown

The following table shows the DDSI functions exposed by the PDD layer.

OhcdPdd_CheckConfigPower OhcdPdd_Open
OhcdPdd_Close OhcdPdd_PowerDown
OhcdPdd_Deinit OhcdPdd_PowerUp
OhcdPdd_DllMain OhcdPdd_Read
OhcdPdd_Init OhcdPdd_Seek
OhcdPdd_IoControl OhcdPdd_Write

OEMs must write their own HCD modules if their platforms contain universal host controller driver (UHCD)–compliant host controllers, instead of OHCD-compliant host controllers. An HCD module for UHCD hardware must expose the same interface to the USB driver module as the sample HCD module. The OHCD sample is suitable to use as a model while developing an HCD module for UHCD hardware.