]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/i386/rtclock_native.c
xnu-4903.270.47.tar.gz
[apple/xnu.git] / osfmk / i386 / rtclock_native.c
index 13cde8e79ff765720fb954895b8660f6076644ae..720b743e877b00b961063a687a2f3f5de4ccf6de 100644 (file)
@@ -2,7 +2,7 @@
  * 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,
@@ -22,7 +22,7 @@
  * 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);
        }
 }
 
@@ -131,7 +131,7 @@ rtc_lapic_set_tsc_deadline_timer(uint64_t deadline, uint64_t now)
        } else {
                lapic_set_tsc_deadline_timer(0);
        }
-       
+
        KERNEL_DEBUG_CONSTANT(
                DECR_SET_TSC_DEADLINE | DBG_FUNC_NONE,
                now, deadline,
@@ -139,23 +139,23 @@ rtc_lapic_set_tsc_deadline_timer(uint64_t deadline, uint64_t now)
                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.
@@ -163,33 +163,33 @@ rtc_timer_t       *rtc_timer = &rtc_timer_lapic; /* defaults to LAPIC timer */
 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() */