#else
LOG("System Sleep\n");
#endif
-
+ if (thermalWarningState) {
+ const OSSymbol *event = OSSymbol::withCString(kIOPMThermalLevelWarningKey);
+ if (event) {
+ systemPowerEventOccurred(event, kIOPMThermalLevelUnknown);
+ event->release();
+ }
+ }
((IOService *)this)->stop_watchdog_timer(); //14456299
getPlatform()->sleepKernel();
userWasActive = false;
fullWakeReason = kFullWakeReasonNone;
+
OSString * wakeType = OSDynamicCast(
OSString, getProperty(kIOPMRootDomainWakeTypeKey));
OSString * wakeReason = OSDynamicCast(
currentFactors |= kIOPMSleepFactorLocalUserActivity;
if (darkWakeHibernateError && !CAP_HIGHEST(kIOPMSystemCapabilityGraphics))
currentFactors |= kIOPMSleepFactorHibernateFailed;
+ if (thermalWarningState)
+ currentFactors |= kIOPMSleepFactorThermalWarning;
DLOG("sleep factors 0x%llx\n", currentFactors);
{
obj = copyProperty(key);
}
- if (obj && (num = OSDynamicCast(OSNumber, obj)))
+ if (obj)
{
- *option = num->unsigned32BitValue();
- ok = true;
+ if ((num = OSDynamicCast(OSNumber, obj)))
+ {
+ *option = num->unsigned32BitValue();
+ ok = true;
+ }
+ else if (OSDynamicCast(OSBoolean, obj))
+ {
+ *option = (obj == kOSBooleanTrue) ? 1 : 0;
+ ok = true;
+ }
}
if (obj)
break;
#endif
- if (lowBatteryCondition)
+ if (lowBatteryCondition || thermalWarningState)
{
- break; // always sleep on low battery
+ break; // always sleep on low battery or when in thermal warning state
}
if (sleepReason == kIOPMSleepReasonDarkWakeThermalEmergency)
bool IOPMrootDomain::checkSystemCanSustainFullWake( void )
{
#if !NO_KERNEL_HID
- if (lowBatteryCondition)
+ if (lowBatteryCondition || thermalWarningState)
{
// Low battery wake, or received a low battery notification
// while system is awake. This condition will persist until
return attempt;
}
+void IOPMrootDomain::setThermalState(OSObject *value)
+{
+ OSNumber * num;
+
+ if (gIOPMWorkLoop->inGate() == false) {
+ gIOPMWorkLoop->runAction(
+ OSMemberFunctionCast(IOWorkLoop::Action, this, &IOPMrootDomain::setThermalState),
+ (OSObject *)this,
+ (void *)value);
+
+ return;
+ }
+ if (value && (num = OSDynamicCast(OSNumber, value))) {
+ thermalWarningState = ((num->unsigned32BitValue() == kIOPMThermalLevelWarning) ||
+ (num->unsigned32BitValue() == kIOPMThermalLevelTrap)) ? 1 : 0;
+ }
+}
+
IOReturn IOPMrootDomain::systemPowerEventOccurred(
const OSSymbol *event,
OSObject *value)
// UNLOCK
if (featuresDictLock) IOLockUnlock(featuresDictLock);
- if (shouldUpdate)
+ if (shouldUpdate) {
+ if (event &&
+ event->isEqualTo(kIOPMThermalLevelWarningKey)) {
+ setThermalState(value);
+ }
messageClients (kIOPMMessageSystemPowerEventOccurred, (void *)NULL);
+ }
return kIOReturnSuccess;
}