/*
- * Copyright (c) 2000-2010 Apple Inc. All rights reserved.
+ * Copyright (c) 2000-2011 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* @OSF_COPYRIGHT@
*/
-#include <platforms.h>
-#include <mach_kdb.h>
#include <mach/mach_types.h>
#include <i386/tsc.h>
#include <i386/rtclock_protos.h>
#include <i386/pal_routines.h>
-#include <kern/etimer.h>
+#include <kern/timer_queue.h>
static uint64_t rtc_decrementer_min;
static uint64_t rtc_decrementer_max;
}
}
-static inline uint64_t
-_absolutetime_to_tsc(uint64_t ns)
-{
- uint32_t generation;
- uint64_t tsc;
-
- do {
- generation = pal_rtc_nanotime_info.generation;
- tsc = tmrCvt(ns - pal_rtc_nanotime_info.ns_base, tscFCvtn2t)
- + pal_rtc_nanotime_info.tsc_base;
- } while (generation == 0 ||
- generation != pal_rtc_nanotime_info.generation);
-
- return tsc;
-}
/*
* Regular local APIC timer case:
} else {
lapic_set_timer(FALSE, one_shot, divide_by_1, 0);
}
+
+ KERNEL_DEBUG_CONSTANT(
+ DECR_SET_APIC_DEADLINE | DBG_FUNC_NONE,
+ now, deadline,
+ set, LAPIC_READ(TIMER_CURRENT_COUNT),
+ 0);
+
return set;
}
static uint64_t
rtc_lapic_set_tsc_deadline_timer(uint64_t deadline, uint64_t now)
{
- uint64_t set = 0;
+ uint64_t delta;
+ uint64_t delta_tsc;
+ uint64_t tsc = rdtsc64();
+ uint64_t set = 0;
if (deadline > 0) {
/*
* Convert to TSC
*/
- set = now + deadline_to_decrementer(deadline, now);
- lapic_set_tsc_deadline_timer(_absolutetime_to_tsc(set));
+ delta = deadline_to_decrementer(deadline, now);
+ set = now + delta;
+ delta_tsc = tmrCvt(delta, tscFCvtn2t);
+ lapic_set_tsc_deadline_timer(tsc + delta_tsc);
} else {
lapic_set_tsc_deadline_timer(0);
}
KERNEL_DEBUG_CONSTANT(
DECR_SET_TSC_DEADLINE | DBG_FUNC_NONE,
now, deadline,
- rdtsc64(), lapic_get_tsc_deadline_timer(),
+ tsc, lapic_get_tsc_deadline_timer(),
0);
return set;