13#define NDEBUG_USBHUB_POWER
22 DPRINT(
"USBH_CompletePowerIrp: HubExtension - %p, Irp - %p, NtStatus - %lX\n",
27 Irp->IoStatus.Status = NtStatus;
46 DPRINT(
"USBH_HubCancelWakeIrp: HubExtension - %p, Irp - %p\n",
68 DPRINT(
"USBH_HubESDRecoverySetD3Completion ... \n");
84 DPRINT(
"USBH_HubSetD0: HubExtension - %p\n", HubExtension);
96 DPRINT(
"USBH_HubSetD0: HubFlags - %lX\n", HubExtension->HubFlags);
141 DPRINT(
"USBH_IdleCancelPowerHubWorker: ... \n");
146 HubExtension->CurrentPowerState.DeviceState !=
PowerDeviceD0 &&
152 Irp = WorkItemIdlePower->
Irp;
170 DPRINT(
"USBH_HubQueuePortWakeIrps ... \n");
172 NumPorts = HubExtension->HubDescriptor->bNumberOfPorts;
180 PortDevice = HubExtension->PortData[
Port].DeviceObject;
191 DPRINT1(
"USBH_HubQueuePortWakeIrps: UNIMPLEMENTED. FIXME\n");
206 DPRINT(
"USBH_HubCompleteQueuedPortWakeIrps ... \n");
210 DPRINT1(
"USBH_HubCompleteQueuedPortWakeIrps: UNIMPLEMENTED. FIXME\n");
222 DPRINT(
"USBH_HubCompletePortWakeIrps: NtStatus - %x\n", NtStatus);
244 DPRINT(
"USBH_FdoPoRequestD0Completion ... \n");
250 HubExtension->
HubFlags &= ~USBHUB_FDO_FLAG_WAKEUP_START;
265 DPRINT1(
"USBH_CompletePortWakeIrpsWorker: UNIMPLEMENTED. FIXME\n");
281 DPRINT(
"USBH_FdoWWIrpIoCompletion: DeviceObject - %p, Irp - %p\n",
291 HubExtension->
HubFlags &= ~USBHUB_FDO_FLAG_PENDING_WAKE_IRP;
305 DPRINT(
"USBH_FdoWWIrpIoCompletion: Status - %lX\n",
Status);
309 DPRINT1(
"USBH_FdoWWIrpIoCompletion: DbgBreakPoint() \n");
337 DPRINT(
"USBH_FdoWWIrpIoCompletion: Status - %lX\n",
Status);
359 DPRINT(
"USBH_PowerIrpCompletion: DeviceObject - %p, Irp - %p\n",
369 DPRINT(
"USBH_PowerIrpCompletion: Status - %lX\n",
Status);
376 HubExtension->
HubFlags &= ~USBHUB_FDO_FLAG_SET_D0_STATE;
381 HubExtension->
HubFlags &= ~USBHUB_FDO_FLAG_SET_D0_STATE;
386 DPRINT(
"USBH_PowerIrpCompletion: OldDeviceState - %x\n", OldDeviceState);
390 DPRINT1(
"USBH_PowerIrpCompletion: USBHUB_FDO_FLAG_HIBERNATE_STATE. FIXME\n");
394 HubExtension->
HubFlags &= ~USBHUB_FDO_FLAG_HIBERNATE_STATE;
398 DPRINT1(
"USBH_PowerIrpCompletion: PowerDeviceD3. FIXME\n");
408 DPRINT(
"USBH_PowerIrpCompletion: Status - %lX\n",
Status);
433 DPRINT(
"USBH_FdoDeferPoRequestCompletion ... \n");
455 PoCallDriver(
Extension->LowerDevice, PowerIrp);
474 DPRINT_PWR(
"USBH_FdoPower: HubExtension - %p, Irp - %p, Minor - %X\n",
482 DPRINT_PWR(
"USBH_FdoPower: IRP_MN_WAIT_WAKE\n");
495 PoCallDriver(HubExtension->LowerDevice,
Irp);
500 DPRINT_PWR(
"USBH_FdoPower: IRP_MN_POWER_SEQUENCE\n");
504 DPRINT_PWR(
"USBH_FdoPower: IRP_MN_SET_POWER\n");
507 DPRINT_PWR(
"USBH_FdoPower: IRP_MN_SET_POWER/DevicePowerState\n");
512 DPRINT_PWR(
"USBH_FdoPower: PowerState - %x\n",
515 if (HubExtension->CurrentPowerState.DeviceState ==
PowerState.DeviceState)
521 PoCallDriver(HubExtension->LowerDevice,
Irp);
552 PoCallDriver(HubExtension->LowerDevice,
Irp);
558 if (HubExtension->ResetRequestCount)
583 HubExtension->CurrentPowerState.DeviceState =
PowerState.DeviceState;
600 HubExtension->HubFlags &= ~USBHUB_FDO_FLAG_DO_SUSPENSE;
621 PoCallDriver(HubExtension->LowerDevice,
Irp);
625 HubExtension->HubFlags &= ~USBHUB_FDO_FLAG_DO_SUSPENSE;
636 DPRINT1(
"USBH_FdoPower: Unsupported PowerState.DeviceState\n");
654 PortData = HubExtension->PortData;
658 if (PortData && HubExtension->HubDescriptor)
661 Port < HubExtension->HubDescriptor->bNumberOfPorts;
672 IsAllPortsD3 =
FALSE;
698 if (DevicePwrState.
DeviceState != HubExtension->CurrentPowerState.DeviceState &&
701 HubExtension->PowerIrp =
Irp;
717 PoCallDriver(HubExtension->LowerDevice,
Irp);
724 HubExtension->SystemPowerState.SystemState =
PowerState.SystemState;
734 return PoCallDriver(HubExtension->LowerDevice,
Irp);
740 DPRINT_PWR(
"USBH_FdoPower: IRP_MN_QUERY_POWER\n");
744 DPRINT1(
"USBH_FdoPower: unknown IRP_MN_POWER!\n");
750 Status = PoCallDriver(HubExtension->LowerDevice,
Irp);
763 DPRINT_PWR(
"USBH_FdoPower: PortExtension - %p, Irp - %p, Minor - %X\n",
771 DPRINT_PWR(
"USBHUB_PdoPower: IRP_MN_WAIT_WAKE\n");
776 DPRINT_PWR(
"USBHUB_PdoPower: IRP_MN_POWER_SEQUENCE\n");
781 DPRINT_PWR(
"USBHUB_PdoPower: IRP_MN_SET_POWER\n");
786 DPRINT_PWR(
"USBHUB_PdoPower: IRP_MN_QUERY_POWER\n");
791 DPRINT1(
"USBHUB_PdoPower: unknown IRP_MN_POWER!\n");
797 Irp->IoStatus.Information = 0;
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
#define InterlockedIncrement
#define InterlockedExchange
#define InterlockedDecrement
#define NT_SUCCESS(StatCode)
VOID NTAPI USBH_HubCancelWakeIrp(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PIRP Irp)
NTSTATUS NTAPI USBH_HubSetD0(IN PUSBHUB_FDO_EXTENSION HubExtension)
VOID NTAPI USBH_HubCompletePortWakeIrps(IN PUSBHUB_FDO_EXTENSION HubExtension, IN NTSTATUS NtStatus)
NTSTATUS NTAPI USBH_FdoPower(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PIRP Irp, IN UCHAR Minor)
VOID NTAPI USBH_CompletePortWakeIrpsWorker(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PVOID Context)
VOID NTAPI USBH_HubQueuePortWakeIrps(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PLIST_ENTRY ListIrps)
VOID NTAPI USBH_FdoPoRequestD0Completion(IN PDEVICE_OBJECT DeviceObject, IN UCHAR MinorFunction, IN POWER_STATE PowerState, IN PVOID Context, IN PIO_STATUS_BLOCK IoStatus)
NTSTATUS NTAPI USBH_PowerIrpCompletion(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
VOID NTAPI USBH_FdoDeferPoRequestCompletion(IN PDEVICE_OBJECT DeviceObject, IN UCHAR MinorFunction, IN POWER_STATE PowerState, IN PVOID Context, IN PIO_STATUS_BLOCK IoStatus)
VOID NTAPI USBH_HubCompleteQueuedPortWakeIrps(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PLIST_ENTRY ListIrps, IN NTSTATUS NtStatus)
VOID NTAPI USBH_IdleCancelPowerHubWorker(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PVOID Context)
VOID NTAPI USBH_CompletePowerIrp(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PIRP Irp, IN NTSTATUS NtStatus)
NTSTATUS NTAPI USBH_PdoPower(IN PUSBHUB_PORT_PDO_EXTENSION PortExtension, IN PIRP Irp, IN UCHAR Minor)
VOID NTAPI USBH_HubESDRecoverySetD3Completion(IN PDEVICE_OBJECT DeviceObject, IN UCHAR MinorFunction, IN POWER_STATE PowerState, IN PVOID Context, IN PIO_STATUS_BLOCK IoStatus)
NTSTATUS NTAPI USBH_FdoWWIrpIoCompletion(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
#define InterlockedExchangePointer(Target, Value)
#define IsListEmpty(ListHead)
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
#define KeInitializeEvent(pEvt, foo, foo2)
#define KeSetEvent(pEvt, foo, foo2)
#define InitializeListHead(ListHead)
_Inout_opt_ PUNICODE_STRING Extension
NTSYSAPI void WINAPI DbgBreakPoint(void)
#define LOW_REALTIME_PRIORITY
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
__in UCHAR __in POWER_STATE __in_opt PVOID __in PIO_STATUS_BLOCK IoStatus
#define IoCopyCurrentIrpStackLocationToNext(Irp)
#define IoCompleteRequest
BOOLEAN NTAPI IoCancelIrp(IN PIRP Irp)
VOID NTAPI IoReleaseCancelSpinLock(IN KIRQL Irql)
VOID NTAPI IoAcquireCancelSpinLock(OUT PKIRQL Irql)
VOID NTAPI PoStartNextPowerIrp(IN PIRP Irp)
NTSTATUS NTAPI PoRequestPowerIrp(_In_ PDEVICE_OBJECT DeviceObject, _In_ UCHAR MinorFunction, _In_ POWER_STATE PowerState, _In_opt_ PREQUEST_POWER_COMPLETE CompletionFunction, _In_opt_ __drv_aliasesMem PVOID Context, _Outptr_opt_ PIRP *pIrp)
enum _DEVICE_POWER_STATE DEVICE_POWER_STATE
LONG NTAPI KeReleaseSemaphore(IN PKSEMAPHORE Semaphore, IN KPRIORITY Increment, IN LONG Adjustment, IN BOOLEAN Wait)
#define STATUS_MORE_PROCESSING_REQUIRED
union _IO_STACK_LOCATION::@1581 Parameters
struct _IO_STACK_LOCATION::@3980::@4016 Power
POWER_STATE CurrentPowerState
KEVENT PendingRequestEvent
PDEVICE_OBJECT RootHubPdo
POWER_STATE SystemPowerState
PDEVICE_OBJECT DeviceObject
POWER_STATE CurrentPowerState
#define STATUS_UNSUCCESSFUL
#define STATUS_INVALID_DEVICE_STATE
DEVICE_POWER_STATE DeviceState
SYSTEM_POWER_STATE SystemState
PUSBHUB_FDO_EXTENSION NTAPI USBH_GetRootHubExtension(IN PUSBHUB_FDO_EXTENSION HubExtension)
NTSTATUS NTAPI USBH_SubmitStatusChangeTransfer(IN PUSBHUB_FDO_EXTENSION HubExtension)
NTSTATUS NTAPI USBH_Wait(IN ULONG Milliseconds)
VOID NTAPI USBH_CheckIdleDeferred(IN PUSBHUB_FDO_EXTENSION HubExtension)
BOOLEAN NTAPI USBH_CheckIdleAbort(IN PUSBHUB_FDO_EXTENSION HubExtension, IN BOOLEAN IsWait, IN BOOLEAN IsExtCheck)
#define USBHUB_FDO_FLAG_DEVICE_STARTED
#define USBHUB_FDO_FLAG_DEVICE_STOPPING
#define USBHUB_FDO_FLAG_DO_SUSPENSE
#define USBHUB_FDO_FLAG_HIBERNATE_STATE
#define USBH_EXTENSION_TYPE_HUB
#define USBHUB_FDO_FLAG_DO_ENUMERATION
#define USBHUB_FDO_FLAG_WAKEUP_START
#define USBHUB_FDO_FLAG_NOT_D0_STATE
#define USBHUB_FDO_FLAG_PENDING_WAKE_IRP
#define USBHUB_FDO_FLAG_SET_D0_STATE
#define USBHUB_FDO_FLAG_WAIT_IDLE_REQUEST
#define USBHUB_FDO_FLAG_DEVICE_STOPPED
_In_ PDEVICE_OBJECT DeviceObject
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ WDF_DEVICE_POWER_STATE PowerState
_In_ UCHAR _In_ UCHAR MinorFunction
#define IRP_MN_POWER_SEQUENCE
#define IRP_MN_QUERY_POWER
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql