MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ffclock_reset_clock

Function ffclock_reset_clock

freebsd/kern/kern_tc.c:532–560  ·  view source on GitHub ↗

* Reset the feed-forward clock estimates. Called from inittodr() to get things * kick started and uses the timecounter nominal frequency as a first period * estimate. Note: this function may be called several time just after boot. * Note: this is the only function that sets the value of boot time for the * monotonic (i.e. uptime) version of the feed-forward clock. */

Source from the content-addressed store, hash-verified

530 * monotonic (i.e. uptime) version of the feed-forward clock.
531 */
532void
533ffclock_reset_clock(struct timespec *ts)
534{
535 struct timecounter *tc;
536 struct ffclock_estimate cest;
537
538 tc = timehands->th_counter;
539 memset(&cest, 0, sizeof(struct ffclock_estimate));
540
541 timespec2bintime(ts, &ffclock_boottime);
542 timespec2bintime(ts, &(cest.update_time));
543 ffclock_read_counter(&cest.update_ffcount);
544 cest.leapsec_next = 0;
545 cest.period = ((1ULL << 63) / tc->tc_frequency) << 1;
546 cest.errb_abs = 0;
547 cest.errb_rate = 0;
548 cest.status = FFCLOCK_STA_UNSYNC;
549 cest.leapsec_total = 0;
550 cest.leapsec = 0;
551
552 mtx_lock(&ffclock_mtx);
553 bcopy(&cest, &ffclock_estimate, sizeof(struct ffclock_estimate));
554 ffclock_updated = INT8_MAX;
555 mtx_unlock(&ffclock_mtx);
556
557 printf("ffclock reset: %s (%llu Hz), time = %ld.%09lu\n", tc->tc_name,
558 (unsigned long long)tc->tc_frequency, (long)ts->tv_sec,
559 (unsigned long)ts->tv_nsec);
560}
561
562/*
563 * Sub-routine to convert a time interval measured in RAW counter units to time

Callers 1

inittodrFunction · 0.85

Calls 6

memsetFunction · 0.85
timespec2bintimeFunction · 0.85
ffclock_read_counterFunction · 0.85
mtx_lockFunction · 0.70
mtx_unlockFunction · 0.70
printfFunction · 0.70

Tested by

no test coverage detected