-}
-
-static thread_call_t calend_wakeup_call;
-static thread_call_data_t calend_wakeup_call_data;
-
-static void
-calend_wakeup_resynch(
- thread_call_param_t p0,
- thread_call_param_t p1)
-{
- long seconds = PEGetGMTTimeOfDay();
- spl_t s;
-
- LOCK_RTC(s);
- calend_setup_internal(seconds);
- UNLOCK_RTC(s);
-}
-
-static IOReturn
-calend_sleep_wake_notif(
- void *target,
- void *refCon,
- UInt32 messageType,
- void *provider,
- void *messageArg,
- vm_size_t argSize)
-{
- if (messageType != kIOMessageSystemHasPoweredOn)
- return (kIOReturnUnsupported);
-
- if (calend_wakeup_call != NULL)
- thread_call_enter(calend_wakeup_call);
-
- return (kIOReturnSuccess);
-}
-
-void
-clock_initialize_calendar(void)
-{
- long seconds;
- spl_t s;
-
- thread_call_setup(&calend_wakeup_call_data, calend_wakeup_resynch, NULL);
- calend_wakeup_call = &calend_wakeup_call_data;
-
- registerSleepWakeInterest(calend_sleep_wake_notif, NULL, NULL);
-
- seconds = PEGetGMTTimeOfDay();
-
- LOCK_RTC(s);
- if (!rtclock.calend_is_set)
- calend_setup_internal(seconds);