ReactOS  0.4.15-dev-3440-g915569a
fxpkgfdoum.cpp
Go to the documentation of this file.
1 /*++
2 
3 Copyright (c) Microsoft Corporation
4 
5 Module Name:
6 
7  FxPkgFdoUm.cpp
8 
9 Abstract:
10 
11  This module implements the pnp/power package for the driver
12  framework.
13 
14 Author:
15 
16 
17 
18 
19 Environment:
20 
21  User mode only
22 
23 Revision History:
24 
25 
26 
27 --*/
28 
29 #include "../pnppriv.hpp"
30 
31 #include <initguid.h>
32 #include <wdmguid.h>
33 
34 
35 #if defined(EVENT_TRACING)
36 // Tracing support
37 extern "C" {
38 #include "FxPkgFdoUm.tmh"
39 }
40 #endif
41 
46  )
47 
48 /*++
49 
50 Routine Description:
51 
52  This method is invoked in response to a Pnp FilterResourceRequirements IRP.
53 
54 Arguments:
55 
56  Device - a pointer to the FxDevice
57 
58  Irp - a pointer to the FxIrp
59 
60 Returns:
61 
62  NTSTATUS
63 
64 --*/
65 
66 {
68  ASSERTMSG("Not implemented for UMDF\n", FALSE);
69 
71 }
72 
77  )
78 
79 /*++
80 
81 Routine Description:
82 
83  This method is invoked in response to a Pnp QueryCapabilities IRP.
84 
85 Arguments:
86 
87  Device - a pointer to the FxDevice
88 
89  Irp - a pointer to the FxIrp
90 
91 Returns:
92 
93  NTSTATUS
94 
95 --*/
96 
97 {
99 
100  //
101  // Set a completion routine on the IRP
102  //
103  Irp->CopyCurrentIrpStackLocationToNext();
104  Irp->SetCompletionRoutine(
106  this
107  );
108 
109  //
110  // Send the IRP down the stack
111  //
112  Irp->CallDriver(m_Device->GetAttachedDevice());
113 
114  return STATUS_SUCCESS;
115 }
116 
118 NTSTATUS
121  __inout MdIrp Irp,
123  )
124 {
126  FxPkgFdo* pThis;
127  FxIrp irp(Irp);
128 
130 
131  pThis = (FxPkgFdo*) Context;
132  status = irp.GetStatus();
133 
134  //
135  // Now that the IRP has returned to us, we modify what the bus driver
136  // set up.
137  //
138  if (NT_SUCCESS(status)) {
140  }
141 
142  pThis->CompletePnpRequest(&irp, status);
143 
145 }
146 
148 NTSTATUS
151  __inout FxIrp *Irp
152  )
153 
154 /*++
155 
156 Routine Description:
157 
158  This method is invoked in response to a Pnp QueryPnpDeviceState IRP.
159 
160 Arguments:
161 
162  Irp - a pointer to the FxIrp
163 
164 Returns:
165 
166  NTSTATUS
167 
168 --*/
169 
170 {
171  FxPkgFdo* pThis;
172 
173  pThis = (FxPkgFdo*) This;
174 
175  //
176  // Set a completion routine on the IRP
177  //
178  Irp->CopyCurrentIrpStackLocationToNext();
179  Irp->SetCompletionRoutine(
181  pThis
182  );
183 
184  //
185  // Send the IRP down the stack
186  //
187  Irp->CallDriver(pThis->m_Device->GetAttachedDevice());
188 
189  return STATUS_SUCCESS;
190 }
191 
193 NTSTATUS
196  __inout MdIrp Irp,
198  )
199 {
201  FxPkgFdo* pThis;
202  FxIrp irp(Irp);
203 
205 
206  pThis = (FxPkgFdo*) Context;
207  status = irp.GetStatus();
208 
209  if (status == STATUS_NOT_SUPPORTED) {
210  //
211  // Morph into a successful code so that we process the request
212  //
215  }
216 
217  if (NT_SUCCESS(status)) {
219  }
220  else {
223  "Lower stack returned error for query pnp device state, %!STATUS!",
224  status);
225  }
226 
227  //
228  // Since we already sent the request down the stack, we must complete it
229  // now.
230  //
231  pThis->CompletePnpRequest(&irp, status);
232 
234 }
235 
237 NTSTATUS
240  )
241 /*++
242 
243 
244 
245 
246 
247 
248 
249 
250 
251 
252 
253 Routine Description:
254 
255  After creating a FxPkgFdo, the driver writer will initialize it by passing
256  a set of driver callbacks that allow the driver writer to customize the
257  behavior when handling certain IRPs.
258 
259  This is the place to do any initialization that might fail.
260 
261 Arguments:
262 
263  Device - a pointer to the FxDevice
264 
265  DispatchTable - a driver supplied table of callbacks
266 
267 Returns:
268 
269  NTSTATUS
270 
271 --*/
272 {
275 
277 
279  if (!NT_SUCCESS(status)) {
280  return status;
281  }
282 
284  if (!NT_SUCCESS(status)) {
285  return status;
286  }
287 
288  return status;
289 }
290 
292 NTSTATUS
294  VOID
295  )
296 /*++
297 
298 Routine Description:
299  This routine asks the PDO to ask its parent bus driver to Surprise-Remove
300  and re-enumerate the PDO. This will be done only at the point of
301  catastrophic software failure, and occasionally after catastrophic hardware
302  failure.
303 
304 Arguments:
305  None
306 
307 Return Value:
308  status
309 
310  --*/
311 {
312  HRESULT hr;
313  IWudfDeviceStack2* pDevStack = m_Device->GetDeviceStack2();
314 
315  hr = pDevStack->ReenumerateSelf();
316  if (SUCCEEDED(hr)) {
317  return STATUS_SUCCESS;
318  }
319 
320  return STATUS_NOT_SUPPORTED;
321 }
322 
CfxDevice * m_Device
Definition: fxobject.hpp:329
VOID HandleQueryCapabilitiesCompletion(__inout FxIrp *Irp)
Definition: fxpkgfdo.cpp:613
virtual _Must_inspect_result_ NTSTATUS AskParentToRemoveAndReenumerate(VOID)
Definition: fxpkgfdokm.cpp:567
return STATUS_NOT_SUPPORTED
static _Must_inspect_result_ NTSTATUS _PnpQueryCapabilitiesCompletionRoutine(__in MdDeviceObject DeviceObject, __inout MdIrp Irp, __inout PVOID Context)
Definition: fxpkgfdokm.cpp:227
HRESULT hr
Definition: shlfolder.c:183
VOID SetStatus(__in NTSTATUS Status)
Definition: fxirpum.cpp:457
#define STATUS_MORE_PROCESSING_REQUIRED
Definition: shellext.h:68
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
LONG NTSTATUS
Definition: precomp.h:26
Definition: fxirp.hpp:28
VOID HandleQueryPnpDeviceStateCompletion(__inout FxIrp *Irp)
Definition: fxpkgfdo.cpp:763
virtual _Must_inspect_result_ NTSTATUS Initialize(__in PWDFDEVICE_INIT DeviceInit)
Definition: fxpkgpnp.cpp:349
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
return STATUS_NOT_IMPLEMENTED
#define FALSE
Definition: types.h:117
_Must_inspect_result_ NTSTATUS PnpFilterResourceRequirements(__inout FxIrp *Irp)
Definition: fxpkgfdokm.cpp:43
_In_ PIRP Irp
Definition: csq.h:116
IWudfDeviceStack2 * GetDeviceStack2(VOID)
Definition: fxdeviceum.hpp:444
#define ASSERTMSG(msg, exp)
Definition: nt_native.h:431
if SUCCEEDED(hr)
MdDeviceObject __inline GetAttachedDevice(VOID)
Definition: fxdevice.hpp:210
IWudfIrp * MdIrp
Definition: mxum.h:103
_Must_inspect_result_ NTSTATUS PnpQueryCapabilities(__inout FxIrp *Irp)
Definition: fxpkgfdokm.cpp:244
IWudfDeviceStack * pDevStack
_Must_inspect_result_ NTSTATUS AllocateEnumInfo(VOID)
Definition: fxpkgpnp.cpp:4920
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
LONG HRESULT
Definition: typedefs.h:79
VOID HandleQueryCapabilities(__inout FxIrp *Irp)
Definition: fxpkgfdo.cpp:572
#define __inout
Definition: dbghelp.h:50
#define _Must_inspect_result_
Definition: ms_sal.h:558
PFX_DRIVER_GLOBALS pGlobals
virtual _Must_inspect_result_ NTSTATUS Initialize(__in PWDFDEVICE_INIT DeviceInit)
Definition: fxpkgfdokm.cpp:361
static _Must_inspect_result_ NTSTATUS _PnpQueryPnpDeviceState(__inout FxPkgPnp *This, __inout FxIrp *Irp)
Definition: fxpkgfdokm.cpp:305
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
#define TRACINGPNP
Definition: dbgtrace.h:67
static _Must_inspect_result_ NTSTATUS _PnpQueryPnpDeviceStateCompletionRoutine(__in MdDeviceObject DeviceObject, __inout MdIrp Irp, __inout PVOID Context)
Definition: fxpkgfdokm.cpp:288
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
_In_ PWDFDEVICE_INIT DeviceInit
Definition: wdfcontrol.h:113
#define STATUS_SUCCESS
Definition: shellext.h:65
#define __in
Definition: dbghelp.h:35
static SERVICE_STATUS status
Definition: service.c:31
FxIrp * irp
NTSTATUS CompletePnpRequest(__inout FxIrp *Irp, __in NTSTATUS Status)
Definition: fxpkgpnp.cpp:5752
NTSTATUS GetStatus()
Definition: fxirpum.cpp:466
Definition: ps.c:97