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.
This commit is contained in:
Joel Sherrill committed 2008-12-03 17:28:10 +00:00
1 parent c783c77742
commit 959f887aaf
4 files changed
+214 -36

No files matched your search

+8
View File
@@ -1,3 +1,11 @@
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.
2008-12-02 Joel Sherrill <joel.sherrill@oarcorp.com>
* startup/bspgetworkarea.c: Remove debug prints.
File diff suppressed because it is too large. Load diff
+35
View File
@@ -46,6 +46,41 @@ RTEMS_BSPOPTS_HELP([BSP_PRESS_KEY_FOR_RESET],
before rebooting the PC. This is useful for unattended PC deployments
])
RTEMS_BSPOPTS_SET([CLOCK_DRIVER_USE_TSC],[*],[0])
RTEMS_BSPOPTS_HELP([CLOCK_DRIVER_USE_TSC],
[If enabled, the clock driver will use the TSC register available
with Pentium-class CPUs to report close to nanosecond-accuracy
clock times.
Enable it, if:
- you have nanosecond timing enabled (you do NOT have
USE_TICKS_FOR_CPU_USAGE_STATISTICS enabled)
- you do NOT have CLOCK_DRIVER_USE_8254 enabled (use one, the other,
or neither)
- you have a Pentium which supports TSC (all Intels, and probably
all or most clones)
- you do not have a variable-speed CPU clock. Note that some
motherboard BIOS will automatically vary clock speed for thermal
control. Note also, however, that really new Pentium-class chips
from Intel and AMD will maintain a constant-rate TSC regardless.
])
RTEMS_BSPOPTS_SET([CLOCK_DRIVER_USE_8254],[*],[0])
RTEMS_BSPOPTS_HELP([CLOCK_DRIVER_USE_8254],
[If enabled, the clock driver will use the good old 8254 chip
to report microsecond-accuracy clock times.
Enable it, if:
- you have nanosecond timing enabled (you do NOT have
USE_TICKS_FOR_CPU_USAGE_STATISTICS enabled)
- you do NOT have CLOCK_DRIVER_USE_TSC enabled (use one, the other,
or neither)
- you do not mind adding roughly 5 microseconds to each context switch.
])
if test X${CLOCK_DRIVER_USE_TSC} = X1 -a X${CLOCK_DRIVER_USE_8254} = X1 ; then
AC_MSG_ERROR([pc386 both TSC and 8254 specified for clock driver])
fi
#define CLOCK_DRIVER_USE_8254 $CLOCK_DRIVER_USE_8254
## if this is an i386, does gas have good code16 support?
RTEMS_I386_GAS_CODE16
AM_CONDITIONAL(RTEMS_GAS_CODE16,[test "$RTEMS_GAS_CODE16" = "yes"])
+6 -21
View File
@@ -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
@@ -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 */