From 959f887aaf4e81fa8a18556a2d390dd6bc283c3d Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Wed, 3 Dec 2008 17:28:10 +0000 Subject: 2008-12-03 Joel Sherrill Michael South PR 1344/bsps * configure.ac, clock/ckinit.c, timer/timer.c: Add use of TSC for nanoseconds granularity. i8254 is very slow on some systems. TSC use is auto-detected by default. --- c/src/lib/libbsp/i386/pc386/timer/timer.c | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) (limited to 'c/src/lib/libbsp/i386/pc386/timer/timer.c') diff --git a/c/src/lib/libbsp/i386/pc386/timer/timer.c b/c/src/lib/libbsp/i386/pc386/timer/timer.c index d45074ec46..534813e789 100644 --- a/c/src/lib/libbsp/i386/pc386/timer/timer.c +++ b/c/src/lib/libbsp/i386/pc386/timer/timer.c @@ -42,6 +42,7 @@ #include #include +#include /*-------------------------------------------------------------------------+ | Constants @@ -59,18 +60,18 @@ | Global Variables +--------------------------------------------------------------------------*/ volatile uint32_t Ttimer_val; -bool benchmark_timer_find_average_overhead = true; +bool benchmark_timer_find_average_overhead = true; volatile unsigned int fastLoop1ms, slowLoop1ms; -void (*benchmark_timer_initialize_function)(void) = 0; + +void (*benchmark_timer_initialize_function)(void) = 0; uint32_t (*benchmark_timer_read_function)(void) = 0; -void (*Timer_exit_function)(void) = 0; +void (*Timer_exit_function)(void) = 0; /*-------------------------------------------------------------------------+ | External Prototypes +--------------------------------------------------------------------------*/ extern void timerisr(void); /* timer (int 08h) Interrupt Service Routine (defined in 'timerisr.s') */ -extern int x86_capability; /* * forward declarations @@ -82,22 +83,6 @@ void Timer_exit(void); | Pentium optimized timer handling. +--------------------------------------------------------------------------*/ -/*-------------------------------------------------------------------------+ -| Function: rdtsc -| Description: Read the value of PENTIUM on-chip cycle counter. -| Global Variables: None. -| Arguments: None. -| Returns: Value of PENTIUM on-chip cycle counter. -+--------------------------------------------------------------------------*/ -static inline unsigned long long -rdtsc(void) -{ - /* Return the value of the on-chip cycle counter. */ - unsigned long long result; - asm volatile(".byte 0x0F, 0x31" : "=A" (result)); - return result; -} /* rdtsc */ - /*-------------------------------------------------------------------------+ | Function: Timer_exit | Description: Timer cleanup routine at RTEMS exit. NOTE: This routine is @@ -288,7 +273,7 @@ benchmark_timer_initialize(void) static bool First = true; if (First) { - if (x86_capability & (1 << 4) ) { + if (x86_has_tsc()) { #if defined(DEBUG) printk("TSC: timer initialization\n"); #endif /* DEBUG */ -- cgit v1.2.3