OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [lib/] [libcpu/] [powerpc/] [mpc505/] [timer/] [timer.c] - Blame information for rev 173

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*  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
 
24
rtems_boolean Timer_driver_Find_average_overhead;
25
 
26
static unsigned int volatile lastInitValue;
27
 
28
void 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
 
48
int 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
 
60
rtems_status_code Empty_function( void )
61
{
62
  return RTEMS_SUCCESSFUL;
63
}
64
 
65
void Set_find_average_overhead(
66
  rtems_boolean find_flag
67
)
68
{
69
  Timer_driver_Find_average_overhead = find_flag;
70
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.