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

4.11
Last change on this file since 8fbe2e6 was 8fbe2e6, checked in by Joel Sherrill <joel.sherrill@…>, on Sep 4, 2014 at 1:59:49 PM

Use correct prototype of benchmark_timer_read()

This change starts with removing the effectively empty file
timerdrv.h. The prototypes for benchmark_timer_XXX() were in
btimer.h which was not universally used. Thus every use of
timerdrv.h had to be changed to btimer.h. Then the prototypes
for benchmark_timer_read() had to be adjusted to return
benchmark_timer_t rather than int or uint32_t.

I took this opportunity to also correct the file headers to
separate the copyright from the file description comments which
is needed to ensure the copyright isn't propagated into Doxygen
output.

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