source: rtems/c/src/lib/libbsp/mips/jmr3904/timer/timer.c @ 35f52a6

4.104.114.95
Last change on this file since 35f52a6 was 35f52a6, checked in by Joel Sherrill <joel.sherrill@…>, on 08/31/08 at 16:07:58

2008-08-31 Joel Sherrill <joel.sherrill@…>

  • timer/timer.c: Rename timer driver methods to follow RTEMS programming conventions.
  • Property mode set to 100644
File size: 2.3 KB
Line 
1/*
2 *  This file implements a benchmark timer using a TX39 timer.
3 *
4 *  NOTE: On the simulator, the count directly reflects instructions.
5 *
6 *  COPYRIGHT (c) 1989-2000.
7 *  On-Line Applications Research Corporation (OAR).
8 *
9 *  The license and distribution terms for this file may be
10 *  found in found in the file LICENSE in this distribution or at
11 *  http://www.rtems.com/license/LICENSE.
12 *
13 *  $Id$
14 */
15
16#include <assert.h>
17
18#include <bsp.h>
19
20rtems_boolean benchmark_timerfind_average_overhead;
21
22void benchmark_timerinitialize(void)
23{
24  /*
25   *  Programming the compare register as the maximum value should let
26   *  it run long enough and accurate enough not to require an interrupt.
27   *  but if it ever does generate an interrupt, we will simply fault.
28   *
29   *  NOTE:  This is similar to the clock driver initialization
30   *         with the exception that the divider is disabled and
31   *         the compare register is set to the maximum value.
32   */
33
34  TX3904_TIMER_WRITE( TX3904_TIMER1_BASE, TX3904_TIMER_TCR,   0x20 );
35  TX3904_TIMER_WRITE( TX3904_TIMER1_BASE, TX3904_TIMER_CCDR, 0x3 );
36  TX3904_TIMER_WRITE( TX3904_TIMER1_BASE, TX3904_TIMER_TRR, 0x0 );
37  TX3904_TIMER_WRITE( TX3904_TIMER1_BASE, TX3904_TIMER_CPRA, 0xFFFFFFFF );
38  TX3904_TIMER_WRITE( TX3904_TIMER1_BASE, TX3904_TIMER_TISR, 0x00 );
39  TX3904_TIMER_WRITE( TX3904_TIMER1_BASE, TX3904_TIMER_ITMR, 0x0001 );
40  TX3904_TIMER_WRITE( TX3904_TIMER1_BASE, TX3904_TIMER_TCR,   0xe0 );
41}
42
43#define AVG_OVERHEAD      0  /* It typically takes N instructions */
44                             /*     to start/stop the timer. */
45#define LEAST_VALID       1  /* Don't trust a value lower than this */
46                             /* tx39 simulator can count instructions. :) */
47
48int benchmark_timerread(void)
49{
50  uint32_t          total;
51
52  total = TX3904_TIMER_READ( TX3904_TIMER1_BASE, TX3904_TIMER_TRR );
53
54  if ( benchmark_timerfind_average_overhead == 1 )
55    return total;          /* in one microsecond units */
56
57  if ( total < LEAST_VALID )
58    return 0;            /* below timer resolution */
59
60  return total - AVG_OVERHEAD;
61}
62
63rtems_status_code benchmark_timerempty_function( void )
64{
65  return RTEMS_SUCCESSFUL;
66}
67
68void benchmark_timerdisable_subtracting_average_overhead(
69  rtems_boolean find_flag
70)
71{
72  benchmark_timerfind_average_overhead = find_flag;
73}
Note: See TracBrowser for help on using the repository browser.