PopCheckThermalPolicy
VOID __fastcall PopCheckThermalPolicy(
_POP_THERMAL_ZONE *ThermalZone,
UINT64 CurrentTime,
UINT8 *PassiveEngaged,
INT *ThrottleDelta){
DEVICE_OBJECT *DeviceAttachmentBaseRefWithTag;
unsigned int CriticalTripPoint;
unsigned __int8 v10;
unsigned int S4TransitionTripPoint;
bool v12;
unsigned int ThermalStandbyTripPoint;
__int64 i;
UINT64 SampleRate;
unsigned int CurrentTemperature;
unsigned int PassiveTripPoint;
UINT8 v18;
unsigned __int8 ThermalStandby;
unsigned int LastTemp;
int HighPrecisionThrottle;
unsigned int v22;
unsigned int MinimumThrottle;
int v24;
int v25;
unsigned int v26;
bool v27;
DeviceAttachmentBaseRefWithTag = IoGetDeviceAttachmentBaseRefWithTag(ThermalZone->PolicyDevice.Device, 0x6D546F50ui64);
ThermalZone->PollingRate = 1000000 * ThermalZone->Info.PollingPeriod;
CriticalTripPoint = ThermalZone->Info.CriticalTripPoint;
if( CriticalTripPoint && ThermalZone->Info.CurrentTemperature >= CriticalTripPoint )
{
PopPrintEx(
0i64,
(INT8 *)"Thermal Zone %S(%p): Above critical temperature(_TMP %d, _CRT %d). Shutdown initiated\n");
v10 = 1;
}
else
{
v10 = 0;
}
ThermalZone->Policy.Critical = v10;
S4TransitionTripPoint = ThermalZone->Info.S4TransitionTripPoint;
v12 = S4TransitionTripPoint && ThermalZone->Info.CurrentTemperature >= S4TransitionTripPoint;
ThermalZone->Policy.Hibernate = v12;
ThermalStandbyTripPoint = ThermalZone->Info.ThermalStandbyTripPoint;
if( ThermalStandbyTripPoint )
{
ThermalStandby = ThermalZone->Policy.ThermalStandby;
if( ThermalZone->Info.CurrentTemperature < ThermalStandbyTripPoint )
{
if( ThermalStandby )
ThermalZone->Policy.ThermalStandby = 0;
}
else if( !ThermalStandby )
{
ThermalZone->Policy.ThermalStandby = 1;
}
}
for( i = 0i64; (unsigned int)i < ThermalZone->Info.ActiveTripPointCount; i = (unsigned int)(i + 1) )
{
if( ThermalZone->Info.CurrentTemperature >= ThermalZone->Info.ActiveTripPoint[i] )
break;
}
SampleRate = ThermalZone->SampleRate;
ThermalZone->Policy.ActiveLevel = i;
if( CurrentTime - ThermalZone->LastPassiveTime < SampleRate )
{
*ThrottleDelta = 0;
v18 = ThermalZone->Flags & 1;
}
else
{
CurrentTemperature = ThermalZone->Info.CurrentTemperature;
if( ThermalZone->Throttle != 100
|| (PassiveTripPoint = ThermalZone->Info.PassiveTripPoint) != 0 && CurrentTemperature >= PassiveTripPoint )
{
if( (ThermalZone->Flags & 1) != 0 )
{
LastTemp = ThermalZone->LastTemp;
}
else
{
ThermalZone->SampleRate = 10000 * ThermalZone->Info.SamplingPeriod;
LastTemp = ThermalZone->Info.PassiveTripPoint;
}
HighPrecisionThrottle = ThermalZone->HighPrecisionThrottle;
v22 = ThermalZone->Info.ThermalConstant2 * (CurrentTemperature - ThermalZone->Info.PassiveTripPoint)
+ (CurrentTemperature - LastTemp) * ThermalZone->Info.ThermalConstant1;
if( CurrentTemperature == LastTemp || (((CurrentTemperature - LastTemp) ^ v22) & 0x80000000) == 0 )
HighPrecisionThrottle -= v22;
if( HighPrecisionThrottle > 1000 )
HighPrecisionThrottle = 1000;
MinimumThrottle = ThermalZone->Info.MinimumThrottle;
v24 = 0;
if( HighPrecisionThrottle >= 0 )
v24 = HighPrecisionThrottle;
v25 = 10 * MinimumThrottle;
if( v24 >= (int)(10 * MinimumThrottle) )
v25 = v24;
ThermalZone->HighPrecisionThrottle = v25;
v26 = (v25 + 5) / 10;
v27 = v26 < ThermalZone->Info.OverThrottleThreshold;
ThermalZone->Policy.PassiveLimit = v26;
ThermalZone->Policy.OverThrottled = v27;
v18 = 1;
*ThrottleDelta = 0;
ThermalZone->LastTemp = CurrentTemperature;
ThermalZone->LastPassiveTime = CurrentTime;
ThermalZone->Policy.ActivationReasons = 1;
}
else
{
*ThrottleDelta = 0;
ThermalZone->Policy.ActivationReasons = 0;
v18 = 0;
}
}
*PassiveEngaged = v18;
if( DeviceAttachmentBaseRefWithTag )
ObfDereferenceObjectWithTag(DeviceAttachmentBaseRefWithTag, 0x6D546F50ui64);
}Referenced by:
PopThermalWorker