ReactOS 0.4.15-dev-5667-ged97270
power.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS USB Hub Driver
3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4 * PURPOSE: USBHub power handling functions
5 * COPYRIGHT: Copyright 2017 Vadim Galyant <vgal@rambler.ru>
6 */
7
8#include "usbhub.h"
9
10#define NDEBUG
11#include <debug.h>
12
13#define NDEBUG_USBHUB_POWER
14#include "dbg_uhub.h"
15
16VOID
19 IN PIRP Irp,
20 IN NTSTATUS NtStatus)
21{
22 DPRINT("USBH_CompletePowerIrp: HubExtension - %p, Irp - %p, NtStatus - %lX\n",
23 HubExtension,
24 Irp,
25 NtStatus);
26
27 Irp->IoStatus.Status = NtStatus;
28
30
31 if (!InterlockedDecrement(&HubExtension->PendingRequestCount))
32 {
33 KeSetEvent(&HubExtension->PendingRequestEvent,
35 FALSE);
36 }
37
39}
40
41VOID
44 IN PIRP Irp)
45{
46 DPRINT("USBH_HubCancelWakeIrp: HubExtension - %p, Irp - %p\n",
47 HubExtension,
48 Irp);
49
51
52 if (InterlockedExchange((PLONG)&HubExtension->FdoWaitWakeLock, 1))
53 {
55 Irp->IoStatus.Status = STATUS_CANCELLED;
57 }
58}
59
60VOID
67{
68 DPRINT("USBH_HubESDRecoverySetD3Completion ... \n");
69
72 FALSE);
73}
74
78{
79 PUSBHUB_FDO_EXTENSION RootHubDevExt;
83
84 DPRINT("USBH_HubSetD0: HubExtension - %p\n", HubExtension);
85
86 RootHubDevExt = USBH_GetRootHubExtension(HubExtension);
87
89 {
91 return Status;
92 }
93
94 if (HubExtension->HubFlags & USBHUB_FDO_FLAG_WAIT_IDLE_REQUEST)
95 {
96 DPRINT("USBH_HubSetD0: HubFlags - %lX\n", HubExtension->HubFlags);
97
98 KeWaitForSingleObject(&HubExtension->IdleEvent,
101 FALSE,
102 NULL);
103 }
104
106
107 PowerState.DeviceState = PowerDeviceD0;
108
109 Status = PoRequestPowerIrp(HubExtension->LowerPDO,
113 &Event,
114 NULL);
115
116 if (Status == STATUS_PENDING)
117 {
119 Suspended,
121 FALSE,
122 NULL);
123 }
124
125 while (HubExtension->HubFlags & USBHUB_FDO_FLAG_WAKEUP_START)
126 {
127 USBH_Wait(10);
128 }
129
130 return Status;
131}
132
133VOID
134NTAPI
137{
138 PUSBHUB_IDLE_PORT_CANCEL_CONTEXT WorkItemIdlePower;
139 PIRP Irp;
140
141 DPRINT("USBH_IdleCancelPowerHubWorker: ... \n");
142
143 WorkItemIdlePower = Context;
144
145 if (HubExtension &&
146 HubExtension->CurrentPowerState.DeviceState != PowerDeviceD0 &&
147 HubExtension->HubFlags & USBHUB_FDO_FLAG_DEVICE_STARTED)
148 {
149 USBH_HubSetD0(HubExtension);
150 }
151
152 Irp = WorkItemIdlePower->Irp;
154
156}
157
158VOID
159NTAPI
161 IN PLIST_ENTRY ListIrps)
162{
163 PDEVICE_OBJECT PortDevice;
164 PUSBHUB_PORT_PDO_EXTENSION PortExtension;
165 USHORT NumPorts;
166 USHORT Port;
167 PIRP WakeIrp;
169
170 DPRINT("USBH_HubQueuePortWakeIrps ... \n");
171
172 NumPorts = HubExtension->HubDescriptor->bNumberOfPorts;
173
174 InitializeListHead(ListIrps);
175
177
178 for (Port = 0; Port < NumPorts; ++Port)
179 {
180 PortDevice = HubExtension->PortData[Port].DeviceObject;
181
182 if (PortDevice)
183 {
184 PortExtension = PortDevice->DeviceExtension;
185
186 WakeIrp = PortExtension->PdoWaitWakeIrp;
187 PortExtension->PdoWaitWakeIrp = NULL;
188
189 if (WakeIrp)
190 {
191 DPRINT1("USBH_HubQueuePortWakeIrps: UNIMPLEMENTED. FIXME\n");
193 }
194 }
195 }
196
198}
199
200VOID
201NTAPI
203 IN PLIST_ENTRY ListIrps,
204 IN NTSTATUS NtStatus)
205{
206 DPRINT("USBH_HubCompleteQueuedPortWakeIrps ... \n");
207
208 while (!IsListEmpty(ListIrps))
209 {
210 DPRINT1("USBH_HubCompleteQueuedPortWakeIrps: UNIMPLEMENTED. FIXME\n");
212 }
213}
214
215VOID
216NTAPI
218 IN NTSTATUS NtStatus)
219{
220 LIST_ENTRY ListIrps;
221
222 DPRINT("USBH_HubCompletePortWakeIrps: NtStatus - %x\n", NtStatus);
223
224 if (HubExtension->HubFlags & USBHUB_FDO_FLAG_DEVICE_STARTED)
225 {
226 USBH_HubQueuePortWakeIrps(HubExtension, &ListIrps);
227
229 &ListIrps,
230 NtStatus);
231 }
232}
233
234VOID
235NTAPI
241{
242 PUSBHUB_FDO_EXTENSION HubExtension;
243
244 DPRINT("USBH_FdoPoRequestD0Completion ... \n");
245
246 HubExtension = Context;
247
249
250 HubExtension->HubFlags &= ~USBHUB_FDO_FLAG_WAKEUP_START;
251
252 if (!InterlockedDecrement(&HubExtension->PendingRequestCount))
253 {
254 KeSetEvent(&HubExtension->PendingRequestEvent,
256 FALSE);
257 }
258}
259
260VOID
261NTAPI
264{
265 DPRINT1("USBH_CompletePortWakeIrpsWorker: UNIMPLEMENTED. FIXME\n");
267}
268
270NTAPI
272 IN PIRP Irp,
274{
275 PUSBHUB_FDO_EXTENSION HubExtension;
279 PIRP WakeIrp;
280
281 DPRINT("USBH_FdoWWIrpIoCompletion: DeviceObject - %p, Irp - %p\n",
283 Irp);
284
285 HubExtension = Context;
286
287 Status = Irp->IoStatus.Status;
288
290
291 HubExtension->HubFlags &= ~USBHUB_FDO_FLAG_PENDING_WAKE_IRP;
292
293 WakeIrp = InterlockedExchangePointer((PVOID *)&HubExtension->PendingWakeIrp,
294 NULL);
295
296 if (!InterlockedDecrement(&HubExtension->PendingRequestCount))
297 {
298 KeSetEvent(&HubExtension->PendingRequestEvent,
300 FALSE);
301 }
302
304
305 DPRINT("USBH_FdoWWIrpIoCompletion: Status - %lX\n", Status);
306
307 if (!NT_SUCCESS(Status))
308 {
309 DPRINT1("USBH_FdoWWIrpIoCompletion: DbgBreakPoint() \n");
311 }
312 else
313 {
314 PowerState.DeviceState = PowerDeviceD0;
315
316 HubExtension->HubFlags |= USBHUB_FDO_FLAG_WAKEUP_START;
318
320
321 PoRequestPowerIrp(HubExtension->LowerPDO,
325 (PVOID)HubExtension,
326 NULL);
327 }
328
329 if (!WakeIrp)
330 {
331 if (!InterlockedExchange(&HubExtension->FdoWaitWakeLock, 1))
332 {
334 }
335 }
336
337 DPRINT("USBH_FdoWWIrpIoCompletion: Status - %lX\n", Status);
338
340 {
342 }
343
344 return Status;
345}
346
348NTAPI
350 IN PIRP Irp,
352{
353 PUSBHUB_FDO_EXTENSION HubExtension;
354 PIO_STACK_LOCATION IoStack;
355 DEVICE_POWER_STATE OldDeviceState;
358
359 DPRINT("USBH_PowerIrpCompletion: DeviceObject - %p, Irp - %p\n",
361 Irp);
362
363 HubExtension = Context;
364
366 PowerState = IoStack->Parameters.Power.State;
367
368 Status = Irp->IoStatus.Status;
369 DPRINT("USBH_PowerIrpCompletion: Status - %lX\n", Status);
370
371 if (!NT_SUCCESS(Status))
372 {
373 if (PowerState.DeviceState == PowerDeviceD0)
374 {
376 HubExtension->HubFlags &= ~USBHUB_FDO_FLAG_SET_D0_STATE;
377 }
378 }
379 else if (PowerState.DeviceState == PowerDeviceD0)
380 {
381 HubExtension->HubFlags &= ~USBHUB_FDO_FLAG_SET_D0_STATE;
382
383 OldDeviceState = HubExtension->CurrentPowerState.DeviceState;
385
386 DPRINT("USBH_PowerIrpCompletion: OldDeviceState - %x\n", OldDeviceState);
387
388 if (HubExtension->HubFlags & USBHUB_FDO_FLAG_HIBERNATE_STATE)
389 {
390 DPRINT1("USBH_PowerIrpCompletion: USBHUB_FDO_FLAG_HIBERNATE_STATE. FIXME\n");
392 }
393
394 HubExtension->HubFlags &= ~USBHUB_FDO_FLAG_HIBERNATE_STATE;
395
396 if (OldDeviceState == PowerDeviceD3)
397 {
398 DPRINT1("USBH_PowerIrpCompletion: PowerDeviceD3. FIXME\n");
400 }
401
402 if (!(HubExtension->HubFlags & USBHUB_FDO_FLAG_DEVICE_STOPPED) &&
404 {
406 }
407
408 DPRINT("USBH_PowerIrpCompletion: Status - %lX\n", Status);
409
411 {
413 return Status;
414 }
415 }
416
417 return Status;
418}
419
420VOID
421NTAPI
427{
429 PUSBHUB_FDO_EXTENSION HubExtension = NULL;
430 PIRP PowerIrp;
431 PIO_STACK_LOCATION IoStack;
432
433 DPRINT("USBH_FdoDeferPoRequestCompletion ... \n");
434
436
437 PowerIrp = Extension->PowerIrp;
438
439 if (Extension->Common.ExtensionType == USBH_EXTENSION_TYPE_HUB)
440 {
441 HubExtension = Context;
442 }
443
444 IoStack = IoGetCurrentIrpStackLocation(PowerIrp);
445
446 if (IoStack->Parameters.Power.State.SystemState == PowerSystemWorking &&
447 HubExtension && HubExtension->LowerPDO == HubExtension->RootHubPdo)
448 {
450 USBH_CheckIdleDeferred(HubExtension);
451 }
452
454 PoStartNextPowerIrp(PowerIrp);
455 PoCallDriver(Extension->LowerDevice, PowerIrp);
456}
457
459NTAPI
461 IN PIRP Irp,
462 IN UCHAR Minor)
463{
465 PIO_STACK_LOCATION IoStack;
467 POWER_STATE DevicePwrState;
468 BOOLEAN IsAllPortsD3;
469 PUSBHUB_PORT_DATA PortData;
470 PDEVICE_OBJECT PdoDevice;
471 PUSBHUB_PORT_PDO_EXTENSION PortExtension;
472 ULONG Port;
473
474 DPRINT_PWR("USBH_FdoPower: HubExtension - %p, Irp - %p, Minor - %X\n",
475 HubExtension,
476 Irp,
477 Minor);
478
479 switch (Minor)
480 {
481 case IRP_MN_WAIT_WAKE:
482 DPRINT_PWR("USBH_FdoPower: IRP_MN_WAIT_WAKE\n");
483
485
488 HubExtension,
489 TRUE,
490 TRUE,
491 TRUE);
492
495 PoCallDriver(HubExtension->LowerDevice, Irp);
496
497 return STATUS_PENDING;
498
500 DPRINT_PWR("USBH_FdoPower: IRP_MN_POWER_SEQUENCE\n");
501 break;
502
503 case IRP_MN_SET_POWER:
504 DPRINT_PWR("USBH_FdoPower: IRP_MN_SET_POWER\n");
505
507 DPRINT_PWR("USBH_FdoPower: IRP_MN_SET_POWER/DevicePowerState\n");
508 PowerState = IoStack->Parameters.Power.State;
509
510 if (IoStack->Parameters.Power.Type == DevicePowerState)
511 {
512 DPRINT_PWR("USBH_FdoPower: PowerState - %x\n",
513 PowerState.DeviceState);
514
515 if (HubExtension->CurrentPowerState.DeviceState == PowerState.DeviceState)
516 {
518
521 PoCallDriver(HubExtension->LowerDevice, Irp);
522
523 return STATUS_PENDING;
524 }
525
526 switch (PowerState.DeviceState)
527 {
528 case PowerDeviceD0:
529 if (!(HubExtension->HubFlags & USBHUB_FDO_FLAG_SET_D0_STATE))
530 {
531 HubExtension->HubFlags &= ~(USBHUB_FDO_FLAG_NOT_D0_STATE |
533
534 HubExtension->HubFlags |= USBHUB_FDO_FLAG_SET_D0_STATE;
535
537
540 HubExtension,
541 TRUE,
542 TRUE,
543 TRUE);
544 }
545 else
546 {
549 }
550
552 PoCallDriver(HubExtension->LowerDevice, Irp);
553 return STATUS_PENDING;
554
555 case PowerDeviceD1:
556 case PowerDeviceD2:
557 case PowerDeviceD3:
558 if (HubExtension->ResetRequestCount)
559 {
560 IoCancelIrp(HubExtension->ResetPortIrp);
561
562 KeWaitForSingleObject(&HubExtension->ResetEvent,
563 Executive,
565 FALSE,
566 NULL);
567 }
568
569 if (!(HubExtension->HubFlags & USBHUB_FDO_FLAG_DEVICE_STOPPED))
570 {
571 HubExtension->HubFlags |= (USBHUB_FDO_FLAG_NOT_D0_STATE |
573
574 IoCancelIrp(HubExtension->SCEIrp);
575
576 KeWaitForSingleObject(&HubExtension->StatusChangeEvent,
577 Executive,
579 FALSE,
580 NULL);
581 }
582
583 HubExtension->CurrentPowerState.DeviceState = PowerState.DeviceState;
584
585 if (HubExtension->HubFlags & USBHUB_FDO_FLAG_DO_SUSPENSE &&
586 USBH_CheckIdleAbort(HubExtension, TRUE, TRUE) == TRUE)
587 {
588 HubExtension->HubFlags &= ~(USBHUB_FDO_FLAG_NOT_D0_STATE |
590
591 HubExtension->CurrentPowerState.DeviceState = PowerDeviceD0;
592
594
596
597 Irp->IoStatus.Status = STATUS_UNSUCCESSFUL;
599
600 HubExtension->HubFlags &= ~USBHUB_FDO_FLAG_DO_SUSPENSE;
601
602 KeReleaseSemaphore(&HubExtension->IdleSemaphore,
604 1,
605 FALSE);
606
607 return STATUS_UNSUCCESSFUL;
608 }
609
611
614 HubExtension,
615 TRUE,
616 TRUE,
617 TRUE);
618
621 PoCallDriver(HubExtension->LowerDevice, Irp);
622
623 if (HubExtension->HubFlags & USBHUB_FDO_FLAG_DO_SUSPENSE)
624 {
625 HubExtension->HubFlags &= ~USBHUB_FDO_FLAG_DO_SUSPENSE;
626
627 KeReleaseSemaphore(&HubExtension->IdleSemaphore,
629 1,
630 FALSE);
631 }
632
633 return STATUS_PENDING;
634
635 default:
636 DPRINT1("USBH_FdoPower: Unsupported PowerState.DeviceState\n");
638 break;
639 }
640 }
641 else
642 {
643 if (PowerState.SystemState != PowerSystemWorking)
644 {
646 PowerState.SystemState;
647 }
648
649 if (PowerState.SystemState == PowerSystemHibernate)
650 {
651 HubExtension->HubFlags |= USBHUB_FDO_FLAG_HIBERNATE_STATE;
652 }
653
654 PortData = HubExtension->PortData;
655
656 IsAllPortsD3 = TRUE;
657
658 if (PortData && HubExtension->HubDescriptor)
659 {
660 for (Port = 0;
661 Port < HubExtension->HubDescriptor->bNumberOfPorts;
662 Port++)
663 {
664 PdoDevice = PortData[Port].DeviceObject;
665
666 if (PdoDevice)
667 {
668 PortExtension = PdoDevice->DeviceExtension;
669
670 if (PortExtension->CurrentPowerState.DeviceState != PowerDeviceD3)
671 {
672 IsAllPortsD3 = FALSE;
673 break;
674 }
675 }
676 }
677 }
678
679 if (PowerState.SystemState == PowerSystemWorking)
680 {
681 DevicePwrState.DeviceState = PowerDeviceD0;
682 }
683 else if (HubExtension->HubFlags & USBHUB_FDO_FLAG_PENDING_WAKE_IRP ||
684 !IsAllPortsD3)
685 {
686 DevicePwrState.DeviceState = HubExtension->DeviceState[PowerState.SystemState];
687
688 if (DevicePwrState.DeviceState == PowerDeviceUnspecified)
689 {
690 goto Exit;
691 }
692 }
693 else
694 {
695 DevicePwrState.DeviceState = PowerDeviceD3;
696 }
697
698 if (DevicePwrState.DeviceState != HubExtension->CurrentPowerState.DeviceState &&
699 HubExtension->HubFlags & USBHUB_FDO_FLAG_DEVICE_STARTED)
700 {
701 HubExtension->PowerIrp = Irp;
702
704
705 if (PoRequestPowerIrp(HubExtension->LowerPDO,
707 DevicePwrState,
709 (PVOID)HubExtension,
711 {
712 return STATUS_PENDING;
713 }
714
717 PoCallDriver(HubExtension->LowerDevice, Irp);
718
719 return STATUS_PENDING;
720 }
721
722 Exit:
723
724 HubExtension->SystemPowerState.SystemState = PowerState.SystemState;
725
726 if (PowerState.SystemState == PowerSystemWorking)
727 {
728 USBH_CheckIdleDeferred(HubExtension);
729 }
730
733
734 return PoCallDriver(HubExtension->LowerDevice, Irp);
735 }
736
737 break;
738
740 DPRINT_PWR("USBH_FdoPower: IRP_MN_QUERY_POWER\n");
741 break;
742
743 default:
744 DPRINT1("USBH_FdoPower: unknown IRP_MN_POWER!\n");
745 break;
746 }
747
750 Status = PoCallDriver(HubExtension->LowerDevice, Irp);
751
752 return Status;
753}
754
756NTAPI
758 IN PIRP Irp,
759 IN UCHAR Minor)
760{
761 NTSTATUS Status = Irp->IoStatus.Status;
762
763 DPRINT_PWR("USBH_FdoPower: PortExtension - %p, Irp - %p, Minor - %X\n",
764 PortExtension,
765 Irp,
766 Minor);
767
768 switch (Minor)
769 {
770 case IRP_MN_WAIT_WAKE:
771 DPRINT_PWR("USBHUB_PdoPower: IRP_MN_WAIT_WAKE\n");
773 break;
774
776 DPRINT_PWR("USBHUB_PdoPower: IRP_MN_POWER_SEQUENCE\n");
778 break;
779
780 case IRP_MN_SET_POWER:
781 DPRINT_PWR("USBHUB_PdoPower: IRP_MN_SET_POWER\n");
783 break;
784
786 DPRINT_PWR("USBHUB_PdoPower: IRP_MN_QUERY_POWER\n");
788 break;
789
790 default:
791 DPRINT1("USBHUB_PdoPower: unknown IRP_MN_POWER!\n");
793 break;
794 }
795
796 Irp->IoStatus.Status = Status;
797 Irp->IoStatus.Information = 0;
799
800 return Status;
801}
unsigned char BOOLEAN
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedExchange
Definition: armddk.h:54
#define InterlockedDecrement
Definition: armddk.h:52
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
_In_ PIRP Irp
Definition: csq.h:116
#define DPRINT_PWR(...)
Definition: dbg_uhub.h:108
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
VOID NTAPI USBH_HubCancelWakeIrp(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PIRP Irp)
Definition: power.c:43
NTSTATUS NTAPI USBH_HubSetD0(IN PUSBHUB_FDO_EXTENSION HubExtension)
Definition: power.c:77
VOID NTAPI USBH_HubCompletePortWakeIrps(IN PUSBHUB_FDO_EXTENSION HubExtension, IN NTSTATUS NtStatus)
Definition: power.c:217
NTSTATUS NTAPI USBH_FdoPower(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PIRP Irp, IN UCHAR Minor)
Definition: power.c:460
VOID NTAPI USBH_CompletePortWakeIrpsWorker(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PVOID Context)
Definition: power.c:262
VOID NTAPI USBH_HubQueuePortWakeIrps(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PLIST_ENTRY ListIrps)
Definition: power.c:160
VOID NTAPI USBH_FdoPoRequestD0Completion(IN PDEVICE_OBJECT DeviceObject, IN UCHAR MinorFunction, IN POWER_STATE PowerState, IN PVOID Context, IN PIO_STATUS_BLOCK IoStatus)
Definition: power.c:236
NTSTATUS NTAPI USBH_PowerIrpCompletion(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
Definition: power.c:349
VOID NTAPI USBH_FdoDeferPoRequestCompletion(IN PDEVICE_OBJECT DeviceObject, IN UCHAR MinorFunction, IN POWER_STATE PowerState, IN PVOID Context, IN PIO_STATUS_BLOCK IoStatus)
Definition: power.c:422
VOID NTAPI USBH_HubCompleteQueuedPortWakeIrps(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PLIST_ENTRY ListIrps, IN NTSTATUS NtStatus)
Definition: power.c:202
VOID NTAPI USBH_IdleCancelPowerHubWorker(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PVOID Context)
Definition: power.c:135
VOID NTAPI USBH_CompletePowerIrp(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PIRP Irp, IN NTSTATUS NtStatus)
Definition: power.c:18
NTSTATUS NTAPI USBH_PdoPower(IN PUSBHUB_PORT_PDO_EXTENSION PortExtension, IN PIRP Irp, IN UCHAR Minor)
Definition: power.c:757
VOID NTAPI USBH_HubESDRecoverySetD3Completion(IN PDEVICE_OBJECT DeviceObject, IN UCHAR MinorFunction, IN POWER_STATE PowerState, IN PVOID Context, IN PIO_STATUS_BLOCK IoStatus)
Definition: power.c:62
NTSTATUS NTAPI USBH_FdoWWIrpIoCompletion(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
Definition: power.c:271
#define InterlockedExchangePointer(Target, Value)
Definition: dshow.h:45
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define KeSetEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:476
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
_Inout_opt_ PUNICODE_STRING Extension
Definition: fltkernel.h:1092
Status
Definition: gdiplustypes.h:25
CPPORT Port[4]
Definition: headless.c:35
NTSYSAPI void WINAPI DbgBreakPoint(void)
#define LOW_REALTIME_PRIORITY
IoMarkIrpPending(Irp)
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:498
__in UCHAR __in POWER_STATE __in_opt PVOID __in PIO_STATUS_BLOCK IoStatus
Definition: mxum.h:159
#define KernelMode
Definition: asm.h:34
@ NotificationEvent
#define IoCopyCurrentIrpStackLocationToNext(Irp)
Definition: ntifs_ex.h:413
#define IoCompleteRequest
Definition: irp.c:1240
BOOLEAN NTAPI IoCancelIrp(IN PIRP Irp)
Definition: irp.c:1101
VOID NTAPI IoReleaseCancelSpinLock(IN KIRQL Irql)
Definition: util.c:150
VOID NTAPI IoAcquireCancelSpinLock(OUT PKIRQL Irql)
Definition: util.c:56
VOID NTAPI PoStartNextPowerIrp(IN PIRP Irp)
Definition: power.c:746
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)
Definition: power.c:647
@ PowerSystemWorking
Definition: ntpoapi.h:36
@ PowerSystemHibernate
Definition: ntpoapi.h:40
@ DevicePowerState
Definition: ntpoapi.h:63
@ PowerDeviceD1
Definition: ntpoapi.h:50
@ PowerDeviceUnspecified
Definition: ntpoapi.h:48
@ PowerDeviceD0
Definition: ntpoapi.h:49
@ PowerDeviceD2
Definition: ntpoapi.h:51
@ PowerDeviceD3
Definition: ntpoapi.h:52
enum _DEVICE_POWER_STATE DEVICE_POWER_STATE
#define STATUS_PENDING
Definition: ntstatus.h:82
unsigned short USHORT
Definition: pedump.c:61
LONG NTAPI KeReleaseSemaphore(IN PKSEMAPHORE Semaphore, IN KPRIORITY Increment, IN LONG Adjustment, IN BOOLEAN Wait)
Definition: semphobj.c:54
#define STATUS_MORE_PROCESSING_REQUIRED
Definition: shellext.h:68
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71
static void Exit(void)
Definition: sock.c:1330
PVOID DeviceExtension
Definition: env_spec_w32.h:418
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3128
IO_STATUS_BLOCK IoStatus
Definition: typedefs.h:120
LONG PendingRequestCount
Definition: usbhub.h:180
PDEVICE_OBJECT LowerPDO
Definition: usbhub.h:149
POWER_STATE CurrentPowerState
Definition: usbhub.h:160
KEVENT PendingRequestEvent
Definition: usbhub.h:181
PDEVICE_OBJECT RootHubPdo
Definition: usbhub.h:151
POWER_STATE SystemPowerState
Definition: usbhub.h:161
PDEVICE_OBJECT DeviceObject
Definition: usbhub.h:119
POWER_STATE CurrentPowerState
Definition: usbhub.h:222
#define NTAPI
Definition: typedefs.h:36
#define IN
Definition: typedefs.h:39
int32_t * PLONG
Definition: typedefs.h:58
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define STATUS_INVALID_DEVICE_STATE
Definition: udferr_usr.h:178
#define STATUS_CANCELLED
Definition: udferr_usr.h:170
DEVICE_POWER_STATE DeviceState
Definition: ntpoapi.h:58
SYSTEM_POWER_STATE SystemState
Definition: ntpoapi.h:57
PUSBHUB_FDO_EXTENSION NTAPI USBH_GetRootHubExtension(IN PUSBHUB_FDO_EXTENSION HubExtension)
Definition: usbhub.c:699
NTSTATUS NTAPI USBH_SubmitStatusChangeTransfer(IN PUSBHUB_FDO_EXTENSION HubExtension)
Definition: usbhub.c:2442
NTSTATUS NTAPI USBH_Wait(IN ULONG Milliseconds)
Definition: usbhub.c:23
VOID NTAPI USBH_CheckIdleDeferred(IN PUSBHUB_FDO_EXTENSION HubExtension)
Definition: usbhub.c:3957
BOOLEAN NTAPI USBH_CheckIdleAbort(IN PUSBHUB_FDO_EXTENSION HubExtension, IN BOOLEAN IsWait, IN BOOLEAN IsExtCheck)
Definition: usbhub.c:3221
#define USBHUB_FDO_FLAG_DEVICE_STARTED
Definition: usbhub.h:33
#define USBHUB_FDO_FLAG_DEVICE_STOPPING
Definition: usbhub.h:34
#define USBHUB_FDO_FLAG_DO_SUSPENSE
Definition: usbhub.h:56
#define USBHUB_FDO_FLAG_HIBERNATE_STATE
Definition: usbhub.h:54
#define USBH_EXTENSION_TYPE_HUB
Definition: usbhub.h:28
#define USBHUB_FDO_FLAG_DO_ENUMERATION
Definition: usbhub.h:52
#define USBHUB_FDO_FLAG_WAKEUP_START
Definition: usbhub.h:49
#define USBHUB_FDO_FLAG_NOT_D0_STATE
Definition: usbhub.h:43
#define USBHUB_FDO_FLAG_PENDING_WAKE_IRP
Definition: usbhub.h:39
#define USBHUB_FDO_FLAG_SET_D0_STATE
Definition: usbhub.h:42
#define USBHUB_FDO_FLAG_WAIT_IDLE_REQUEST
Definition: usbhub.h:44
#define USBHUB_FDO_FLAG_DEVICE_STOPPED
Definition: usbhub.h:37
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ WDF_DEVICE_POWER_STATE PowerState
Definition: wdfdevice.h:3034
_In_ UCHAR _In_ UCHAR MinorFunction
Definition: wdfdevice.h:1699
_Out_opt_ PULONG Minor
Definition: cmfuncs.h:44
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2793
#define IRP_MN_WAIT_WAKE
#define EVENT_INCREMENT
Definition: iotypes.h:597
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define IRP_MN_POWER_SEQUENCE
#define IRP_MN_SET_POWER
#define IRP_MN_QUERY_POWER
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:792
@ Suspended
Definition: ketypes.h:408
@ Executive
Definition: ketypes.h:403
unsigned char UCHAR
Definition: xmlstorage.h:181