ReactOS 0.4.15-dev-7924-g5949c20
fxdevicefdoapi.cpp
Go to the documentation of this file.
1/*++
2
3Copyright (c) Microsoft Corporation
4
5Module Name:
6
7 FxDeviceFdoApi.cpp
8
9Abstract:
10
11 This module exposes the "C" interface to the FxDevice object.
12
13Author:
14
15
16
17Environment:
18
19 Kernel mode only
20
21Revision History:
22
23--*/
24
25#include "fxcorepch.hpp"
26
27extern "C" {
28// #include "FxDeviceFdoApi.tmh"
29}
30
31//
32// Extern "C" the rest of the file
33//
34extern "C" {
35
40WDFEXPORT(WdfFdoAddStaticChild)(
41 __in
43 __in
44 WDFDEVICE Fdo,
45 __in
46 WDFDEVICE Child
47 )
48/*++
49
50Routine Description:
51 Adds a statically enumerated child to the static device list.
52
53Arguments:
54 Fdo - the parent of the child
55
56 Child - the child to add
57
58Return Value:
59 NTSTATUS
60
61 --*/
62
63{
69
71 Fdo,
73 (PVOID*)&pFdo);
74
75 //
76 // Verify type
77 //
78 if (pFdo->IsLegacy() || pFdo->IsFdo() == FALSE) {
80
83 "WDFDEVICE 0x%p is either legacy or is not a Fdo, %!STATUS!",
84 Fdo, status);
85
86 return status;
87 }
88
90 Child,
92 (PVOID*)&pPdo);
93
94 if (pPdo->IsLegacy() || pPdo->IsPdo() == FALSE) {
96
99 "WDFDEVICE Child 0x%p is either legacy or is not a PDO, %!STATUS!",
100 Child, status);
101
102 return status;
103 }
104
106
107 //
108 // Try to add the device to the list. We use the FxDevice* of the PDO as the
109 // unique ID in the list.
110 //
111 description.Header.IdentificationDescriptionSize = sizeof(description);
113
115
118 }
119
120 return status;
121}
122
124VOID
126WDFEXPORT(WdfFdoLockStaticChildListForIteration)(
127 __in
129 __in
130 WDFDEVICE Fdo
131 )
132/*++
133
134Routine Description:
135 Locks the static child list for iteration. Any adds or removes that occur
136 while the list is locked are pended until it is unlocked. Locking can
137 be nested. When the unlock count is zero, the changes are evaluated.
138
139Arguments:
140 Fdo - the parent who owns the list of static children
141
142Return Value:
143 None
144
145 --*/
146
147{
152
154 Fdo,
156 (PVOID*)&pDevice,
158
159 //
160 // Verify type
161 //
162 if (pDevice->IsLegacy() || (pDevice->IsFdo() == FALSE)) {
165 "Invalid WDFDEVICE %p is not an FDO", Fdo);
167 return;
168 }
169
171
172 //
173 // Create a fake iterator to begin iteration. We will not need it in the
174 // retrieve next static child call.
175 //
177
179}
180
183WDFDEVICE
185WDFEXPORT(WdfFdoRetrieveNextStaticChild)(
186 __in
188 __in
189 WDFDEVICE Fdo,
190 __in
191 WDFDEVICE PreviousChild,
192 __in
194 )
195/*++
196
197Routine Description:
198 Returns the next static child in the list based on the PreviousChild and
199 Flags values.
200
201Arguments:
202 Fdo - the parent which owns the static child list
203
204 PreviousChild - The child returned on the last call to this DDI. If NULL,
205 returns the first static child specified by the Flags criteria
206
207 Flags - combination of values from WDF_RETRIEVE_CHILD_FLAGS.
208 WdfRetrievePresentChildren - reports children who have been reported as
209 present to pnp
210 WdfRetrieveMissingChildren = reports children who have been reported as
211 missing to pnp
212 WdfRetrievePendingChildren = reports children who have been added to the
213 list, but not yet reported to pnp
214
215Return Value:
216 next WDFDEVICE handle representing a static child or NULL
217
218 --*/
219{
223 WDFDEVICE next;
224
226 Fdo,
228 (PVOID*)&pDevice,
230
231 //
232 // validate Flags
233 //
234 if (Flags == 0 || (Flags & ~WdfRetrieveAllChildren) != 0) {
237 "Invalid Flags 0x%x", Flags);
239 return NULL;
240 }
241
242 //
243 // Verify type
244 //
245 if (pDevice->IsLegacy() || (pDevice->IsFdo() == FALSE)) {
248 "WDFDEVICE %p is not an FDO", Fdo);
250 return NULL;
251 }
252
254
256
257 return next;
258}
259
261VOID
263WDFEXPORT(WdfFdoUnlockStaticChildListFromIteration)(
264 __in
266 __in
267 WDFDEVICE Fdo
268 )
269/*++
270
271Routine Description:
272 Unlocks the static child list from iteration. Upon the last unlock, any
273 pended modifications to the list will be applied.
274
275Arguments:
276 Fdo - the parent who owns the static child list
277
278Return Value:
279 None
280
281 --*/
282{
287
289 Fdo,
291 (PVOID*)&pDevice,
293
294 //
295 // Verify type
296 //
297 if (pDevice->IsLegacy() || (pDevice->IsFdo() == FALSE)) {
300 "WDFDEVICE %p is not an FDO", Fdo);
302 return;
303 }
304
305 //
306 // Local iterator used to end iteration. WdfRetrieveAllChildren is an
307 // arbitrary value.
308 //
310
313}
314
319WDFEXPORT(WdfFdoQueryForInterface)(
320 __in
322 __in
323 WDFDEVICE Fdo,
324 __in
326 __out
328 __in
330 __in
334 )
335/*++
336
337Routine Description:
338 Sends a query interface pnp request to the top of the stack (which means that
339 the request will travel through this device before going down the stack).
340
341Arguments:
342 Fdo - the device stack which is being queried
343
344 InterfaceType - interface type specifier
345
346 Interface - Interface block which will be filled in by the component which
347 responds to the query interface
348
349 Size - size in bytes of Interfce
350
351 Version - version of InterfaceType being requested
352
353 InterfaceSpecificData - Additional data associated with Interface
354
355Return Value:
356 NTSTATUS
357
358 --*/
359{
365
367 Fdo,
371
372 pDevice = NULL;
373
376
379 return status;
380 }
381
382 //
383 // See if we have a full fledged WDFDEVICE or a miniport WDFDEVICE
384 //
386 //
387 // Verify type
388 //
389 if (pDevice->IsLegacy() || (pDevice->IsFdo() == FALSE)) {
391
394 "WDFDEVICE 0x%p Device is either legacy or is not a Fdo %!STATUS!",
395 Fdo, status);
396
397 return status;
398 }
399 }
400 else {
401 //
402 // miniport WDFDEVICE, nothing to check
403 //
404 DO_NOTHING();
405 }
406
409}
410
412WDFCHILDLIST
414WDFEXPORT(WdfFdoGetDefaultChildList)(
415 __in
417 __in
418 WDFDEVICE Fdo
419 )
420/*++
421
422Routine Description:
423 Returns the default dynamic child list associated with the FDO. For a
424 valid handle to be returned, the driver must have configured the default
425 list in its device init phase.
426
427Arguments:
428 Fdo - the FDO being asked to return the handle
429
430Return Value:
431 a valid handle value or NULL
432
433 --*/
434{
438
440 Fdo,
442 (PVOID*)&pDevice,
444
445 //
446 // Verify type
447 //
448 if (pDevice->IsLegacy() || (pDevice->IsFdo() == FALSE)) {
451 "WDFDEVICE %p is not an FDO", Fdo);
453 return NULL;
454 }
455
457
459 return (WDFCHILDLIST) pPkgFdo->m_DefaultDeviceList->GetObjectHandle();
460 }
461 else {
464 "Default child list for FDO %p not configured, call "
465 "WdfFdoInitSetDefaultChildListConfig to do so", Fdo);
466 return NULL;
467 }
468}
469
470} // extern "C"
LONG NTSTATUS
Definition: precomp.h:26
VOID BeginIteration(__inout PWDF_CHILD_LIST_ITERATOR Iterator)
_Must_inspect_result_ NTSTATUS Add(__in PWDF_CHILD_IDENTIFICATION_DESCRIPTION_HEADER IdentificationDescription, __in_opt PWDF_CHILD_ADDRESS_DESCRIPTION_HEADER AddressDescription, __in_opt PULONG ScanTag=NULL)
VOID EndIteration(__inout PWDF_CHILD_LIST_ITERATOR Iterator)
WDFDEVICE GetNextStaticDevice(__in WDFDEVICE PreviousDevice, __in ULONG Flags)
_Must_inspect_result_ NTSTATUS QueryForInterface(__in const GUID *InterfaceType, __out PINTERFACE Interface, __in USHORT Size, __in USHORT Version, __in PVOID InterfaceSpecificData, __in_opt MdDeviceObject TargetDevice=NULL)
_Must_inspect_result_ NTSTATUS QueryInterface(__inout FxQueryInterfaceParams *Params)
__inline FxPkgFdo * GetFdoPkg(VOID)
Definition: fxdevice.hpp:1236
__inline BOOLEAN IsPdo(VOID)
Definition: fxdevice.hpp:1245
__inline BOOLEAN IsLegacy(VOID)
Definition: fxdevice.hpp:1209
__inline BOOLEAN IsFdo(VOID)
Definition: fxdevice.hpp:1227
virtual VOID SetDeviceTelemetryInfoFlags(_In_ FxDeviceInfoFlags Flag)
Definition: fxdevice.hpp:1807
PVOID __inline GetObjectHandle(VOID)
Definition: fxobject.hpp:603
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
FxChildList * m_DefaultDeviceList
Definition: fxpkgfdo.hpp:40
FxChildList * m_StaticDeviceList
Definition: fxpkgfdo.hpp:42
#define __in
Definition: dbghelp.h:35
#define __in_opt
Definition: dbghelp.h:38
#define __out
Definition: dbghelp.h:62
#define TRACINGDEVICE
Definition: dbgtrace.h:58
#define FALSE
Definition: types.h:117
#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)
PFX_DRIVER_GLOBALS pFxDriverGlobals
NTSTATUS status
FxObjectHandleGetPtrAndGlobals(GetFxDriverGlobals(DriverGlobals), Fdo, FX_TYPE_DEVICE,(PVOID *)&pDevice, &pFxDriverGlobals)
FxDeviceBase * pDeviceBase
_Must_inspect_result_ __in WDFDEVICE __in LPCGUID __out PINTERFACE __in USHORT __in USHORT __in_opt PVOID InterfaceSpecificData
FxPkgFdo * pPkgFdo
return NULL
_Must_inspect_result_ __in WDFDEVICE __in WDFDEVICE PreviousChild
FxDevice * pDevice
FxDevice * pFdo
FxObjectHandleGetPtr(GetFxDriverGlobals(DriverGlobals), Fdo, FX_TYPE_DEVICE,(PVOID *)&pFdo)
_Must_inspect_result_ __in WDFDEVICE __in WDFDEVICE __in ULONG Flags
_Must_inspect_result_ __in WDFDEVICE __in LPCGUID __out PINTERFACE Interface
FxDevice * pPdo
WDFDEVICE next
_Must_inspect_result_ __in WDFDEVICE __in LPCGUID InterfaceType
_Must_inspect_result_ __in WDFDEVICE Fdo
_Must_inspect_result_ __in WDFDEVICE __in LPCGUID __out PINTERFACE __in USHORT __in USHORT Version
WDF_CHILD_LIST_ITERATOR iterator
_Must_inspect_result_ __in WDFDEVICE __in LPCGUID __out PINTERFACE __in USHORT Size
_Must_inspect_result_ __in WDFDEVICE __in WDFDEVICE Child
FxVerifierDbgBreakPoint(pFxDriverGlobals)
DriverGlobals
__inline PFX_DRIVER_GLOBALS GetFxDriverGlobals(__in PWDF_DRIVER_GLOBALS DriverGlobals)
Definition: fxglobals.h:597
#define WDFEXPORT(a)
Definition: fxmacros.hpp:157
#define FxPointerNotNull(FxDriverGlobals, Ptr)
Definition: fxmacros.hpp:253
@ DeviceInfoHasStaticChildren
@ FX_TYPE_DEVICE
Definition: fxtypes.h:47
@ FX_TYPE_DEVICE_BASE
Definition: fxtypes.h:83
__inline NTSTATUS FxVerifierCheckIrqlLevel(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in KIRQL Irql)
Definition: fxverifier.h:158
GLenum const GLfloat * params
Definition: glext.h:5645
#define _Must_inspect_result_
Definition: ms_sal.h:558
#define DO_NOTHING()
Definition: mxgeneral.h:32
unsigned short USHORT
Definition: pedump.c:61
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
Definition: ps.c:97
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STDCALL
Definition: wdf.h:45
@ WdfRetrieveAllChildren
Definition: wdfchildlist.h:65
FORCEINLINE VOID WDF_CHILD_LIST_ITERATOR_INIT(_Out_ PWDF_CHILD_LIST_ITERATOR Iterator, _In_ ULONG Flags)
Definition: wdfchildlist.h:450
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
_Must_inspect_result_ _In_ WDFDEVICE Fdo
Definition: wdffdo.h:461
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE Interface
Definition: wdffdo.h:465
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID InterfaceType
Definition: wdffdo.h:463
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE _In_ USHORT _In_ USHORT Version
Definition: wdffdo.h:469
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE _In_ USHORT _In_ USHORT _In_opt_ PVOID InterfaceSpecificData
Definition: wdffdo.h:472
_Must_inspect_result_ _In_ WDFDEVICE _In_opt_ WDFDEVICE PreviousChild
Definition: wdffdo.h:591
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFDEVICE Child
Definition: wdffdo.h:536
const char * description
Definition: directx.c:2497
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170