diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2008-12-03 17:28:10 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2008-12-03 17:28:10 +0000 |
commit | 959f887aaf4e81fa8a18556a2d390dd6bc283c3d (patch) | |
tree | 87b14540d68525a13bf85fbc99f67170ecd9e673 /c/src/lib/libbsp/i386/pc386/timer/timer.c | |
parent | 2008-12-03 Joel Sherrill <joel.sherrill@OARcorp.com> (diff) | |
download | rtems-959f887aaf4e81fa8a18556a2d390dd6bc283c3d.tar.bz2 |
2008-12-03 Joel Sherrill <joel.sherrill@OARcorp.com>
Michael South <msouth@msouth.org>
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.
Diffstat (limited to 'c/src/lib/libbsp/i386/pc386/timer/timer.c')
-rw-r--r-- | c/src/lib/libbsp/i386/pc386/timer/timer.c | 27 |
1 files changed, 6 insertions, 21 deletions
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 <bsp.h> #include <bsp/irq.h> +#include <libcpu/cpuModel.h> /*-------------------------------------------------------------------------+ | 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 @@ -83,22 +84,6 @@ void Timer_exit(void); +--------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------+ -| 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 | not really necessary, since there will be a reset at exit. @@ -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 */ |