ReactOS 0.4.15-dev-7705-g2320c37
fxpoweridlestatemachine.hpp
Go to the documentation of this file.
1//
2// Copyright (C) Microsoft. All rights reserved.
3//
4#ifndef _FXPOWERIDLESTATEMACHINE_H_
5#define _FXPOWERIDLESTATEMACHINE_H_
6
7//
8// This is a magical number based on inspection. If the queue overflows,
9// it is OK to increase these numbers without fear of either dependencies or
10// weird side affects.
11//
13
15 // CAN BE REUSED = 0x0001,
27 PowerIdleNull = 0x0000,
28};
29
30// begin_wpp config
31// CUSTOM_TYPE(FxPowerIdleEvents, ItemEnum(FxPowerIdleEvents));
32// end_wpp
33
70};
71
72//
73// NOTE: if you change these flags (order, values, etc), you must also modify
74// m_FlagsByName to match your changes.
75//
85};
86
90};
91
92typedef
96 );
97
100
102
103#if FX_SUPER_DBG
104 BOOLEAN EventDebugged;
105#endif
106};
107
110
112
114};
115
117
118public:
120 VOID
121 );
122
124 VOID
125 );
126
129 Init(
130 VOID
131 );
132
133 VOID
135 VOID
136 );
137
138 BOOLEAN
140 VOID
141 );
142
143 VOID
144 Start(
145 VOID
146 );
147
148 VOID
149 Stop(
150 VOID
151 );
152
153 VOID
154 Reset(
155 VOID
156 );
157
161 VOID
162 );
163
169 );
170
171 VOID
174 __in_opt LONG Line = 0,
176 );
177
178 BOOLEAN
180 VOID
181 );
182
183 VOID
185 VOID
186 )
187 {
189 }
190
196 __in_opt LONG Line = 0,
198 )
199 {
201 }
202
207 )
208 {
209 return PowerReferenceWorker(FALSE, // WaitForD0
210 Flags);
211 }
212
213 VOID
216 );
217
218protected:
219
220 VOID
223 );
224
225 BOOLEAN
227 VOID
228 )
229 {
231 }
232
233 BOOLEAN
235 VOID
236 )
237 {
238 //
239 // If we are canceling the timer, be well sure it is started
240 //
242
244 m_Flags &= ~FxPowerIdleTimerStarted;
245 return TRUE;
246 }
247 else {
248 return FALSE;
249 }
250 }
251
252 BOOLEAN
254 VOID
255 )
256 {
258 }
259
260 VOID
262 VOID
263 );
264
271 __in_opt LONG Line = 0,
273 );
274
275 static
278
279 static
281 Stopped(
283 );
284
285 static
287 Started(
289 );
290
291 static
295 );
296
297 static
301 );
302
303 static
305 Disabled(
307 );
308
309 static
313 );
314
315 static
319 );
320
321 static
325 );
326
327 static
329 TimingOut(
331 );
332
333 static
337 );
338
339 static
343 );
344
345 static
349 );
350
351 static
353 GoingToDx(
355 );
356
357 static
361 );
362
363 static
367 );
368
369 static
373 );
374
375 static
379 );
380
381 static
385 );
386
387 static
391 );
392
393 static
395 PowerUp(
397 );
398
399 static
403 );
404
405 static
409 );
410
411 static
415 );
416
417 static
421 );
422
423 static
427 );
428
429 static
431 Disabling(
433 );
434
435 static
439 );
440
441 static
445 );
446
447private:
448 VOID
450 VOID
451 );
452
453public:
455
456protected:
457 //
458 // Lock which guards state
459 //
461
462 //
463 // Number of pending requests which require being in D0
464 //
466
467 //
468 // Tracks power references and releases.
469 //
471
472 //
473 // Timer which will be set when the I/O count goes to zero
474 //
476
477 //
478 // Event to wait on when transitioning from Dx to D0
479 //
481
482 union {
483 //
484 // Combintaion of FxPowerIdleFlags enum values
485 //
487
488 //
489 // Not used in the code. Here so that you can easily decode m_Flags in
490 // the debugger without needing the enum definition.
491 //
492 struct {
502 };
503
504 //
505 // Index into m_EventHistory where to place the next value
506 //
508
509 //
510 // Index into m_StateHistory where to place the next value
512
513 //
514 // our current state
515 //
517
518 //
519 // Circular history of events fed into this state machine
520 //
522
523 //
524 // Circular history of states the state machine was in
525 //
527
538
540
541 //
542 // We use a coalescable timer for idle timeout. The tolerable delay for the
543 // idle timer is defined below. The value below is an arbitrary choice and
544 // can be changed if necessary. MSDN documentation suggests 100 ms as being
545 // a reasonable choice.
546 //
548};
549
550#endif // _FXPOWERIDLESTATEMACHINE_H_
unsigned char BOOLEAN
@ Started
Definition: acpisys.h:14
LONG NTSTATUS
Definition: precomp.h:26
Definition: File.h:16
static const FxIdleStateTable m_StateTable[]
static FxPowerIdleStates InDxDisabled(__inout FxPowerIdleMachine *This)
static MdDeferredRoutineType _PowerTimeoutDpcRoutine
static FxPowerIdleStates PowerUp(__inout FxPowerIdleMachine *This)
static const FxPowerIdleTargetState m_StoppedStates[]
static FxPowerIdleStates CheckIoCount(__inout FxPowerIdleMachine *This)
static FxPowerIdleStates TimedOutEnabled(__inout FxPowerIdleMachine *This)
static const FxPowerIdleTargetState m_TimedOutStates[]
static FxPowerIdleStates DecrementIo(__inout FxPowerIdleMachine *This)
static FxPowerIdleStates TimingOut(__inout FxPowerIdleMachine *This)
static FxPowerIdleStates InDxPowerUpFailure(__inout FxPowerIdleMachine *This)
static FxPowerIdleStates InDxIoIncrement(__inout FxPowerIdleMachine *This)
VOID ProcessEventLocked(__in FxPowerIdleEvents Event)
static FxPowerIdleStates PowerUpComplete(__inout FxPowerIdleMachine *This)
static FxPowerIdleStates PowerFailed(__inout FxPowerIdleMachine *This)
static FxPowerIdleStates StartedPowerFailed(__inout FxPowerIdleMachine *This)
static const FxPowerIdleTargetState m_WaitForTimeoutStates[]
_Must_inspect_result_ NTSTATUS PowerReference(__in BOOLEAN WaitForD0, __in_opt PVOID Tag=NULL, __in_opt LONG Line=0, __in_opt PSTR File=NULL)
static const ULONG m_IdleTimerTolerableDelayMS
static const FxPowerIdleTargetState m_DisabledStates[]
static FxPowerIdleStates TimedOutPowerDown(__inout FxPowerIdleMachine *This)
static FxPowerIdleStates TimedOutPowerDownFailed(__inout FxPowerIdleMachine *This)
struct FxPowerIdleMachine::@4774::@4776 m_FlagsByName
_Must_inspect_result_ NTSTATUS PowerReferenceWithFlags(__in FxPowerReferenceFlags Flags)
static FxPowerIdleStates Disabling(__inout FxPowerIdleMachine *This)
FxPowerIdleStates m_StateHistory[FxPowerIdleEventQueueDepth]
_Must_inspect_result_ NTSTATUS PowerReferenceWorker(__in BOOLEAN WaitForD0, __in FxPowerReferenceFlags Flags, __in_opt PVOID Tag=NULL, __in_opt LONG Line=0, __in_opt PSTR File=NULL)
static const FxPowerIdleTargetState m_StartedStates[]
FxPowerIdleEvents m_EventHistory[FxPowerIdleEventQueueDepth]
static FxPowerIdleStates InDx(__inout FxPowerIdleMachine *This)
static FxPowerIdleStates StartTimer(__inout FxPowerIdleMachine *This)
static FxPowerIdleStates CancelTimer(__inout FxPowerIdleMachine *This)
_Must_inspect_result_ NTSTATUS IoIncrement(VOID)
static FxPowerIdleStates InDxEnabled(__inout FxPowerIdleMachine *This)
static FxPowerIdleStates TimedOutDisabled(__inout FxPowerIdleMachine *This)
static const FxPowerIdleTargetState m_BusyStates[]
_Must_inspect_result_ NTSTATUS IoIncrementWithFlags(__in FxPowerReferenceFlags Flags, __out_opt PULONG Count=NULL)
static FxPowerIdleStates GoingToDx(__inout FxPowerIdleMachine *This)
static FxPowerIdleStates TimedOutIoIncrement(__inout FxPowerIdleMachine *This)
static FxPowerIdleStates TimerExpired(__inout FxPowerIdleMachine *This)
static const FxPowerIdleTargetState m_DisablingWaitForTimeoutStates[]
static const FxPowerIdleTargetState m_TimerRunningStates[]
static FxPowerIdleStates StartedPowerUp(__inout FxPowerIdleMachine *This)
FxPowerIdleStates m_CurrentIdleState
VOID ProcessPowerEvent(__in FxPowerIdleEvents Event)
static FxPowerIdleStates InDxStopped(__inout FxPowerIdleMachine *This)
static const FxPowerIdleTargetState m_InDxStates[]
VOID IoDecrement(__in_opt PVOID Tag=NULL, __in_opt LONG Line=0, __in_opt PSTR File=NULL)
static FxPowerIdleStates DisablingTimerExpired(__inout FxPowerIdleMachine *This)
static const FxPowerIdleTargetState m_PowerFailedWaitForTimeoutStates[]
Definition: mxlock.h:102
_Must_inspect_result_ __inline BOOLEAN Stop(VOID)
Definition: mxtimerkm.h:273
#define __out_opt
Definition: dbghelp.h:65
#define __in
Definition: dbghelp.h:35
#define __inout
Definition: dbghelp.h:50
#define __in_opt
Definition: dbghelp.h:38
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
@ Stopped
Definition: fbtusb.h:81
@ FxPowerIdleTimerCanceled
@ FxPowerIdleIsStarted
@ FxPowerIdlePowerFailed
@ FxPowerIdleSendPnpPowerUpEvent
@ FxPowerIdleTimerEnabled
@ FxPowerIdleTimerStarted
@ FxPowerIdleIoPresentSent
@ FxIdleCheckIoCount
@ FxIdleTimerRunning
@ FxIdleTimedOutEnabled
@ FxIdleDisablingWaitForTimeout
@ FxIdleInDxIoIncrement
@ FxIdleTimedOutIoIncrement
@ FxIdlePowerUpComplete
@ FxIdleTimedOutPowerDown
@ FxIdleDisablingTimerExpired
@ FxIdleTimerExpired
@ FxIdlePowerFailedWaitForTimeout
@ FxIdleInDxPowerUpFailure
@ FxIdleTimedOutPowerDownFailed
@ FxIdleStartedPowerUp
@ FxIdleTimedOutDisabled
@ FxIdleInDxDisabled
@ FxIdleStartedPowerFailed
@ FxIdleWaitForTimeout
const UCHAR FxPowerIdleEventQueueDepth
FxPowerIdleStates(* PFN_POWER_IDLE_STATE_ENTRY_FUNCTION)(FxPowerIdleMachine *)
@ FxPowerReferenceDefault
@ FxPowerReferenceSendPnpPowerUpEvent
@ PowerIdleEventIoIncrement
@ PowerIdleEventPowerUpComplete
@ PowerIdleEventEnabled
@ PowerIdleEventPowerDown
@ PowerIdleEventPowerDownFailed
@ PowerIdleEventStop
@ PowerIdleEventTimerExpired
@ PowerIdleEventDisabled
@ PowerIdleEventStart
@ PowerIdleEventPowerUpFailed
@ PowerIdleEventIoDecrement
_In_opt_ PVOID _Out_ BOOLEAN * Stop
Definition: ldrtypes.h:241
#define ASSERT(a)
Definition: mode.c:44
@ Disabled
Definition: mountmgr.h:158
#define _Must_inspect_result_
Definition: ms_sal.h:558
KDEFERRED_ROUTINE MdDeferredRoutineType
Definition: mxkm.h:35
int Count
Definition: noreturn.cpp:7
long LONG
Definition: pedump.c:60
NTSTATUS EnterCRAndWaitAndLeave(VOID)
Definition: fxwaitlock.hpp:87
LONG ReadState(VOID)
Definition: fxwaitlock.hpp:160
const FxPowerIdleTargetState * TargetStates
PFN_POWER_IDLE_STATE_ENTRY_FUNCTION StateFunc
Definition: ncftp.h:79
uint32_t * PULONG
Definition: typedefs.h:59
char * PSTR
Definition: typedefs.h:51
uint32_t ULONG
Definition: typedefs.h:59
@ Start
Definition: partlist.h:33
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
Definition: wdfdevice.h:4065
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN WaitForD0
Definition: wdfdevice.h:4006
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
unsigned char UCHAR
Definition: xmlstorage.h:181