source: rtems/c/src/lib/libcpu/powerpc/mpc505/timer/timer.c @ 96284fd8

4.104.114.84.95
Last change on this file since 96284fd8 was 96284fd8, checked in by Joel Sherrill <joel.sherrill@…>, on Aug 19, 1999 at 9:47:51 PM

Support for MPC505 from Sergei Organov <osv@…>. His patch was
against 3.6.0 so was painful to merge. It should be OK but there
is no guarantee and there are no BSPs in the tree to exercise it.

  • Property mode set to 100644
File size: 2.0 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 *  All rights assigned to U.S. Government, 1994.
14 *
15 *  This material may be reproduced by or for the U.S. Government pursuant
16 *  to the copyright license under the clause at DFARS 252.227-7013.  This
17 *  notice must appear in all copies of this file and its derivatives.
18 *
19 *  timer.c,v 1.2 1995/05/31 16:56:39 joel Exp
20 */
21
22#include "rtems.h"
23
24rtems_boolean Timer_driver_Find_average_overhead;
25
26static unsigned int volatile lastInitValue;
27
28void Timer_initialize( void )
29{
30  asm volatile( " mftb %0": "=r" (lastInitValue) );
31}
32
33/*
34 *  The following controls the behavior of Read_timer().
35 *
36 *  AVG_OVEREHAD is the overhead for starting and stopping the timer.  It
37 *  is usually deducted from the number returned.
38 *
39 *  LEAST_VALID is the lowest number this routine should trust.  Numbers
40 *  below this are "noise" and zero is returned.
41 */
42
43#define AVG_OVERHEAD      0  /* It typically takes X.X microseconds */
44                             /* (Y countdowns) to start/stop the timer. */
45                             /* This value is in microseconds. */
46#define LEAST_VALID       1  /* Don't trust a clicks value lower than this */
47
48int Read_timer( void )
49{
50  rtems_unsigned32 value;
51  asm volatile ( " mftb %0": "=r" (value) );
52  return value - lastInitValue;
53}
54
55/*
56 *  Empty function call used in loops to measure basic cost of looping
57 *  in Timing Test Suite.
58 */
59
60rtems_status_code Empty_function( void )
61{
62  return RTEMS_SUCCESSFUL;
63}
64
65void Set_find_average_overhead(
66  rtems_boolean find_flag
67)
68{
69  Timer_driver_Find_average_overhead = find_flag;
70}
Note: See TracBrowser for help on using the repository browser.