Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/kern_tc.c
Show First 20 Lines • Show All 1,876 Lines • ▼ Show 20 Lines | #ifdef FFCLOCK | ||||
bintime_add(&bt, &pps->capffth->tick_time); | bintime_add(&bt, &pps->capffth->tick_time); | ||||
(*pseq_ffc)++; | (*pseq_ffc)++; | ||||
bintime2timespec(&bt, tsp_ffc); | bintime2timespec(&bt, tsp_ffc); | ||||
#endif | #endif | ||||
#ifdef PPS_SYNC | #ifdef PPS_SYNC | ||||
if (fhard) { | if (fhard) { | ||||
uint64_t nsec; | uint64_t nsec; | ||||
uint64_t freq; | |||||
/* | /* | ||||
* Feed the NTP PLL/FLL. | * Feed the NTP PLL/FLL. | ||||
* The FLL wants to know how many (hardware) nanoseconds | * The FLL wants to know how many (hardware) nanoseconds | ||||
* elapsed since the previous event. | * elapsed since the previous event. | ||||
*/ | */ | ||||
tcount = pps->capcount - pps->ppscount[2]; | tcount = pps->capcount - pps->ppscount[2]; | ||||
pps->ppscount[2] = pps->capcount; | pps->ppscount[2] = pps->capcount; | ||||
tcount &= captc->tc_counter_mask; | tcount &= captc->tc_counter_mask; | ||||
nsec = 1000000000; | nsec = 1000000000; | ||||
nsec *= tcount; | nsec *= tcount; | ||||
nsec /= captc->tc_frequency; | freq = captc->tc_frequency; | ||||
nsec = (nsec + freq / 2) / freq; | |||||
imp: so we go from nsec = nsec / freq to nsec = (nsec + freq / 2) / freq which is nsec / freq + freq… | |||||
hardpps(tsp, (long)nsec); | hardpps(tsp, (long)nsec); | ||||
} | } | ||||
#endif | #endif | ||||
/* Wakeup anyone sleeping in pps_fetch(). */ | /* Wakeup anyone sleeping in pps_fetch(). */ | ||||
wakeup(pps); | wakeup(pps); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 357 Lines • Show Last 20 Lines |
so we go from nsec = nsec / freq to nsec = (nsec + freq / 2) / freq which is nsec / freq + freq / (2 * freq) or nsec / freq + 1/2 which looks good.