ReactOS 0.4.16-dev-91-g764881a
fxeventqueue.hpp
Go to the documentation of this file.
1//
2// Copyright (C) Microsoft. All rights reserved.
3//
4#ifndef _FXEVENTQUEUE_H_
5#define _FXEVENTQUEUE_H_
6
9 VOID
10 )
11 {
12 m_Event = NULL;
16 }
17
20 VOID
21 )
22 {
23 return ((m_Event != NULL) || m_DeleteObject) ? TRUE : FALSE;
24 }
25
26 VOID
28 __inout FxPkgPnp* PkgPnp
29 );
30
35};
36
37typedef
40 __in FxPkgPnp* PkgPnp,
43 );
44
49};
50
51struct FxEventQueue : public FxStump {
53 __in UCHAR QueueDepth
54 );
55
60 );
61
65 VOID
66 Lock(
69 )
70 {
71 m_QueueLock.Acquire(Irql);
72 }
73
76 VOID
77 Unlock(
80 )
81 {
82 m_QueueLock.Release(Irql);
83 }
84
87 VOID
88 )
89 {
91 }
92
95 VOID
96 )
97 {
98 return m_QueueHead == m_QueueTail;
99 }
100
101 VOID
103 VOID
104 )
105 {
107 }
108
109 UCHAR
111 VOID
112 )
113 {
114 return m_QueueHead;
115 }
116
117 UCHAR
119 VOID
120 )
121 {
123 return m_QueueHead;
124 }
125
126 UCHAR
128 VOID
129 )
130 {
131 UCHAR index;
132
133 // Save the index which is the current tail
135
136 // goto next slot
138
139 // return the old tail as the slot to insert at
140 return index;
141 }
142
143 UCHAR
145 VOID
146 )
147 {
148 UCHAR cur;
149
152
153 return cur;
154 }
155
156 BOOLEAN
158 VOID
159 )
160 {
162 }
163
164 VOID
167 )
168 {
169 if (IsIdleLocked()) {
171 m_QueueFlags &= ~FxEventQueueFlagDelayDeletion;
172 Info->m_DeleteObject = TRUE;
173 }
174
175 if (IsClosedLocked()) {
176 Info->m_Event = m_WorkItemFinished;
178 }
179 }
180 }
181
182 BOOLEAN
185 );
186
187 VOID
189 VOID
190 );
191
192protected:
193 VOID
194 Configure(
195 __in FxPkgPnp* Pnp,
198 );
199
200 BOOLEAN
202 VOID
203 );
204
205 VOID
207 VOID
208 );
209
210 BOOLEAN
212 VOID
213 )
214 {
215 //
216 // We are idle if there is no work item queued, no work item running,
217 // and there are no events in the queue. Since m_WorkItemQueued is
218 // cleared before we enter the state machine, we must also track the
219 // number of work items running.
220 //
222 m_WorkItemRunningCount == 0x0 &&
223 IsEmpty()) {
224 return TRUE;
225 }
226 else {
227 return FALSE;
228 }
229 }
230
231protected:
232 // index into the beginning of the circular event ring buffer
234
235 // index into the end of the circular event ring buffer
237
238 // circular event ring buffer size
240
242
244
245 //
246 // Context that is passed back to the the state machine as
247 // part of the event worker
248 //
250
251 //
252 // Lock for the queue
253 //
255
256public:
258
259protected:
261
262 //
263 // Guarded by m_QueueLock. Will be set to a valid pointer value when pnp
264 // wants to remove the device and we want to synchronize against the work
265 // item running.
266 //
268
269 //
270 //
271 union {
272 //
273 // See FxEventQueueFlags for values
274 //
276
277 struct {
282 };
283
284 //
285 // Count of times the work item is running. Since m_WorkItemQueued is
286 // cleared before we enter the state machine, we must also track the
287 // number of instances to make sure we know when we are idle or not.
288 //
290};
291
294 __in UCHAR QueueDepth
295 );
296
298
301 Init(
302 __inout FxPkgPnp* Pnp,
304 __in PVOID WorkerContext = NULL
305 );
306
307 VOID
309 VOID
310 )
311 {
312 if (QueueToThreadWorker()) {
314 }
315 }
316
317protected:
318 VOID
320 VOID
321 );
322
323 static
326
328};
329
330//
331// struct that encapsulates posting a work item to the dedicated power thread
332// or work item depending on the power pagable status of the stack.
333//
336 __in UCHAR QueueDepth
337 );
338
340 VOID
341 );
342
345 Init(
346 __inout FxPkgPnp* Pnp,
348 __in PVOID WorkerContext = NULL
349 );
350
351 VOID
353 VOID
354 )
355 {
356 if (QueueToThreadWorker()) {
358 }
359 }
360
361protected:
362 static
363 WORKER_THREAD_ROUTINE
365
366 static
369
370 VOID
372 VOID
373 );
374
376
377 // work item used to queue to the thread
379};
380
381#endif // _FXEVENTQUEUE_H_
unsigned char BOOLEAN
#define VOID
Definition: acefi.h:82
LONG NTSTATUS
Definition: precomp.h:26
#define index(s, c)
Definition: various.h:29
Definition: mxlock.h:102
_Out_ PKIRQL Irql
Definition: csq.h:179
#define __in
Definition: dbghelp.h:35
#define __inout
Definition: dbghelp.h:50
#define __out
Definition: dbghelp.h:62
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
@ IsEmpty
Definition: atl_ax.c:995
#define __drv_savesIRQL
Definition: driverspecs.h:326
#define __drv_deref(annotes)
Definition: driverspecs.h:265
#define __drv_setsIRQL(irql)
Definition: driverspecs.h:328
#define __drv_restoresIRQL
Definition: driverspecs.h:322
#define __drv_requiresIRQL(irql)
Definition: driverspecs.h:321
#define __drv_maxIRQL(irql)
Definition: driverspecs.h:291
UCHAR KIRQL
Definition: env_spec_w32.h:591
KIRQL * PKIRQL
Definition: env_spec_w32.h:592
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
_Must_inspect_result_ _In_ PFLT_CALLBACK_DATA _In_ PFLT_DEFERRED_IO_WORKITEM_ROUTINE WorkerRoutine
Definition: fltkernel.h:1977
DriverGlobals
VOID(* PFN_PNP_EVENT_WORKER)(__in FxPkgPnp *PkgPnp, __in FxPostProcessInfo *Info, __in PVOID Context)
FxEventQueueFlags
@ FxEventQueueFlagWorkItemQueued
@ FxEventQueueFlagClosed
@ FxEventQueueFlagDelayDeletion
FxCollectionEntry * cur
GLuint index
Definition: glext.h:6031
#define _Must_inspect_result_
Definition: ms_sal.h:558
IWudfIrp * MdIrp
Definition: mxum.h:103
IO_WORKITEM_ROUTINE MX_WORKITEM_ROUTINE
Definition: mxworkitemkm.h:26
@ Unlock
Definition: ntsecapi.h:294
VOID IncrementHead(VOID)
UCHAR m_HistoryIndex
BOOLEAN QueueToThreadWorker(VOID)
Definition: eventqueue.cpp:154
UCHAR IncrementHistoryIndex(VOID)
UCHAR WorkItemQueued
UCHAR InsertAtTail(VOID)
MxLock m_QueueLock
UCHAR m_WorkItemRunningCount
VOID EventQueueWorker(VOID)
Definition: eventqueue.cpp:229
FxPkgPnp * m_PkgPnp
BOOLEAN IsIdleLocked(VOID)
BOOLEAN IsEmpty(VOID)
UCHAR InsertAtHead(VOID)
FxWaitLockInternal m_StateMachineLock
BOOLEAN IsClosedLocked(VOID)
UCHAR GetHead(VOID)
VOID Configure(__in FxPkgPnp *Pnp, __in PFN_PNP_EVENT_WORKER WorkerRoutine, __in PVOID Context)
Definition: eventqueue.cpp:77
FxCREvent * m_WorkItemFinished
BOOLEAN SetFinished(__in FxCREvent *Event)
Definition: eventqueue.cpp:91
VOID GetFinishedState(__inout FxPostProcessInfo *Info)
PFN_PNP_EVENT_WORKER m_EventWorker
BOOLEAN IsFull(VOID)
_Releases_lock_(this->m_QueueLock) __drv_requiresIRQL(DISPATCH_LEVEL) VOID Unlock(__in __drv_restoresIRQL KIRQL Irql)
struct FxEventQueue::@4754::@4756 m_QueueFlagsByName
_Acquires_lock_(this->m_QueueLock) __drv_maxIRQL(DISPATCH_LEVEL) __drv_setsIRQL(DISPATCH_LEVEL) VOID Lock(__out __drv_deref(__drv_savesIRQL) PKIRQL Irql)
PVOID m_EventWorkerContext
VOID SetDelayedDeletion(VOID)
Definition: eventqueue.cpp:135
BOOLEAN m_SetRemovedEvent
BOOLEAN SomethingToDo(VOID)
VOID Evaluate(__inout FxPkgPnp *PkgPnp)
Definition: fxpkgpnp.hpp:4566
FxCREvent * m_Event
static MX_WORKITEM_ROUTINE _WorkItemCallback
VOID QueueWorkItem(VOID)
Definition: eventqueue.cpp:400
WORK_QUEUE_ITEM m_EventWorkQueueItem
static WORKER_THREAD_ROUTINE _WorkerThreadRoutine
static MX_WORKITEM_ROUTINE _WorkItemCallback
VOID QueueWorkItem(VOID)
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:690
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
Definition: wdfsync.h:127
static void Initialize()
Definition: xlate.c:212
unsigned char UCHAR
Definition: xmlstorage.h:181