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

Subversion Repositories openrisc_me

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

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:00:59 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
void 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
int Read_timer()
46
{
47
  rtems_unsigned64  clicks;
48
  rtems_unsigned64  total64;
49
  rtems_unsigned32  total;
50
 
51
  /* approximately CLOCK_SPEED clicks per microsecond */
52
 
53
  clicks = PPC_Get_timebase_register();
54
 
55
  assert( clicks > Timer_driver_Start_time );
56
 
57
  total64 = clicks - Timer_driver_Start_time;
58
 
59
  assert( total64 <= 0xffffffff );  /* fits into a unsigned32 */
60
 
61
  total = (rtems_unsigned32) total64;
62
 
63
  if ( Timer_driver_Find_average_overhead == 1 )
64
    return total;          /* in "clicks" of the decrementer units */
65
 
66
  if ( total < BSP_TIMER_LEAST_VALID )
67
    return 0;            /* below timer resolution */
68
 
69
  return BSP_Convert_decrementer(total - BSP_TIMER_AVG_OVERHEAD);
70
}
71
 
72
rtems_status_code Empty_function( void )
73
{
74
  return RTEMS_SUCCESSFUL;
75
}
76
 
77
void Set_find_average_overhead(
78
  rtems_boolean find_flag
79
)
80
{
81
  Timer_driver_Find_average_overhead = find_flag;
82
}

powered by: WebSVN 2.1.0

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