* 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. */
| 530 | * monotonic (i.e. uptime) version of the feed-forward clock. |
| 531 | */ |
| 532 | void |
| 533 | ffclock_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 |
no test coverage detected