/*
- * Copyright (c) 2000-2007 Apple Inc. All rights reserved.
+ * Copyright (c) 2000-2008 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
#include <mach/mach_types.h>
+#include <kern/timer_queue.h>
#include <kern/clock.h>
#include <kern/thread.h>
#include <kern/processor.h>
#include <i386/cpu_topology.h>
#include <i386/cpu_threads.h>
-/* XXX from <arch>/rtclock.c */
-clock_timer_func_t rtclock_timer_expire;
-
/*
* Event timer interrupt.
*
/* has a pending clock timer expired? */
if (mytimer->deadline <= abstime) { /* Have we expired the deadline? */
mytimer->has_expired = TRUE; /* Remember that we popped */
- mytimer->deadline = EndOfAllTime; /* Set timer request to the end of all time in case we have no more events */
- (*rtclock_timer_expire)(abstime); /* Process pop */
+ mytimer->deadline = timer_queue_expire(&mytimer->queue, abstime);
mytimer->has_expired = FALSE;
}
}
/*
- * Set the clock deadline; called by the thread scheduler.
+ * Set the clock deadline.
*/
void etimer_set_deadline(uint64_t deadline)
{
}
splx(s);
}
+
+void etimer_timer_expire(void *arg);
+
+void
+etimer_timer_expire(
+__unused void *arg)
+{
+ rtclock_timer_t *mytimer;
+ uint64_t abstime;
+ cpu_data_t *pp;
+ x86_lcpu_t *lcpu;
+
+ pp = current_cpu_datap();
+ lcpu = x86_lcpu();
+
+ mytimer = &pp->rtclock_timer;
+ abstime = mach_absolute_time();
+
+ mytimer->has_expired = TRUE;
+ mytimer->deadline = timer_queue_expire(&mytimer->queue, abstime);
+ mytimer->has_expired = FALSE;
+
+ lcpu->rtcPop = EndOfAllTime;
+ etimer_resync_deadlines();
+}
+
+queue_t
+timer_queue_assign(
+ uint64_t deadline)
+{
+ cpu_data_t *cdp = current_cpu_datap();
+ rtclock_timer_t *timer;
+
+ if (cdp->cpu_running) {
+ timer = &cdp->rtclock_timer;
+
+ if (deadline < timer->deadline)
+ etimer_set_deadline(deadline);
+ }
+ else
+ timer = &cpu_datap(master_cpu)->rtclock_timer;
+
+ return (&timer->queue);
+}
+
+void
+timer_queue_cancel(
+ queue_t queue,
+ uint64_t deadline,
+ uint64_t new_deadline)
+{
+ if (queue == ¤t_cpu_datap()->rtclock_timer.queue) {
+ if (deadline < new_deadline)
+ etimer_set_deadline(new_deadline);
+ }
+}