The term subdevice is used to describe the binding of the four components that are listed in the following table.
| Component | Description |
|---|---|
| Miniport | An object that exposes the miniport interface |
| Port | An object that exposes the port interface |
| List of resources | Adapter driver resources that are assigned to the subdevice |
| Reference string | A name added to the device path name to specify a subdevice during filter creation |
The PortCls system driver does not distinguish between the port driver and the miniport driver—it simply requires an object, such as the port-driver object, with an interface that can handle system-generated requests. Similarly, PortCls is not directly involved in managing resources—it only needs to bind the request handler (the port driver) to a resource list. The adapter driver is responsible for binding the port, miniport, and resource-list objects.
The following code example shows how the adapter driver performs these actions:
//
// Instantiate the port by calling a function supplied by PortCls.
//
PPORT port;
NTSTATUS ntStatus = PcNewPort(&port, PortClassId);
if (NT_SUCCESS(ntStatus))
{
PUNKNOWN miniport;
//
// Create the miniport object.
//
if (MiniportCreate) // a function to create a proprietary miniport
{
ntStatus = MiniportCreate(&miniport,
MiniportClassId, NULL, NonPagedPool);
}
else // Ask PortCls for one of its built-in miniports.
{
ntStatus = PcNewMiniport((PMINIPORT*)&miniport,
MiniportClassId);
}
if (NT_SUCCESS(ntStatus))
{
//
// Bind the port, miniport, and resources.
//
ntStatus = port->Init(DeviceObject,
Irp, miniport, UnknownAdapter, ResourceList);
if (NT_SUCCESS(ntStatus))
{
//
// Hand the port driver and the reference
// string to PortCls.
//
ntStatus = PcRegisterSubdevice(DeviceObject,
Name, port);
}
//
// We no longer need to reference the miniport driver.
// Either the port driver now references it,
// or binding failed and it should be deleted.
//
miniport->Release();
}
//
// Release the reference that existed when PcNewPort() gave us
// the pointer in the first place. This reference must be released
// regardless of whether the binding of the port and miniport
// drivers succeeded.
//
port->Release();
}
For information on the PortCls function calls in the preceding code example, see PcNewPort, PcNewMiniport, and PcRegisterSubdevice.