ReactOS  0.4.14-dev-614-gbfd8a84
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 
16 VOID
17 NTAPI
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 
41 VOID
42 NTAPI
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 
60 VOID
61 NTAPI
67 {
68  DPRINT("USBH_HubESDRecoverySetD3Completion ... \n");
69 
72  FALSE);
73 }
74 
76 NTAPI
78 {
79  PUSBHUB_FDO_EXTENSION RootHubDevExt;
81  KEVENT Event;
83 
84  DPRINT("USBH_HubSetD0: HubExtension - %p\n", HubExtension);
85 
86  RootHubDevExt = USBH_GetRootHubExtension(HubExtension);
87 
88  if (RootHubDevExt->SystemPowerState.SystemState != PowerSystemWorking)
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,
99  Suspended,
100  KernelMode,
101  FALSE,
102  NULL);
103  }
104 
106 
108 
109  Status = PoRequestPowerIrp(HubExtension->LowerPDO,
111  PowerState,
113  &Event,
114  NULL);
115 
116  if (Status == STATUS_PENDING)
117  {
119  Suspended,
120  KernelMode,
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 
133 VOID
134 NTAPI
136  IN PVOID Context)
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;
153  Irp->IoStatus.Status = STATUS_CANCELLED;
154 
156 }
157 
158 VOID
159 NTAPI
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;
168  KIRQL OldIrql;
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");
192  DbgBreakPoint();
193  }
194  }
195  }
196 
198 }
199 
200 VOID
201 NTAPI
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");
211  DbgBreakPoint();
212  }
213 }
214 
215 VOID
216 NTAPI
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 
234 VOID
235 NTAPI
239  IN PVOID Context,
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 
260 VOID
261 NTAPI
263  IN PVOID Context)
264 {
265  DPRINT1("USBH_CompletePortWakeIrpsWorker: UNIMPLEMENTED. FIXME\n");
266  DbgBreakPoint();
267 }
268 
269 NTSTATUS
270 NTAPI
272  IN PIRP Irp,
273  IN PVOID Context)
274 {
275  PUSBHUB_FDO_EXTENSION HubExtension;
277  KIRQL OldIrql;
279  PIRP WakeIrp;
280 
281  DPRINT("USBH_FdoWWIrpIoCompletion: DeviceObject - %p, Irp - %p\n",
282  DeviceObject,
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");
310  DbgBreakPoint();
311  }
312  else
313  {
315 
316  HubExtension->HubFlags |= USBHUB_FDO_FLAG_WAKEUP_START;
318 
320 
321  PoRequestPowerIrp(HubExtension->LowerPDO,
323  PowerState,
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 
347 NTSTATUS
348 NTAPI
350  IN PIRP Irp,
351  IN PVOID Context)
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",
360  DeviceObject,
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  {
374  {
376  HubExtension->HubFlags &= ~USBHUB_FDO_FLAG_SET_D0_STATE;
377  }
378  }
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");
391  DbgBreakPoint();
392  }
393 
394  HubExtension->HubFlags &= ~USBHUB_FDO_FLAG_HIBERNATE_STATE;
395 
396  if (OldDeviceState == PowerDeviceD3)
397  {
398  DPRINT1("USBH_PowerIrpCompletion: PowerDeviceD3. FIXME\n");
399  DbgBreakPoint();
400  }
401 
402  if (!(HubExtension->HubFlags & USBHUB_FDO_FLAG_DEVICE_STOPPED) &&
404  {
405  USBH_SubmitStatusChangeTransfer(HubExtension);
406  }
407 
408  DPRINT("USBH_PowerIrpCompletion: Status - %lX\n", Status);
409 
411  {
413  return Status;
414  }
415  }
416 
417  return Status;
418 }
419 
420 VOID
421 NTAPI
425  IN PVOID Context,
427 {
429  PUSBHUB_FDO_EXTENSION HubExtension = NULL;
430  PIRP PowerIrp;
431  PIO_STACK_LOCATION IoStack;
432 
433  DPRINT("USBH_FdoDeferPoRequestCompletion ... \n");
434 
435  Extension = Context;
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 
458 NTSTATUS
459 NTAPI
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",
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,
564  KernelMode,
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,
578  KernelMode,
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 
593  USBH_SubmitStatusChangeTransfer(HubExtension);
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");
637  DbgBreakPoint();
638  break;
639  }
640  }
641  else
642  {
644  {
647  }
648 
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 
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,
710  NULL) == STATUS_PENDING)
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 
727  {
728  USBH_CheckIdleDeferred(HubExtension);
729  }
730 
733 
734  return PoCallDriver(HubExtension->LowerDevice, Irp);
735  }
736 
737  break;
738 
739  case IRP_MN_QUERY_POWER:
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 
755 NTSTATUS
756 NTAPI
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 
785  case IRP_MN_QUERY_POWER:
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 }
#define USBHUB_FDO_FLAG_DO_SUSPENSE
Definition: usbhub.h:56
_Out_opt_ PULONG Minor
Definition: cmfuncs.h:44
CPPORT Port[4]
Definition: headless.c:34
#define IN
Definition: typedefs.h:38
#define TRUE
Definition: types.h:120
_In_ UCHAR _In_ POWER_STATE PowerState
Definition: pofuncs.h:42
#define USBHUB_FDO_FLAG_PENDING_WAKE_IRP
Definition: usbhub.h:39
#define IRP_MN_POWER_SEQUENCE
#define IRP_MN_QUERY_POWER
#define USBHUB_FDO_FLAG_WAKEUP_START
Definition: usbhub.h:49
#define STATUS_MORE_PROCESSING_REQUIRED
Definition: shellext.h:68
VOID NTAPI USBH_HubCompleteQueuedPortWakeIrps(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PLIST_ENTRY ListIrps, IN NTSTATUS NtStatus)
Definition: power.c:202
NTSTATUS NTAPI USBH_FdoWWIrpIoCompletion(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
Definition: power.c:271
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG IN BOOLEAN OUT PIO_STATUS_BLOCK IoStatus
Definition: fatprocs.h:2650
NTSTATUS NTAPI PoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN OUT PIRP Irp)
Definition: power.c:485
#define USBHUB_FDO_FLAG_DEVICE_STOPPED
Definition: usbhub.h:37
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI USBH_Wait(IN ULONG Milliseconds)
Definition: usbhub.c:23
VOID NTAPI IoAcquireCancelSpinLock(OUT PKIRQL Irql)
Definition: util.c:56
VOID NTAPI USBH_CompletePortWakeIrpsWorker(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PVOID Context)
Definition: power.c:262
#define LOW_REALTIME_PRIORITY
void DbgBreakPoint()
Definition: mach.c:553
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
#define USBHUB_FDO_FLAG_HIBERNATE_STATE
Definition: usbhub.h:54
#define USBHUB_FDO_FLAG_WAIT_IDLE_REQUEST
Definition: usbhub.h:44
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:515
#define STATUS_INVALID_DEVICE_STATE
Definition: udferr_usr.h:178
PDEVICE_OBJECT DeviceObject
Definition: usbhub.h:119
SYSTEM_POWER_STATE SystemState
Definition: ntpoapi.h:57
FORCEINLINE VOID IoCopyCurrentIrpStackLocationToNext(_Inout_ PIRP Irp)
Definition: iofuncs.h:2820
UCHAR KIRQL
Definition: env_spec_w32.h:591
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
POWER_STATE CurrentPowerState
Definition: usbhub.h:222
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
NTSTATUS NTAPI USBH_PowerIrpCompletion(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
Definition: power.c:349
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:435
PVOID DeviceExtension
Definition: env_spec_w32.h:418
unsigned char BOOLEAN
PUSBHUB_FDO_EXTENSION NTAPI USBH_GetRootHubExtension(IN PUSBHUB_FDO_EXTENSION HubExtension)
Definition: usbhub.c:699
smooth NULL
Definition: ftsmooth.c:416
VOID NTAPI USBH_CheckIdleDeferred(IN PUSBHUB_FDO_EXTENSION HubExtension)
Definition: usbhub.c:3876
#define IoCompleteRequest
Definition: irp.c:1240
void DPRINT(...)
Definition: polytest.cpp:61
LONG PendingRequestCount
Definition: usbhub.h:180
#define USBHUB_FDO_FLAG_DO_ENUMERATION
Definition: usbhub.h:52
enum _DEVICE_POWER_STATE DEVICE_POWER_STATE
#define USBHUB_FDO_FLAG_NOT_D0_STATE
Definition: usbhub.h:43
#define InterlockedExchangePointer(Target, Value)
Definition: dshow.h:45
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
POWER_STATE SystemPowerState
Definition: usbhub.h:161
static void Exit(void)
Definition: sock.c:1331
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
#define STATUS_CANCELLED
Definition: udferr_usr.h:170
DEVICE_POWER_STATE DeviceState
Definition: ntpoapi.h:58
NTSTATUS NTAPI USBH_FdoPower(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PIRP Irp, IN UCHAR Minor)
Definition: power.c:460
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
KEVENT PendingRequestEvent
Definition: usbhub.h:181
unsigned char UCHAR
Definition: xmlstorage.h:181
#define USBHUB_FDO_FLAG_DEVICE_STARTED
Definition: usbhub.h:33
#define InterlockedDecrement
Definition: armddk.h:52
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
#define IRP_MN_SET_POWER
VOID NTAPI USBH_IdleCancelPowerHubWorker(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PVOID Context)
Definition: power.c:135
Definition: typedefs.h:117
VOID NTAPI USBH_CompletePowerIrp(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PIRP Irp, IN NTSTATUS NtStatus)
Definition: power.c:18
#define DPRINT_PWR(...)
Definition: dbg_uhub.h:108
_In_ UCHAR MinorFunction
Definition: pofuncs.h:42
#define USBHUB_FDO_FLAG_SET_D0_STATE
Definition: usbhub.h:42
#define InterlockedExchange
Definition: armddk.h:54
VOID NTAPI IoReleaseCancelSpinLock(IN KIRQL Irql)
Definition: util.c:150
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
POWER_STATE CurrentPowerState
Definition: usbhub.h:160
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
#define EVENT_INCREMENT
Definition: iotypes.h:565
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define InterlockedIncrement
Definition: armddk.h:53
#define USBHUB_FDO_FLAG_DEVICE_STOPPING
Definition: usbhub.h:34
VOID NTAPI PoStartNextPowerIrp(IN PIRP Irp)
Definition: power.c:626
PDEVICE_OBJECT LowerPDO
Definition: usbhub.h:149
LONG NTAPI KeReleaseSemaphore(IN PKSEMAPHORE Semaphore, IN KPRIORITY Increment, IN LONG Adjustment, IN BOOLEAN Wait)
Definition: semphobj.c:54
unsigned short USHORT
Definition: pedump.c:61
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
NTSTATUS NTAPI USBH_SubmitStatusChangeTransfer(IN PUSBHUB_FDO_EXTENSION HubExtension)
Definition: usbhub.c:2361
PDEVICE_OBJECT RootHubPdo
Definition: usbhub.h:151
NTSTATUS NTAPI USBH_PdoPower(IN PUSBHUB_PORT_PDO_EXTENSION PortExtension, IN PIRP Irp, IN UCHAR Minor)
Definition: power.c:757
#define DPRINT1
Definition: precomp.h:8
BOOLEAN NTAPI IoCancelIrp(IN PIRP Irp)
Definition: irp.c:1101
NTSTATUS NTAPI USBH_HubSetD0(IN PUSBHUB_FDO_EXTENSION HubExtension)
Definition: power.c:77
#define USBH_EXTENSION_TYPE_HUB
Definition: usbhub.h:28
VOID NTAPI USBH_HubCancelWakeIrp(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PIRP Irp)
Definition: power.c:43
BOOLEAN NTAPI USBH_CheckIdleAbort(IN PUSBHUB_FDO_EXTENSION HubExtension, IN BOOLEAN IsWait, IN BOOLEAN IsExtCheck)
Definition: usbhub.c:3140
struct tagContext Context
Definition: acpixf.h:1030
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:566
#define IRP_MN_WAIT_WAKE
NTSTATUS NTAPI PoRequestPowerIrp(IN PDEVICE_OBJECT DeviceObject, IN UCHAR MinorFunction, IN POWER_STATE PowerState, IN PREQUEST_POWER_COMPLETE CompletionFunction, IN PVOID Context, OUT PIRP *pIrp OPTIONAL)
Definition: power.c:528
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
VOID NTAPI USBH_HubQueuePortWakeIrps(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PLIST_ENTRY ListIrps)
Definition: power.c:160
return STATUS_SUCCESS
Definition: btrfs.c:2938
IoMarkIrpPending(Irp)
signed int * PLONG
Definition: retypes.h:5
_Inout_opt_ PUNICODE_STRING Extension
Definition: fltkernel.h:1092
VOID NTAPI USBH_HubCompletePortWakeIrps(IN PUSBHUB_FDO_EXTENSION HubExtension, IN NTSTATUS NtStatus)
Definition: power.c:217