xref: /reactos/sdk/include/wdf/kmdf/1.17/wdftimer.h (revision 40462c92)
1 /*++
2 
3 Copyright (c) Microsoft Corporation.  All rights reserved.
4 
5 _WdfVersionBuild_
6 
7 Module Name:
8 
9     wdftimer.h
10 
11 Abstract:
12 
13     This is the C header for driver framework TIMER object
14 
15 Revision History:
16 
17 
18 --*/
19 
20 //
21 // NOTE: This header is generated by stubwork.  Please make any
22 //       modifications to the corresponding template files
23 //       (.x or .y) and use stubwork to regenerate the header
24 //
25 
26 #ifndef _WDFTIMER_H_
27 #define _WDFTIMER_H_
28 
29 #ifndef WDF_EXTERN_C
30   #ifdef __cplusplus
31     #define WDF_EXTERN_C       extern "C"
32     #define WDF_EXTERN_C_START extern "C" {
33     #define WDF_EXTERN_C_END   }
34   #else
35     #define WDF_EXTERN_C
36     #define WDF_EXTERN_C_START
37     #define WDF_EXTERN_C_END
38   #endif
39 #endif
40 
41 WDF_EXTERN_C_START
42 
43 
44 
45 #if (NTDDI_VERSION >= NTDDI_WIN2K)
46 
47 
48 
49 
50 #define TolerableDelayUnlimited ((ULONG)-1)
51 
52 //
53 // This is the function that gets called back into the driver
54 // when the TIMER fires.
55 //
56 typedef
57 _Function_class_(EVT_WDF_TIMER)
58 _IRQL_requires_same_
59 _IRQL_requires_max_(DISPATCH_LEVEL)
60 VOID
61 EVT_WDF_TIMER(
62     _In_
63     WDFTIMER Timer
64     );
65 
66 typedef EVT_WDF_TIMER *PFN_WDF_TIMER;
67 
68 //
69 // Disable warning C4324: structure was padded due to DECLSPEC_ALIGN
70 // This padding is intentional and necessary.
71 #pragma warning(push)
72 #pragma warning(disable: 4324)
73 
74 typedef struct _WDF_TIMER_CONFIG {
75     ULONG Size;
76     PFN_WDF_TIMER EvtTimerFunc;
77 
78     ULONG Period;
79 
80     //
81     // If this is TRUE, the Timer will automatically serialize
82     // with the event callback handlers of its Parent Object.
83     //
84     // Parent Object's callback constraints should be compatible
85     // with the Timer DPC (DISPATCH_LEVEL), or the request will fail.
86     //
87     BOOLEAN AutomaticSerialization;
88 
89     //
90     // Optional tolerance for the timer in milliseconds.
91     //
92     ULONG TolerableDelay;
93 
94     //
95     // If this is TRUE, high resolution timers will be used. The default
96     // value is FALSE
97     //
98     DECLSPEC_ALIGN(8) BOOLEAN UseHighResolutionTimer;
99 
100 } WDF_TIMER_CONFIG, *PWDF_TIMER_CONFIG;
101 
102 #pragma warning(pop)
103 
104 VOID
105 FORCEINLINE
106 WDF_TIMER_CONFIG_INIT(
107     _Out_ PWDF_TIMER_CONFIG Config,
108     _In_  PFN_WDF_TIMER     EvtTimerFunc
109     )
110 {
111     RtlZeroMemory(Config, sizeof(WDF_TIMER_CONFIG));
112     Config->Size = sizeof(WDF_TIMER_CONFIG);
113     Config->EvtTimerFunc = EvtTimerFunc;
114     Config->Period = 0;
115     Config->AutomaticSerialization = TRUE;
116     Config->TolerableDelay = 0;
117 }
118 
119 VOID
120 FORCEINLINE
121 WDF_TIMER_CONFIG_INIT_PERIODIC(
122     _Out_ PWDF_TIMER_CONFIG Config,
123     _In_  PFN_WDF_TIMER     EvtTimerFunc,
124     _In_  LONG             Period
125     )
126 {
127     RtlZeroMemory(Config, sizeof(WDF_TIMER_CONFIG));
128     Config->Size = sizeof(WDF_TIMER_CONFIG);
129     Config->EvtTimerFunc = EvtTimerFunc;
130     Config->Period = Period;
131     Config->AutomaticSerialization = TRUE;
132     Config->TolerableDelay = 0;
133 }
134 
135 
136 //
137 // WDF Function: WdfTimerCreate
138 //
139 typedef
140 _Must_inspect_result_
141 _IRQL_requires_max_(DISPATCH_LEVEL)
142 WDFAPI
143 NTSTATUS
144 (*PFN_WDFTIMERCREATE)(
145     _In_
146     PWDF_DRIVER_GLOBALS DriverGlobals,
147     _In_
148     PWDF_TIMER_CONFIG Config,
149     _In_
150     PWDF_OBJECT_ATTRIBUTES Attributes,
151     _Out_
152     WDFTIMER* Timer
153     );
154 
155 _Must_inspect_result_
156 _IRQL_requires_max_(DISPATCH_LEVEL)
157 NTSTATUS
158 FORCEINLINE
159 WdfTimerCreate(
160     _In_
161     PWDF_TIMER_CONFIG Config,
162     _In_
163     PWDF_OBJECT_ATTRIBUTES Attributes,
164     _Out_
165     WDFTIMER* Timer
166     )
167 {
168     return ((PFN_WDFTIMERCREATE) WdfFunctions[WdfTimerCreateTableIndex])(WdfDriverGlobals, Config, Attributes, Timer);
169 }
170 
171 //
172 // WDF Function: WdfTimerStart
173 //
174 typedef
175 _IRQL_requires_max_(DISPATCH_LEVEL)
176 WDFAPI
177 BOOLEAN
178 (*PFN_WDFTIMERSTART)(
179     _In_
180     PWDF_DRIVER_GLOBALS DriverGlobals,
181     _In_
182     WDFTIMER Timer,
183     _In_
184     LONGLONG DueTime
185     );
186 
187 _IRQL_requires_max_(DISPATCH_LEVEL)
188 BOOLEAN
189 FORCEINLINE
190 WdfTimerStart(
191     _In_
192     WDFTIMER Timer,
193     _In_
194     LONGLONG DueTime
195     )
196 {
197     return ((PFN_WDFTIMERSTART) WdfFunctions[WdfTimerStartTableIndex])(WdfDriverGlobals, Timer, DueTime);
198 }
199 
200 //
201 // WDF Function: WdfTimerStop
202 //
203 typedef
204 _When_(Wait == __true, _IRQL_requires_max_(PASSIVE_LEVEL))
205 _When_(Wait == __false, _IRQL_requires_max_(DISPATCH_LEVEL))
206 WDFAPI
207 BOOLEAN
208 (*PFN_WDFTIMERSTOP)(
209     _In_
210     PWDF_DRIVER_GLOBALS DriverGlobals,
211     _In_
212     WDFTIMER Timer,
213     _In_
214     BOOLEAN Wait
215     );
216 
217 _When_(Wait == __true, _IRQL_requires_max_(PASSIVE_LEVEL))
218 _When_(Wait == __false, _IRQL_requires_max_(DISPATCH_LEVEL))
219 BOOLEAN
220 FORCEINLINE
221 WdfTimerStop(
222     _In_
223     WDFTIMER Timer,
224     _In_
225     BOOLEAN Wait
226     )
227 {
228     return ((PFN_WDFTIMERSTOP) WdfFunctions[WdfTimerStopTableIndex])(WdfDriverGlobals, Timer, Wait);
229 }
230 
231 //
232 // WDF Function: WdfTimerGetParentObject
233 //
234 typedef
235 _IRQL_requires_max_(DISPATCH_LEVEL)
236 WDFAPI
237 WDFOBJECT
238 (*PFN_WDFTIMERGETPARENTOBJECT)(
239     _In_
240     PWDF_DRIVER_GLOBALS DriverGlobals,
241     _In_
242     WDFTIMER Timer
243     );
244 
245 _IRQL_requires_max_(DISPATCH_LEVEL)
246 WDFOBJECT
247 FORCEINLINE
248 WdfTimerGetParentObject(
249     _In_
250     WDFTIMER Timer
251     )
252 {
253     return ((PFN_WDFTIMERGETPARENTOBJECT) WdfFunctions[WdfTimerGetParentObjectTableIndex])(WdfDriverGlobals, Timer);
254 }
255 
256 
257 
258 #endif // (NTDDI_VERSION >= NTDDI_WIN2K)
259 
260 
261 WDF_EXTERN_C_END
262 
263 #endif // _WDFTIMER_H_
264 
265