ReactOS  0.4.15-dev-2947-g59e1b78
fxpkgpdo.hpp
Go to the documentation of this file.
1 /*++
2 
3 Copyright (c) Microsoft. All rights reserved.
4 
5 Module Name:
6 
7  FxPkgPdo.hpp
8 
9 Abstract:
10 
11  This module implements the pnp package for Pdo objects.
12 
13 Author:
14 
15 
16 
17 Environment:
18 
19  Both kernel and user mode
20 
21 Revision History:
22 
23 
24 --*/
25 
26 #ifndef _FXPKGPDO_H_
27 #define _FXPKGPDO_H_
28 
30 
31 class FxPkgPdo : public FxPkgPnp
32 {
33 public:
34  //
35  // Properties used in handling IRP_MN_QUERY_DEVICE_TEXT
36  //
39 
41 
43 
44  //
45  // The following structure contains the function pointer table
46  // for the "events" this package can raise.
47  //
52 
55 
56  // added in 1.11
58 
60 
62 
64 
65  //
66  // This field is used to indicate that Requests on this PDO could be
67  // forwarded to the parent.
68  //
70 
71 protected:
72  //
73  // Pointer to a null terminated string which is the device ID. This is
74  // not a pointer that can be freed. m_IDsAllocation is the beginning of
75  // the allocation that can be freed.
76  //
78 
79  //
80  // Pointer to a null terminated string which is the instance ID. This is
81  // not a pointer that can be freed. m_IDsAllocation is the beginning of
82  // the allocation that can be freed.
83  //
85 
86  //
87  // Pointer to a multi sz which is the hardware IDs. This is
88  // not a pointer that can be freed. m_IDsAllocation is the beginning of
89  // the allocation that can be freed.
90  //
92 
93  //
94  // Pointer to a multi sz which is the compatible IDs. This is
95  // not a pointer that can be freed. m_IDsAllocation is the beginning of
96  // the allocation that can be freed.
97  //
99 
100  //
101  // Pointer to a null terminated string which is the unique ID. This is
102  // not a pointer that can be freed. m_IDsAllocation is the beginning of
103  // the allocation that can be freed.
104  //
106 
107  //
108  // Single allocation for all static ID strings (device, instance, hw, compat)
109  // for the device
110  //
112 
114 
115  //
116  // IRP_MN_EJECT needs to be handled synchronously because PnP manager does
117  // not serialize it with other state changing PnP irps if not handled
118  // synchronously. This event is used to signal the completion of
119  // IRP_MN_EJECT processing.
120  //
122 
124 
125  //
126  // Parameter to track whether the EvtDeviceEnableWakeAtBus callback was
127  // invoked and to determine whether the EvtDeviceDisableWakeAtBus callback
128  // should be invoked or not. The EnableWakeAtBus callback may not get
129  // invoked if an upper driver in the stack completed the wait wake irp
130  // instead of passing it down the stack and the power policy owner is
131  // a PDO.
132  //
133  // This parameter can be referenced by either the power state machine or
134  // the power policy state machine when a PDO is the power policy owner
135  // but there is no locking mechanism necessary to synchronize access to
136  // the field. This is because the arrival of a Dx irp will move the power
137  // state machine to a state where it can no longer affect the value of
138  // this field and hence provides an implicit guard that allows the power
139  // policy state machine to use this field while processing the Dx irp.
140  //
142 
143 private:
144  //
145  // Table of internal methods to handle PnP minor function codes.
146  //
148 
149  //
150  // Table of internal methods to handle power minor function codes.
151  //
153 
154 public:
155 
156  FxPkgPdo(
157  __in PFX_DRIVER_GLOBALS FxDriverGlobals,
159  );
160 
161  ~FxPkgPdo();
162 
164  virtual
165  NTSTATUS
166  Initialize(
168  );
169 
170  virtual
171  VOID
174  );
175 
176  VOID
179  );
180 
182  NTSTATUS
185  );
186 
187  VOID
190  );
191 
192  VOID
194  VOID
195  );
196 
198  NTSTATUS
200  __in FxIrp* Irp,
202  );
203 
204  __inline
205  BOOLEAN
207  VOID
208  )
209  {
211  }
212 
213 
214 private:
216  virtual
217  NTSTATUS
219  __in FxIrp* Irp
220  );
221 
223  virtual
224  NTSTATUS
226  __inout FxIrp* Irp
227  );
228 
229  //
230  // The following are static member function. The only reason
231  // I've defined them as member functions at all is so they can see
232  // the private data in this class.
233  //
234 
236  static
237  NTSTATUS
239  __in FxPkgPnp* This,
240  __inout FxIrp *Irp
241  );
242 
244  static
245  NTSTATUS
247  __in FxPkgPnp* This,
248  __inout FxIrp *Irp
249  );
250 
252  NTSTATUS
254  __inout FxIrp *Irp
255  );
256 
258  static
259  NTSTATUS
261  IN FxPkgPnp* This,
262  IN FxIrp *Irp
263  );
264 
266  static
267  NTSTATUS
270  __inout FxIrp *Irp
271  );
272 
274  NTSTATUS
276  __inout FxIrp *Irp
277  );
278 
279  VOID
281  __inout PDEVICE_CAPABILITIES ReportedCaps,
282  __in PDEVICE_CAPABILITIES ParentCaps
283  );
284 
285  static
286  VOID
287  STDCALL
291  );
292 
294  static
295  NTSTATUS
298  __inout FxIrp *Irp
299  );
300 
302  NTSTATUS
304  __inout FxIrp *Irp
305  );
306 
308  static
309  NTSTATUS
312  __inout FxIrp *Irp
313  );
314 
316  NTSTATUS
318  __inout FxIrp *Irp
319  );
320 
322  static
323  NTSTATUS
326  __inout FxIrp *Irp
327  );
328 
330  static
331  NTSTATUS
334  __inout FxIrp *Irp
335  );
336 
338  static
339  NTSTATUS
340  _PnpEject(
342  __inout FxIrp *Irp
343  );
344 
345  virtual
346  BOOLEAN
348  VOID
349  );
350 
351  virtual
354  VOID
355  );
356 
357  virtual
360  VOID
361  );
362 
363  virtual
366  VOID
367  );
368 
369  virtual
372  VOID
373  );
374 
375  virtual
376  VOID
378  VOID
379  );
380 
381  virtual
384  VOID
385  );
386 
388  static
389  NTSTATUS
390  _PnpSetLock(
392  __inout FxIrp *Irp
393  );
394 
396  static
397  NTSTATUS
398  _PnpQueryId(
400  __inout FxIrp *Irp
401  );
402 
404  static
405  NTSTATUS
408  __inout FxIrp *Irp
409  );
410 
412  static
413  NTSTATUS
416  __inout FxIrp *Irp
417  );
418 
420  static
421  NTSTATUS
424  __inout FxIrp *Irp
425  );
426 
427  static
429  NTSTATUS
432  __in FxIrp *Irp
433  );
434 
435  static
437  NTSTATUS
440  __in FxIrp *Irp
441  );
442 
444  NTSTATUS
446  __in FxIrp *Irp
447  );
448 
450  NTSTATUS
452  __in FxIrp *Irp
453  );
454 
455  static
457  NTSTATUS
460  __in FxIrp *Irp
461  );
462 
463  virtual
465  NTSTATUS
467  __in BOOLEAN* ParentOn
468  );
469 
470  virtual
473  VOID
474  );
475 
476  virtual
479  VOID
480  );
481 
482  virtual
484  NTSTATUS
486  VOID
487  );
488 
489  virtual
490  VOID
492  VOID
493  );
494 
495  virtual
496  VOID
498  VOID
499  );
500 
501  virtual
502  VOID
504  __in BOOLEAN IrpMustBePresent = TRUE
505  );
506 
508  virtual
509  NTSTATUS
511  __inout FxIrp* Irp
512  );
513 
514  virtual
515  VOID
517  __in BOOLEAN GracefulRemove
518  );
519 
520  virtual
521  VOID
523  VOID
524  )
525  {
526  //
527  // As the PDO, we already have the interface built in
528  //
529  DO_NOTHING();
530  }
531 
532  virtual
533  VOID
535  VOID
536  )
537  {
538  //
539  // As the PDO, we already have the interface built in
540  //
541  DO_NOTHING();
542  }
543 
545  virtual
546  NTSTATUS
548  VOID
549  );
550 
552  virtual
553  NTSTATUS
555  VOID
556  );
557 
558  virtual
561  VOID
562  )
563  {
564  return m_PdoPnpFunctionTable;
565  }
566 
567  virtual
570  VOID
571  )
572  {
574  }
575 
576  static
577  VOID
578  STDCALL
581  );
582 
583  VOID
585  VOID
586  );
587 
588  VOID
590  VOID
591  );
592 };
593 
594 #endif // _FXPKGPDO_H
enum _WDF_DEVICE_PNP_STATE WDF_DEVICE_PNP_STATE
virtual VOID PowerReleasePendingDeviceIrp(__in BOOLEAN IrpMustBePresent=TRUE)
Definition: pdopower.cpp:241
virtual const PFN_PNP_POWER_CALLBACK * GetDispatchPower(VOID)
Definition: fxpkgpdo.hpp:569
#define IN
Definition: typedefs.h:39
_Must_inspect_result_ NTSTATUS PnpQueryResources(__inout FxIrp *Irp)
Definition: fxpkgpdokm.cpp:49
FxPnpDeviceEject m_DeviceEject
Definition: fxpkgpdo.hpp:50
virtual _Must_inspect_result_ NTSTATUS QueryForPowerThread(VOID)
Definition: fxpkgpdo.cpp:1804
#define IRP_MN_QUERY_POWER
FxPnpDeviceResourcesQuery m_DeviceResourcesQuery
Definition: fxpkgpdo.hpp:48
Definition: ntbasedef.h:628
FxPnpDeviceReportedMissing m_DeviceReportedMissing
Definition: fxpkgpdo.hpp:57
#define TRUE
Definition: types.h:120
uint16_t * PWSTR
Definition: typedefs.h:56
NTSTATUS(FxPkgPdo::* PFN_PDO_HANDLER)(FxIrp *Irp)
Definition: fxpkgpdo.hpp:29
virtual WDF_DEVICE_PNP_STATE PnpEventEjectHardwareOverload(VOID)
Definition: fxpkgpdo.cpp:1045
LONG NTSTATUS
Definition: precomp.h:26
static _Must_inspect_result_ NTSTATUS _PnpFilterResourceRequirements(__inout FxPkgPnp *This, __inout FxIrp *Irp)
Definition: fxpkgpdokm.cpp:343
virtual _Must_inspect_result_ NTSTATUS PowerCheckParentOverload(__in BOOLEAN *ParentOn)
Definition: pdopower.cpp:261
Definition: fxirp.hpp:28
PWSTR m_DeviceID
Definition: fxpkgpdo.hpp:77
BOOLEAN m_AllowForwardRequestToParent
Definition: fxpkgpdo.hpp:69
BOOLEAN m_AddedToStaticList
Definition: fxpkgpdo.hpp:63
VOID HandleQueryCapabilities(__inout PDEVICE_CAPABILITIES ReportedCaps, __in PDEVICE_CAPABILITIES ParentCaps)
Definition: fxpkgpdo.cpp:666
DWORD LCID
Definition: nls.h:13
static _Must_inspect_result_ NTSTATUS _PnpSetLock(__inout FxPkgPnp *This, __inout FxIrp *Irp)
Definition: fxpkgpdo.cpp:1323
_Must_inspect_result_ NTSTATUS HandleQueryInterfaceForReenumerate(__in FxIrp *Irp, __out PBOOLEAN CompleteRequest)
Definition: fxpkgpdo.cpp:1687
virtual VOID ReleaseReenumerationInterface(VOID)
Definition: fxpkgpdo.hpp:534
_Must_inspect_result_ NTSTATUS PnpQueryDeviceRelations(__inout FxIrp *Irp)
Definition: fxpkgpdo.cpp:434
PWSTR m_CompatibleIDs
Definition: fxpkgpdo.hpp:98
static _Must_inspect_result_ NTSTATUS _PnpQueryBusInformation(__inout FxPkgPnp *This, __inout FxIrp *Irp)
Definition: fxpkgpdo.cpp:1529
BOOLEAN m_CanBeDeleted
Definition: fxpkgpdo.hpp:123
static _Must_inspect_result_ NTSTATUS _PnpEject(__inout FxPkgPnp *This, __inout FxIrp *Irp)
Definition: fxpkgpdo.cpp:968
PWSTR m_InstanceID
Definition: fxpkgpdo.hpp:84
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116
VOID ClearEjectionDevicesList(VOID)
Definition: fxpkgpdo.cpp:1906
PWSTR m_HardwareIDs
Definition: fxpkgpdo.hpp:91
LCID m_DefaultLocale
Definition: fxpkgpdo.hpp:38
static const PFN_PNP_POWER_CALLBACK m_PdoPowerFunctionTable[IRP_MN_QUERY_POWER+1]
Definition: fxpkgpdo.hpp:152
static VOID STDCALL _RemoveAndReenumerateSelf(__in PVOID Context)
Definition: fxpkgpdo.cpp:1665
VOID PowerNotifyParentChildWakeArmed(VOID)
Definition: pdopower.cpp:426
#define __out
Definition: dbghelp.h:62
_Must_inspect_result_ _In_ WDFDEVICE _In_ PDEVICE_OBJECT DependentDevice
Definition: wdfdevice.h:2260
unsigned char BOOLEAN
virtual WDF_DEVICE_PNP_STATE PnpEventFdoRemovedOverload(VOID)
Definition: fxpkgpdo.cpp:1269
virtual WDF_DEVICE_PNP_STATE PnpEventPdoRemovedOverload(VOID)
Definition: fxpkgpdo.cpp:1208
FxPkgPdo(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in CfxDevice *Device)
Definition: fxpkgpdo.cpp:81
virtual WDF_DEVICE_POWER_STATE PowerCheckDeviceTypeNPOverload(VOID)
Definition: pdopower.cpp:310
static _Must_inspect_result_ NTSTATUS _PnpQueryPnpDeviceState(__inout FxPkgPnp *This, __inout FxIrp *Irp)
Definition: fxpkgpdo.cpp:1483
#define IRP_MN_SURPRISE_REMOVAL
Definition: ntifs_ex.h:408
_Must_inspect_result_ NTSTATUS PnpQueryCapabilities(__inout FxIrp *Irp)
Definition: fxpkgpdo.cpp:561
_Must_inspect_result_ NTSTATUS DispatchSystemSetPower(__in FxIrp *Irp)
Definition: pdopower.cpp:95
BOOLEAN m_RawOK
Definition: fxpkgpdo.hpp:59
#define STDCALL
Definition: wdf.h:45
FxChildList * m_OwningChildList
Definition: fxpkgpdo.hpp:42
PWSTR m_ContainerID
Definition: fxpkgpdo.hpp:105
virtual VOID PnpEventSurpriseRemovePendingOverload(VOID)
Definition: fxpkgpdo.cpp:1282
virtual _Must_inspect_result_ NTSTATUS Initialize(__in PWDFDEVICE_INIT DeviceInit)
Definition: fxpkgpdo.cpp:184
__inline BOOLEAN IsForwardRequestToParentEnabled(VOID)
Definition: fxpkgpdo.hpp:206
virtual WDF_DEVICE_PNP_STATE PnpEventCheckForDevicePresenceOverload(VOID)
Definition: fxpkgpdo.cpp:1155
BOOLEAN m_EnableWakeAtBusInvoked
Definition: fxpkgpdo.hpp:141
virtual VOID PowerDisableWakeAtBusOverload(VOID)
Definition: pdopower.cpp:374
static _Must_inspect_result_ NTSTATUS _PnpQueryId(__inout FxPkgPnp *This, __inout FxIrp *Irp)
Definition: fxpkgpdo.cpp:1359
virtual VOID QueryForReenumerationInterface(VOID)
Definition: fxpkgpdo.hpp:522
VOID RegisterCallbacks(__in PWDF_PDO_EVENT_CALLBACKS DispatchTable)
Definition: fxpkgpdo.cpp:1576
NTSTATUS NTAPI CompleteRequest(IN PIRP Irp, IN NTSTATUS Status, IN ULONG_PTR Information)
Definition: dispatch.c:19
virtual const PFN_PNP_POWER_CALLBACK * GetDispatchPnp(VOID)
Definition: fxpkgpdo.hpp:560
VOID PowerNotifyParentChildWakeDisarmed(VOID)
Definition: pdopower.cpp:459
static _Must_inspect_result_ NTSTATUS _DispatchPowerSequence(__inout FxPkgPnp *This, __in FxIrp *Irp)
Definition: pdopower.cpp:39
static _Must_inspect_result_ NTSTATUS _PnpQueryInterface(IN FxPkgPnp *This, IN FxIrp *Irp)
Definition: fxpkgpdo.cpp:522
char * PBOOLEAN
Definition: retypes.h:11
BOOLEAN m_Static
Definition: fxpkgpdo.hpp:61
static const PFN_PNP_POWER_CALLBACK m_PdoPnpFunctionTable[IRP_MN_SURPRISE_REMOVAL+1]
Definition: fxpkgpdo.hpp:147
#define NTSTATUS
Definition: precomp.h:20
virtual VOID DeleteSymbolicLinkOverload(__in BOOLEAN GracefulRemove)
Definition: fxpkgpdo.cpp:1630
#define __inout
Definition: dbghelp.h:50
FxPnpDeviceSetLock m_DeviceSetLock
Definition: fxpkgpdo.hpp:51
#define _Must_inspect_result_
Definition: ms_sal.h:558
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
FxPnpDeviceResourceRequirementsQuery m_DeviceResourceRequirementsQuery
Definition: fxpkgpdo.hpp:49
* PDEVICE_CAPABILITIES
Definition: iotypes.h:965
static _Must_inspect_result_ NTSTATUS _PnpQueryResources(__inout FxPkgPnp *This, __inout FxIrp *Irp)
Definition: fxpkgpdokm.cpp:39
_Must_inspect_result_ NTSTATUS PnpQueryResourceRequirements(__inout FxIrp *Irp)
Definition: fxpkgpdokm.cpp:141
static _Must_inspect_result_ NTSTATUS _DispatchSetPower(__inout FxPkgPnp *This, __in FxIrp *Irp)
Definition: pdopower.cpp:63
virtual VOID FinishInitialize(__in PWDFDEVICE_INIT DeviceInit)
Definition: fxpkgpdo.cpp:340
virtual _Must_inspect_result_ NTSTATUS ProcessRemoveDeviceOverload(__inout FxIrp *Irp)
Definition: fxpkgpdo.cpp:1753
static VOID STDCALL _QueryCapsWorkItem(__in MdDeviceObject DeviceObject, __in PVOID Context)
Definition: fxpkgpdo.cpp:779
_Must_inspect_result_ NTSTATUS AddEjectionDevice(__in MdDeviceObject DependentDevice)
Definition: fxpkgpdo.cpp:1826
virtual _Must_inspect_result_ NTSTATUS AskParentToRemoveAndReenumerate(VOID)
Definition: fxpkgpdo.cpp:1598
_Must_inspect_result_ NTSTATUS(* PFN_PNP_POWER_CALLBACK)(__inout FxPkgPnp *This, __inout FxIrp *Irp)
Definition: fxpkgpnp.hpp:225
FxPowerDeviceEnableWakeAtBus m_DeviceEnableWakeAtBus
Definition: fxpkgpdo.hpp:53
FxDeviceDescriptionEntry * m_Description
Definition: fxpkgpdo.hpp:40
PWSTR m_IDsAllocation
Definition: fxpkgpdo.hpp:111
virtual _Must_inspect_result_ NTSTATUS PowerEnableWakeAtBusOverload(VOID)
Definition: pdopower.cpp:332
static _Must_inspect_result_ NTSTATUS _PnpQueryDeviceRelations(__in FxPkgPnp *This, __inout FxIrp *Irp)
Definition: fxpkgpdo.cpp:424
FxPowerDeviceDisableWakeAtBus m_DeviceDisableWakeAtBus
Definition: fxpkgpdo.hpp:54
virtual WDF_DEVICE_PNP_STATE PnpGetPostRemoveState(VOID)
Definition: fxpkgpdo.cpp:1258
virtual BOOLEAN PnpSendStartDeviceDownTheStackOverload(VOID)
Definition: fxpkgpdo.cpp:1294
virtual _Must_inspect_result_ NTSTATUS FireAndForgetIrp(__inout FxIrp *Irp)
Definition: fxpkgpdo.cpp:384
MxEvent * m_DeviceEjectProcessed
Definition: fxpkgpdo.hpp:121
static _Must_inspect_result_ NTSTATUS _DispatchQueryPower(__inout FxPkgPnp *This, __in FxIrp *Irp)
Definition: pdopower.cpp:201
_In_ PWDFDEVICE_INIT DeviceInit
Definition: wdfcontrol.h:113
VOID RemoveEjectionDevice(__in MdDeviceObject DependentDevice)
Definition: fxpkgpdo.cpp:1890
enum _WDF_DEVICE_POWER_STATE WDF_DEVICE_POWER_STATE
static _Must_inspect_result_ NTSTATUS _PnpQueryDeviceText(__inout FxPkgPnp *This, __inout FxIrp *Irp)
Definition: fxpkgpdo.cpp:858
static _Must_inspect_result_ NTSTATUS _PnpSurpriseRemoval(__inout FxPkgPnp *This, __inout FxIrp *Irp)
Definition: fxpkgpdo.cpp:1561
static _Must_inspect_result_ NTSTATUS _PnpQueryCapabilities(__inout FxPkgPnp *This, __inout FxIrp *Irp)
Definition: fxpkgpdo.cpp:551
_In_ PWDFDEVICE_INIT _In_ PWDF_PDO_EVENT_CALLBACKS DispatchTable
Definition: wdfpdo.h:245
#define __in
Definition: dbghelp.h:35
static _Must_inspect_result_ NTSTATUS _PnpCompleteIrp(__in FxPkgPnp *This, __inout FxIrp *Irp)
Definition: fxpkgpdo.cpp:414
FxRelatedDeviceList * m_EjectionDeviceList
Definition: fxpkgpdo.hpp:113
virtual WDF_DEVICE_POWER_STATE PowerCheckDeviceTypeOverload(VOID)
Definition: pdopower.cpp:289
SINGLE_LIST_ENTRY m_DeviceTextHead
Definition: fxpkgpdo.hpp:37
virtual _Must_inspect_result_ NTSTATUS SendIrpSynchronously(__in FxIrp *Irp)
Definition: fxpkgpdo.cpp:361
_Must_inspect_result_ NTSTATUS DispatchDeviceSetPower(__in FxIrp *Irp)
Definition: pdopower.cpp:151
virtual VOID PowerParentPowerDereference(VOID)
Definition: pdopower.cpp:403
static _Must_inspect_result_ NTSTATUS _PnpQueryResourceRequirements(__inout FxPkgPnp *This, __inout FxIrp *Irp)
Definition: fxpkgpdokm.cpp:131
#define DO_NOTHING()
Definition: mxgeneral.h:32