source: rtems/c/src/lib/libcpu/powerpc/mpc505/timer/timer.c @ 73b5bd5d

4.104.114.84.95
Last change on this file since 73b5bd5d was 66c373bf, checked in by Ralf Corsepius <ralf.corsepius@…>, on 03/31/04 at 02:04:00

2004-03-30 Ralf Corsepius <ralf_corsepius@…>

  • mpc505/timer/timer.c, mpc5xx/timer/timer.c, mpc6xx/clock/c_clock.c, mpc6xx/timer/timer.c, mpc8260/clock/clock.c, mpc8260/console-generic/console-generic.c, mpc8260/cpm/cp.c, mpc8260/cpm/dpram.c, mpc8260/include/cpm.h, mpc8260/include/mmu.h, mpc8260/include/mpc8260.h, mpc8260/mmu/mmu.c, mpc8260/timer/timer.c, mpc8xx/clock/clock.c, mpc8xx/console-generic/console-generic.c, mpc8xx/cpm/cp.c, mpc8xx/cpm/dpram.c, mpc8xx/include/cpm.h, mpc8xx/include/mmu.h, mpc8xx/include/mpc8xx.h, mpc8xx/mmu/mmu.c, mpc8xx/timer/timer.c, ppc403/clock/clock.c, ppc403/console/console.c, ppc403/console/console405.c, ppc403/ictrl/ictrl.c, ppc403/ictrl/ictrl.h, ppc403/timer/timer.c, ppc403/tty_drv/tty_drv.c, rtems/powerpc/cache.h, shared/src/cache.c: Convert to using c99 fixed size types.
  • Property mode set to 100644
File size: 1.7 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 *  Timer_initialize() and Read_timer().  Read_timer() usually returns
6 *  the number of microseconds since 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
19rtems_boolean Timer_driver_Find_average_overhead;
20
21static unsigned int volatile lastInitValue;
22
23void Timer_initialize( void )
24{
25  asm volatile( " mftb %0": "=r" (lastInitValue) );
26}
27
28/*
29 *  The following controls the behavior of Read_timer().
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 Read_timer( void )
44{
45  uint32_t   value;
46  asm volatile ( " mftb %0": "=r" (value) );
47  return value - lastInitValue;
48}
49
50/*
51 *  Empty function call used in loops to measure basic cost of looping
52 *  in Timing Test Suite.
53 */
54
55rtems_status_code Empty_function( void )
56{
57  return RTEMS_SUCCESSFUL;
58}
59
60void Set_find_average_overhead(
61  rtems_boolean find_flag
62)
63{
64  Timer_driver_Find_average_overhead = find_flag;
65}
Note: See TracBrowser for help on using the repository browser.