ReactOS 0.4.15-dev-7788-g1ad9096
fxpowerstatemachine.hpp
Go to the documentation of this file.
1//
2// Copyright (C) Microsoft. All rights reserved.
3//
4#ifndef _FXPOWERSTATEMACHINE_H_
5#define _FXPOWERSTATEMACHINE_H_
6
7// @@SMVERIFY_SPLIT_BEGIN
8//
9// Treat these values as a bit field when comparing for known dropped events in
10// the current state and treat them as values when they known transition events
11// from state to the next.
12//
15 PowerD0 = 0x0001,
16 PowerDx = 0x0002,
29 = 0x2000,
30
31 //
32 // Not a real event, just a value that indicates all of the events which
33 // goto the head of the queue and are always processed, even if the state is
34 // locked.
35 //
40
41 //
42 // Not a real event, just a value that indicate all of the events which
43 // should not be in the queue, if a similar event is already enqueued.
44 //
46
48};
49
51 struct {
52 //
53 // Is this a state where we rest and wait for events to bring us out
54 // of that state.
55 //
56 // NOTE: this value is purely notational, we don't use it anywhere in
57 // the state machine. If need be, reuse this slot for something
58 // else without worry.
59 //
61
62 //
63 // Bit of events we know we can drop in this state
64 //
67
68 struct {
69 //
70 // Maps to the same bit location as QueueOpen. Since we start
71 // KnownDroppedEvents at the next bit, start our bits by at the next
72 // bit as well.
73 //
75
76 //
77 // These are defined so that we can easily tell in the debugger what
78 // each set bit in KnownDroppedEvents maps to in the FxPowerEvent enum
79 //
94};
95
96
99
101
103};
104
106
107typedef
110 FxPkgPnp*
111 );
112
113typedef struct POWER_STATE_TABLE {
114 //
115 // Function called when the state is entered
116 //
118
119 //
120 // First state transition out of this state
121 //
123
124 //
125 // Other state transitions out of this state if FirstTargetState is not
126 // matched. This is an array where we expect the final element to be
127 // { PowerEventMaximum, WdfDevStatePowerNull }
128 //
130
132
134
136
137#if FX_STATE_MACHINE_VERIFY
138#define MAX_POWER_STATE_ENTRY_FN_RETURN_STATES (5)
139
140struct POWER_STATE_ENTRY_FUNCTION_TARGET_STATE {
141 //
142 // Return value from state entry function
143 //
145
146 //
147 // type of device the returning state applies to
148 //
149 FxStateMachineDeviceType DeviceType;
150
151 //
152 // Info about the state transition
153 //
155};
156
157struct POWER_STATE_ENTRY_FN_RETURN_STATE_TABLE {
158 //
159 // array of state transitions caused by state entry function
160 //
161 POWER_STATE_ENTRY_FUNCTION_TARGET_STATE TargetStates[MAX_POWER_STATE_ENTRY_FN_RETURN_STATES];
162};
163
164typedef const POWER_STATE_ENTRY_FN_RETURN_STATE_TABLE* CPPOWER_STATE_ENTRY_FN_RETURN_STATE_TABLE;
165#endif // FX_STATE_MACHINE_VERIFY
166
167// @@SMVERIFY_SPLIT_END
168
169//
170// This type of union is done so that we can
171// 1) shrink the array element to the smallest size possible
172// 2) keep types within the structure so we can dump it in the debugger
173//
175 struct {
184 } E;
185
187};
188
189//
190// Same as FxPowerMachineEventQueue
191//
193 struct {
202 } S;
203
205};
206
209 VOID
211 {
212 //
213 // m_WaitWakeLock can not be initialized here since Initiliaze can
214 // return failure for UM. It's now being initialized in Init() function.
215 //
216
218
219 RtlZeroMemory(&m_Queue, sizeof(m_Queue));
221
226 }
227
230 Init(
231 __inout FxPkgPnp* Pnp,
233 );
234
236
238
239 //
240 // Lock to guard wait wake irp
241 //
243
244 //
245 // List of wait wake requests which have either been completed or cancelled
246 // and we are waiting for the state machine to process and complete the irp.
247 //
248 // We require a list of irps (instead of just storage for one irp) because
249 // the power policy owner might be misbehaving and sending wake requests
250 // successively down the stack and we want the state machine to be able
251 // to keep track of all the requests.
252 //
254
255 union {
257
258 union {
259 //
260 // These are defined so that we can easily tell in the debugger what
261 // each set bit in m_SingularEventsPresent maps to in the
262 // FxPowerEvent enum.
263 //
278 };
279
281
283};
284
285#endif // _FXPOWERSTATEMACHINE_H_
unsigned char BOOLEAN
@ Comment
Definition: asmpp.cpp:34
LONG NTSTATUS
Definition: precomp.h:26
Definition: mxlock.h:102
#define __in
Definition: dbghelp.h:35
#define __inout
Definition: dbghelp.h:50
#define FALSE
Definition: types.h:117
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
_Must_inspect_result_ _In_ PFLT_CALLBACK_DATA _In_ PFLT_DEFERRED_IO_WORKITEM_ROUTINE WorkerRoutine
Definition: fltkernel.h:1977
VOID(* PFN_PNP_EVENT_WORKER)(__in FxPkgPnp *PkgPnp, __in FxPostProcessInfo *Info, __in PVOID Context)
#define EVENT_TRAP_FIELD
Definition: fxpkgpnp.hpp:64
const UCHAR PowerEventQueueDepth
Definition: fxpkgpnp.hpp:34
const POWER_STATE_TABLE * CPPOWER_STATE_TABLE
@ PowerImplicitD3
@ PowerEventMaximum
@ PowerPriorityEventsMask
@ PowerWakeCanceled
@ PowerWakeSucceeded
@ PowerMarkPageable
@ PowerWakeFailed
@ PowerMarkNonpageable
@ PowerWakeInterruptCompleteTransition
@ PowerWakeArrival
@ PowerSingularEventMask
@ PowerImplicitD0
@ PowerCompleteD0
@ PowerEventInvalid
@ PowerCompleteDx
@ PowerParentToD0
WDF_DEVICE_POWER_STATE(* PFN_POWER_STATE_ENTRY_FUNCTION)(FxPkgPnp *)
const POWER_EVENT_TARGET_STATE * CPPPOWER_EVENT_TARGET_STATE
struct POWER_STATE_TABLE * PPOWER_STATE_TABLE
DeviceType
Definition: mmdrv.h:42
#define _Must_inspect_result_
Definition: ms_sal.h:558
unsigned short USHORT
Definition: pedump.c:61
UCHAR IncrementHistoryIndex(VOID)
FxPowerMachineEventQueue m_Queue
FxPowerMachineStateHistory m_States
union FxPowerMachine::@4786::@4788 m_SingularEventsPresentByName
LIST_ENTRY m_WaitWakeIrpToBeProcessedList
WDF_DEVICE_POWER_STATE TargetState
POWER_EVENT_TARGET_STATE FirstTargetState
PFN_POWER_STATE_ENTRY_FUNCTION StateFunc
CPPPOWER_EVENT_TARGET_STATE OtherTargetStates
FxPowerStateInfo StateInfo
Definition: typedefs.h:120
char * PSTR
Definition: typedefs.h:51
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG
Definition: typedefs.h:59
struct FxPowerMachineEventQueue::@4784 E
USHORT Events[PowerEventQueueDepth]
WDF_DEVICE_POWER_STATE State2
WDF_DEVICE_POWER_STATE State6
WDF_DEVICE_POWER_STATE State7
struct FxPowerMachineStateHistory::@4785 S
WDF_DEVICE_POWER_STATE State1
WDF_DEVICE_POWER_STATE State3
USHORT History[PowerEventQueueDepth]
WDF_DEVICE_POWER_STATE State5
WDF_DEVICE_POWER_STATE State8
WDF_DEVICE_POWER_STATE State4
struct FxPowerStateInfo::@4782 Bits
struct FxPowerStateInfo::@4783 BitsByName
enum _WDF_DEVICE_POWER_STATE WDF_DEVICE_POWER_STATE
@ WdfDevStatePowerObjectCreated
Definition: wdfdevice.h:130