OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [lib/] [libbsp/] [powerpc/] [score603e/] [timer/] [timer.c] - Blame information for rev 30

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*  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
 *  Copyright assigned to U.S. Government, 1994.
13
 *
14
 *  The license and distribution terms for this file may in
15
 *  the file LICENSE in this distribution or at
16
 *  http://www.OARcorp.com/rtems/license.html.
17
 *
18
 *  $Id: timer.c,v 1.2 2001-09-27 12:01:04 chris Exp $
19
 */
20
 
21
#include <assert.h>
22
 
23
#include <bsp.h>
24
 
25
rtems_unsigned64 Timer_driver_Start_time;
26
 
27
rtems_boolean Timer_driver_Find_average_overhead;
28
 
29
/*
30
 * Timer_initialize
31
 */
32
 
33
void Timer_initialize()
34
{
35
 
36
  /*
37
   *  Timer runs long and accurate enough not to require an interrupt.
38
   */
39
 
40
  Timer_driver_Start_time = PPC_Get_timebase_register();
41
}
42
 
43
/*
44
 *  Read_timer
45
 */
46
 
47
int Read_timer()
48
{
49
  rtems_unsigned64  clicks;
50
  rtems_unsigned64  total64;
51
  rtems_unsigned32  total;
52
 
53
  /* approximately CLOCK_SPEED clicks per microsecond */
54
 
55
  clicks = PPC_Get_timebase_register();
56
 
57
  assert( clicks > Timer_driver_Start_time );
58
 
59
  total64 = clicks - Timer_driver_Start_time;
60
 
61
  assert( total64 <= 0xffffffff );  /* fits into a unsigned32 */
62
 
63
  total = (rtems_unsigned32) total64;
64
 
65
  if ( Timer_driver_Find_average_overhead == 1 )
66
    return total;          /* in "clicks" of the decrementer units */
67
 
68
  if ( total < BSP_TIMER_LEAST_VALID )
69
    return 0;            /* below timer resolution */
70
 
71
  return BSP_Convert_decrementer(total - BSP_TIMER_AVG_OVERHEAD);
72
}
73
 
74
rtems_status_code Empty_function( void )
75
{
76
  return RTEMS_SUCCESSFUL;
77
}
78
 
79
void Set_find_average_overhead(
80
  rtems_boolean find_flag
81
)
82
{
83
  Timer_driver_Find_average_overhead = find_flag;
84
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.