实现 MiniportCancelIdleNotification 处理程序函数

NDIS 调用微型端口驱动程序的 MiniportCancelIdleNotification 处理程序函数,以便取消空闲通知过程并将网络适配器转换为全电源状态。 调用此函数时,微型端口驱动程序必须执行以下步骤:

  1. 微型端口驱动程序必须取消以前针对空闲通知发出的任何特定于总线的 IRP。

  2. 微型端口驱动程序调用 NdisMIdleNotificationComplete 此调用通知 NDIS 空闲通知已完成。 然后,NDIS 通过将网络适配器转换为全电源状态来编译选择性挂起操作。

例如,当调用 MiniportCancelIdleNotification,USB 微型端口驱动程序会调用 IoCancelIrp 来取消 USB 空闲请求的 I/O 请求数据包(IRP)(IOCTL_INTERNAL_USB_SUBMIT_IDLE_NOTIFICATION)。 USB 微型端口驱动程序以前在其 MiniportIdleNotification 处理程序函数中发布了此 IRP。 一旦 USB 总线驱动程序取消了 IRP,它就会调用 IRP 的完成例程。 当 USB 总线驱动程序调用完成例程时,它会确认 IRP 已取消,并且设备可以恢复到全功率状态。 在完成例程的上下文中,微型端口驱动程序调用 NdisMIdleNotificationComplete

请注意,USB 总线驱动程序可以在调用 IoCancelIrp 的上下文中同步调用完成例程,也可以在 MiniportCancelIdleNotification 返回后异步调用。

下面是 USB 微型端口驱动程序的 MiniportCancelIdleNotification 处理程序函数的示例 此示例显示了取消 USB 空闲请求 IRP 所涉及的步骤。

//
// MiniportCancelIdleNotification()
//
// This routine is called if NDIS has to cancel an idle notification.
// All that is needed is to cancel the selective suspend IRP.
//
VOID MiniportCancelIdleNotification(
    _In_ NDIS_HANDLE MiniportAdapterContext
    )
{
    IoCancelIrp(Adapter->UsbSsIrp);
}

有关为 USB 空闲请求 IRP 实现完成例程的指南,请参阅 “实现 USB 空闲请求 IRP 完成例程”。