source: rtems/c/src/lib/libbsp/powerpc/score603e/timer/timer.c @ b14e2f2

4.104.114.84.95
Last change on this file since b14e2f2 was b14e2f2, checked in by Joel Sherrill <joel.sherrill@…>, on 09/04/03 at 18:52:35

2003-09-04 Joel Sherrill <joel@…>

  • PCI_bus/PCI.h, clock/clock.c, console/85c30.c, console/85c30.h, console/console.c, console/consolebsp.h, console/consolereserveresources.c, console/tbl85c30.c, include/bsp.h, include/coverhd.h, include/gen2.h, include/tod.h, startup/FPGA.c, startup/bspclean.c, startup/bspstart.c, startup/genpvec.c, startup/setvec.c, startup/vmeintr.c, timer/timer.c, tod/tod.c: URL for license changed.
  • Property mode set to 100644
File size: 1.6 KB
Line 
1/*  timer.c
2 *
3 *  This file implements a benchmark timer using the General Purpose Timer.
4 *
5 *  Notes:
6 *
7 *  BSP_TIMER_AVG_OVERHEAD and BSP_TIMER_LEAST_VALID are required to be
8 *  provided in bsp.h
9 *
10 *  COPYRIGHT (c) 1989-1997.
11 *  On-Line Applications Research Corporation (OAR).
12 *
13 *  The license and distribution terms for this file may in
14 *  the file LICENSE in this distribution or at
15 *  http://www.rtems.com/license/LICENSE.
16 *
17 *  $Id$
18 */
19
20#include <assert.h>
21
22#include <bsp.h>
23
24rtems_unsigned64 Timer_driver_Start_time;
25
26rtems_boolean Timer_driver_Find_average_overhead;
27
28/*
29 * Timer_initialize
30 */
31
32void Timer_initialize()
33{
34
35  /*
36   *  Timer runs long and accurate enough not to require an interrupt.
37   */
38
39  Timer_driver_Start_time = PPC_Get_timebase_register();
40}
41
42/*
43 *  Read_timer
44 */
45
46int Read_timer()
47{
48  rtems_unsigned64  clicks;
49  rtems_unsigned64  total64;
50  rtems_unsigned32  total;
51
52  /* approximately CLOCK_SPEED clicks per microsecond */
53
54  clicks = PPC_Get_timebase_register();
55
56  assert( clicks > Timer_driver_Start_time );
57
58  total64 = clicks - Timer_driver_Start_time;
59
60  assert( total64 <= 0xffffffff );  /* fits into a unsigned32 */
61
62  total = (rtems_unsigned32) total64;
63
64  if ( Timer_driver_Find_average_overhead == 1 )
65    return total;          /* in "clicks" of the decrementer units */
66
67  if ( total < BSP_TIMER_LEAST_VALID )
68    return 0;            /* below timer resolution */
69
70  return BSP_Convert_decrementer(total - BSP_TIMER_AVG_OVERHEAD);
71}
72
73rtems_status_code Empty_function( void )
74{
75  return RTEMS_SUCCESSFUL;
76}
77
78void Set_find_average_overhead(
79  rtems_boolean find_flag
80)
81{
82  Timer_driver_Find_average_overhead = find_flag;
83}
Note: See TracBrowser for help on using the repository browser.