ReactOS  0.4.15-dev-3017-g1d9542d
fxdevicepdoapi.cpp
Go to the documentation of this file.
1 /*++
2 
3 Copyright (c) Microsoft Corporation
4 
5 Module Name:
6 
7  FxDevicePdoApi.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 "FxDevicePdoApi.tmh"
29 }
30 
33  __in
34  IN PFX_DRIVER_GLOBALS CallersGlobals,
35  __in
36  WDFDEVICE Device,
37  __in
39  __out
40  FxPkgPdo **Package,
41  __out
42  PFX_DRIVER_GLOBALS* ObjectGlobals,
43  __out_opt
44  FxDevice **OutDevice = NULL
45  )
46 {
49 
50  FxObjectHandleGetPtrAndGlobals(CallersGlobals,
51  Device,
53  (PVOID*) &pDevice,
54  ObjectGlobals);
55 
56  //
57  // If the optional "OutDevice" argument is present, return the pointer
58  // to the device.
59  //
60  if (OutDevice != NULL) {
61  *OutDevice = pDevice;
62  }
63 
64  //
65  // Check to see if a PDO package is installed on the device.
66  //
67  if (pDevice->IsPdo()) {
68  *Package = (FxPkgPdo *) pDevice->GetPdoPkg();
70  }
71  else {
73  "%s: Incorrect device handle supplied (0x%p). "
74  "Device is not a PDO.", FunctionName, Device);
75 
77  }
78 
79  return status;
80 }
81 
82 //
83 // Extern "C" the rest of the file file
84 //
85 extern "C" {
86 
90 STDCALL
91 WDFEXPORT(WdfPdoMarkMissing)(
92  __in
94  __in
95  WDFDEVICE Device
96  )
97 {
102 
104  Device,
106  &pPkgPdo,
108  &pDevice);
109 
111  //
112  // Check to see if the device is enumerated off of a child list. If so,
113  // have the child list object perform any necessary actions.
114  //
116  }
117 
118  return status;
119 }
120 
122 WDFAPI
123 VOID
124 STDCALL
125 WDFEXPORT(WdfPdoRequestEject)(
126  __in
128  __in
129  WDFDEVICE Device
130  )
131 {
133  FxPkgPdo *pPkgPdo;
134  FxDevice *pDevice;
136 
138  Device,
140  &pPkgPdo,
142  &pDevice);
143 
144  if (NT_SUCCESS(status)) {
145  PDEVICE_OBJECT pdo;
146 
148 
149  if (pdo != NULL) {
151  }
152  else {
154  "PDO WDFDEVICE %p not reported yet to pnp, cannot eject!",
155  Device);
157  }
158  }
159  else {
161  "Can only eject PDOs, %!STATUS!", status);
163  }
164 }
165 
167 WDFDEVICE
168 STDCALL
169 WDFEXPORT(WdfPdoGetParent)(
170  __in
172  __in
173  WDFDEVICE Device
174  )
175 {
178  FxPkgPdo *pPkgPdo;
179  FxDevice *pDevice;
180 
182  Device,
184  &pPkgPdo,
186  &pDevice);
187 
188  if (NT_SUCCESS(status)) {
189  return pDevice->m_ParentDevice->GetHandle();
190  }
191  else {
193  "Can only eject PDOs, %!STATUS!", status);
194 
195  return NULL;
196  }
197 }
198 
201 WDFAPI
202 NTSTATUS
203 STDCALL
204 WDFEXPORT(WdfPdoRetrieveIdentificationDescription)(
205  __in
207  __in
208  WDFDEVICE Device,
209  __inout
211  )
212 {
215  FxPkgPdo *pPkgPdo;
216 
218  Device,
220  &pPkgPdo,
222 
224 
225  if (NT_SUCCESS(status)) {
227 
228  if (pPkgPdo->m_Description == NULL) {
230  }
231 
233 
234  //
235  // The fact that a statically enumerated PDO is enumerated using an
236  // FxChildList should not be exposed to the driver. Besides, the driver
237  // does not know the definition of the identificaiton descirption anyways.
238  //
239  if (pList->IsStaticList() ||
241  IdentificationDescription->IdentificationDescriptionSize) {
243  }
244 
247 
249  }
250 
251  return status;
252 }
253 
256 WDFAPI
257 NTSTATUS
258 STDCALL
259 WDFEXPORT(WdfPdoRetrieveAddressDescription)(
260  __in
262  __in
263  WDFDEVICE Device,
264  __inout
266  )
267 {
270  FxPkgPdo *pPkgPdo;
271 
273  Device,
275  &pPkgPdo,
277 
279 
280  if (NT_SUCCESS(status)) {
282 
283  if (pPkgPdo->m_Description == NULL) {
285  }
286 
288 
289  //
290  // A call to pList->IsStaticList() in the if below is not needed because
291  // a static list does not have address descriptions. Make sure this
292  // assumption is not violated through the ASSERT().
293  //
295 
296  if (pList->HasAddressDescriptions() == FALSE ||
298  AddressDescription->AddressDescriptionSize) {
300  }
301 
304 
306  }
307 
308  return status;
309 }
310 
313 WDFAPI
314 NTSTATUS
315 STDCALL
316 WDFEXPORT(WdfPdoUpdateAddressDescription)(
317  __in
319  __in
320  WDFDEVICE Device,
321  __inout
323  )
324 {
327  FxPkgPdo *pPkgPdo;
328 
330  Device,
332  &pPkgPdo,
334 
336 
337  if (NT_SUCCESS(status)) {
339 
340  if (pPkgPdo->m_Description == NULL) {
342  }
343 
345 
347  AddressDescription->AddressDescriptionSize) {
349  }
350 
353 
355  }
356 
357  return status;
358 }
359 
362 NTSTATUS
363 STDCALL
364 WDFEXPORT(WdfPdoAddEjectionRelationsPhysicalDevice)(
365  __in
367  __in
368  WDFDEVICE Device,
369  __in
371  )
372 /*++
373 
374 Routine Description:
375  Registers a PDO from another non descendant (not verifiable though) pnp
376  stack to be reported as also requiring eject when this PDO is ejected.
377 
378  The PDO could be another device enumerated by this driver.
379 
380 Arguments:
381  Device - the PDO for this driver
382 
383  PhysicalDevice - PDO for the other stack
384 
385 Return Value:
386  NTSTATUS
387 
388  --*/
389 {
391  FxPkgPdo* pPkgPdo;
393 
395  Device,
397  &pPkgPdo,
399 
401 
403  return status;
404  }
405 
407 
408  return status;
409 }
410 
412 VOID
413 STDCALL
414 WDFEXPORT(WdfPdoRemoveEjectionRelationsPhysicalDevice)(
415  __in
417  __in
418  WDFDEVICE Device,
419  __in
421  )
422 /*++
423 
424 Routine Description:
425  Deregisters a PDO from another non descendant (not verifiable though) pnp
426  stack so that it will not be reported as also requiring eject when this PDO
427  is ejected.
428 
429 Arguments:
430  Device - the PDO for this driver
431 
432  PhysicalDevice - PDO for the other stack
433 
434 Return Value:
435  None
436 
437  --*/
438 {
440  FxPkgPdo* pPkgPdo;
442 
444  Device,
446  &pPkgPdo,
448 
450 
451  if (!NT_SUCCESS(status)) {
452  return; // status;
453  }
454 
456 }
457 
459 VOID
460 STDCALL
461 WDFEXPORT(WdfPdoClearEjectionRelationsDevices)(
462  __in
464  __in
465  WDFDEVICE Device
466  )
467 /*++
468 
469 Routine Description:
470  Deregisters all PDOs so that they will not be reported as also requiring
471  eject when this PDO is ejected.
472 
473 Arguments:
474  Device - this driver's PDO
475 
476 Return Value:
477  None
478 
479  --*/
480 
481 {
483  FxPkgPdo* pPkgPdo;
485 
487  Device,
489  &pPkgPdo,
491 
492  if (!NT_SUCCESS(status)) {
493  return; // status;
494  }
495 
497 }
498 
499 } // extern "C"
500 
_Must_inspect_result_ __in WDFDEVICE Device
signed char * PCHAR
Definition: retypes.h:7
BOOLEAN HasAddressDescriptions(VOID)
#define IN
Definition: typedefs.h:39
NTSTATUS GetPdoPackageFromDeviceHandle(__in IN PFX_DRIVER_GLOBALS CallersGlobals, __in WDFDEVICE Device, __in PCHAR FunctionName, __out FxPkgPdo **Package, __out PFX_DRIVER_GLOBALS *ObjectGlobals, __out_opt FxDevice **OutDevice=NULL)
PFX_DRIVER_GLOBALS pFxDriverGlobals
CfxDevice * m_ParentDevice
Definition: fxdevice.hpp:569
_Must_inspect_result_ __in WDFDEVICE __inout PWDF_CHILD_IDENTIFICATION_DESCRIPTION_HEADER IdentificationDescription
WDFDEVICE __inline GetHandle(VOID)
Definition: fxdevice.hpp:237
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
DriverGlobals
PWDF_CHILD_IDENTIFICATION_DESCRIPTION_HEADER GetId(VOID)
_Must_inspect_result_ NTSTATUS UpdateDeviceAsMissing(__in CfxDevice *Device)
#define __out_opt
Definition: dbghelp.h:65
#define FALSE
Definition: types.h:117
VOID ClearEjectionDevicesList(VOID)
Definition: fxpkgpdo.cpp:1906
#define WDFEXPORT(a)
Definition: fxmacros.hpp:157
FxChildList * pList
#define WDFAPI
Definition: wdftypes.h:53
FxChildList * GetParentList(VOID)
#define __out
Definition: dbghelp.h:62
_Inout_ PWDF_CHILD_ADDRESS_DESCRIPTION_HEADER AddressDescription
Definition: wdfchildlist.h:255
VOID GetAddressDescriptionFromEntry(__in FxDeviceDescriptionEntry *Entry, __out PWDF_CHILD_ADDRESS_DESCRIPTION_HEADER AddressDescription)
BOOLEAN IsStaticList(VOID)
#define TRACINGDEVICE
Definition: dbgtrace.h:58
#define STDCALL
Definition: wdf.h:45
#define ASSERT(a)
Definition: mode.c:44
FxChildList * m_OwningChildList
Definition: fxpkgpdo.hpp:42
ULONG GetIdentificationDescriptionSize(VOID)
return NULL
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
FxPointerNotNull(pFxDriverGlobals, IdentificationDescription)
_In_ PWDF_CHILD_IDENTIFICATION_DESCRIPTION_HEADER IdentificationDescription
Definition: wdfchildlist.h:124
__inline FxPkgPdo * GetPdoPkg(VOID)
Definition: fxdevice.hpp:1254
FxPkgPdo * pPkgPdo
#define __inout
Definition: dbghelp.h:50
VOID NTAPI IoRequestDeviceEject(IN PDEVICE_OBJECT PhysicalDeviceObject)
Definition: devaction.c:2232
#define _Must_inspect_result_
Definition: ms_sal.h:558
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
NTSTATUS status
MdDeviceObject __inline GetSafePhysicalDevice(VOID)
Definition: fxdevice.hpp:1005
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
_Must_inspect_result_ NTSTATUS AddEjectionDevice(__in MdDeviceObject DependentDevice)
Definition: fxpkgpdo.cpp:1826
ULONG GetAddressDescriptionSize(VOID)
FxDeviceDescriptionEntry * m_Description
Definition: fxpkgpdo.hpp:40
FxDevice * pDevice
_Must_inspect_result_ __in WDFDEVICE __inout PWDF_CHILD_ADDRESS_DESCRIPTION_HEADER AddressDescription
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK void *Context ACPI_BUFFER *RetBuffer UINT16 ACPI_RESOURCE **ResourcePtr ACPI_GENERIC_ADDRESS *Reg UINT32 *ReturnValue UINT8 UINT8 *Slp_TypB ACPI_PHYSICAL_ADDRESS PhysicalAddress64 UINT32 UINT32 *TimeElapsed UINT32 ACPI_STATUS const char UINT32 ACPI_STATUS const char UINT32 const char * FunctionName
Definition: acpixf.h:1274
VOID CopyId(__out PWDF_CHILD_IDENTIFICATION_DESCRIPTION_HEADER Dest, __in PWDF_CHILD_IDENTIFICATION_DESCRIPTION_HEADER Source)
FxObjectHandleGetPtrAndGlobals(GetFxDriverGlobals(DriverGlobals), Device, FX_TYPE_DEVICE,(PVOID *)&pDevice, &pFxDriverGlobals)
_Must_inspect_result_ __in WDFDEVICE __in PDEVICE_OBJECT PhysicalDevice
VOID RemoveEjectionDevice(__in MdDeviceObject DependentDevice)
Definition: fxpkgpdo.cpp:1890
__inline BOOLEAN IsPdo(VOID)
Definition: fxdevice.hpp:1245
#define STATUS_SUCCESS
Definition: shellext.h:65
__inline PFX_DRIVER_GLOBALS GetFxDriverGlobals(__in PWDF_DRIVER_GLOBALS DriverGlobals)
Definition: fxglobals.h:597
_Must_inspect_result_ __drv_maxIRQL(DISPATCH_LEVEL) NTSTATUS STDCALL WDFEXPORT(WdfPdoMarkMissing)(__in PWDF_DRIVER_GLOBALS DriverGlobals
VOID UpdateAddressDescriptionFromEntry(__inout FxDeviceDescriptionEntry *Entry, __in PWDF_CHILD_ADDRESS_DESCRIPTION_HEADER AddressDescription)
#define __in
Definition: dbghelp.h:35
#define __FUNCTION__
Definition: types.h:112
FxVerifierDbgBreakPoint(pFxDriverGlobals)
_Must_inspect_result_ _In_ WDFDEVICE _In_ PDEVICE_OBJECT PhysicalDevice
Definition: wdfdevice.h:2320
Definition: ps.c:97