ReactOS 0.4.16-dev-297-gc569aee
fxpkgio.hpp
Go to the documentation of this file.
1/*++
2
3Copyright (c) Microsoft Corporation
4
5Module Name:
6
7 FxPkgIo.hpp
8
9Abstract:
10
11 This module implements the I/O package for the driver frameworks.
12
13Author:
14
15
16
17Environment:
18
19 Both kernel and user mode
20
21Revision History:
22
23--*/
24
25#ifndef _FXPKGIO_H_
26#define _FXPKGIO_H_
27
28
29
30
31#include "fxpkgioshared.hpp"
33#include "fxdevicecallbacks.hpp"
34#include "fxcxdeviceinfo.hpp"
35
36//
37// This flag is or-ed with a pointer value that is ptr aligned, only lower 2 bits are available.
38//
39#define FX_IN_DISPATCH_CALLBACK 0x00000001
40
45};
46
47#define IO_ITERATOR_FLUSH_TAG (PVOID) 'sulf'
48#define IO_ITERATOR_POWER_TAG (PVOID) 'ewop'
49
50//
51// This class is allocated by the driver frameworks manager
52// PER DEVICE, and is not package global, but per device global,
53// data.
54//
55// This is similar to the NT DeviceExtension.
56//
57class FxPkgIo : public FxPackage
58{
59
60private:
61
63
64 //
65 // This is the list of IoQueue objects allocated by the driver
66 // and associated with this device. The IoPackage instance
67 // will release these references automatically when the device
68 // is removed.
69 //
71
72 //
73 // This is the forwarding table
74 //
76
77 //
78 // This is the seed value used to pass to the
79 // FxRandom for testing forward progress
80 //
82
83 // TRUE if behave as a filter (forward default requests)
85
87
88 //
89 // TRUE if queues are shutting down (surprise_remove/remove in progress).
90 //
92
93 //
94 // We'll maintain the dynamic dispatch table "per device" so that it is possible
95 // to have different callbacks for each device.
96 // Note that each device may be associted with multiple class extension in the future.
97 //
99
100 //
101 // If !=NULL, a pre-process callback was registered
102 //
104
105public:
106
107 FxPkgIo(
108 __in PFX_DRIVER_GLOBALS FxDriverGlobals,
110 );
111
112 ~FxPkgIo();
113
114 //
115 // Package manager dispatch entries
116 //
118 virtual
120 Dispatch(
122 );
123
124 //
125 // Returns the Top level queue for the Io based on the Irp MajorFunction
126 //
127 FxIoQueue*
130 )
131 {
133 }
134
135 // Do not specify argument names
137 NTSTATUS,
138 VerifyDispatchContext,
140 );
141
142 //
143 // Api's supplied by this package
144 //
151 );
152
158 __in_opt FxIoInCallerContext* IoInCallerCtx,
160 );
161
162/*++
163
164 Routine Description:
165
166 Initializes the default queue, and allows the driver to
167 pass configuration information.
168
169 The driver callbacks registered in this call are used
170 to supply the callbacks for the driver default I/O queue.
171
172Arguments:
173
174 hDevice - Pointer Device Object
175
176Return Value:
177
178 NTSTATUS
179
180--*/
186 );
187
188 //
189 // Register the I/O in-caller context callback
190 //
191 __inline
192 VOID
195 )
196 {
198 }
199
200 // Do not specify argument names
202 NTSTATUS,
203 VerifyEnqueueRequestUpdateFlags,
206 );
207
208 // Do not specify argument names
210 VOID,
211 VerifyEnqueueRequestRestoreFlags,
213 _In_ SHORT
214 );
215
216 //
217 // Enqueue a request to the I/O processing pipeline
218 // from the device driver
219 //
225 );
226
227 FxDriver*
228 GetDriver(
229 VOID
230 );
231
232 __inline
233 CfxDevice*
235 VOID
236 )
237 {
238 return m_Device;
239 }
240
241 __inline
242 FxIoQueue*
244 VOID
245 )
246 {
247 return m_DefaultQueue;
248 }
249
250 __inline
251 BOOLEAN
253 VOID
254 )
255 {
256 return m_Filter;
257 }
258
259 //
260 // This is called as a result of a power management state
261 // that requests that all I/O in progress stop.
262 //
263 //
264 // FxIoStopProcessingForPowerHold:
265 // the function returns when the driver has acknowledged that it has
266 // stopped all I/O processing, but may have outstanding "in-flight" requests
267 // that have not been completed.
268 //
269 // FxIoStopProcessingForPowerPurge:
270 // the function returns when all requests have been completed and/or
271 // cancelled., and there are no more in-flight requests.
272 //
273 // Any queues not marked as PowerManaged will be left alone.
274 //
275 // This is called on a PASSIVE_LEVEL thread that can block until
276 // I/O has been stopped, or completed/cancelled.
277 //
282 );
283
284 //
285 // This is called to start, or resume processing when PNP/Power
286 // resources have been supplied to the device driver.
287 //
288 // The driver is notified of resumption for any in-flight I/O.
289 //
293
294 //
295 // This is called on a device which has been restarted from the removed
296 // state. It will reset purged queues so that they can accept new requests
297 // when ResumeProcessingForPower is called afterwards.
298 //
299 VOID
301 VOID
302 );
303
304 //
305 // Called by CfxDevice when WdfDeviceSetFilter is called.
306 //
309 SetFilter(
311 );
312
313 //
314 // Create an IoQueue and associate it with the FxIoPkg per device
315 // instance.
316 //
322 __in_opt FxDriver* Caller,
323 __deref_out FxIoQueue** ppQueue
324 );
325
326 VOID
329 );
330
335 __in_opt FxCxDeviceInfo* CxDeviceInfo,
338 );
339
343 __inout FxIoQueue* TargetQueue,
345 );
346
351 );
352
353 __inline
354 VOID
357 )
358 {
360
361 //
362 // If this is called, the driver called WDFREQUEST.Complete
363 // from the PreProcess callback handler.
364 //
365 // Since we have a handler, the FXREQUEST object will
366 // dereference itself upon return from this callback, which
367 // will destroy the final reference count.
368 //
369 }
370
371 __inline
372 BOOLEAN
375 )
376 {
377 UCHAR index;
378
379 for (index = 0; index <= IRP_MJ_MAXIMUM_FUNCTION; index++) {
380 if (m_DispatchTable[index] == Queue) {
381 return TRUE;
382 }
383 }
384 return FALSE;
385 }
386
389 __in FxIoInCallerContext *InCallerContextInfo,
392 );
393
394 __inline
397 __in_opt FxCxDeviceInfo* CxDeviceInfo
398 )
399 {
400 if (CxDeviceInfo != NULL) {
401 return &CxDeviceInfo->IoInCallerContextCallback;
402 }
403 else {
405 }
406 }
407
408private:
409
410 VOID
412 __inout FxIoQueue* IoQueue
413 );
414
415 VOID
417 __inout FxIoQueue* IoQueue
418 );
419
420 FxIoQueue*
422 __in FxIoQueueNode* QueueBookmark,
424 );
425
426 FxIoQueue*
428 __in FxIoQueueNode* QueueBookmark,
430 );
431
432 VOID
434 __in PSINGLE_LIST_ENTRY SListHead,
436 );
437
442 );
443
444};
445
446#endif // _FXPKGIO_H
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
#define index(s, c)
Definition: various.h:29
PFN_WDF_IO_IN_CALLER_CONTEXT m_Method
CfxDevice * m_Device
Definition: fxobject.hpp:329
_Must_inspect_result_ NTSTATUS SetFilter(__in BOOLEAN Value)
Definition: fxpkgio.cpp:1120
__inline VOID SetIoInCallerContextCallback(__inout PFN_WDF_IO_IN_CALLER_CONTEXT EvtIoInCallerContext)
Definition: fxpkgio.hpp:193
_Must_inspect_result_ NTSTATUS CreateQueue(__in PWDF_IO_QUEUE_CONFIG Config, __in PWDF_OBJECT_ATTRIBUTES QueueAttributes, __in_opt FxDriver *Caller, __deref_out FxIoQueue **ppQueue)
Definition: fxpkgio.cpp:981
FxIoQueue * m_DispatchTable[IRP_MJ_MAXIMUM_FUNCTION+1]
Definition: fxpkgio.hpp:75
_Must_inspect_result_ NTSTATUS FlushAllQueuesByFileObject(__in MdFileObject FileObject)
Definition: fxpkgio.cpp:1393
_Must_inspect_result_ NTSTATUS VerifierFreeRequestToTestForwardProgess(__in FxRequest *Request)
Definition: fxpkgio.cpp:1758
__inline VOID RequestCompletedCallback(__in FxRequest *Request)
Definition: fxpkgio.hpp:355
FxIoQueue * GetFirstIoQueueLocked(__in FxIoQueueNode *QueueBookmark, __in PVOID Tag)
Definition: fxpkgio.cpp:1610
FxIoQueue * GetDispatchQueue(_In_ UCHAR MajorFunction)
Definition: fxpkgio.hpp:128
__inline CfxDevice * GetDevice(VOID)
Definition: fxpkgio.hpp:234
_Must_inspect_result_ NTSTATUS ConfigureForwarding(__inout FxIoQueue *TargetQueue, __in WDF_REQUEST_TYPE RequestType)
Definition: fxpkgio.cpp:910
_Must_inspect_result_ NTSTATUS ResumeProcessingForPower()
Definition: fxpkgio.cpp:1254
FX_DECLARE_VF_FUNCTION_P2(NTSTATUS, VerifyEnqueueRequestUpdateFlags, _In_ FxRequest *, _Inout_ SHORT *)
~FxPkgIo()
Definition: fxpkgio.cpp:80
FxIoQueue * m_DefaultQueue
Definition: fxpkgio.hpp:62
VOID ResetStateForRestart(VOID)
Definition: fxpkgio.cpp:1332
VOID RemoveIoQueue(__inout FxIoQueue *IoQueue)
Definition: fxpkgio.cpp:1593
_Must_inspect_result_ NTSTATUS __fastcall DispatchStep1(__inout MdIrp Irp, __in WDFCONTEXT DispatchContext)
Definition: fxpkgio.cpp:165
_Must_inspect_result_ NTSTATUS EnqueueRequest(__in CfxDevice *Device, __inout FxRequest *pRequest)
Definition: fxpkgio.cpp:607
ULONG m_RandomSeed
Definition: fxpkgio.hpp:81
FX_DECLARE_VF_FUNCTION_P1(NTSTATUS, VerifyDispatchContext, _In_ WDFCONTEXT)
BOOLEAN m_QueuesAreShuttingDown
Definition: fxpkgio.hpp:91
VOID AddIoQueue(__inout FxIoQueue *IoQueue)
Definition: fxpkgio.cpp:1533
__inline FxIoInCallerContext * GetIoInCallerContextCallback(__in_opt FxCxDeviceInfo *CxDeviceInfo)
Definition: fxpkgio.hpp:396
_Must_inspect_result_ NTSTATUS __fastcall DispatchStep2(__inout MdIrp Irp, __in_opt FxIoInCallerContext *IoInCallerCtx, __in_opt FxIoQueue *Queue)
Definition: fxpkgio.cpp:342
__inline BOOLEAN IsFilter(VOID)
Definition: fxpkgio.hpp:252
FxIoInCallerContext m_InCallerContextCallback
Definition: fxpkgio.hpp:103
FX_DECLARE_VF_FUNCTION_P2(VOID, VerifyEnqueueRequestRestoreFlags, _In_ FxRequest *, _In_ SHORT)
BOOLEAN m_PowerStateOn
Definition: fxpkgio.hpp:86
NTSTATUS DispathToInCallerContextCallback(__in FxIoInCallerContext *InCallerContextInfo, __in FxRequest *Request, __inout MdIrp Irp)
Definition: fxpkgio.cpp:1699
__inline FxIoQueue * GetDefaultQueue(VOID)
Definition: fxpkgio.hpp:243
__inline BOOLEAN IsTopLevelQueue(__in FxIoQueue *Queue)
Definition: fxpkgio.hpp:373
LIST_ENTRY m_IoQueueListHead
Definition: fxpkgio.hpp:70
FxIoQueue * GetNextIoQueueLocked(__in FxIoQueueNode *QueueBookmark, __in PVOID Tag)
Definition: fxpkgio.cpp:1640
VOID RemoveQueueReferences(__inout FxIoQueue *pQueue)
Definition: fxpkgio.cpp:1091
_Must_inspect_result_ NTSTATUS StopProcessingForPower(__in FxIoStopProcessingForPowerAction Action)
Definition: fxpkgio.cpp:1143
_Must_inspect_result_ NTSTATUS ConfigureDynamicDispatching(__in UCHAR MajorFunction, __in_opt FxCxDeviceInfo *CxDeviceInfo, __in PFN_WDFDEVICE_WDM_IRP_DISPATCH EvtDeviceWdmIrpDispatch, __in_opt WDFCONTEXT DriverContext)
Definition: fxpkgio.cpp:786
BOOLEAN m_Filter
Definition: fxpkgio.hpp:84
VOID GetIoQueueListLocked(__in PSINGLE_LIST_ENTRY SListHead, __inout FxIoIteratorList ListType)
Definition: fxpkgio.cpp:1480
LIST_ENTRY m_DynamicDispatchInfoListHead
Definition: fxpkgio.hpp:98
_Must_inspect_result_ NTSTATUS InitializeDefaultQueue(__in CfxDevice *Device, __inout FxIoQueue *Queue)
Definition: fxpkgio.cpp:489
_In_ PIRP Irp
Definition: csq.h:116
#define __in
Definition: dbghelp.h:35
#define __deref_out
Definition: dbghelp.h:26
#define __inout
Definition: dbghelp.h:50
#define __in_opt
Definition: dbghelp.h:38
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
return pDevice GetDriver() -> GetHandle()
_Must_inspect_result_ _In_ WDFDEVICE _In_opt_ WDFDRIVER _In_ UCHAR _In_ PFN_WDFDEVICE_WDM_IRP_DISPATCH EvtDeviceWdmIrpDispatch
FxIoQueue * pQueue
FxRequest * pRequest
FxIoIteratorList
Definition: fxpkgio.hpp:41
@ FxIoQueueIteratorListPowerOn
Definition: fxpkgio.hpp:43
@ FxIoQueueIteratorListInvalid
Definition: fxpkgio.hpp:42
@ FxIoQueueIteratorListPowerOff
Definition: fxpkgio.hpp:44
FxIoStopProcessingForPowerAction
GLuint index
Definition: glext.h:6031
#define __fastcall
Definition: sync.c:38
PFILE_OBJECT MdFileObject
Definition: mxgeneralkm.h:32
IWudfIrp * MdIrp
Definition: mxum.h:103
#define _Inout_
Definition: no_sal2.h:162
#define _Must_inspect_result_
Definition: no_sal2.h:62
#define _In_
Definition: no_sal2.h:158
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:325
short SHORT
Definition: pedump.c:59
Definition: typedefs.h:120
Definition: ntbasedef.h:636
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_CHILD_LIST_CONFIG Config
Definition: wdfchildlist.h:476
_In_ UCHAR _In_ UCHAR _In_ ULONG _In_ WDFCONTEXT DriverContext
Definition: wdfdevice.h:1703
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
Definition: wdfdevice.h:4065
_In_ UCHAR _In_ UCHAR _In_ ULONG _In_ WDFCONTEXT _Inout_ PIRP _In_ WDFCONTEXT DispatchContext
Definition: wdfdevice.h:1708
EVT_WDFDEVICE_WDM_IRP_DISPATCH * PFN_WDFDEVICE_WDM_IRP_DISPATCH
Definition: wdfdevice.h:1710
_In_ PWDFDEVICE_INIT _In_ PFN_WDF_IO_IN_CALLER_CONTEXT EvtIoInCallerContext
Definition: wdfdevice.h:3505
enum _WDF_REQUEST_TYPE WDF_REQUEST_TYPE
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550
_Must_inspect_result_ _In_ WDFDEVICE _In_ PIRP _In_ WDFQUEUE Queue
Definition: wdfdevice.h:2225
EVT_WDF_IO_IN_CALLER_CONTEXT * PFN_WDF_IO_IN_CALLER_CONTEXT
Definition: wdfdevice.h:1728
_In_ UCHAR MajorFunction
Definition: wdfdevice.h:1697
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFQUEUE _In_ _Strict_type_match_ WDF_REQUEST_TYPE RequestType
Definition: wdfdevice.h:4233
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_IO_QUEUE_CONFIG _In_opt_ PWDF_OBJECT_ATTRIBUTES QueueAttributes
Definition: wdfio.h:617
_In_ WDFIOTARGET _In_ _Strict_type_match_ WDF_IO_TARGET_SENT_IO_ACTION Action
Definition: wdfiotarget.h:510
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413
_In_ USHORT _In_ ULONG _In_ PSOCKADDR _In_ PSOCKADDR _Reserved_ ULONG _In_opt_ PVOID _In_opt_ const WSK_CLIENT_CONNECTION_DISPATCH * Dispatch
Definition: wsk.h:188
#define IRP_MJ_MAXIMUM_FUNCTION
unsigned char UCHAR
Definition: xmlstorage.h:181