ReactOS  0.4.15-dev-3439-g2693a26
powerpolicystatemachinekm.cpp
Go to the documentation of this file.
1 /*++
2 
3 Copyright (c) Microsoft. All rights reserved.
4 
5 Module Name:
6 
7  PowerPolicyStateMachineKM.cpp
8 
9 Abstract:
10 
11 
12 Environment:
13 
14  Kernel mode only
15 
16 Revision History:
17 
18 --*/
19 
20 #include "../pnppriv.hpp"
21 
22 #if FX_IS_KERNEL_MODE
23 #include <usbdrivr.h>
24 #endif
25 
26 #include "fxusbidleinfo.hpp"
27 
28 extern "C" {
29 #if defined(EVENT_TRACING)
30 #include "PowerPolicyStateMachineKM.tmh"
31 #endif
32 }
33 
34 VOID
36  __in FxIrp* Irp
37  )
38 /*++
39 
40 Routine Description:
41  Gets source of wake if OS supports this.
42 
43 Arguments:
44  Irp
45 
46 Return Value:
47  None
48 
49  --*/
50 {
51  //
52  // Check to see if this device caused the machine to wake up
53  //
55  PoGetSystemWake(Irp->GetIrp());
56 
60  "WDFDEVICE 0x%p !devobj 0x%p WW !irp 0x%p is a source of "
61  "wake",
64  Irp->GetIrp());
65  }
66 }
67 
68 BOOLEAN
70  __in KIRQL CurrentIrql,
71  __in BOOLEAN CallerSpecifiedProcessingOnDifferentThread
72  )
73 /*++
74 Routine Description:
75 
76  This function returns whether the power policy state machine should process
77  the current event on the same thread or on a different one.
78 
79 
80 
81 
82 
83 
84 
85 
86 
87 
88 
89 
90 
91 
92 
93 
94 
95 
96 
97 
98 
99 
100 
101 
102 
103 
104 
105 
106 
107 
108 
109 Arguemnts:
110 
111  CurrentIrql - The current IRQL
112 
113  CallerSpecifiedProcessingOnDifferentThread - Whether or not caller of
114  PowerPolicyProcessEvent specified that the event be processed on a
115  different thread.
116 
117 Returns:
118  TRUE if the power policy state machine should process the event on a
119  different thread.
120 
121  FALSE if the power policy state machine should process the event on the
122  same thread
123 
124 --*/
125 {
126  //
127  // For KMDF, we ignore what the caller of PowerPolicyProcessEvent specified
128  // (which should always be FALSE, BTW) and base our decision on the current
129  // IRQL. If we are running at PASSIVE_LEVEL, we process on the same thread
130  // else we queue a work item.
131  //
132  UNREFERENCED_PARAMETER(CallerSpecifiedProcessingOnDifferentThread);
133 
134  ASSERT(FALSE == CallerSpecifiedProcessingOnDifferentThread);
135 
136  return (CurrentIrql == PASSIVE_LEVEL) ? FALSE : TRUE;
137 }
138 
140 NTSTATUS
142  VOID
143  )
144 {
145  MdIrp pIrp;
146  MxDeviceObject attachedDevObj;
147 
148  attachedDevObj.SetObject(((FxPkgPnp*)m_CallbackInfo.IdleContext)->GetDevice()->GetAttachedDevice());
149 
150  pIrp = FxIrp::AllocateIrp(attachedDevObj.GetStackSize());
151 
152  if (pIrp == NULL) {
154  }
155 
157 
158  return STATUS_SUCCESS;
159 }
160 
161 VOID
163  VOID
164  )
165 {
166  // FxIrp* usbIdleIrp;
167 
168  // //
169  // // This will be set to TRUE if USBSS completion event gets dropped.
170  // //
171  // m_PowerPolicyMachine.m_Owner->m_UsbIdle->m_EventDropped = FALSE;
172 
173  // usbIdleIrp = &m_PowerPolicyMachine.m_Owner->m_UsbIdle->m_IdleIrp;
174 
175  // usbIdleIrp->Reuse();
176 
177  // usbIdleIrp->SetCompletionRoutineEx(
178  // m_Device->GetDeviceObject(),
179  // _PowerPolicyUsbSelectiveSuspendCompletionRoutine,
180  // this);
181 
182  // usbIdleIrp->SetMajorFunction(IRP_MJ_INTERNAL_DEVICE_CONTROL);
183  // usbIdleIrp->SetParameterIoctlCode(
184  // IOCTL_INTERNAL_USB_SUBMIT_IDLE_NOTIFICATION);
185  // usbIdleIrp->SetParameterIoctlInputBufferLength(
186  // sizeof(m_PowerPolicyMachine.m_Owner->m_UsbIdle->m_CallbackInfo));
187  // usbIdleIrp->SetParameterIoctlType3InputBuffer(
188  // (PVOID) &m_PowerPolicyMachine.m_Owner->m_UsbIdle->m_CallbackInfo);
189 
190  // m_PowerPolicyMachine.m_Owner->m_UsbIdle->m_IdleIrp.CallDriver(
191  // m_Device->GetAttachedDevice()
192  // );
194 }
195 
196 VOID
198  VOID
199  )
200 {
202 }
203 
205 VOID
206 FxUsbIdleInfo::_UsbIdleCallback(
208  )
209 {
210  FxPkgPnp* pPkgPnp;
211  FxUsbIdleInfo* pThis;
213 
214  pPkgPnp = (FxPkgPnp*) Context;
215 
218  "Entering USB Selective Suspend Idle callback");
219 
221 
222  ASSERT(pThis->m_IdleCallbackEvent == NULL);
223  pThis->m_IdleCallbackEvent = event.GetSelfPointer();
224 
226 
227  event.EnterCRAndWaitAndLeave();
228  pThis->m_IdleCallbackEvent = NULL;
229 
232  "Leaving USB Selective Suspend Idle callback");
233 }
234 
235 
236 VOID
238  VOID
239  )
240 {
243 }
244 
245 
246 
CfxDevice * m_Device
Definition: fxobject.hpp:329
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
CCHAR GetStackSize(VOID)
MdDeviceObject __inline GetDeviceObject(VOID)
Definition: fxdevice.hpp:174
FxCREvent * m_IdleCallbackEvent
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
WDFDEVICE __inline GetHandle(VOID)
Definition: fxdevice.hpp:237
__drv_maxIRQL(PASSIVE_LEVEL) VOID FxUsbIdleInfo
LONG NTSTATUS
Definition: precomp.h:26
FxAutoIrp m_IdleIrp
Definition: fxirp.hpp:28
FxPowerPolicyMachine m_PowerPolicyMachine
Definition: fxpkgpnp.hpp:4153
FxIrp * pIrp
VOID PowerPolicySubmitUsbIdleNotification(VOID)
VOID Set(VOID)
Definition: fxwaitlock.hpp:144
#define TRACE_LEVEL_INFORMATION
Definition: storswtr.h:29
VOID PowerPolicyCancelUsbSS(VOID)
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define FALSE
Definition: types.h:117
_In_ PIRP Irp
Definition: csq.h:116
#define TRACE_LEVEL_VERBOSE
Definition: storswtr.h:30
USB_IDLE_CALLBACK_INFO m_CallbackInfo
unsigned char BOOLEAN
IWudfIrp * MdIrp
Definition: mxum.h:103
_Must_inspect_result_ NTSTATUS Initialize(VOID)
FxPkgPnp * pPkgPnp
FxPowerPolicyOwnerSettings * m_Owner
#define ROSWDFNOTIMPLEMENTED
Definition: fxglobals.h:52
#define ASSERT(a)
Definition: mode.c:44
VOID PowerPolicyProcessEvent(__in FxPowerPolicyEvent Event, __in BOOLEAN ProcessEventOnDifferentThread=FALSE)
static _Must_inspect_result_ MdIrp AllocateIrp(_In_ CCHAR StackSize, _In_opt_ FxDevice *Device=NULL)
Definition: fxirpum.cpp:1089
struct _cl_event * event
Definition: glext.h:7739
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
#define _Must_inspect_result_
Definition: ms_sal.h:558
#define TRACINGPNP
Definition: dbgtrace.h:67
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
BOOLEAN ShouldProcessPowerPolicyEventOnDifferentThread(__in KIRQL CurrentIrql, __in BOOLEAN CallerSpecifiedProcessingOnDifferentThread)
__inline VOID SetObject(__in_opt MdDeviceObject DeviceObject)
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
#define NULL
Definition: types.h:112
VOID PowerPolicyUpdateSystemWakeSource(__in FxIrp *Irp)
BOOLEAN Cancel(VOID)
Definition: fxirpum.cpp:475
#define STATUS_SUCCESS
Definition: shellext.h:65
MdIrp SetIrp(MdIrp irp)
Definition: fxirpkm.hpp:71
#define __in
Definition: dbghelp.h:35