source: rtems/c/src/lib/libbsp/sparc/leon2/timer/timer.c @ 9b4422a2

4.115
Last change on this file since 9b4422a2 was 9b4422a2, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/12 at 15:09:24

Remove All CVS Id Strings Possible Using a Script

Script does what is expected and tries to do it as
smartly as possible.

+ remove occurrences of two blank comment lines

next to each other after Id string line removed.

+ remove entire comment blocks which only exited to

contain CVS Ids

+ If the processing left a blank line at the top of

a file, it was removed.

  • Property mode set to 100644
File size: 1.9 KB
Line 
1/*  timer.c
2 *
3 *  This file implements a benchmark timer using timer 2.
4 *
5 *  COPYRIGHT (c) 1989-1998.
6 *  On-Line Applications Research Corporation (OAR).
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.rtems.com/license/LICENSE.
11 *
12 *  Ported to LEON implementation of the SPARC by On-Line Applications
13 *  Research Corporation (OAR) under contract to the European Space
14 *  Agency (ESA).
15 *
16 *  LEON modifications of respective RTEMS file: COPYRIGHT (c) 1995.
17 *  European Space Agency.
18 */
19
20
21#include <bsp.h>
22#include <rtems/btimer.h>
23
24bool benchmark_timer_find_average_overhead;
25
26bool benchmark_timer_is_initialized = false;
27
28void benchmark_timer_initialize(void)
29{
30  /*
31   *  Timer runs long and accurate enough not to require an interrupt.
32   */
33
34  if ( benchmark_timer_is_initialized == false ) {
35
36    /* approximately 1 us per countdown */
37    LEON_REG.Timer_Counter_2 = 0xffffff;
38    LEON_REG.Timer_Reload_2 = 0xffffff;
39
40  } else {
41    benchmark_timer_is_initialized = true;
42  }
43
44  LEON_REG.Timer_Control_2 = (
45    LEON_REG_TIMER_COUNTER_ENABLE_COUNTING |
46      LEON_REG_TIMER_COUNTER_LOAD_COUNTER
47  );
48
49}
50
51#define AVG_OVERHEAD      3  /* It typically takes 3.0 microseconds */
52                             /*     to start/stop the timer. */
53#define LEAST_VALID       2  /* Don't trust a value lower than this */
54
55uint32_t benchmark_timer_read(void)
56{
57  uint32_t total;
58
59  total = LEON_REG.Timer_Counter_2;
60
61  total = 0xffffff - total;
62
63  if ( benchmark_timer_find_average_overhead == true )
64    return total;          /* in one microsecond units */
65
66  if ( total < LEAST_VALID )
67    return 0;            /* below timer resolution */
68
69  return total - AVG_OVERHEAD;
70}
71
72void benchmark_timer_disable_subtracting_average_overhead(
73  bool find_flag
74)
75{
76  benchmark_timer_find_average_overhead = find_flag;
77}
Note: See TracBrowser for help on using the repository browser.