子 裝置 一詞可用來描述下表中列出的四個元件的繫結。
| 元件 | 說明 |
|---|---|
迷你埠物件 |
公開迷你埠驅動程式 IMiniportXxx 介面的物件 |
Port 物件 |
公開埠驅動程式 IPortXxx 介面的物件 |
資源清單物件 |
包含分配給子裝置的適配器驅動程式資源清單的物件 |
參考字串 |
新增至裝置路徑名稱的名稱,用於在篩選器建立期間指定子裝置 |
子裝置的 IMiniportXxx 和 IPortXxx 介面分別繼承自基底介面 IMiniport 和 IPort。
PortCls 系統驅動程式不會區分埠驅動程式和迷你埠驅動程式。 它只需要一個物件,例如埠對象,具有可以處理系統產生的請求的介面。
同樣地,PortCls 不直接參與資源管理。 它只需要將請求處理常式(埠驅動程式)綁定到資源清單即可。 配接器驅動程式負責將埠、迷你埠和資源清單物件系結在一起。
下列程式碼範例顯示配接器驅動程式如何執行這些動作:
//
// 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();
}
如需上述程式碼範例中 PortCls 函式呼叫的相關資訊,請參閱 PcNewPort、 PcNewMiniport 和 PcRegisterSubdevice。