source: rtems/c/src/lib/libcpu/powerpc/mpc505/timer/timer.c @ 8f6a68e8

4.104.114.84.95
Last change on this file since 8f6a68e8 was 8f6a68e8, checked in by Joel Sherrill <joel.sherrill@…>, on 09/04/03 at 13:47:29

2003-09-04 Joel Sherrill <joel@…>

  • mpc505/timer/timer.c, ppc403/console/console.c, ppc403/console/console405.c: Removed incorrect statement about copyright assignment.
  • Property mode set to 100644
File size: 1.7 KB
RevLine 
[96284fd8]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 *
[8f6a68e8]14 * $Id$
[96284fd8]15 */
16
[a982e0c6]17#include <rtems.h>
[96284fd8]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  rtems_unsigned32 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.