+ OSMemberFunctionCast(IOWorkLoop::Action, this,
+ &IOPMrootDomain::setClamShellSleepDisable),
+ (OSObject *) this,
+ (void *) disable, (void *)(uintptr_t) bitmask);
+ return;
+ }
+
+ oldMask = clamshellSleepDisableMask;
+ if (disable) {
+ clamshellSleepDisableMask |= bitmask;
+ } else {
+ clamshellSleepDisableMask &= ~bitmask;
+ }
+ DLOG("setClamShellSleepDisable(%x->%x)\n", oldMask, clamshellSleepDisableMask);
+
+ if (clamshellExists && clamshellClosed &&
+ (clamshellSleepDisableMask != oldMask) &&
+ (clamshellSleepDisableMask == 0)) {
+ handlePowerNotification(kLocalEvalClamshellCommand);
+ }
+}
+
+//******************************************************************************
+// wakeFromDoze
+//
+// Deprecated.
+//******************************************************************************
+
+void
+IOPMrootDomain::wakeFromDoze( void )
+{
+ // Preserve symbol for familes (IOUSBFamily and IOGraphics)
+}
+
+//******************************************************************************
+// recordRTCAlarm
+//
+// Record the earliest scheduled RTC alarm to determine whether a RTC wake
+// should be a dark wake or a full wake. Both Maintenance and SleepService
+// alarms are dark wake, while AutoWake (WakeByCalendarDate) and DebugWake
+// (WakeRelativeToSleep) should trigger a full wake. Scheduled power-on
+// PMSettings are ignored.
+//
+// Caller serialized using settingsCtrlLock.
+//******************************************************************************
+
+void
+IOPMrootDomain::recordRTCAlarm(
+ const OSSymbol *type,
+ OSObject *object )
+{
+ uint32_t previousAlarmMask = _scheduledAlarmMask;
+
+ if (type == gIOPMSettingDebugWakeRelativeKey) {
+ OSNumber * n = OSDynamicCast(OSNumber, object);
+ if (n) {
+ // Debug wake has highest scheduling priority so it overrides any
+ // pre-existing alarm.
+ uint32_t debugSecs = n->unsigned32BitValue();
+ _nextScheduledAlarmType.reset(type, OSRetain);
+ _nextScheduledAlarmUTC = debugSecs;
+
+ _debugWakeSeconds = debugSecs;
+ OSBitOrAtomic(kIOPMAlarmBitDebugWake, &_scheduledAlarmMask);
+ DLOG("next alarm (%s) in %u secs\n",
+ type->getCStringNoCopy(), debugSecs);
+ }
+ } else if ((type == gIOPMSettingAutoWakeCalendarKey.get()) ||
+ (type == gIOPMSettingMaintenanceWakeCalendarKey.get()) ||
+ (type == gIOPMSettingSleepServiceWakeCalendarKey.get())) {
+ OSData * data = OSDynamicCast(OSData, object);
+ if (data && (data->getLength() == sizeof(IOPMCalendarStruct))) {
+ const IOPMCalendarStruct * cs;
+ bool replaceNextAlarm = false;
+ clock_sec_t secs;
+
+ cs = (const IOPMCalendarStruct *) data->getBytesNoCopy();
+ secs = IOPMConvertCalendarToSeconds(cs);
+ DLOG("%s " YMDTF "\n", type->getCStringNoCopy(), YMDT(cs));
+
+ // Update the next scheduled alarm type
+ if ((_nextScheduledAlarmType == NULL) ||
+ ((_nextScheduledAlarmType != gIOPMSettingDebugWakeRelativeKey) &&
+ (secs < _nextScheduledAlarmUTC))) {
+ replaceNextAlarm = true;
+ }
+
+ if (type == gIOPMSettingAutoWakeCalendarKey.get()) {
+ if (cs->year) {
+ _calendarWakeAlarmUTC = IOPMConvertCalendarToSeconds(cs);
+ OSBitOrAtomic(kIOPMAlarmBitCalendarWake, &_scheduledAlarmMask);
+ } else {
+ // TODO: can this else-block be removed?
+ _calendarWakeAlarmUTC = 0;
+ OSBitAndAtomic(~kIOPMAlarmBitCalendarWake, &_scheduledAlarmMask);
+ }
+ }
+ if (type == gIOPMSettingMaintenanceWakeCalendarKey.get()) {
+ OSBitOrAtomic(kIOPMAlarmBitMaintenanceWake, &_scheduledAlarmMask);
+ }
+ if (type == gIOPMSettingSleepServiceWakeCalendarKey.get()) {
+ OSBitOrAtomic(kIOPMAlarmBitSleepServiceWake, &_scheduledAlarmMask);
+ }