1 // 2 // Copyright (C) Microsoft. All rights reserved. 3 // 4 #ifndef _FXPOXINTERFACE_H_ 5 #define _FXPOXINTERFACE_H_ 6 7 #include "fxdevicepwrreqstatemachine.hpp" 8 9 class FxPoxInterface { 10 11 friend class FxDevicePwrRequirementMachine; 12 13 public: 14 FxPoxInterface( 15 __in FxPkgPnp* PkgPnp 16 ); 17 18 ~FxPoxInterface( 19 VOID 20 ); 21 22 NTSTATUS 23 CreateDevicePowerRequirementMachine( 24 VOID 25 ); 26 27 NTSTATUS 28 NotifyDevicePowerDown( 29 VOID 30 ); 31 32 33 VOID 34 DeviceIsPoweredOn( 35 VOID 36 ); 37 38 FxPkgPnp* 39 PkgPnp( 40 VOID 41 ) 42 { 43 return m_PkgPnp; 44 } 45 46 POHANDLE 47 GetPoHandle( 48 VOID 49 ) 50 { 51 return m_PoHandle; 52 } 53 54 NTSTATUS 55 InitializeComponents( 56 VOID 57 ); 58 59 VOID 60 UninitializeComponents( 61 VOID 62 ); 63 64 VOID 65 RequestComponentActive( 66 VOID 67 ); 68 69 BOOLEAN 70 DeclareComponentIdle( 71 VOID 72 ); 73 74 VOID 75 UpdateIdleTimeoutHint( 76 VOID 77 ); 78 79 VOID 80 SimulateDevicePowerRequired( 81 VOID 82 ); 83 84 VOID 85 SimulateDevicePowerNotRequired( 86 VOID 87 ); 88 89 VOID 90 PoxReportDevicePoweredOn( 91 VOID 92 ); 93 94 VOID 95 PowerRequiredCallbackInvoked( 96 VOID 97 ); 98 99 VOID 100 PowerNotRequiredCallbackInvoked( 101 VOID 102 ); 103 104 private: 105 106 NTSTATUS 107 PoxRegisterDevice( 108 VOID 109 ); 110 111 VOID 112 DprProcessEventFromPoxCallback( 113 __in FxDevicePwrRequirementEvents Event 114 ); 115 116 struct _POX_SETTINGS * 117 GetPowerFrameworkSettings( 118 VOID 119 ); 120 121 VOID 122 PowerRequiredCallbackWorker( 123 __in BOOLEAN InvokedFromPoxCallback 124 ); 125 126 VOID 127 PowerNotRequiredCallbackWorker( 128 __in BOOLEAN InvokedFromPoxCallback 129 ); 130 131 VOID 132 PoxStartDevicePowerManagement( 133 VOID 134 ); 135 136 137 VOID 138 PoxUnregisterDevice( 139 VOID 140 ); 141 142 VOID 143 PoxActivateComponent( 144 VOID 145 ); 146 147 VOID 148 PoxIdleComponent( 149 VOID 150 ); 151 152 VOID 153 PoxSetDeviceIdleTimeout( 154 __in ULONGLONG IdleTimeout 155 ); 156 157 static PO_FX_COMPONENT_IDLE_STATE_CALLBACK StateCallback; 158 static PO_FX_COMPONENT_ACTIVE_CONDITION_CALLBACK ComponentActiveCallback; 159 static PO_FX_COMPONENT_IDLE_CONDITION_CALLBACK ComponentIdleCallback; 160 static PO_FX_DEVICE_POWER_REQUIRED_CALLBACK PowerRequiredCallback; 161 static PO_FX_DEVICE_POWER_NOT_REQUIRED_CALLBACK PowerNotRequiredCallback; 162 static PO_FX_POWER_CONTROL_CALLBACK PowerControlCallback; 163 164 public: 165 // 166 // Device power requirement state machine 167 // 168 FxDevicePwrRequirementMachine * m_DevicePowerRequirementMachine; 169 170 // 171 // Idle timeout hint to be provided to power framework at the next 172 // opportunity, i.e. a pending update to the idle timeout hint. 173 // 174 ULONG m_NextIdleTimeoutHint; 175 176 private: 177 FxPkgPnp* m_PkgPnp; 178 179 // 180 // Handle obtained upon registration with power manager 181 // 182 POHANDLE m_PoHandle; 183 184 // 185 // Variable that tracks whether device power is required and the lock that 186 // protects this variable 187 // 188 BOOLEAN m_DevicePowerRequired; 189 MxLock m_DevicePowerRequiredLock; 190 191 // 192 // Idle timeout hint currently provided to power framework. 193 // 194 ULONG m_CurrentIdleTimeoutHint; 195 }; 196 197 #endif // _FXPOXINTERFACE_H_ 198