1 //
2 //    Copyright (C) Microsoft.  All rights reserved.
3 //
4 #include "../pnppriv.hpp"
5 
6 #include <initguid.h>
7 #include <wdmguid.h>
8 
9 extern "C" {
10 #if defined(EVENT_TRACING)
11 #include "PoxInterfaceUm.tmh"
12 #endif
13 }
14 
15 VOID
16 FxPoxInterface::PoxStartDevicePowerManagement(
17     )
18 {
19     m_PkgPnp->GetDevice()->GetDeviceStack2()->PoFxStartDevicePowerManagement();
20 
21     return;
22 }
23 
24 NTSTATUS
25 FxPoxInterface::PoxRegisterDevice(
26     )
27 {
28     HRESULT hr;
29 
30     hr = m_PkgPnp->GetDevice()->GetDeviceStack2()->PoFxRegisterDevice();
31 
32     if (S_OK == hr)
33     {
34         return STATUS_SUCCESS;
35     }
36     else
37     {
38         PUMDF_VERSION_DATA driverVersion = m_PkgPnp->GetDevice()->GetDeviceStack()->GetMinDriverVersion();
39 
40         return CHostFxUtil::NtStatusFromHr(
41                 hr,
42                 driverVersion->MajorNumber,
43                 driverVersion->MinorNumber,
44                 m_PkgPnp->GetDevice()->GetDeviceStack()->ShouldPreserveIrpCompletionStatusCompatibility()
45                 );
46     }
47 
48 }
49 
50 VOID
51 FxPoxInterface::PoxUnregisterDevice(
52     VOID
53     )
54 {
55     m_PkgPnp->GetDevice()->GetDeviceStack2()->PoFxUnregisterDevice();
56     return;
57 }
58 
59 VOID
60 FxPoxInterface::PoxActivateComponent(
61     VOID
62     )
63 {
64     m_PkgPnp->GetDevice()->GetDeviceStack2()->PoFxActivateComponent();
65     return;
66 }
67 
68 VOID
69 FxPoxInterface::PoxIdleComponent(
70     VOID
71     )
72 {
73     m_PkgPnp->GetDevice()->GetDeviceStack2()->PoFxIdleComponent();
74     return;
75 }
76 
77 VOID
78 FxPoxInterface::PoxReportDevicePoweredOn(
79     VOID
80     )
81 {
82     m_PkgPnp->GetDevice()->GetDeviceStack2()->PoFxReportDevicePoweredOn();
83     return;
84 }
85 
86 VOID
87 FxPoxInterface::PoxSetDeviceIdleTimeout(
88     __in ULONGLONG IdleTimeout
89     )
90 {
91     m_PkgPnp->GetDevice()->GetDeviceStack2()->PoFxSetDeviceIdleTimeout(IdleTimeout);
92     return;
93 }
94 
95 
96 VOID
97 FxPoxInterface::PowerRequiredCallbackInvoked(
98     VOID
99     )
100 {
101     PowerRequiredCallbackWorker(FALSE /* InvokedFromPoxCallback */);
102     return;
103 }
104 
105 VOID
106 FxPoxInterface::PowerNotRequiredCallbackInvoked(
107     VOID
108     )
109 {
110     //
111     // Notice that it is important that we first acknowledge the callback
112     // because once we queue an event in the state machine, the state machine
113     // could end up calling PoFxUnregister from the same thread
114     //
115     m_PkgPnp->GetDevice()->GetDeviceStack2()->PoFxCompleteDevicePowerNotRequired();
116 
117     //
118     // The contract with the reflector is that the reflector guarantees to
119     // not send this event from the PoFx callback
120     //
121     PowerNotRequiredCallbackWorker(FALSE /* InvokedFromPoxCallback */);
122 
123     return;
124 }
125 
126