1 /*++
2 
3 Copyright (c) Microsoft Corporation
4 
5 Module Name:
6 
7     supportUM.cpp
8 
9 Abstract:
10 
11     This module implements the pnp support routines.
12 
13 Author:
14 
15 
16 Environment:
17 
18     User mode only
19 
20 Revision History:
21 
22 --*/
23 
24 #include "../pnppriv.hpp"
25 
26 VOID
27 CopyQueryInterfaceToIrpStack(
28     __in PPOWER_THREAD_INTERFACE PowerThreadInterface,
29     __in FxIrp* Irp
30     )
31 {
32     UNREFERENCED_PARAMETER(PowerThreadInterface);
33     UNREFERENCED_PARAMETER(Irp);
34 
35     ASSERTMSG("Not implemented for UMDF\n", FALSE);
36 }
37 
38 _Must_inspect_result_
39 NTSTATUS
40 GetStackCapabilities(
41     __in PFX_DRIVER_GLOBALS DriverGlobals,
42     __in MxDeviceObject* DeviceInStack,
43     __in_opt PD3COLD_SUPPORT_INTERFACE D3ColdInterface,
44     __out PSTACK_DEVICE_CAPABILITIES Capabilities
45     )
46 {
47     HRESULT hr;
48     NTSTATUS status;
49     MdDeviceObject deviceObject;
50     IWudfDeviceStack* deviceStack;
51 
52     UNREFERENCED_PARAMETER(DriverGlobals);
53     UNREFERENCED_PARAMETER(D3ColdInterface);
54 
55     deviceObject = DeviceInStack->GetObject();
56     deviceStack = deviceObject->GetDeviceStackInterface();
57 
58     hr = deviceStack->GetStackCapabilities(Capabilities);
59 
60     if (S_OK == hr) {
61         status = STATUS_SUCCESS;
62     }
63     else {
64         PUMDF_VERSION_DATA driverVersion = deviceStack->GetMinDriverVersion();
65         BOOL preserveCompat =
66              deviceStack->ShouldPreserveIrpCompletionStatusCompatibility();
67 
68         status = CHostFxUtil::NtStatusFromHr(hr,
69                                              driverVersion->MajorNumber,
70                                              driverVersion->MinorNumber,
71                                              preserveCompat);
72     }
73 
74     return status;
75 }
76 
77 VOID
78 SetD3ColdSupport(
79     __in PFX_DRIVER_GLOBALS DriverGlobals,
80     __in MxDeviceObject* DeviceInStack,
81     __in PD3COLD_SUPPORT_INTERFACE D3ColdInterface,
82     __in BOOLEAN UseD3Cold
83     )
84 {
85     MdDeviceObject deviceObject;
86     IWudfDeviceStack* deviceStack;
87 
88     UNREFERENCED_PARAMETER(DriverGlobals);
89     UNREFERENCED_PARAMETER(D3ColdInterface);
90 
91     deviceObject = DeviceInStack->GetObject();
92     deviceStack = deviceObject->GetDeviceStackInterface();
93 
94     deviceStack->SetD3ColdSupport(UseD3Cold);
95 }
96 
97 PVOID
98 GetIoMgrObjectForWorkItemAllocation(
99     VOID
100     )
101 /*++
102 Routine description:
103     Returns an IO manager object that can be passed in to IoAllocateWorkItem
104 
105 Arguments:
106     None
107 
108 Return value:
109     Pointer to the object that can be passed in to IoAllocateWorkItem
110 --*/
111 {
112     //
113     // In user-mode we don't need an IO manager object for work item allocation
114     // so we return NULL.
115     //
116     return NULL;
117 }
118 
119 BOOLEAN
120 IdleTimeoutManagement::_SystemManagedIdleTimeoutAvailable(
121     VOID
122     )
123 {
124 
125     return TRUE;
126 }
127 
128 _Must_inspect_result_
129 NTSTATUS
130 SendDeviceUsageNotification(
131     __in MxDeviceObject* RelatedDevice,
132     __inout FxIrp* RelatedIrp,
133     __in MxWorkItem* Workitem,
134     __in FxIrp* OriginalIrp,
135     __in BOOLEAN Revert
136     )
137 {
138     UNREFERENCED_PARAMETER(RelatedDevice);
139     UNREFERENCED_PARAMETER(RelatedIrp);
140     UNREFERENCED_PARAMETER(Workitem);
141     UNREFERENCED_PARAMETER(OriginalIrp);
142     UNREFERENCED_PARAMETER(Revert);
143 
144     ASSERTMSG("Not implemented for UMDF\n", FALSE);
145 
146     return STATUS_NOT_IMPLEMENTED;
147 }
148 
149 
150