ReactOS 0.4.16-dev-106-g10b08aa
powerpolicystatemachinekm.cpp
Go to the documentation of this file.
1/*++
2
3Copyright (c) Microsoft. All rights reserved.
4
5Module Name:
6
7 PowerPolicyStateMachineKM.cpp
8
9Abstract:
10
11
12Environment:
13
14 Kernel mode only
15
16Revision 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
28extern "C" {
29#if defined(EVENT_TRACING)
30#include "PowerPolicyStateMachineKM.tmh"
31#endif
32}
33
34VOID
37 )
38/*++
39
40Routine Description:
41 Gets source of wake if OS supports this.
42
43Arguments:
44 Irp
45
46Return 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
70 __in KIRQL CurrentIrql,
71 __in BOOLEAN CallerSpecifiedProcessingOnDifferentThread
72 )
73/*++
74Routine 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
109Arguemnts:
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
117Returns:
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
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
161VOID
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
196VOID
198 VOID
199 )
200{
202}
203
205VOID
206FxUsbIdleInfo::_UsbIdleCallback(
208 )
209{
211 FxUsbIdleInfo* pThis;
213
215
218 "Entering USB Selective Suspend Idle callback");
219
221
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
236VOID
238 VOID
239 )
240{
243}
244
245
246
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
WDFDEVICE __inline GetHandle(VOID)
Definition: fxdevice.hpp:237
MdDeviceObject __inline GetDeviceObject(VOID)
Definition: fxdevice.hpp:174
Definition: fxirp.hpp:28
static _Must_inspect_result_ MdIrp AllocateIrp(_In_ CCHAR StackSize, _In_opt_ FxDevice *Device=NULL)
Definition: fxirpum.cpp:1089
BOOLEAN Cancel(VOID)
Definition: fxirpum.cpp:475
MdIrp SetIrp(MdIrp irp)
Definition: fxirpkm.hpp:71
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
CfxDevice * m_Device
Definition: fxobject.hpp:329
BOOLEAN ShouldProcessPowerPolicyEventOnDifferentThread(__in KIRQL CurrentIrql, __in BOOLEAN CallerSpecifiedProcessingOnDifferentThread)
VOID PowerPolicyUpdateSystemWakeSource(__in FxIrp *Irp)
VOID PowerPolicySubmitUsbIdleNotification(VOID)
VOID PowerPolicyCancelUsbSS(VOID)
FxPowerPolicyMachine m_PowerPolicyMachine
Definition: fxpkgpnp.hpp:4153
VOID PowerPolicyProcessEvent(__in FxPowerPolicyEvent Event, __in BOOLEAN ProcessEventOnDifferentThread=FALSE)
__inline VOID SetObject(__in_opt MdDeviceObject DeviceObject)
CCHAR GetStackSize(VOID)
_In_ PIRP Irp
Definition: csq.h:116
#define __in
Definition: dbghelp.h:35
#define TRACINGPNP
Definition: dbgtrace.h:67
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define __drv_maxIRQL(irql)
Definition: driverspecs.h:291
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
UCHAR KIRQL
Definition: env_spec_w32.h:591
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
FxPkgPnp * pPkgPnp
#define ROSWDFNOTIMPLEMENTED
Definition: fxglobals.h:52
@ PwrPolUsbSelectiveSuspendCallback
FxIrp * pIrp
struct _cl_event * event
Definition: glext.h:7739
#define ASSERT(a)
Definition: mode.c:44
#define _Must_inspect_result_
Definition: ms_sal.h:558
IWudfIrp * MdIrp
Definition: mxum.h:103
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define STATUS_SUCCESS
Definition: shellext.h:65
#define TRACE_LEVEL_VERBOSE
Definition: storswtr.h:30
#define TRACE_LEVEL_INFORMATION
Definition: storswtr.h:29
FxCREvent * GetSelfPointer(VOID)
Definition: fxwaitlock.hpp:180
VOID Set(VOID)
Definition: fxwaitlock.hpp:144
FxPowerPolicyOwnerSettings * m_Owner
FxAutoIrp m_IdleIrp
FxCREvent * m_IdleCallbackEvent
USB_IDLE_CALLBACK_INFO m_CallbackInfo
_Must_inspect_result_ NTSTATUS Initialize(VOID)
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158