xref: /reactos/sdk/include/wdf/kmdf/1.17/wdftimer.h (revision 8a978a17)
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 STDCALL
62 EVT_WDF_TIMER(
63     _In_
64     WDFTIMER Timer
65     );
66 
67 typedef EVT_WDF_TIMER *PFN_WDF_TIMER;
68 
69 //
70 // Disable warning C4324: structure was padded due to DECLSPEC_ALIGN
71 // This padding is intentional and necessary.
72 #ifdef _MSC_VER
73 #pragma warning(push)
74 #pragma warning(disable: 4324)
75 #endif
76 
77 typedef struct _WDF_TIMER_CONFIG {
78     ULONG Size;
79     PFN_WDF_TIMER EvtTimerFunc;
80 
81     ULONG Period;
82 
83     //
84     // If this is TRUE, the Timer will automatically serialize
85     // with the event callback handlers of its Parent Object.
86     //
87     // Parent Object's callback constraints should be compatible
88     // with the Timer DPC (DISPATCH_LEVEL), or the request will fail.
89     //
90     BOOLEAN AutomaticSerialization;
91 
92     //
93     // Optional tolerance for the timer in milliseconds.
94     //
95     ULONG TolerableDelay;
96 
97     //
98     // If this is TRUE, high resolution timers will be used. The default
99     // value is FALSE
100     //
101     DECLSPEC_ALIGN(8) BOOLEAN UseHighResolutionTimer;
102 
103 } WDF_TIMER_CONFIG, *PWDF_TIMER_CONFIG;
104 
105 #ifdef _MSC_VER
106 #pragma warning(pop)
107 #endif
108 
109 FORCEINLINE
110 VOID
111 WDF_TIMER_CONFIG_INIT(
112     _Out_ PWDF_TIMER_CONFIG Config,
113     _In_  PFN_WDF_TIMER     EvtTimerFunc
114     )
115 {
116     RtlZeroMemory(Config, sizeof(WDF_TIMER_CONFIG));
117     Config->Size = sizeof(WDF_TIMER_CONFIG);
118     Config->EvtTimerFunc = EvtTimerFunc;
119     Config->Period = 0;
120     Config->AutomaticSerialization = TRUE;
121     Config->TolerableDelay = 0;
122 }
123 
124 FORCEINLINE
125 VOID
126 WDF_TIMER_CONFIG_INIT_PERIODIC(
127     _Out_ PWDF_TIMER_CONFIG Config,
128     _In_  PFN_WDF_TIMER     EvtTimerFunc,
129     _In_  LONG             Period
130     )
131 {
132     RtlZeroMemory(Config, sizeof(WDF_TIMER_CONFIG));
133     Config->Size = sizeof(WDF_TIMER_CONFIG);
134     Config->EvtTimerFunc = EvtTimerFunc;
135     Config->Period = Period;
136     Config->AutomaticSerialization = TRUE;
137     Config->TolerableDelay = 0;
138 }
139 
140 
141 //
142 // WDF Function: WdfTimerCreate
143 //
144 typedef
145 _Must_inspect_result_
146 _IRQL_requires_max_(DISPATCH_LEVEL)
147 WDFAPI
148 NTSTATUS
149 (STDCALL *PFN_WDFTIMERCREATE)(
150     _In_
151     PWDF_DRIVER_GLOBALS DriverGlobals,
152     _In_
153     PWDF_TIMER_CONFIG Config,
154     _In_
155     PWDF_OBJECT_ATTRIBUTES Attributes,
156     _Out_
157     WDFTIMER* Timer
158     );
159 
160 _Must_inspect_result_
161 _IRQL_requires_max_(DISPATCH_LEVEL)
162 FORCEINLINE
163 NTSTATUS
164 WdfTimerCreate(
165     _In_
166     PWDF_TIMER_CONFIG Config,
167     _In_
168     PWDF_OBJECT_ATTRIBUTES Attributes,
169     _Out_
170     WDFTIMER* Timer
171     )
172 {
173     return ((PFN_WDFTIMERCREATE) WdfFunctions[WdfTimerCreateTableIndex])(WdfDriverGlobals, Config, Attributes, Timer);
174 }
175 
176 //
177 // WDF Function: WdfTimerStart
178 //
179 typedef
180 _IRQL_requires_max_(DISPATCH_LEVEL)
181 WDFAPI
182 BOOLEAN
183 (STDCALL *PFN_WDFTIMERSTART)(
184     _In_
185     PWDF_DRIVER_GLOBALS DriverGlobals,
186     _In_
187     WDFTIMER Timer,
188     _In_
189     LONGLONG DueTime
190     );
191 
192 _IRQL_requires_max_(DISPATCH_LEVEL)
193 FORCEINLINE
194 BOOLEAN
195 WdfTimerStart(
196     _In_
197     WDFTIMER Timer,
198     _In_
199     LONGLONG DueTime
200     )
201 {
202     return ((PFN_WDFTIMERSTART) WdfFunctions[WdfTimerStartTableIndex])(WdfDriverGlobals, Timer, DueTime);
203 }
204 
205 //
206 // WDF Function: WdfTimerStop
207 //
208 typedef
209 _When_(Wait == __true, _IRQL_requires_max_(PASSIVE_LEVEL))
210 _When_(Wait == __false, _IRQL_requires_max_(DISPATCH_LEVEL))
211 WDFAPI
212 BOOLEAN
213 (STDCALL *PFN_WDFTIMERSTOP)(
214     _In_
215     PWDF_DRIVER_GLOBALS DriverGlobals,
216     _In_
217     WDFTIMER Timer,
218     _In_
219     BOOLEAN Wait
220     );
221 
222 _When_(Wait == __true, _IRQL_requires_max_(PASSIVE_LEVEL))
223 _When_(Wait == __false, _IRQL_requires_max_(DISPATCH_LEVEL))
224 FORCEINLINE
225 BOOLEAN
226 WdfTimerStop(
227     _In_
228     WDFTIMER Timer,
229     _In_
230     BOOLEAN Wait
231     )
232 {
233     return ((PFN_WDFTIMERSTOP) WdfFunctions[WdfTimerStopTableIndex])(WdfDriverGlobals, Timer, Wait);
234 }
235 
236 //
237 // WDF Function: WdfTimerGetParentObject
238 //
239 typedef
240 _IRQL_requires_max_(DISPATCH_LEVEL)
241 WDFAPI
242 WDFOBJECT
243 (STDCALL *PFN_WDFTIMERGETPARENTOBJECT)(
244     _In_
245     PWDF_DRIVER_GLOBALS DriverGlobals,
246     _In_
247     WDFTIMER Timer
248     );
249 
250 _IRQL_requires_max_(DISPATCH_LEVEL)
251 FORCEINLINE
252 WDFOBJECT
253 WdfTimerGetParentObject(
254     _In_
255     WDFTIMER Timer
256     )
257 {
258     return ((PFN_WDFTIMERGETPARENTOBJECT) WdfFunctions[WdfTimerGetParentObjectTableIndex])(WdfDriverGlobals, Timer);
259 }
260 
261 
262 
263 #endif // (NTDDI_VERSION >= NTDDI_WIN2K)
264 
265 
266 WDF_EXTERN_C_END
267 
268 #endif // _WDFTIMER_H_
269 
270