ReactOS  0.4.15-dev-2947-g59e1b78
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,
17  PowerWakeArrival = 0x0004,
19  PowerWakeFailed = 0x0010,
21  PowerImplicitD0 = 0x0040,
22  PowerImplicitD3 = 0x0080,
23  PowerParentToD0 = 0x0100,
26  PowerCompleteD0 = 0x0800,
27  PowerCompleteDx = 0x1000,
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  //
66  } Bits;
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  //
93  } BitsByName;
94 };
95 
96 
99 
101 
103 };
104 
106 
107 typedef
110  FxPkgPnp*
111  );
112 
113 typedef 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 
140 struct 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  //
154  PSTR Comment;
155 };
156 
157 struct 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 
164 typedef 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));
220  RtlZeroMemory(&m_States, sizeof(m_States));
221 
226  }
227 
229  NTSTATUS
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_
const UCHAR PowerEventQueueDepth
Definition: fxpkgpnp.hpp:34
FxPowerStateInfo StateInfo
USHORT History[PowerEventQueueDepth]
struct FxPowerMachineStateHistory::@4575 S
POWER_EVENT_TARGET_STATE FirstTargetState
_Must_inspect_result_ _In_ PFLT_CALLBACK_DATA _In_ PFLT_DEFERRED_IO_WORKITEM_ROUTINE WorkerRoutine
Definition: fltkernel.h:1976
LONG NTSTATUS
Definition: precomp.h:26
_In_ ULONG _In_ ULONG State
Definition: potypes.h:516
WDF_DEVICE_POWER_STATE TargetState
WDF_DEVICE_POWER_STATE State2
UCHAR IncrementHistoryIndex(VOID)
#define EVENT_TRAP_FIELD
Definition: fxpkgpnp.hpp:64
WDF_DEVICE_POWER_STATE(* PFN_POWER_STATE_ENTRY_FUNCTION)(FxPkgPnp *)
const POWER_STATE_TABLE * CPPOWER_STATE_TABLE
struct FxPowerMachineEventQueue::@4574 E
const POWER_EVENT_TARGET_STATE * CPPPOWER_EVENT_TARGET_STATE
WDF_DEVICE_POWER_STATE State6
#define FALSE
Definition: types.h:117
VOID(* PFN_PNP_EVENT_WORKER)(__in FxPkgPnp *PkgPnp, __in FxPostProcessInfo *Info, __in PVOID Context)
unsigned char BOOLEAN
struct FxPowerStateInfo::@4573 BitsByName
DeviceType
Definition: mmdrv.h:41
_Must_inspect_result_ NTSTATUS Init(__inout FxPkgPnp *Pnp, __in PFN_PNP_EVENT_WORKER WorkerRoutine)
WDF_DEVICE_POWER_STATE State5
WDF_DEVICE_POWER_STATE State4
FxPowerMachineEventQueue m_Queue
union FxPowerMachine::@4576::@4578 m_SingularEventsPresentByName
WDF_DEVICE_POWER_STATE State3
FxPowerMachineStateHistory m_States
#define __inout
Definition: dbghelp.h:50
Definition: typedefs.h:119
#define _Must_inspect_result_
Definition: ms_sal.h:558
WDF_DEVICE_POWER_STATE State7
Definition: mxlock.h:101
PFN_POWER_STATE_ENTRY_FUNCTION StateFunc
unsigned short USHORT
Definition: pedump.c:61
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
signed char * PSTR
Definition: retypes.h:7
WDF_DEVICE_POWER_STATE State8
USHORT Events[PowerEventQueueDepth]
WDF_DEVICE_POWER_STATE State1
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
CPPPOWER_EVENT_TARGET_STATE OtherTargetStates
enum _WDF_DEVICE_POWER_STATE WDF_DEVICE_POWER_STATE
struct POWER_STATE_TABLE * PPOWER_STATE_TABLE
#define __in
Definition: dbghelp.h:35
LIST_ENTRY m_WaitWakeIrpToBeProcessedList
struct FxPowerStateInfo::@4572 Bits