xref: /reactos/sdk/include/wdf/kmdf/1.17/wdfworkitem.h (revision c8d07514)
1 /*++
2 
3 Copyright (c) Microsoft Corporation.  All rights reserved.
4 
5 _WdfVersionBuild_
6 
7 Module Name:
8 
9     wdfworkitem.h
10 
11 Abstract:
12 
13     This is the Windows Driver Framework work item DDIs
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 _WDFWORKITEM_H_
27 #define _WDFWORKITEM_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 WorkItem fires.
52 //
53 typedef
54 _Function_class_(EVT_WDF_WORKITEM)
55 _IRQL_requires_same_
56 _IRQL_requires_max_(PASSIVE_LEVEL)
57 VOID
58 STDCALL
59 EVT_WDF_WORKITEM(
60     _In_
61     WDFWORKITEM WorkItem
62     );
63 
64 typedef EVT_WDF_WORKITEM *PFN_WDF_WORKITEM;
65 
66 typedef struct _WDF_WORKITEM_CONFIG {
67 
68     ULONG Size;
69 
70     PFN_WDF_WORKITEM EvtWorkItemFunc;
71 
72     //
73     // If this is TRUE, the workitem will automatically serialize
74     // with the event callback handlers of its Parent Object.
75     //
76     // Parent Object's callback constraints should be compatible
77     // with the work item (PASSIVE_LEVEL), or the request will fail.
78     //
79     BOOLEAN AutomaticSerialization;
80 
81 } WDF_WORKITEM_CONFIG, *PWDF_WORKITEM_CONFIG;
82 
83 FORCEINLINE
84 VOID
85 WDF_WORKITEM_CONFIG_INIT(
86     _Out_ PWDF_WORKITEM_CONFIG Config,
87     _In_ PFN_WDF_WORKITEM     EvtWorkItemFunc
88     )
89 {
90     RtlZeroMemory(Config, sizeof(WDF_WORKITEM_CONFIG));
91     Config->Size = sizeof(WDF_WORKITEM_CONFIG);
92     Config->EvtWorkItemFunc = EvtWorkItemFunc;
93 
94     Config->AutomaticSerialization = TRUE;
95 }
96 
97 
98 //
99 // WDF Function: WdfWorkItemCreate
100 //
101 typedef
102 _Must_inspect_result_
103 _IRQL_requires_max_(DISPATCH_LEVEL)
104 WDFAPI
105 NTSTATUS
106 (STDCALL *PFN_WDFWORKITEMCREATE)(
107     _In_
108     PWDF_DRIVER_GLOBALS DriverGlobals,
109     _In_
110     PWDF_WORKITEM_CONFIG Config,
111     _In_
112     PWDF_OBJECT_ATTRIBUTES Attributes,
113     _Out_
114     WDFWORKITEM* WorkItem
115     );
116 
117 _Must_inspect_result_
118 _IRQL_requires_max_(DISPATCH_LEVEL)
119 FORCEINLINE
120 NTSTATUS
121 WdfWorkItemCreate(
122     _In_
123     PWDF_WORKITEM_CONFIG Config,
124     _In_
125     PWDF_OBJECT_ATTRIBUTES Attributes,
126     _Out_
127     WDFWORKITEM* WorkItem
128     )
129 {
130     return ((PFN_WDFWORKITEMCREATE) WdfFunctions[WdfWorkItemCreateTableIndex])(WdfDriverGlobals, Config, Attributes, WorkItem);
131 }
132 
133 //
134 // WDF Function: WdfWorkItemEnqueue
135 //
136 typedef
137 _IRQL_requires_max_(DISPATCH_LEVEL)
138 WDFAPI
139 VOID
140 (STDCALL *PFN_WDFWORKITEMENQUEUE)(
141     _In_
142     PWDF_DRIVER_GLOBALS DriverGlobals,
143     _In_
144     WDFWORKITEM WorkItem
145     );
146 
147 _IRQL_requires_max_(DISPATCH_LEVEL)
148 FORCEINLINE
149 VOID
150 WdfWorkItemEnqueue(
151     _In_
152     WDFWORKITEM WorkItem
153     )
154 {
155     ((PFN_WDFWORKITEMENQUEUE) WdfFunctions[WdfWorkItemEnqueueTableIndex])(WdfDriverGlobals, WorkItem);
156 }
157 
158 //
159 // WDF Function: WdfWorkItemGetParentObject
160 //
161 typedef
162 _IRQL_requires_max_(DISPATCH_LEVEL)
163 WDFAPI
164 WDFOBJECT
165 (STDCALL *PFN_WDFWORKITEMGETPARENTOBJECT)(
166     _In_
167     PWDF_DRIVER_GLOBALS DriverGlobals,
168     _In_
169     WDFWORKITEM WorkItem
170     );
171 
172 _IRQL_requires_max_(DISPATCH_LEVEL)
173 FORCEINLINE
174 WDFOBJECT
175 WdfWorkItemGetParentObject(
176     _In_
177     WDFWORKITEM WorkItem
178     )
179 {
180     return ((PFN_WDFWORKITEMGETPARENTOBJECT) WdfFunctions[WdfWorkItemGetParentObjectTableIndex])(WdfDriverGlobals, WorkItem);
181 }
182 
183 //
184 // WDF Function: WdfWorkItemFlush
185 //
186 typedef
187 _IRQL_requires_max_(PASSIVE_LEVEL)
188 WDFAPI
189 VOID
190 (STDCALL *PFN_WDFWORKITEMFLUSH)(
191     _In_
192     PWDF_DRIVER_GLOBALS DriverGlobals,
193     _In_
194     WDFWORKITEM WorkItem
195     );
196 
197 _IRQL_requires_max_(PASSIVE_LEVEL)
198 FORCEINLINE
199 VOID
200 WdfWorkItemFlush(
201     _In_
202     WDFWORKITEM WorkItem
203     )
204 {
205     ((PFN_WDFWORKITEMFLUSH) WdfFunctions[WdfWorkItemFlushTableIndex])(WdfDriverGlobals, WorkItem);
206 }
207 
208 
209 
210 #endif // (NTDDI_VERSION >= NTDDI_WIN2K)
211 
212 
213 WDF_EXTERN_C_END
214 
215 #endif // _WDFWORKITEM_H_
216 
217