X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/15129b1c8dbb3650c63b70adb1cad9af601c6c17..d26ffc64f583ab2d29df48f13518685602bc8832:/osfmk/i386/rtclock.c diff --git a/osfmk/i386/rtclock.c b/osfmk/i386/rtclock.c index 415ee92fd..c8abc4b1e 100644 --- a/osfmk/i386/rtclock.c +++ b/osfmk/i386/rtclock.c @@ -39,7 +39,6 @@ * the cpu clock counted by the timestamp MSR. */ -#include #include @@ -72,8 +71,6 @@ #include #define UI_CPUFREQ_ROUNDING_FACTOR 10000000 -int rtclock_config(void); - int rtclock_init(void); uint64_t tsc_rebase_abs_time = 0; @@ -108,19 +105,6 @@ _absolutetime_to_nanotime(uint64_t abstime, clock_sec_t *secs, clock_usec_t *nan *nanosecs = (clock_usec_t)(abstime % (uint64_t)NSEC_PER_SEC); } -/* - * Configure the real-time clock device. Return success (1) - * or failure (0). - */ - -int -rtclock_config(void) -{ - /* nothing to do */ - return (1); -} - - /* * Nanotime/mach_absolutime_time * ----------------------------- @@ -161,7 +145,7 @@ _rtc_nanotime_init(pal_rtc_nanotime_t *rntp, uint64_t base) _pal_rtc_nanotime_store(tsc, base, rntp->scale, rntp->shift, rntp); } -static void +void rtc_nanotime_init(uint64_t base) { _rtc_nanotime_init(&pal_rtc_nanotime_info, base); @@ -271,7 +255,7 @@ rtc_sleep_wakeup( uint64_t base) { /* Set fixed configuration for lapic timers */ - rtc_timer->config(); + rtc_timer->rtc_config(); /* * Reset nanotime. @@ -281,6 +265,21 @@ rtc_sleep_wakeup( rtc_nanotime_init(base); } +void +rtc_decrementer_configure(void) { + rtc_timer->rtc_config(); +} +/* + * rtclock_early_init() is called very early at boot to + * establish mach_absolute_time() and set it to zero. + */ +void +rtclock_early_init(void) +{ + assert(tscFreq); + rtc_set_timescale(tscFreq); +} + /* * Initialize the real-time clock device. * In addition, various variables used to support the clock are initialized. @@ -295,7 +294,6 @@ rtclock_init(void) if (cpu_number() == master_cpu) { assert(tscFreq); - rtc_set_timescale(tscFreq); /* * Adjust and set the exported cpu speed. @@ -316,7 +314,7 @@ rtclock_init(void) } /* Set fixed configuration for lapic timers */ - rtc_timer->config(); + rtc_timer->rtc_config(); rtc_timer_start(); return (1); @@ -338,9 +336,6 @@ rtc_set_timescale(uint64_t cycles) cycles <<= 1; } - if ( shift != 0 ) - printf("Slow TSC, rtc_nanotime.shift == %d\n", shift); - rntp->scale = (uint32_t)(((uint64_t)NSEC_PER_SEC << 32) / cycles); rntp->shift = shift; @@ -361,8 +356,12 @@ rtc_set_timescale(uint64_t cycles) static uint64_t rtc_export_speed(uint64_t cyc_per_sec) { + pal_rtc_nanotime_t *rntp = &pal_rtc_nanotime_info; uint64_t cycles; + if (rntp->shift != 0 ) + printf("Slow TSC, rtc_nanotime.shift == %d\n", rntp->shift); + /* Round: */ cycles = ((cyc_per_sec + (UI_CPUFREQ_ROUNDING_FACTOR/2)) / UI_CPUFREQ_ROUNDING_FACTOR) @@ -403,21 +402,9 @@ clock_get_system_nanotime( } void -clock_gettimeofday_set_commpage( - uint64_t abstime, - uint64_t epoch, - uint64_t offset, - clock_sec_t *secs, - clock_usec_t *microsecs) +clock_gettimeofday_set_commpage(uint64_t abstime, uint64_t sec, uint64_t frac, uint64_t scale, uint64_t tick_per_sec) { - uint64_t now = abstime + offset; - uint32_t remain; - - remain = _absolutetime_to_microtime(now, secs, microsecs); - - *secs += (clock_sec_t)epoch; - - commpage_set_timestamp(abstime - remain, *secs); + commpage_set_timestamp(abstime, sec, frac, scale, tick_per_sec); } void @@ -468,8 +455,7 @@ rtclock_intr( */ uint64_t -setPop( - uint64_t time) +setPop(uint64_t time) { uint64_t now; uint64_t pop; @@ -478,10 +464,10 @@ setPop( if (time == 0 || time == EndOfAllTime ) { time = EndOfAllTime; now = 0; - pop = rtc_timer->set(0, 0); + pop = rtc_timer->rtc_set(0, 0); } else { now = rtc_nanotime_read(); /* The time in nanoseconds */ - pop = rtc_timer->set(time, now); + pop = rtc_timer->rtc_set(time, now); } /* Record requested and actual deadlines set */ @@ -497,6 +483,12 @@ mach_absolute_time(void) return rtc_nanotime_read(); } +uint64_t +mach_approximate_time(void) +{ + return rtc_nanotime_read(); +} + void clock_interval_to_absolutetime_interval( uint32_t interval, @@ -515,15 +507,6 @@ absolutetime_to_microtime( _absolutetime_to_microtime(abstime, secs, microsecs); } -void -absolutetime_to_nanotime( - uint64_t abstime, - clock_sec_t *secs, - clock_nsec_t *nanosecs) -{ - _absolutetime_to_nanotime(abstime, secs, nanosecs); -} - void nanotime_to_absolutetime( clock_sec_t secs,