ReactOS 0.4.15-dev-7934-g1dc8d80
fxtimerapi.cpp
Go to the documentation of this file.
1/*++
2
3Copyright (c) Microsoft Corporation
4
5Module Name:
6
7 FxTimerApi.cpp
8
9Abstract:
10
11 This implements the WDFTIMER API's
12
13Author:
14
15
16
17Environment:
18
19 Both kernel and user mode
20
21Revision History:
22
23
24--*/
25
26#include "coreprivshared.hpp"
27
28#include "fxtimer.hpp"
29
30extern "C" {
31// #include "FxTimerApi.tmh"
32}
33
34//
35// extern "C" the entire file
36//
37extern "C" {
38
43WDFEXPORT(WdfTimerCreate)(
44 __in
46 __in
48 __in
50 __out
51 WDFTIMER * Timer
52 )
53
54/*++
55
56Routine Description:
57
58 Create a TIMER object that will call the supplied function
59 when it fires. It returns a handle to the WDFTIMER object.
60
61Arguments:
62
63 Config - WDF_TIMER_CONFIG structure.
64
65 Attributes - WDF_OBJECT_ATTRIBUTES to set the parent object, to request
66 a context memory allocation and a DestroyCallback.
67
68 Timer - Pointer to location to return the resulting WDFTIMER handle.
69
70Returns:
71
72 STATUS_SUCCESS - A WDFTIMER handle has been created.
73
74Notes:
75
76 The WDFTIMER object is deleted either when the DEVICE or QUEUE it is
77 associated with is deleted, or WdfObjectDelete is called.
78
79--*/
80
81{
82 DDI_ENTRY();
83
87
89
94 return status;
95 }
96
98 Attributes->ParentObject,
100 (PVOID*)&pParent,
102
105
106 if (Config->Size != sizeof(WDF_TIMER_CONFIG) &&
107 Config->Size != sizeof(WDF_TIMER_CONFIG_V1_7) &&
108 Config->Size != sizeof(WDF_TIMER_CONFIG_V1_11)) {
110
113 "PWDF_TIMER_CONFIG Size %d, expected %d, %!STATUS!",
114 Config->Size, sizeof(WDF_TIMER_CONFIG), status);
115
116 return status;
117 }
118
119 if (Config->Period > MAXLONG) {
121
124 "Period value %u for a periodic timer cannot be greater than "
125 "MAXLONG, %!STATUS!", Config->Period, status);
126
127 return status;
128 }
129
130 //
131 // For version 1.13 and higher, the tolerable delay could
132 // go upto MAXULONG
133 //
134 if (Config->Size > sizeof(WDF_TIMER_CONFIG_V1_7) &&
136 if (Config->TolerableDelay > MAXLONG) {
137
139
142 "TolerableDelay value %u cannot be greater than MAXLONG, "
143 "%!STATUS!", Config->TolerableDelay, status);
144
145 return status;
146 }
147 }
148
149 if (Config->Size > sizeof(WDF_TIMER_CONFIG_V1_11)) {
150
151#if (FX_CORE_MODE == FX_CORE_USER_MODE)
152 if (Config->UseHighResolutionTimer) {
153
157 "UseHighResolutionTimer option is not supported for UMDF "
158 "%!STATUS!", status);
159 return status;
160 }
161#endif
162
163 if ((Config->TolerableDelay > 0) &&
164 (Config->UseHighResolutionTimer)) {
165
167
170 "UseHighResolutionTimer option sepcified with non zero tolerable delay %u "
171 "%!STATUS!", Config->TolerableDelay, status);
172
173 return status;
174 }
175 }
176
180 if (!NT_SUCCESS(status)) {
181 return status;
182 }
183
184 if (Config->Period > 0 &&
185 Attributes->ExecutionLevel == WdfExecutionLevelPassive) {
187
190 "Passive level periodic timer is not supported. "
191 "Use one shot timer and queue the next timer from the callback "
192 "or use a dedicated thread, %!STATUS!",
193 status);
194
195 return status;
196 }
197
199}
200
204WDFEXPORT(WdfTimerStart)(
205 __in
207 __in
208 WDFTIMER Timer,
209 __in
211 )
212
213/*++
214
215Routine Description:
216
217 Enqueue the TIMER to run at the specified time.
218
219Arguments:
220
221 WDFTIMER - Handle to WDFTIMER object created with WdfTimerCreate.
222
223 DueTime - Time to execute
224
225Returns:
226
227 TRUE if the timer object was in the system's timer queue
228
229--*/
230
231{
232 DDI_ENTRY();
233
236
238 Timer,
240 (PVOID*)&pFxTimer);
241
243
244 return pFxTimer->Start(li);
245}
246
251WDFEXPORT(WdfTimerStop)(
252 __in
254 __in
255 WDFTIMER Timer,
256 __in
258 )
259
260/*++
261
262Routine Description:
263
264 Stop the TIMER
265
266Arguments:
267
268 WDFTIMER - Handle to WDFTIMER object created with WdfTimerCreate.
269
270Returns:
271
272 TRUE if the timer object was in the system's timer queue
273
274--*/
275
276{
277 DDI_ENTRY();
278
282
284 Timer,
286 (PVOID*)&pFxTimer,
288
289 if (Wait) {
291 if (!NT_SUCCESS(status)) {
292 return FALSE;
293 }
294 }
295
297}
298
302WDFEXPORT(WdfTimerGetParentObject)(
303 __in
305 __in
306 WDFTIMER Timer
307 )
308
309/*++
310
311Routine Description:
312
313 Return the Parent Object handle supplied to WdfTimerCreate
314
315Arguments:
316
317 WDFTIMER - Handle to WDFTIMER object created with WdfTimerCreate.
318
319Returns:
320
321 Handle to the framework object that is the specified timer object's
322 parent object
323
324--*/
325
326{
327 DDI_ENTRY();
328
330
332 Timer,
334 (PVOID*)&pFxTimer);
335
337}
338
339} // extern "C"
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN Stop(__in BOOLEAN Wait)
Definition: fxtimer.cpp:633
WDFOBJECT GetObject(VOID)
Definition: fxtimer.hpp:176
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 Start(__in LARGE_INTEGER DueTime)
Definition: fxtimer.cpp:537
#define __in
Definition: dbghelp.h:35
#define __out
Definition: dbghelp.h:62
#define TRACINGDEVICE
Definition: dbgtrace.h:58
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define __drv_when(cond, annotes)
Definition: driverspecs.h:335
#define __drv_maxIRQL(irql)
Definition: driverspecs.h:291
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
DriverGlobals
__inline PFX_DRIVER_GLOBALS GetFxDriverGlobals(__in PWDF_DRIVER_GLOBALS DriverGlobals)
Definition: fxglobals.h:597
#define DDI_ENTRY()
Definition: fxglobalskm.h:56
#define WDFEXPORT(a)
Definition: fxmacros.hpp:157
#define FxPointerNotNull(FxDriverGlobals, Ptr)
Definition: fxmacros.hpp:253
FxTimer * pFxTimer
Definition: fxtimerapi.cpp:234
__in WDFTIMER __in LONGLONG DueTime
Definition: fxtimerapi.cpp:231
NTSTATUS status
Definition: fxtimerapi.cpp:86
__in WDFTIMER __in BOOLEAN Wait
Definition: fxtimerapi.cpp:276
_Must_inspect_result_ __in PWDF_TIMER_CONFIG __in PWDF_OBJECT_ATTRIBUTES __out WDFTIMER * Timer
Definition: fxtimerapi.cpp:81
FxObjectHandleGetPtrAndGlobals(pFxDriverGlobals, Attributes->ParentObject, FX_TYPE_OBJECT,(PVOID *)&pParent, &pFxDriverGlobals)
FxObject * pParent
Definition: fxtimerapi.cpp:85
FxObjectHandleGetPtr(GetFxDriverGlobals(DriverGlobals), Timer, FX_TYPE_TIMER,(PVOID *)&pFxTimer)
LARGE_INTEGER li
Definition: fxtimerapi.cpp:235
_Must_inspect_result_ __in PWDF_TIMER_CONFIG Config
Definition: fxtimerapi.cpp:47
_Must_inspect_result_ __in PWDF_TIMER_CONFIG __in PWDF_OBJECT_ATTRIBUTES Attributes
Definition: fxtimerapi.cpp:49
PFX_DRIVER_GLOBALS pFxDriverGlobals
Definition: fxtimerapi.cpp:84
@ FX_TYPE_OBJECT
Definition: fxtypes.h:45
@ FX_TYPE_TIMER
Definition: fxtypes.h:81
@ FX_VALIDATE_OPTION_PARENT_REQUIRED
@ FX_VALIDATE_OPTION_EXECUTION_LEVEL_ALLOWED
_Must_inspect_result_ NTSTATUS __inline FxValidateObjectAttributesForParentHandle(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PWDF_OBJECT_ATTRIBUTES Attributes, __in ULONG Flags=FX_VALIDATE_OPTION_NONE_SPECIFIED)
_Must_inspect_result_ NTSTATUS FxValidateObjectAttributes(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PWDF_OBJECT_ATTRIBUTES Attributes, __in ULONG Flags=FX_VALIDATE_OPTION_NONE_SPECIFIED)
__inline NTSTATUS FxVerifierCheckIrqlLevel(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in KIRQL Irql)
Definition: fxverifier.h:158
#define _Must_inspect_result_
Definition: ms_sal.h:558
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:423
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
_Must_inspect_result_ BOOLEAN IsVersionGreaterThanOrEqualTo(__in ULONG Major, __in ULONG Minor)
Definition: globalskm.cpp:92
Definition: ps.c:97
int64_t LONGLONG
Definition: typedefs.h:68
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
#define MAXLONG
Definition: umtypes.h:116
LONGLONG QuadPart
Definition: typedefs.h:114
#define STDCALL
Definition: wdf.h:45
_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
@ WdfExecutionLevelPassive
Definition: wdfobject.h:54