kern_tc.c (36719) | kern_tc.c (36741) |
---|---|
1static volatile int print_tci = 1; 2 3/*- 4 * Copyright (c) 1997, 1998 Poul-Henning Kamp <phk@FreeBSD.org> 5 * Copyright (c) 1982, 1986, 1991, 1993 6 * The Regents of the University of California. All rights reserved. 7 * (c) UNIX System Laboratories, Inc. 8 * All or some portions of this file are derived from material licensed --- 25 unchanged lines hidden (view full) --- 34 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 35 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 36 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 37 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 38 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 39 * SUCH DAMAGE. 40 * 41 * @(#)kern_clock.c 8.5 (Berkeley) 1/21/94 | 1static volatile int print_tci = 1; 2 3/*- 4 * Copyright (c) 1997, 1998 Poul-Henning Kamp <phk@FreeBSD.org> 5 * Copyright (c) 1982, 1986, 1991, 1993 6 * The Regents of the University of California. All rights reserved. 7 * (c) UNIX System Laboratories, Inc. 8 * All or some portions of this file are derived from material licensed --- 25 unchanged lines hidden (view full) --- 34 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 35 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 36 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 37 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 38 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 39 * SUCH DAMAGE. 40 * 41 * @(#)kern_clock.c 8.5 (Berkeley) 1/21/94 |
42 * $Id: kern_clock.c,v 1.70 1998/05/28 09:30:16 phk Exp $ | 42 * $Id: kern_clock.c,v 1.71 1998/06/07 08:40:41 phk Exp $ |
43 */ 44 45#include <sys/param.h> 46#include <sys/systm.h> 47#include <sys/dkstat.h> 48#include <sys/callout.h> 49#include <sys/kernel.h> 50#include <sys/proc.h> --- 489 unchanged lines hidden (view full) --- 540 tv->tv_sec += boottime.tv_sec; 541 while (tv->tv_usec >= 1000000) { 542 tv->tv_usec -= 1000000; 543 tv->tv_sec++; 544 } 545} 546 547void | 43 */ 44 45#include <sys/param.h> 46#include <sys/systm.h> 47#include <sys/dkstat.h> 48#include <sys/callout.h> 49#include <sys/kernel.h> 50#include <sys/proc.h> --- 489 unchanged lines hidden (view full) --- 540 tv->tv_sec += boottime.tv_sec; 541 while (tv->tv_usec >= 1000000) { 542 tv->tv_usec -= 1000000; 543 tv->tv_sec++; 544 } 545} 546 547void |
548nanotime(struct timespec *tv) | 548nanotime(struct timespec *ts) |
549{ 550 unsigned count; 551 u_int64_t delta; 552 struct timecounter *tc; 553 554 tc = (struct timecounter *)timecounter; | 549{ 550 unsigned count; 551 u_int64_t delta; 552 struct timecounter *tc; 553 554 tc = (struct timecounter *)timecounter; |
555 tv->tv_sec = tc->offset_sec; | 555 ts->tv_sec = tc->offset_sec; |
556 count = tco_getdelta(tc); 557 delta = tc->offset_nano; 558 delta += ((u_int64_t)count * tc->scale_nano_f); 559 delta >>= 32; 560 delta += ((u_int64_t)count * tc->scale_nano_i); 561 delta += boottime.tv_usec * 1000; | 556 count = tco_getdelta(tc); 557 delta = tc->offset_nano; 558 delta += ((u_int64_t)count * tc->scale_nano_f); 559 delta >>= 32; 560 delta += ((u_int64_t)count * tc->scale_nano_i); 561 delta += boottime.tv_usec * 1000; |
562 tv->tv_sec += boottime.tv_sec; | 562 ts->tv_sec += boottime.tv_sec; |
563 while (delta >= 1000000000) { 564 delta -= 1000000000; | 563 while (delta >= 1000000000) { 564 delta -= 1000000000; |
565 tv->tv_sec++; | 565 ts->tv_sec++; |
566 } | 566 } |
567 tv->tv_nsec = delta; | 567 ts->tv_nsec = delta; |
568} 569 570void | 568} 569 570void |
571timecounter_timespec(unsigned count, struct timespec *ts) 572{ 573 u_int64_t delta; 574 struct timecounter *tc; 575 576 tc = (struct timecounter *)timecounter; 577 ts->tv_sec = tc->offset_sec; 578 count -= tc->offset_count; 579 count &= tc->counter_mask; 580 delta = tc->offset_nano; 581 delta += ((u_int64_t)count * tc->scale_nano_f); 582 delta >>= 32; 583 delta += ((u_int64_t)count * tc->scale_nano_i); 584 delta += boottime.tv_usec * 1000; 585 ts->tv_sec += boottime.tv_sec; 586 while (delta >= 1000000000) { 587 delta -= 1000000000; 588 ts->tv_sec++; 589 } 590 ts->tv_nsec = delta; 591} 592 593void |
|
571getmicrouptime(struct timeval *tvp) 572{ 573 struct timecounter *tc; 574 575 tc = timecounter; 576 tvp->tv_sec = tc->offset_sec; 577 tvp->tv_usec = tc->offset_micro; 578} --- 142 unchanged lines hidden (view full) --- 721#endif 722 723static struct timecounter * 724sync_other_counter(void) 725{ 726 struct timecounter *tc, *tco; 727 unsigned delta; 728 | 594getmicrouptime(struct timeval *tvp) 595{ 596 struct timecounter *tc; 597 598 tc = timecounter; 599 tvp->tv_sec = tc->offset_sec; 600 tvp->tv_usec = tc->offset_micro; 601} --- 142 unchanged lines hidden (view full) --- 744#endif 745 746static struct timecounter * 747sync_other_counter(void) 748{ 749 struct timecounter *tc, *tco; 750 unsigned delta; 751 |
752 if (timecounter->poll_pps) 753 timecounter->poll_pps(timecounter); |
|
729 tc = timecounter->other; 730 tco = tc->other; 731 *tc = *timecounter; 732 tc->other = tco; 733 delta = tco_getdelta(tc); 734 tc->offset_count += delta; 735 tc->offset_count &= tc->counter_mask; 736 tc->offset_nano += (u_int64_t)delta * tc->scale_nano_f; --- 72 unchanged lines hidden (view full) --- 809{ 810 static unsigned now; 811 return (++now); 812} 813 814static struct timecounter dummy_timecounter[3] = { 815 { 816 dummy_get_timecount, | 754 tc = timecounter->other; 755 tco = tc->other; 756 *tc = *timecounter; 757 tc->other = tco; 758 delta = tco_getdelta(tc); 759 tc->offset_count += delta; 760 tc->offset_count &= tc->counter_mask; 761 tc->offset_nano += (u_int64_t)delta * tc->scale_nano_f; --- 72 unchanged lines hidden (view full) --- 834{ 835 static unsigned now; 836 return (++now); 837} 838 839static struct timecounter dummy_timecounter[3] = { 840 { 841 dummy_get_timecount, |
842 0, |
|
817 ~0u, 818 1000000, 819 "dummy" 820 } 821}; 822 823static void 824initdummytimecounter(void *dummy) 825{ 826 init_timecounter(dummy_timecounter); 827} 828 829SYSINIT(dummytc, SI_SUB_CONSOLE, SI_ORDER_FIRST, initdummytimecounter, NULL) | 843 ~0u, 844 1000000, 845 "dummy" 846 } 847}; 848 849static void 850initdummytimecounter(void *dummy) 851{ 852 init_timecounter(dummy_timecounter); 853} 854 855SYSINIT(dummytc, SI_SUB_CONSOLE, SI_ORDER_FIRST, initdummytimecounter, NULL) |