ReactOS 0.4.15-dev-7907-g95bf896
fxdevicepdoapi.cpp
Go to the documentation of this file.
1/*++
2
3Copyright (c) Microsoft Corporation
4
5Module Name:
6
7 FxDevicePdoApi.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 "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,
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//
85extern "C" {
86
91WDFEXPORT(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
122WDFAPI
123VOID
125WDFEXPORT(WdfPdoRequestEject)(
126 __in
128 __in
129 WDFDEVICE Device
130 )
131{
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
167WDFDEVICE
169WDFEXPORT(WdfPdoGetParent)(
170 __in
172 __in
173 WDFDEVICE Device
174 )
175{
180
182 Device,
184 &pPkgPdo,
186 &pDevice);
187
188 if (NT_SUCCESS(status)) {
190 }
191 else {
193 "Can only eject PDOs, %!STATUS!", status);
194
195 return NULL;
196 }
197}
198
201WDFAPI
204WDFEXPORT(WdfPdoRetrieveIdentificationDescription)(
205 __in
207 __in
208 WDFDEVICE Device,
209 __inout
211 )
212{
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
256WDFAPI
259WDFEXPORT(WdfPdoRetrieveAddressDescription)(
260 __in
262 __in
263 WDFDEVICE Device,
264 __inout
266 )
267{
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
298 AddressDescription->AddressDescriptionSize) {
300 }
301
304
306 }
307
308 return status;
309}
310
313WDFAPI
316WDFEXPORT(WdfPdoUpdateAddressDescription)(
317 __in
319 __in
320 WDFDEVICE Device,
321 __inout
323 )
324{
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
364WDFEXPORT(WdfPdoAddEjectionRelationsPhysicalDevice)(
365 __in
367 __in
368 WDFDEVICE Device,
369 __in
371 )
372/*++
373
374Routine 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
380Arguments:
381 Device - the PDO for this driver
382
383 PhysicalDevice - PDO for the other stack
384
385Return Value:
386 NTSTATUS
387
388 --*/
389{
393
395 Device,
397 &pPkgPdo,
399
401
403 return status;
404 }
405
407
408 return status;
409}
410
412VOID
414WDFEXPORT(WdfPdoRemoveEjectionRelationsPhysicalDevice)(
415 __in
417 __in
418 WDFDEVICE Device,
419 __in
421 )
422/*++
423
424Routine 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
429Arguments:
430 Device - the PDO for this driver
431
432 PhysicalDevice - PDO for the other stack
433
434Return Value:
435 None
436
437 --*/
438{
442
444 Device,
446 &pPkgPdo,
448
450
451 if (!NT_SUCCESS(status)) {
452 return; // status;
453 }
454
456}
457
459VOID
461WDFEXPORT(WdfPdoClearEjectionRelationsDevices)(
462 __in
464 __in
465 WDFDEVICE Device
466 )
467/*++
468
469Routine Description:
470 Deregisters all PDOs so that they will not be reported as also requiring
471 eject when this PDO is ejected.
472
473Arguments:
474 Device - this driver's PDO
475
476Return Value:
477 None
478
479 --*/
480
481{
485
487 Device,
489 &pPkgPdo,
491
492 if (!NT_SUCCESS(status)) {
493 return; // status;
494 }
495
497}
498
499} // extern "C"
500
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:1279
LONG NTSTATUS
Definition: precomp.h:26
_Must_inspect_result_ NTSTATUS UpdateDeviceAsMissing(__in CfxDevice *Device)
VOID GetAddressDescriptionFromEntry(__in FxDeviceDescriptionEntry *Entry, __out PWDF_CHILD_ADDRESS_DESCRIPTION_HEADER AddressDescription)
BOOLEAN HasAddressDescriptions(VOID)
BOOLEAN IsStaticList(VOID)
VOID UpdateAddressDescriptionFromEntry(__inout FxDeviceDescriptionEntry *Entry, __in PWDF_CHILD_ADDRESS_DESCRIPTION_HEADER AddressDescription)
ULONG GetIdentificationDescriptionSize(VOID)
ULONG GetAddressDescriptionSize(VOID)
VOID CopyId(__out PWDF_CHILD_IDENTIFICATION_DESCRIPTION_HEADER Dest, __in PWDF_CHILD_IDENTIFICATION_DESCRIPTION_HEADER Source)
WDFDEVICE __inline GetHandle(VOID)
Definition: fxdevice.hpp:237
CfxDevice * m_ParentDevice
Definition: fxdevice.hpp:569
MdDeviceObject __inline GetSafePhysicalDevice(VOID)
Definition: fxdevice.hpp:1005
__inline BOOLEAN IsPdo(VOID)
Definition: fxdevice.hpp:1245
__inline FxPkgPdo * GetPdoPkg(VOID)
Definition: fxdevice.hpp:1254
VOID RemoveEjectionDevice(__in MdDeviceObject DependentDevice)
Definition: fxpkgpdo.cpp:1890
FxChildList * m_OwningChildList
Definition: fxpkgpdo.hpp:42
FxDeviceDescriptionEntry * m_Description
Definition: fxpkgpdo.hpp:40
_Must_inspect_result_ NTSTATUS AddEjectionDevice(__in MdDeviceObject DependentDevice)
Definition: fxpkgpdo.cpp:1826
VOID ClearEjectionDevicesList(VOID)
Definition: fxpkgpdo.cpp:1906
#define __out_opt
Definition: dbghelp.h:65
#define __in
Definition: dbghelp.h:35
#define __inout
Definition: dbghelp.h:50
#define __out
Definition: dbghelp.h:62
#define TRACINGDEVICE
Definition: dbgtrace.h:58
VOID NTAPI IoRequestDeviceEject(IN PDEVICE_OBJECT PhysicalDeviceObject)
Definition: devaction.c:2203
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define __FUNCTION__
Definition: types.h:116
#define __drv_maxIRQL(irql)
Definition: driverspecs.h:291
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
FxChildList * pList
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
FxObjectHandleGetPtrAndGlobals(GetFxDriverGlobals(DriverGlobals), Device, FX_TYPE_DEVICE,(PVOID *)&pDevice, &pFxDriverGlobals)
NTSTATUS status
return NULL
_Must_inspect_result_ __in WDFDEVICE __in PDEVICE_OBJECT PhysicalDevice
FxDevice * pDevice
_Must_inspect_result_ __in WDFDEVICE Device
FxVerifierDbgBreakPoint(pFxDriverGlobals)
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)
FxPkgPdo * pPkgPdo
_Must_inspect_result_ __in WDFDEVICE __inout PWDF_CHILD_ADDRESS_DESCRIPTION_HEADER AddressDescription
_Must_inspect_result_ __in WDFDEVICE __inout PWDF_CHILD_IDENTIFICATION_DESCRIPTION_HEADER IdentificationDescription
PFX_DRIVER_GLOBALS 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
@ FX_TYPE_DEVICE
Definition: fxtypes.h:47
#define ASSERT(a)
Definition: mode.c:44
#define _Must_inspect_result_
Definition: ms_sal.h:558
#define STATUS_SUCCESS
Definition: shellext.h:65
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
PWDF_CHILD_IDENTIFICATION_DESCRIPTION_HEADER GetId(VOID)
FxChildList * GetParentList(VOID)
Definition: ps.c:97
#define IN
Definition: typedefs.h:39
char * PCHAR
Definition: typedefs.h:51
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STDCALL
Definition: wdf.h:45
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
_In_ PWDF_CHILD_IDENTIFICATION_DESCRIPTION_HEADER IdentificationDescription
Definition: wdfchildlist.h:124
_Inout_ PWDF_CHILD_ADDRESS_DESCRIPTION_HEADER AddressDescription
Definition: wdfchildlist.h:255
_Must_inspect_result_ _In_ WDFDEVICE _In_ PDEVICE_OBJECT PhysicalDevice
Definition: wdfdevice.h:2323
#define WDFAPI
Definition: wdftypes.h:53