xref: /reactos/sdk/include/wdf/kmdf/1.17/wdfdpc.h (revision 545df815)
1 /*++
2 
3 Copyright (c) Microsoft Corporation.  All rights reserved.
4 
5 _WdfVersionBuild_
6 
7 Module Name:
8 
9     wdfdpc.h
10 
11 Abstract:
12 
13     This is the C header for driver frameworks DPC 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 _WDFDPC_H_
27 #define _WDFDPC_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 // This is the function that gets called back into the driver
51 // when the DPC fires.
52 //
53 typedef
54 _Function_class_(EVT_WDF_DPC)
55 _IRQL_requires_same_
56 _IRQL_requires_(DISPATCH_LEVEL)
57 VOID
58 STDCALL
59 EVT_WDF_DPC(
60     _In_
61     WDFDPC Dpc
62     );
63 
64 typedef EVT_WDF_DPC *PFN_WDF_DPC;
65 
66 typedef struct _WDF_DPC_CONFIG {
67     ULONG       Size;
68     PFN_WDF_DPC EvtDpcFunc;
69 
70     //
71     // If this is TRUE, the DPC will automatically serialize
72     // with the event callback handlers of its Parent Object.
73     //
74     // Parent Object's callback constraints should be compatible
75     // with the DPC (DISPATCH_LEVEL), or the request will fail.
76     //
77     BOOLEAN     AutomaticSerialization;
78 
79 } WDF_DPC_CONFIG, *PWDF_DPC_CONFIG;
80 
81 FORCEINLINE
82 VOID
WDF_DPC_CONFIG_INIT(_Out_ PWDF_DPC_CONFIG Config,_In_ PFN_WDF_DPC EvtDpcFunc)83 WDF_DPC_CONFIG_INIT(
84     _Out_ PWDF_DPC_CONFIG Config,
85     _In_  PFN_WDF_DPC     EvtDpcFunc
86     )
87 {
88     RtlZeroMemory(Config, sizeof(WDF_DPC_CONFIG));
89     Config->Size = sizeof(WDF_DPC_CONFIG);
90     Config->EvtDpcFunc = EvtDpcFunc;
91 
92     Config->AutomaticSerialization = TRUE;
93 }
94 
95 //
96 // WDF Function: WdfDpcCreate
97 //
98 typedef
99 _Must_inspect_result_
100 _IRQL_requires_max_(DISPATCH_LEVEL)
101 WDFAPI
102 NTSTATUS
103 (STDCALL *PFN_WDFDPCCREATE)(
104     _In_
105     PWDF_DRIVER_GLOBALS DriverGlobals,
106     _In_
107     PWDF_DPC_CONFIG Config,
108     _In_
109     PWDF_OBJECT_ATTRIBUTES Attributes,
110     _Out_
111     WDFDPC* Dpc
112     );
113 
114 _Must_inspect_result_
_IRQL_requires_max_(DISPATCH_LEVEL)115 _IRQL_requires_max_(DISPATCH_LEVEL)
116 FORCEINLINE
117 NTSTATUS
118 WdfDpcCreate(
119     _In_
120     PWDF_DPC_CONFIG Config,
121     _In_
122     PWDF_OBJECT_ATTRIBUTES Attributes,
123     _Out_
124     WDFDPC* Dpc
125     )
126 {
127     return ((PFN_WDFDPCCREATE) WdfFunctions[WdfDpcCreateTableIndex])(WdfDriverGlobals, Config, Attributes, Dpc);
128 }
129 
130 //
131 // WDF Function: WdfDpcEnqueue
132 //
133 typedef
134 _IRQL_requires_max_(HIGH_LEVEL)
135 WDFAPI
136 BOOLEAN
137 (STDCALL *PFN_WDFDPCENQUEUE)(
138     _In_
139     PWDF_DRIVER_GLOBALS DriverGlobals,
140     _In_
141     WDFDPC Dpc
142     );
143 
_IRQL_requires_max_(HIGH_LEVEL)144 _IRQL_requires_max_(HIGH_LEVEL)
145 FORCEINLINE
146 BOOLEAN
147 WdfDpcEnqueue(
148     _In_
149     WDFDPC Dpc
150     )
151 {
152     return ((PFN_WDFDPCENQUEUE) WdfFunctions[WdfDpcEnqueueTableIndex])(WdfDriverGlobals, Dpc);
153 }
154 
155 //
156 // WDF Function: WdfDpcCancel
157 //
158 typedef
159 _When_(Wait == __true, _IRQL_requires_max_(PASSIVE_LEVEL))
160 _When_(Wait == __false, _IRQL_requires_max_(HIGH_LEVEL))
161 WDFAPI
162 BOOLEAN
163 (STDCALL *PFN_WDFDPCCANCEL)(
164     _In_
165     PWDF_DRIVER_GLOBALS DriverGlobals,
166     _In_
167     WDFDPC Dpc,
168     _In_
169     BOOLEAN Wait
170     );
171 
172 _When_(Wait == __true, _IRQL_requires_max_(PASSIVE_LEVEL))
173 _When_(Wait == __false, _IRQL_requires_max_(HIGH_LEVEL))
174 FORCEINLINE
175 BOOLEAN
WdfDpcCancel(_In_ WDFDPC Dpc,_In_ BOOLEAN Wait)176 WdfDpcCancel(
177     _In_
178     WDFDPC Dpc,
179     _In_
180     BOOLEAN Wait
181     )
182 {
183     return ((PFN_WDFDPCCANCEL) WdfFunctions[WdfDpcCancelTableIndex])(WdfDriverGlobals, Dpc, Wait);
184 }
185 
186 //
187 // WDF Function: WdfDpcGetParentObject
188 //
189 typedef
190 _IRQL_requires_max_(HIGH_LEVEL)
191 WDFAPI
192 WDFOBJECT
193 (STDCALL *PFN_WDFDPCGETPARENTOBJECT)(
194     _In_
195     PWDF_DRIVER_GLOBALS DriverGlobals,
196     _In_
197     WDFDPC Dpc
198     );
199 
_IRQL_requires_max_(HIGH_LEVEL)200 _IRQL_requires_max_(HIGH_LEVEL)
201 FORCEINLINE
202 WDFOBJECT
203 WdfDpcGetParentObject(
204     _In_
205     WDFDPC Dpc
206     )
207 {
208     return ((PFN_WDFDPCGETPARENTOBJECT) WdfFunctions[WdfDpcGetParentObjectTableIndex])(WdfDriverGlobals, Dpc);
209 }
210 
211 //
212 // WDF Function: WdfDpcWdmGetDpc
213 //
214 typedef
215 _IRQL_requires_max_(HIGH_LEVEL)
216 WDFAPI
217 PKDPC
218 (STDCALL *PFN_WDFDPCWDMGETDPC)(
219     _In_
220     PWDF_DRIVER_GLOBALS DriverGlobals,
221     _In_
222     WDFDPC Dpc
223     );
224 
_IRQL_requires_max_(HIGH_LEVEL)225 _IRQL_requires_max_(HIGH_LEVEL)
226 FORCEINLINE
227 PKDPC
228 WdfDpcWdmGetDpc(
229     _In_
230     WDFDPC Dpc
231     )
232 {
233     return ((PFN_WDFDPCWDMGETDPC) WdfFunctions[WdfDpcWdmGetDpcTableIndex])(WdfDriverGlobals, Dpc);
234 }
235 
236 
237 
238 #endif // (NTDDI_VERSION >= NTDDI_WIN2K)
239 
240 
241 WDF_EXTERN_C_END
242 
243 #endif // _WDFDPC_H_
244 
245