ReactOS 0.4.15-dev-7958-gcd0bb1a
fxtimer.hpp
Go to the documentation of this file.
1/*++
2
3Copyright (c) Microsoft Corporation
4
5Module Name:
6
7 FxTimer.hpp
8
9Abstract:
10
11 This module implements a frameworks managed TIMER that
12 can synchrononize with driver frameworks object locks.
13
14Author:
15
16
17
18
19Environment:
20
21 Both kernel and user mode
22
23Revision History:
24
25
26--*/
27
28#ifndef _FXTIMER_H_
29#define _FXTIMER_H_
30
31//
32// Driver Frameworks TIMER Design:
33//
34// The driver frameworks provides an optional TIMER wrapper object that allows
35// a reference counted TIMER object to be created that can synchronize
36// automatically with certain frameworks objects.
37//
38// This provides automatic synchronization between the TIMER's execution, and the
39// frameworks objects event callbacks into the device driver.
40//
41
42class FxTimer : public FxNonPagedObject {
43
44private:
45
46 //
47 // Kernel Timer Object
48 //
50
51 //
52 // This is the Framework object who is associated with the TIMER
53 // if supplied
54 //
56
57 //
58 // This is the supplied Period to WdfTimerCreate
59 //
61
62 //
63 // Optional tolerance for the timer in milliseconds
64 //
66
67 //
68 // This indicates whether a high resolution attribute is set
69 // for the timer
70 //
72
73 //
74 // This is the callback lock for the object this TIMER will
75 // synchronize with
76 //
78
79 //
80 // This is the object whose reference count actually controls
81 // the lifetime of the m_CallbackLock
82 //
84
85 //
86 // This is the user supplied callback function
87 //
89
90 //
91 // This workitem object will be used to queue workitem from the timer
92 // dpc callback if the caller requests passive callback.
93 //
95
96 //
97 // This is a pointer to thread object that invoked our dpc callback
98 // callback. This value will be used to avoid deadlock when we try
99 // to stop or delete the timer.
100 //
102
103 //
104 // This is a pointer to the Stop thread object when driver invokes the
105 // timer's WdfTimerStop function.
106 //
108
109 //
110 // TRUE if the timer was restarted while stopping.
111 //
113
114 //
115 // TRUE if a start operation was aborted b/c stop was in progress.
116 //
118
119 //
120 // Ensures only one of either Delete or Cleanup runsdown the object
121 //
123
124public:
125 static
128 _Create(
129 __in PFX_DRIVER_GLOBALS FxDriverGlobals,
132 __in FxObject* ParentObject,
133 __out WDFTIMER* Timer
134 );
135
136 FxTimer(
137 __in PFX_DRIVER_GLOBALS FxDriverGlobals
138 );
139
140 virtual
141 ~FxTimer(
142 VOID
143 );
144
150 __in FxObject* ParentObject,
151 __out WDFTIMER* Timer
152 );
153
154 virtual
155 BOOLEAN
156 Dispose(
157 VOID
158 );
159
160 BOOLEAN
161 Start(
163 );
164
165 BOOLEAN
166 Stop(
168 );
169
170 VOID
172 VOID
173 );
174
177 VOID
178 )
179 {
180 if( m_Object != NULL ) {
181 return m_Object->GetObjectHandle();
182 }
183 else {
184 return NULL;
185 }
186 }
187
188 WDFTIMER
190 VOID
191 )
192 {
193 return (WDFTIMER) GetObjectHandle();
194 }
195
196private:
197
198 //
199 // Called from Dispose, or cleanup list to perform final flushing of any
200 // outstanding DPC's and dereferencing of objects.
201 //
202 VOID
204 VOID
205 );
206
207 static
210
211 static
214
215 static
218};
219
220#endif // _FXTIMER_H
221
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
PVOID __inline GetObjectHandle(VOID)
Definition: fxobject.hpp:603
FxSystemWorkItem * m_SystemWorkItem
Definition: fxtimer.hpp:94
static MdExtCallbackType _FxTimerExtCallbackThunk
Definition: fxtimer.hpp:217
virtual ~FxTimer(VOID)
Definition: fxtimer.cpp:67
BOOLEAN m_StartAborted
Definition: fxtimer.hpp:117
FxObject * m_CallbackLockObject
Definition: fxtimer.hpp:83
static FN_WDF_SYSTEMWORKITEM _FxTimerWorkItemCallback
Definition: fxtimer.hpp:209
ULONG m_TolerableDelay
Definition: fxtimer.hpp:65
MxTimer m_Timer
Definition: fxtimer.hpp:49
MxThread m_StopThread
Definition: fxtimer.hpp:107
virtual BOOLEAN Dispose(VOID)
Definition: fxtimer.cpp:458
WDFTIMER GetHandle(VOID)
Definition: fxtimer.hpp:189
static MdDeferredRoutineType _FxTimerDpcThunk
Definition: fxtimer.hpp:213
WDFOBJECT GetObject(VOID)
Definition: fxtimer.hpp:176
VOID TimerHandler(VOID)
Definition: fxtimer.cpp:300
FxCallbackLock * m_CallbackLock
Definition: fxtimer.hpp:77
FxObject * m_Object
Definition: fxtimer.hpp:55
static _Must_inspect_result_ NTSTATUS _Create(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PWDF_TIMER_CONFIG Config, __in PWDF_OBJECT_ATTRIBUTES Attributes, __in FxObject *ParentObject, __out WDFTIMER *Timer)
Definition: fxtimer.cpp:87
BOOLEAN m_UseHighResolutionTimer
Definition: fxtimer.hpp:71
BOOLEAN m_RunningDown
Definition: fxtimer.hpp:122
VOID FlushAndRundown(VOID)
Definition: fxtimer.cpp:481
ULONG m_Period
Definition: fxtimer.hpp:60
volatile POINTER_ALIGNMENT MxThread m_CallbackThread
Definition: fxtimer.hpp:101
PFN_WDF_TIMER m_Callback
Definition: fxtimer.hpp:88
BOOLEAN m_StopAgain
Definition: fxtimer.hpp:112
#define __in
Definition: dbghelp.h:35
#define __out
Definition: dbghelp.h:62
#define NULL
Definition: types.h:112
return pObject GetObjectHandle()
EVT_SYSTEMWORKITEM FN_WDF_SYSTEMWORKITEM
_In_opt_ PVOID _Out_ BOOLEAN * Stop
Definition: ldrtypes.h:241
#define _Must_inspect_result_
Definition: ms_sal.h:558
KDEFERRED_ROUTINE MdDeferredRoutineType
Definition: mxkm.h:35
EXT_CALLBACK MdExtCallbackType
Definition: mxkm.h:36
uint32_t ULONG
Definition: typedefs.h:59
@ Start
Definition: partlist.h:33
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_CHILD_LIST_CONFIG Config
Definition: wdfchildlist.h:476
_Must_inspect_result_ _In_ WDFDMAENABLER _In_ _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes
_In_ WDFDPC _In_ BOOLEAN Wait
Definition: wdfdpc.h:170
EVT_WDF_TIMER * PFN_WDF_TIMER
Definition: wdftimer.h:67
_In_ WDFTIMER _In_ LONGLONG DueTime
Definition: wdftimer.h:190
#define POINTER_ALIGNMENT
static void Initialize()
Definition: xlate.c:212