source: rtems/c/src/lib/libcpu/powerpc/mpc505/timer/timer.c @ 183af89

4.115
Last change on this file since 183af89 was f9acc33, checked in by Ralf Corsepius <ralf.corsepius@…>, on 02/11/11 at 09:46:53

2011-02-11 Ralf Corsépius <ralf.corsepius@…>

  • e500/mmu/mmu.c, mpc505/ictrl/ictrl.c, mpc505/timer/timer.c, mpc5xx/ictrl/ictrl.c, mpc5xx/timer/timer.c, mpc6xx/altivec/vec_sup.c, mpc6xx/clock/c_clock.c, mpc6xx/mmu/bat.c, mpc6xx/mmu/bat.h, mpc6xx/mmu/pte121.c, mpc8260/timer/timer.c, mpc8xx/timer/timer.c, new-exceptions/cpu.c, new-exceptions/bspsupport/ppc_exc_initialize.c, ppc403/clock/clock.c, ppc403/console/console.c, ppc403/console/console.c.polled, ppc403/console/console405.c, ppc403/irq/ictrl.c, ppc403/tty_drv/tty_drv.c, rtems/powerpc/cache.h, shared/include/powerpc-utility.h, shared/src/cache.c: Use "asm" instead of "asm" for improved c99-compliance.
  • Property mode set to 100644
File size: 1.6 KB
Line 
1/*  timer.c
2 *
3 *  This file manages the benchmark timer used by the RTEMS Timing Test
4 *  Suite.  Each measured time period is demarcated by calls to
5 *  benchmark_timer_initialize() and benchmark_timer_read().  benchmark_timer_read() usually returns
6 *  the number of microseconds since benchmark_timer_initialize() exitted.
7 *
8 *  NOTE: It is important that the timer start/stop overhead be
9 *        determined when porting or modifying this code.
10 *
11 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
12 *  On-Line Applications Research Corporation (OAR).
13 *
14 * $Id$
15 */
16
17#include <rtems.h>
18
19bool benchmark_timer_find_average_overhead;
20
21static unsigned int volatile lastInitValue;
22
23void benchmark_timer_initialize( void )
24{
25  __asm__ volatile( " mftb %0": "=r" (lastInitValue) );
26}
27
28/*
29 *  The following controls the behavior of benchmark_timer_read().
30 *
31 *  AVG_OVEREHAD is the overhead for starting and stopping the timer.  It
32 *  is usually deducted from the number returned.
33 *
34 *  LEAST_VALID is the lowest number this routine should trust.  Numbers
35 *  below this are "noise" and zero is returned.
36 */
37
38#define AVG_OVERHEAD      0  /* It typically takes X.X microseconds */
39                             /* (Y countdowns) to start/stop the timer. */
40                             /* This value is in microseconds. */
41#define LEAST_VALID       1  /* Don't trust a clicks value lower than this */
42
43int benchmark_timer_read( void )
44{
45  uint32_t   value;
46  __asm__ volatile ( " mftb %0": "=r" (value) );
47  return value - lastInitValue;
48}
49
50void benchmark_timer_disable_subtracting_average_overhead(bool find_flag)
51{
52  benchmark_timer_find_average_overhead = find_flag;
53}
Note: See TracBrowser for help on using the repository browser.