ReactOS  0.4.15-dev-1638-gc0caa5c
fxdevicefdoapi.cpp
Go to the documentation of this file.
1 /*++
2 
3 Copyright (c) Microsoft Corporation
4 
5 Module Name:
6 
7  FxDeviceFdoApi.cpp
8 
9 Abstract:
10 
11  This module exposes the "C" interface to the FxDevice object.
12 
13 Author:
14 
15 
16 
17 Environment:
18 
19  Kernel mode only
20 
21 Revision History:
22 
23 --*/
24 
25 #include "fxcorepch.hpp"
26 
27 extern "C" {
28 // #include "FxDeviceFdoApi.tmh"
29 }
30 
31 //
32 // Extern "C" the rest of the file
33 //
34 extern "C" {
35 
39 STDCALL
40 WDFEXPORT(WdfFdoAddStaticChild)(
41  __in
43  __in
44  WDFDEVICE Fdo,
45  __in
46  WDFDEVICE Child
47  )
48 /*++
49 
50 Routine Description:
51  Adds a statically enumerated child to the static device list.
52 
53 Arguments:
54  Fdo - the parent of the child
55 
56  Child - the child to add
57 
58 Return 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 
105  pPkgFdo = pFdo->GetFdoPkg();
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 
124 VOID
125 STDCALL
126 WDFEXPORT(WdfFdoLockStaticChildListForIteration)(
127  __in
129  __in
130  WDFDEVICE Fdo
131  )
132 /*++
133 
134 Routine 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 
139 Arguments:
140  Fdo - the parent who owns the list of static children
141 
142 Return Value:
143  None
144 
145  --*/
146 
147 {
151  FxPkgFdo* pPkgFdo;
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 
183 WDFDEVICE
184 STDCALL
185 WDFEXPORT(WdfFdoRetrieveNextStaticChild)(
186  __in
188  __in
189  WDFDEVICE Fdo,
190  __in
191  WDFDEVICE PreviousChild,
192  __in
193  ULONG Flags
194  )
195 /*++
196 
197 Routine Description:
198  Returns the next static child in the list based on the PreviousChild and
199  Flags values.
200 
201 Arguments:
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 
215 Return Value:
216  next WDFDEVICE handle representing a static child or NULL
217 
218  --*/
219 {
221  FxDevice* pDevice;
222  FxPkgFdo* pPkgFdo;
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 
261 VOID
262 STDCALL
263 WDFEXPORT(WdfFdoUnlockStaticChildListFromIteration)(
264  __in
266  __in
267  WDFDEVICE Fdo
268  )
269 /*++
270 
271 Routine Description:
272  Unlocks the static child list from iteration. Upon the last unlock, any
273  pended modifications to the list will be applied.
274 
275 Arguments:
276  Fdo - the parent who owns the static child list
277 
278 Return Value:
279  None
280 
281  --*/
282 {
285  FxDevice* pDevice;
286  FxPkgFdo* pPkgFdo;
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 
317 NTSTATUS
318 STDCALL
319 WDFEXPORT(WdfFdoQueryForInterface)(
320  __in
322  __in
323  WDFDEVICE Fdo,
324  __in
326  __out
328  __in
329  USHORT Size,
330  __in
331  USHORT Version,
332  __in_opt
334  )
335 /*++
336 
337 Routine 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 
341 Arguments:
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 
355 Return Value:
356  NTSTATUS
357 
358  --*/
359 {
362  FxDevice* pDevice;
365 
367  Fdo,
369  (PVOID*)&pDeviceBase,
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 
412 WDFCHILDLIST
413 STDCALL
414 WDFEXPORT(WdfFdoGetDefaultChildList)(
415  __in
417  __in
418  WDFDEVICE Fdo
419  )
420 /*++
421 
422 Routine 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 
427 Arguments:
428  Fdo - the FDO being asked to return the handle
429 
430 Return Value:
431  a valid handle value or NULL
432 
433  --*/
434 {
436  FxDevice* pDevice;
437  FxPkgFdo* pPkgFdo;
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"
_Must_inspect_result_ __in WDFDEVICE __in WDFDEVICE Child
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE _In_ USHORT _In_ USHORT _In_opt_ PVOID InterfaceSpecificData
Definition: wdffdo.h:461
#define _Must_inspect_result_
Definition: no_sal2.h:62
FxDeviceBase * pDeviceBase
_Must_inspect_result_ NTSTATUS QueryInterface(__inout FxQueryInterfaceParams *Params)
_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)
#define __in_opt
Definition: dbghelp.h:38
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
FxPointerNotNull(pFxDriverGlobals, InterfaceType)
_Must_inspect_result_ __in WDFDEVICE __in LPCGUID InterfaceType
FxChildList * m_DefaultDeviceList
Definition: fxpkgfdo.hpp:40
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
_Must_inspect_result_ __in WDFDEVICE __in LPCGUID __out PINTERFACE Interface
FxDevice * pPdo
FxObjectHandleGetPtrAndGlobals(GetFxDriverGlobals(DriverGlobals), Fdo, FX_TYPE_DEVICE,(PVOID *)&pDevice, &pFxDriverGlobals)
FxObjectHandleGetPtr(GetFxDriverGlobals(DriverGlobals), Fdo, FX_TYPE_DEVICE,(PVOID *)&pFdo)
virtual VOID SetDeviceTelemetryInfoFlags(_In_ FxDeviceInfoFlags Flag)
Definition: fxdevice.hpp:1807
DriverGlobals
FxPkgFdo * pPkgFdo
const char * description
Definition: directx.c:2497
__inline BOOLEAN IsLegacy(VOID)
Definition: fxdevice.hpp:1209
_Must_inspect_result_ __in WDFDEVICE __in WDFDEVICE PreviousChild
VOID EndIteration(__inout PWDF_CHILD_LIST_ITERATOR Iterator)
_Must_inspect_result_ __drv_maxIRQL(DISPATCH_LEVEL) NTSTATUS STDCALL WDFEXPORT(WdfFdoAddStaticChild)(__in PWDF_DRIVER_GLOBALS DriverGlobals
FORCEINLINE VOID WDF_CHILD_LIST_ITERATOR_INIT(_Out_ PWDF_CHILD_LIST_ITERATOR Iterator, _In_ ULONG Flags)
Definition: wdfchildlist.h:450
#define FALSE
Definition: types.h:117
GLenum const GLfloat * params
Definition: glext.h:5645
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFDEVICE Child
Definition: wdffdo.h:533
__inline BOOLEAN IsFdo(VOID)
Definition: fxdevice.hpp:1227
#define WDFEXPORT(a)
Definition: fxmacros.hpp:157
_Must_inspect_result_ __in WDFDEVICE __in LPCGUID __out PINTERFACE __in USHORT __in USHORT Version
PVOID __inline GetObjectHandle(VOID)
Definition: fxobject.hpp:603
#define __out
Definition: dbghelp.h:62
_Must_inspect_result_ _In_ WDFDEVICE _In_opt_ WDFDEVICE PreviousChild
Definition: wdffdo.h:589
__inline NTSTATUS FxVerifierCheckIrqlLevel(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in KIRQL Irql)
Definition: fxverifier.h:158
#define TRACINGDEVICE
Definition: dbgtrace.h:58
FxDevice * pFdo
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
PFX_DRIVER_GLOBALS pFxDriverGlobals
#define STDCALL
Definition: wdf.h:45
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
return NULL
IN PVOID IN PVOID IN USHORT Version
Definition: pci.h:361
__inline FxPkgFdo * GetFdoPkg(VOID)
Definition: fxdevice.hpp:1236
_Must_inspect_result_ _In_ WDFDEVICE Fdo
Definition: wdffdo.h:461
_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)
NTSTATUS status
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
WDF_CHILD_LIST_ITERATOR iterator
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
FxChildList * m_StaticDeviceList
Definition: fxpkgfdo.hpp:42
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
_Must_inspect_result_ __in WDFDEVICE __in LPCGUID __out PINTERFACE __in USHORT Size
IN PVOID IN PVOID IN USHORT IN USHORT IN PINTERFACE Interface
Definition: pci.h:361
unsigned short USHORT
Definition: pedump.c:61
FxDevice * pDevice
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
WDFDEVICE next
_Must_inspect_result_ __in WDFDEVICE Fdo
_Must_inspect_result_ __in WDFDEVICE __in WDFDEVICE __in ULONG Flags
unsigned int ULONG
Definition: retypes.h:1
_Must_inspect_result_ __in WDFDEVICE __in LPCGUID __out PINTERFACE __in USHORT __in USHORT __in_opt PVOID InterfaceSpecificData
__inline BOOLEAN IsPdo(VOID)
Definition: fxdevice.hpp:1245
__inline PFX_DRIVER_GLOBALS GetFxDriverGlobals(__in PWDF_DRIVER_GLOBALS DriverGlobals)
Definition: fxglobals.h:597
#define __in
Definition: dbghelp.h:35
WDFDEVICE GetNextStaticDevice(__in WDFDEVICE PreviousDevice, __in ULONG Flags)
VOID BeginIteration(__inout PWDF_CHILD_LIST_ITERATOR Iterator)
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID InterfaceType
Definition: wdffdo.h:461
FxVerifierDbgBreakPoint(pFxDriverGlobals)
#define DO_NOTHING()
Definition: mxgeneral.h:32
Definition: ps.c:97