ReactOS 0.4.15-dev-7788-g1ad9096
fxworkitemapi.cpp
Go to the documentation of this file.
1/*++
2
3Copyright (c) Microsoft Corporation
4
5Module Name:
6
7 FxWorkItemApi.cpp
8
9Abstract:
10
11 This implements the WDFWORKITEM 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 "fxworkitem.hpp"
29
30extern "C" {
31// #include "FxWorkItemApi.tmh"
32}
33
34
35//
36// extern "C" the entire file
37//
38extern "C" {
39
44WDFEXPORT(WdfWorkItemCreate)(
45 __in
47 __in
49 __in
51 __out
52 WDFWORKITEM* WorkItem
53 )
54
55/*++
56
57Routine Description:
58
59 Create a WorkItem object that will call the supplied function with
60 context when it fires. It returns a handle to the WDFWORKITEM object.
61
62Arguments:
63
64 Config - Pointer to WDF_WORKITEM_CONFIG structure
65
66 Attributes - WDF_OBJECT_ATTRIBUTES to set the parent object and to request
67 a context memory allocation, and a DestroyCallback.
68
69 WorkItem - Pointer to the created WDFWORKITEM handle.
70
71Returns:
72
73 STATUS_SUCCESS - A WDFWORKITEM handle has been created.
74
75 The WDFWORKITEM will be automatically deleted when the object it is
76 associated with is deleted.
77
78Notes:
79
80 The WDFWORKITEM object is deleted either when the DEVICE or QUEUE it is
81 associated with is deleted, or WdfObjectDelete is called.
82
83 If the WDFWORKITEM is used to access WDM objects, a Cleanup callback should
84 be registered to allow references to be released.
85
86--*/
87
88{
89 DDI_ENTRY();
90
94
100 return status;
101 }
102
104 Attributes->ParentObject,
106 (PVOID*)&pParent,
108
111
112 if (Config->Size != sizeof(WDF_WORKITEM_CONFIG)) {
114
117 "WDF_WORKITEM_CONFIG Size got %d, expected %d, %!STATUS!",
118 Config->Size, sizeof(WDF_WORKITEM_CONFIG), status);
119
120 return status;
121 }
122
123 if (Config->EvtWorkItemFunc == NULL) {
125
127 "Supplied EvtWorkItemFunc == NULL, %!STATUS!",
128 status);
129
130 return status;
131 }
132
133 //
134 // The parent for FxWorkItem is explicitly part of the API, and ties
135 // synchronization and lifetime.
136 //
138 if (!NT_SUCCESS(status)) {
139 return status;
140 }
141
142 return FxWorkItem::_Create(
144}
145
147VOID
149WDFEXPORT(WdfWorkItemEnqueue)(
150 __in
152 __in
153 WDFWORKITEM WorkItem
154 )
155/*++
156
157Routine Description:
158
159 Enqueue a WorkItem to execute.
160
161Arguments:
162
163 WorkItem - Handle to WDFWORKITEM
164
165Returns:
166
167 None
168
169--*/
170{
171 DDI_ENTRY();
172
174
176 WorkItem,
178 (PVOID*)&pFxWorkItem);
179
181}
182
186WDFEXPORT(WdfWorkItemGetParentObject)(
187 __in
189 __in
190 WDFWORKITEM WorkItem
191 )
192
193/*++
194
195Routine Description:
196
197 Return the Object handle supplied to WdfWorkItemCreate
198
199Arguments:
200
201 WDFWORKITEM - Handle to WDFWORKITEM object created with WdfWorkItemCreate.
202
203Returns:
204
205 Handle to the framework object that is the specified work-item object's
206 parent object.
207
208--*/
209
210{
211 DDI_ENTRY();
212
214
216 WorkItem,
218 (PVOID*)&pFxWorkItem);
219
221}
222
224VOID
226WDFEXPORT(WdfWorkItemFlush)(
227 __in
229 __in
230 WDFWORKITEM WorkItem
231 )
232/*++
233
234Routine Description:
235
236 Wait until any outstanding workitems have completed
237
238Arguments:
239
240 WorkItem - Handle to WDFWORKITEM
241
242Returns:
243
244 None
245
246--*/
247{
248 DDI_ENTRY();
249
251
253 WorkItem,
255 (PVOID*)&pFxWorkItem);
256
257 //
258 // Use the object's globals, not the caller's
259 //
261 PASSIVE_LEVEL))) {
262 return;
263 }
264
266}
267
268} // extern "C"
LONG NTSTATUS
Definition: precomp.h:26
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
VOID Enqueue()
Definition: fxworkitem.cpp:288
WDFOBJECT GetAssociatedObject()
Definition: fxworkitem.hpp:181
VOID FlushAndWait(VOID)
Definition: fxworkitem.cpp:508
static _Must_inspect_result_ NTSTATUS _Create(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PWDF_WORKITEM_CONFIG Config, __in PWDF_OBJECT_ATTRIBUTES Attributes, __in FxObject *ParentObject, __out WDFWORKITEM *WorkItem)
Definition: fxworkitem.cpp:109
#define __in
Definition: dbghelp.h:35
#define __out
Definition: dbghelp.h:62
#define TRACINGDEVICE
Definition: dbgtrace.h:58
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#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
@ FX_TYPE_OBJECT
Definition: fxtypes.h:45
@ FX_TYPE_WORKITEM
Definition: fxtypes.h:78
@ FX_VALIDATE_OPTION_PARENT_REQUIRED
_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
NTSTATUS status
FxWorkItem * pFxWorkItem
FxObjectHandleGetPtrAndGlobals(pFxDriverGlobals, Attributes->ParentObject, FX_TYPE_OBJECT,(PVOID *)&pParent, &pFxDriverGlobals)
_Must_inspect_result_ __in PWDF_WORKITEM_CONFIG __in PWDF_OBJECT_ATTRIBUTES Attributes
FxObject * pParent
FxObjectHandleGetPtr(GetFxDriverGlobals(DriverGlobals), WorkItem, FX_TYPE_WORKITEM,(PVOID *)&pFxWorkItem)
_Must_inspect_result_ __in PWDF_WORKITEM_CONFIG Config
_Must_inspect_result_ __in PWDF_WORKITEM_CONFIG __in PWDF_OBJECT_ATTRIBUTES __out WDFWORKITEM * WorkItem
PFX_DRIVER_GLOBALS pFxDriverGlobals
#define _Must_inspect_result_
Definition: ms_sal.h:558
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
Definition: ps.c:97
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
#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
_Must_inspect_result_ _In_ PWDF_WORKITEM_CONFIG _In_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWORKITEM * WorkItem
Definition: wdfworkitem.h:115