kern_tc.c revision 119160
1/*- 2 * ---------------------------------------------------------------------------- 3 * "THE BEER-WARE LICENSE" (Revision 42): 4 * <phk@FreeBSD.ORG> wrote this file. As long as you retain this notice you 5 * can do whatever you want with this stuff. If we meet some day, and you think 6 * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp 7 * ---------------------------------------------------------------------------- 8 */ 9 10#include <sys/cdefs.h> 11__FBSDID("$FreeBSD: head/sys/kern/kern_tc.c 119160 2003-08-20 05:34:27Z imp $"); 12 13#include "opt_ntp.h" 14 15#include <sys/param.h> 16#include <sys/kernel.h> 17#include <sys/sysctl.h> 18#include <sys/systm.h> 19#include <sys/timepps.h> 20#include <sys/timetc.h> 21#include <sys/timex.h> 22 23/* 24 * a large step happens on boot. This constant detects such 25 * a steps. It is relatively small so that ntp_update_second gets called 26 * enough in the typical 'missed a couple of seconds' case, but doesn't 27 * loop forever when the time step is large. 28 */ 29#define LARGE_STEP 200 30 31/* 32 * Implement a dummy timecounter which we can use until we get a real one 33 * in the air. This allows the console and other early stuff to use 34 * time services. 35 */ 36 37static u_int 38dummy_get_timecount(struct timecounter *tc) 39{ 40 static u_int now; 41 42 return (++now); 43} 44 45static struct timecounter dummy_timecounter = { 46 dummy_get_timecount, 0, ~0u, 1000000, "dummy", -1000000 47}; 48 49struct timehands { 50 /* These fields must be initialized by the driver. */ 51 struct timecounter *th_counter; 52 int64_t th_adjustment; 53 u_int64_t th_scale; 54 u_int th_offset_count; 55 struct bintime th_offset; 56 struct timeval th_microtime; 57 struct timespec th_nanotime; 58 /* Fields not to be copied in tc_windup start with th_generation. */ 59 volatile u_int th_generation; 60 struct timehands *th_next; 61}; 62 63extern struct timehands th0; 64static struct timehands th9 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th0}; 65static struct timehands th8 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th9}; 66static struct timehands th7 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th8}; 67static struct timehands th6 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th7}; 68static struct timehands th5 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th6}; 69static struct timehands th4 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th5}; 70static struct timehands th3 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th4}; 71static struct timehands th2 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th3}; 72static struct timehands th1 = { NULL, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0, &th2}; 73static struct timehands th0 = { 74 &dummy_timecounter, 75 0, 76 (uint64_t)-1 / 1000000, 77 0, 78 {1, 0}, 79 {0, 0}, 80 {0, 0}, 81 1, 82 &th1 83}; 84 85static struct timehands *volatile timehands = &th0; 86struct timecounter *timecounter = &dummy_timecounter; 87static struct timecounter *timecounters = &dummy_timecounter; 88 89time_t time_second = 1; 90time_t time_uptime = 0; 91 92static struct bintime boottimebin; 93struct timeval boottime; 94SYSCTL_STRUCT(_kern, KERN_BOOTTIME, boottime, CTLFLAG_RD, 95 &boottime, timeval, "System boottime"); 96 97SYSCTL_NODE(_kern, OID_AUTO, timecounter, CTLFLAG_RW, 0, ""); 98 99#define TC_STATS(foo) \ 100 static u_int foo; \ 101 SYSCTL_UINT(_kern_timecounter, OID_AUTO, foo, CTLFLAG_RD, &foo, 0, "");\ 102 struct __hack 103 104TC_STATS(nbinuptime); TC_STATS(nnanouptime); TC_STATS(nmicrouptime); 105TC_STATS(nbintime); TC_STATS(nnanotime); TC_STATS(nmicrotime); 106TC_STATS(ngetbinuptime); TC_STATS(ngetnanouptime); TC_STATS(ngetmicrouptime); 107TC_STATS(ngetbintime); TC_STATS(ngetnanotime); TC_STATS(ngetmicrotime); 108TC_STATS(nsetclock); 109 110#undef TC_STATS 111 112static void tc_windup(void); 113 114/* 115 * Return the difference between the timehands' counter value now and what 116 * was when we copied it to the timehands' offset_count. 117 */ 118static __inline u_int 119tc_delta(struct timehands *th) 120{ 121 struct timecounter *tc; 122 123 tc = th->th_counter; 124 return ((tc->tc_get_timecount(tc) - th->th_offset_count) & 125 tc->tc_counter_mask); 126} 127 128/* 129 * Functions for reading the time. We have to loop until we are sure that 130 * the timehands that we operated on was not updated under our feet. See 131 * the comment in <sys/time.h> for a description of these 12 functions. 132 */ 133 134void 135binuptime(struct bintime *bt) 136{ 137 struct timehands *th; 138 u_int gen; 139 140 nbinuptime++; 141 do { 142 th = timehands; 143 gen = th->th_generation; 144 *bt = th->th_offset; 145 bintime_addx(bt, th->th_scale * tc_delta(th)); 146 } while (gen == 0 || gen != th->th_generation); 147} 148 149void 150nanouptime(struct timespec *tsp) 151{ 152 struct bintime bt; 153 154 nnanouptime++; 155 binuptime(&bt); 156 bintime2timespec(&bt, tsp); 157} 158 159void 160microuptime(struct timeval *tvp) 161{ 162 struct bintime bt; 163 164 nmicrouptime++; 165 binuptime(&bt); 166 bintime2timeval(&bt, tvp); 167} 168 169void 170bintime(struct bintime *bt) 171{ 172 173 nbintime++; 174 binuptime(bt); 175 bintime_add(bt, &boottimebin); 176} 177 178void 179nanotime(struct timespec *tsp) 180{ 181 struct bintime bt; 182 183 nnanotime++; 184 bintime(&bt); 185 bintime2timespec(&bt, tsp); 186} 187 188void 189microtime(struct timeval *tvp) 190{ 191 struct bintime bt; 192 193 nmicrotime++; 194 bintime(&bt); 195 bintime2timeval(&bt, tvp); 196} 197 198void 199getbinuptime(struct bintime *bt) 200{ 201 struct timehands *th; 202 u_int gen; 203 204 ngetbinuptime++; 205 do { 206 th = timehands; 207 gen = th->th_generation; 208 *bt = th->th_offset; 209 } while (gen == 0 || gen != th->th_generation); 210} 211 212void 213getnanouptime(struct timespec *tsp) 214{ 215 struct timehands *th; 216 u_int gen; 217 218 ngetnanouptime++; 219 do { 220 th = timehands; 221 gen = th->th_generation; 222 bintime2timespec(&th->th_offset, tsp); 223 } while (gen == 0 || gen != th->th_generation); 224} 225 226void 227getmicrouptime(struct timeval *tvp) 228{ 229 struct timehands *th; 230 u_int gen; 231 232 ngetmicrouptime++; 233 do { 234 th = timehands; 235 gen = th->th_generation; 236 bintime2timeval(&th->th_offset, tvp); 237 } while (gen == 0 || gen != th->th_generation); 238} 239 240void 241getbintime(struct bintime *bt) 242{ 243 struct timehands *th; 244 u_int gen; 245 246 ngetbintime++; 247 do { 248 th = timehands; 249 gen = th->th_generation; 250 *bt = th->th_offset; 251 } while (gen == 0 || gen != th->th_generation); 252 bintime_add(bt, &boottimebin); 253} 254 255void 256getnanotime(struct timespec *tsp) 257{ 258 struct timehands *th; 259 u_int gen; 260 261 ngetnanotime++; 262 do { 263 th = timehands; 264 gen = th->th_generation; 265 *tsp = th->th_nanotime; 266 } while (gen == 0 || gen != th->th_generation); 267} 268 269void 270getmicrotime(struct timeval *tvp) 271{ 272 struct timehands *th; 273 u_int gen; 274 275 ngetmicrotime++; 276 do { 277 th = timehands; 278 gen = th->th_generation; 279 *tvp = th->th_microtime; 280 } while (gen == 0 || gen != th->th_generation); 281} 282 283/* 284 * Initialize a new timecounter and possibly use it. 285 */ 286void 287tc_init(struct timecounter *tc) 288{ 289 unsigned u; 290 291 if (tc->tc_quality >= 0 || bootverbose) 292 printf("Timecounter \"%s\" frequency %ju Hz quality %d", 293 tc->tc_name, (intmax_t)tc->tc_frequency, 294 tc->tc_quality); 295 296 u = tc->tc_frequency / tc->tc_counter_mask; 297 if (u > hz) { 298 printf(" -- Insufficient hz, needs at least %u\n", u); 299 return; 300 } 301 printf("\n"); 302 tc->tc_next = timecounters; 303 timecounters = tc; 304 (void)tc->tc_get_timecount(tc); 305 (void)tc->tc_get_timecount(tc); 306 /* Never automatically use a timecounter with negative quality */ 307 if (tc->tc_quality < 0) 308 return; 309 if (tc->tc_quality < timecounter->tc_quality) 310 return; 311 timecounter = tc; 312} 313 314/* Report the frequency of the current timecounter. */ 315u_int64_t 316tc_getfrequency(void) 317{ 318 319 return (timehands->th_counter->tc_frequency); 320} 321 322/* 323 * Step our concept of UTC. This is done by modifying our estimate of 324 * when we booted. XXX: needs futher work. 325 */ 326void 327tc_setclock(struct timespec *ts) 328{ 329 struct timespec ts2; 330 331 nsetclock++; 332 nanouptime(&ts2); 333 boottime.tv_sec = ts->tv_sec - ts2.tv_sec; 334 /* XXX boottime should probably be a timespec. */ 335 boottime.tv_usec = (ts->tv_nsec - ts2.tv_nsec) / 1000; 336 if (boottime.tv_usec < 0) { 337 boottime.tv_usec += 1000000; 338 boottime.tv_sec--; 339 } 340 timeval2bintime(&boottime, &boottimebin); 341 342 /* XXX fiddle all the little crinkly bits around the fiords... */ 343 tc_windup(); 344} 345 346/* 347 * Initialize the next struct timehands in the ring and make 348 * it the active timehands. Along the way we might switch to a different 349 * timecounter and/or do seconds processing in NTP. Slightly magic. 350 */ 351static void 352tc_windup(void) 353{ 354 struct bintime bt; 355 struct timehands *th, *tho; 356 u_int64_t scale; 357 u_int delta, ncount, ogen; 358 int i; 359 time_t t; 360 361 /* 362 * Make the next timehands a copy of the current one, but do not 363 * overwrite the generation or next pointer. While we update 364 * the contents, the generation must be zero. 365 */ 366 tho = timehands; 367 th = tho->th_next; 368 ogen = th->th_generation; 369 th->th_generation = 0; 370 bcopy(tho, th, offsetof(struct timehands, th_generation)); 371 372 /* 373 * Capture a timecounter delta on the current timecounter and if 374 * changing timecounters, a counter value from the new timecounter. 375 * Update the offset fields accordingly. 376 */ 377 delta = tc_delta(th); 378 if (th->th_counter != timecounter) 379 ncount = timecounter->tc_get_timecount(timecounter); 380 else 381 ncount = 0; 382 th->th_offset_count += delta; 383 th->th_offset_count &= th->th_counter->tc_counter_mask; 384 bintime_addx(&th->th_offset, th->th_scale * delta); 385 386 /* 387 * Hardware latching timecounters may not generate interrupts on 388 * PPS events, so instead we poll them. There is a finite risk that 389 * the hardware might capture a count which is later than the one we 390 * got above, and therefore possibly in the next NTP second which might 391 * have a different rate than the current NTP second. It doesn't 392 * matter in practice. 393 */ 394 if (tho->th_counter->tc_poll_pps) 395 tho->th_counter->tc_poll_pps(tho->th_counter); 396 397 /* 398 * Compute the UTC time, before any leapsecond adjustments, are 399 * made. 400 */ 401 bt = th->th_offset; 402 bintime_add(&bt, &boottimebin); 403 404 /* 405 * Deal with NTP second processing. The for loop normally only 406 * iterates once, but in extreme situations it might keep NTP sane 407 * if timeouts are not run for several seconds. At boot, the 408 * time step can be large when the TOD hardware has been read, so 409 * on really large steps, we call ntp_update_second only twice. 410 * We need to call it twice in case we missed a leap second. 411 */ 412 i = bt.sec - tho->th_microtime.tv_sec; 413 if (i > LARGE_STEP) 414 i = 2; 415 for (; i > 0; i--) { 416 t = bt.sec; 417 ntp_update_second(&th->th_adjustment, &bt.sec); 418 if (bt.sec != t) 419 boottimebin.sec += bt.sec - t; 420 } 421 422 /* Now is a good time to change timecounters. */ 423 if (th->th_counter != timecounter) { 424 th->th_counter = timecounter; 425 th->th_offset_count = ncount; 426 } 427 428 /*- 429 * Recalculate the scaling factor. We want the number of 1/2^64 430 * fractions of a second per period of the hardware counter, taking 431 * into account the th_adjustment factor which the NTP PLL/adjtime(2) 432 * processing provides us with. 433 * 434 * The th_adjustment is nanoseconds per second with 32 bit binary 435 * fraction and we want 64 bit binary fraction of second: 436 * 437 * x = a * 2^32 / 10^9 = a * 4.294967296 438 * 439 * The range of th_adjustment is +/- 5000PPM so inside a 64bit int 440 * we can only multiply by about 850 without overflowing, but that 441 * leaves suitably precise fractions for multiply before divide. 442 * 443 * Divide before multiply with a fraction of 2199/512 results in a 444 * systematic undercompensation of 10PPM of th_adjustment. On a 445 * 5000PPM adjustment this is a 0.05PPM error. This is acceptable. 446 * 447 * We happily sacrifice the lowest of the 64 bits of our result 448 * to the goddess of code clarity. 449 * 450 */ 451 scale = (u_int64_t)1 << 63; 452 scale += (th->th_adjustment / 1024) * 2199; 453 scale /= th->th_counter->tc_frequency; 454 th->th_scale = scale * 2; 455 456 bintime2timeval(&bt, &th->th_microtime); 457 bintime2timespec(&bt, &th->th_nanotime); 458 459 /* 460 * Now that the struct timehands is again consistent, set the new 461 * generation number, making sure to not make it zero. 462 */ 463 if (++ogen == 0) 464 ogen = 1; 465 th->th_generation = ogen; 466 467 /* Go live with the new struct timehands. */ 468 time_second = th->th_microtime.tv_sec; 469 time_uptime = th->th_offset.sec; 470 timehands = th; 471} 472 473/* Report or change the active timecounter hardware. */ 474static int 475sysctl_kern_timecounter_hardware(SYSCTL_HANDLER_ARGS) 476{ 477 char newname[32]; 478 struct timecounter *newtc, *tc; 479 int error; 480 481 tc = timecounter; 482 strlcpy(newname, tc->tc_name, sizeof(newname)); 483 484 error = sysctl_handle_string(oidp, &newname[0], sizeof(newname), req); 485 if (error != 0 || req->newptr == NULL || 486 strcmp(newname, tc->tc_name) == 0) 487 return (error); 488 for (newtc = timecounters; newtc != NULL; newtc = newtc->tc_next) { 489 if (strcmp(newname, newtc->tc_name) != 0) 490 continue; 491 492 /* Warm up new timecounter. */ 493 (void)newtc->tc_get_timecount(newtc); 494 (void)newtc->tc_get_timecount(newtc); 495 496 timecounter = newtc; 497 return (0); 498 } 499 return (EINVAL); 500} 501 502SYSCTL_PROC(_kern_timecounter, OID_AUTO, hardware, CTLTYPE_STRING | CTLFLAG_RW, 503 0, 0, sysctl_kern_timecounter_hardware, "A", ""); 504 505 506/* Report or change the active timecounter hardware. */ 507static int 508sysctl_kern_timecounter_choice(SYSCTL_HANDLER_ARGS) 509{ 510 char buf[32], *spc; 511 struct timecounter *tc; 512 int error; 513 514 spc = ""; 515 error = 0; 516 for (tc = timecounters; error == 0 && tc != NULL; tc = tc->tc_next) { 517 sprintf(buf, "%s%s(%d)", 518 spc, tc->tc_name, tc->tc_quality); 519 error = SYSCTL_OUT(req, buf, strlen(buf)); 520 spc = " "; 521 } 522 return (error); 523} 524 525SYSCTL_PROC(_kern_timecounter, OID_AUTO, choice, CTLTYPE_STRING | CTLFLAG_RD, 526 0, 0, sysctl_kern_timecounter_choice, "A", ""); 527 528/* 529 * RFC 2783 PPS-API implementation. 530 */ 531 532int 533pps_ioctl(u_long cmd, caddr_t data, struct pps_state *pps) 534{ 535 pps_params_t *app; 536 struct pps_fetch_args *fapi; 537#ifdef PPS_SYNC 538 struct pps_kcbind_args *kapi; 539#endif 540 541 switch (cmd) { 542 case PPS_IOC_CREATE: 543 return (0); 544 case PPS_IOC_DESTROY: 545 return (0); 546 case PPS_IOC_SETPARAMS: 547 app = (pps_params_t *)data; 548 if (app->mode & ~pps->ppscap) 549 return (EINVAL); 550 pps->ppsparam = *app; 551 return (0); 552 case PPS_IOC_GETPARAMS: 553 app = (pps_params_t *)data; 554 *app = pps->ppsparam; 555 app->api_version = PPS_API_VERS_1; 556 return (0); 557 case PPS_IOC_GETCAP: 558 *(int*)data = pps->ppscap; 559 return (0); 560 case PPS_IOC_FETCH: 561 fapi = (struct pps_fetch_args *)data; 562 if (fapi->tsformat && fapi->tsformat != PPS_TSFMT_TSPEC) 563 return (EINVAL); 564 if (fapi->timeout.tv_sec || fapi->timeout.tv_nsec) 565 return (EOPNOTSUPP); 566 pps->ppsinfo.current_mode = pps->ppsparam.mode; 567 fapi->pps_info_buf = pps->ppsinfo; 568 return (0); 569 case PPS_IOC_KCBIND: 570#ifdef PPS_SYNC 571 kapi = (struct pps_kcbind_args *)data; 572 /* XXX Only root should be able to do this */ 573 if (kapi->tsformat && kapi->tsformat != PPS_TSFMT_TSPEC) 574 return (EINVAL); 575 if (kapi->kernel_consumer != PPS_KC_HARDPPS) 576 return (EINVAL); 577 if (kapi->edge & ~pps->ppscap) 578 return (EINVAL); 579 pps->kcmode = kapi->edge; 580 return (0); 581#else 582 return (EOPNOTSUPP); 583#endif 584 default: 585 return (ENOTTY); 586 } 587} 588 589void 590pps_init(struct pps_state *pps) 591{ 592 pps->ppscap |= PPS_TSFMT_TSPEC; 593 if (pps->ppscap & PPS_CAPTUREASSERT) 594 pps->ppscap |= PPS_OFFSETASSERT; 595 if (pps->ppscap & PPS_CAPTURECLEAR) 596 pps->ppscap |= PPS_OFFSETCLEAR; 597} 598 599void 600pps_capture(struct pps_state *pps) 601{ 602 struct timehands *th; 603 604 th = timehands; 605 pps->capgen = th->th_generation; 606 pps->capth = th; 607 pps->capcount = th->th_counter->tc_get_timecount(th->th_counter); 608 if (pps->capgen != th->th_generation) 609 pps->capgen = 0; 610} 611 612void 613pps_event(struct pps_state *pps, int event) 614{ 615 struct bintime bt; 616 struct timespec ts, *tsp, *osp; 617 u_int tcount, *pcount; 618 int foff, fhard; 619 pps_seq_t *pseq; 620 621 /* If the timecounter was wound up underneath us, bail out. */ 622 if (pps->capgen == 0 || pps->capgen != pps->capth->th_generation) 623 return; 624 625 /* Things would be easier with arrays. */ 626 if (event == PPS_CAPTUREASSERT) { 627 tsp = &pps->ppsinfo.assert_timestamp; 628 osp = &pps->ppsparam.assert_offset; 629 foff = pps->ppsparam.mode & PPS_OFFSETASSERT; 630 fhard = pps->kcmode & PPS_CAPTUREASSERT; 631 pcount = &pps->ppscount[0]; 632 pseq = &pps->ppsinfo.assert_sequence; 633 } else { 634 tsp = &pps->ppsinfo.clear_timestamp; 635 osp = &pps->ppsparam.clear_offset; 636 foff = pps->ppsparam.mode & PPS_OFFSETCLEAR; 637 fhard = pps->kcmode & PPS_CAPTURECLEAR; 638 pcount = &pps->ppscount[1]; 639 pseq = &pps->ppsinfo.clear_sequence; 640 } 641 642 /* 643 * If the timecounter changed, we cannot compare the count values, so 644 * we have to drop the rest of the PPS-stuff until the next event. 645 */ 646 if (pps->ppstc != pps->capth->th_counter) { 647 pps->ppstc = pps->capth->th_counter; 648 *pcount = pps->capcount; 649 pps->ppscount[2] = pps->capcount; 650 return; 651 } 652 653 /* Return if nothing really happened. */ 654 if (*pcount == pps->capcount) 655 return; 656 657 /* Convert the count to a timespec. */ 658 tcount = pps->capcount - pps->capth->th_offset_count; 659 tcount &= pps->capth->th_counter->tc_counter_mask; 660 bt = pps->capth->th_offset; 661 bintime_addx(&bt, pps->capth->th_scale * tcount); 662 bintime_add(&bt, &boottimebin); 663 bintime2timespec(&bt, &ts); 664 665 /* If the timecounter was wound up underneath us, bail out. */ 666 if (pps->capgen != pps->capth->th_generation) 667 return; 668 669 *pcount = pps->capcount; 670 (*pseq)++; 671 *tsp = ts; 672 673 if (foff) { 674 timespecadd(tsp, osp); 675 if (tsp->tv_nsec < 0) { 676 tsp->tv_nsec += 1000000000; 677 tsp->tv_sec -= 1; 678 } 679 } 680#ifdef PPS_SYNC 681 if (fhard) { 682 u_int64_t scale; 683 684 /* 685 * Feed the NTP PLL/FLL. 686 * The FLL wants to know how many (hardware) nanoseconds 687 * elapsed since the previous event. 688 */ 689 tcount = pps->capcount - pps->ppscount[2]; 690 pps->ppscount[2] = pps->capcount; 691 tcount &= pps->capth->th_counter->tc_counter_mask; 692 scale = (u_int64_t)1 << 63; 693 scale /= pps->capth->th_counter->tc_frequency; 694 scale *= 2; 695 bt.sec = 0; 696 bt.frac = 0; 697 bintime_addx(&bt, scale * tcount); 698 bintime2timespec(&bt, &ts); 699 hardpps(tsp, ts.tv_nsec + 1000000000 * ts.tv_sec); 700 } 701#endif 702} 703 704/* 705 * Timecounters need to be updated every so often to prevent the hardware 706 * counter from overflowing. Updating also recalculates the cached values 707 * used by the get*() family of functions, so their precision depends on 708 * the update frequency. 709 */ 710 711static int tc_tick; 712SYSCTL_INT(_kern_timecounter, OID_AUTO, tick, CTLFLAG_RD, &tc_tick, 0, ""); 713 714void 715tc_ticktock(void) 716{ 717 static int count; 718 719 if (++count < tc_tick) 720 return; 721 count = 0; 722 tc_windup(); 723} 724 725static void 726inittimecounter(void *dummy) 727{ 728 u_int p; 729 730 /* 731 * Set the initial timeout to 732 * max(1, <approx. number of hardclock ticks in a millisecond>). 733 * People should probably not use the sysctl to set the timeout 734 * to smaller than its inital value, since that value is the 735 * smallest reasonable one. If they want better timestamps they 736 * should use the non-"get"* functions. 737 */ 738 if (hz > 1000) 739 tc_tick = (hz + 500) / 1000; 740 else 741 tc_tick = 1; 742 p = (tc_tick * 1000000) / hz; 743 printf("Timecounters tick every %d.%03u msec\n", p / 1000, p % 1000); 744 745 /* warm up new timecounter (again) and get rolling. */ 746 (void)timecounter->tc_get_timecount(timecounter); 747 (void)timecounter->tc_get_timecount(timecounter); 748} 749 750SYSINIT(timecounter, SI_SUB_CLOCKS, SI_ORDER_SECOND, inittimecounter, NULL) 751