source: rtems/c/src/lib/libcpu/a29k/timer/timer.c @ 21677c0e

4.104.114.84.95
Last change on this file since 21677c0e was 21677c0e, checked in by Joel Sherrill <joel.sherrill@…>, on 01/26/00 at 14:20:08

Patch rtems-rc-20000118-0.diff from Ralf Corsepius <corsepiu@…>
that converts the a29k to automake.

This patch contains

  • An initial merger of the libcpu/a29k stuff you sent yesterday. AFAIS, most code inside them seems to be empty stubs. One file even contains a function called mips_* which might indicate that this part might contain mips code or the code the initial porter used as template for porting. Unfortunately, I don't know anything about the a29k so I can't comment on the details.
  • A dummy bsp_specs to libbsp/29k/portsw
  • An update to the automake files related to the a29k.

Note:

  • This patch is completely untested, because I don't have a toolchain for it.
  • The files in libcpu/a29k include bsp.h => The libbsp vs. libcpu-issue hits again.
  • Property mode set to 100644
File size: 3.1 KB
Line 
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 *  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#ifndef lint
23static char _sccsid[] = "@(#)timer.c 05/07/96     1.4\n";
24#endif
25
26#include <rtems.h>
27#include <bsp.h>
28
29#define CLOCKS_PER_MICROSECOND ( CPU_CLOCK_RATE_MHZ )
30#define TIMER_MAX_VALUE 0xffffffff
31
32extern unsigned32 mips_read_timer( void );
33
34static rtems_boolean Timer_driver_Find_average_overhead;
35static unsigned32 Timer_initial_value = 0;
36
37void Timer_initialize( void )
38{
39/*
40   Timer_initial_value = mips_read_timer();
41 */
42  /*
43   *  Somehow start the timer
44   */
45
46  /* Timer on 4650 is always running */
47}
48
49/*
50 *  The following controls the behavior of Read_timer().
51 *
52 *  AVG_OVEREHAD is the overhead for starting and stopping the timer.  It
53 *  is usually deducted from the number returned.
54 *
55 *  LEAST_VALID is the lowest number this routine should trust.  Numbers
56 *  below this are "noise" and zero is returned.
57 */
58
59#define AVG_OVERHEAD      8  /* It typically takes X.X microseconds */
60                             /* (Y countdowns) to start/stop the timer. */
61                             /* This value is in cycles. */
62#define LEAST_VALID       1  /* Don't trust a clicks value lower than this */
63
64int Read_timer( void )
65{
66  unsigned64 clicks;
67  unsigned32 total;
68
69  /*
70   *  Read the timer and see how many clicks it has been since we started.
71   */
72
73  clicks = mips_read_timer();   /* XXX: read some HW here */
74  if (clicks < Timer_initial_value)
75  {
76      clicks += TIMER_MAX_VALUE;
77  }
78  clicks -= Timer_initial_value;
79
80  /*
81   *  Total is calculated by taking into account the number of timer overflow
82   *  interrupts since the timer was initialized and clicks since the last
83   *  interrupts.
84   */
85#if 0 /* leave total in number of cycles */
86   total = clicks / CLOCKS_PER_MICROSECOND;
87#else
88   total = clicks;
89#endif
90
91  if ( Timer_driver_Find_average_overhead == 1 )
92    return total;          /* in # cycles units */
93  else {
94    if ( total < LEAST_VALID )
95      return 0;            /* below timer resolution */
96  /*
97   *  leave total in cycles
98   */
99      return (total - AVG_OVERHEAD);
100    }
101}
102
103/*
104 *  Empty function call used in loops to measure basic cost of looping
105 *  in Timing Test Suite.
106 */
107
108rtems_status_code Empty_function( void )
109{
110  return RTEMS_SUCCESSFUL;
111}
112
113void Set_find_average_overhead(
114  rtems_boolean find_flag
115)
116{
117  Timer_driver_Find_average_overhead = find_flag;
118}
119
Note: See TracBrowser for help on using the repository browser.