* Copyright (c) 2000-2011 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
- *
+ *
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
- *
+ *
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
- *
+ *
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
- *
+ *
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
#include <i386/pal_routines.h>
#include <kern/timer_queue.h>
-static uint64_t rtc_decrementer_min;
-static uint64_t rtc_decrementer_max;
+static uint64_t rtc_decrementer_min;
+static uint64_t rtc_decrementer_max;
static uint64_t
deadline_to_decrementer(
- uint64_t deadline,
- uint64_t now)
+ uint64_t deadline,
+ uint64_t now)
{
- uint64_t delta;
+ uint64_t delta;
- if (deadline <= now)
+ if (deadline <= now) {
return rtc_decrementer_min;
- else {
+ } else {
delta = deadline - now;
- return MIN(MAX(rtc_decrementer_min,delta),rtc_decrementer_max);
+ return MIN(MAX(rtc_decrementer_min, delta), rtc_decrementer_max);
}
}
} else {
lapic_set_tsc_deadline_timer(0);
}
-
+
KERNEL_DEBUG_CONSTANT(
DECR_SET_TSC_DEADLINE | DBG_FUNC_NONE,
now, deadline,
0);
return set;
-}
+}
/*
* Definitions for timer operations table
*/
-rtc_timer_t rtc_timer_lapic = {
+rtc_timer_t rtc_timer_lapic = {
rtc_lapic_config_timer,
rtc_lapic_set_timer
};
-rtc_timer_t rtc_timer_tsc_deadline = {
+rtc_timer_t rtc_timer_tsc_deadline = {
rtc_lapic_config_tsc_deadline_timer,
rtc_lapic_set_tsc_deadline_timer
};
-rtc_timer_t *rtc_timer = &rtc_timer_lapic; /* defaults to LAPIC timer */
+rtc_timer_t *rtc_timer = &rtc_timer_lapic; /* defaults to LAPIC timer */
/*
* rtc_timer_init() is called at startup on the boot processor only.
void
rtc_timer_init(void)
{
- int TSC_deadline_timer = 0;
+ int TSC_deadline_timer = 0;
/* See whether we can use the local apic in TSC-deadline mode */
if ((cpuid_features() & CPUID_FEATURE_TSCTMR)) {
TSC_deadline_timer = 1;
PE_parse_boot_argn("TSC_deadline_timer", &TSC_deadline_timer,
- sizeof(TSC_deadline_timer));
+ sizeof(TSC_deadline_timer));
printf("TSC Deadline Timer supported %s enabled\n",
- TSC_deadline_timer ? "and" : "but not");
+ TSC_deadline_timer ? "and" : "but not");
}
if (TSC_deadline_timer) {
rtc_timer = &rtc_timer_tsc_deadline;
- rtc_decrementer_max = UINT64_MAX; /* effectively none */
+ rtc_decrementer_max = UINT64_MAX; /* effectively none */
/*
* The min could be as low as 1nsec,
* but we're being conservative for now and making it the same
* as for the local apic timer.
*/
- rtc_decrementer_min = 1*NSEC_PER_USEC; /* 1 usec */
+ rtc_decrementer_min = 1 * NSEC_PER_USEC; /* 1 usec */
} else {
/*
* Compute the longest interval using LAPIC timer.
*/
rtc_decrementer_max = tmrCvt(0x7fffffffULL, busFCvtt2n);
kprintf("maxDec: %lld\n", rtc_decrementer_max);
- rtc_decrementer_min = 1*NSEC_PER_USEC; /* 1 usec */
+ rtc_decrementer_min = 1 * NSEC_PER_USEC; /* 1 usec */
}
/* Point LAPIC interrupts to hardclock() */