source: rtems/c/src/lib/libcpu/powerpc/mpc6xx/timer/timer.c @ a73a977

4.104.114.84.95
Last change on this file since a73a977 was a73a977, checked in by Joel Sherrill <joel.sherrill@…>, on 04/18/02 at 20:55:37

2002-04-18 Ralf Corsepius <corsepiu@…>

  • shared/include/cpu.h: Removed.
  • shared/include/Makefile.am: Reflect changes above.
  • shared/include/spr.h: Include rtems/powerpc/registers.h instead of libcpu/cpu.h.
  • mpc6xx/clock/c_clock.c: Reflect changes to <rtems/score/cpu.h>.
  • mpc6xx/exceptions/asm_utils.S: Ditto.
  • mpc6xx/exceptions/raw_exception.c: Ditto.
  • mpc6xx/mmu/mmuAsm.S: Ditto.
  • mpc6xx/timer/timer.c: Ditto.
  • mpc8260/exceptions/asm_utils.S: Ditto.
  • mpc8260/exceptions/raw_exception.c: Ditto.
  • mpc8xx/exceptions/asm_utils.S: Ditto.
  • mpc8xx/exceptions/raw_exception.c: Ditto.
  • ppc403/vectors/vectors.S: Include <asm.h> instead of "asm.h".
  • Property mode set to 100644
File size: 1.9 KB
Line 
1/*  timer.c
2 *
3 *  This file implements a benchmark timer using the General Purpose Timer.
4 *
5 *  Notes: NONE
6 *
7 *  COPYRIGHT (c) 1989-2000.
8 *  On-Line Applications Research Corporation (OAR).
9 *
10 *  The license and distribution terms for this file may in
11 *  the file LICENSE in this distribution or at
12 *  http://www.OARcorp.com/rtems/license.html.
13 *
14 *  $Id$
15 */
16
17#include <rtems/system.h>
18#include <assert.h>
19#include <rtems.h>
20#include <bsp.h>
21
22rtems_unsigned64 Timer_driver_Start_time;
23
24rtems_boolean Timer_driver_Find_average_overhead = 0;
25unsigned clicks_overhead = 0;
26
27/*
28 * Timer Get overhead
29 */
30
31int Timer_get_clicks_overhead()
32{
33  rtems_unsigned64  clicks;
34
35  PPC_Set_timebase_register((unsigned64) 0);
36  clicks = PPC_Get_timebase_register();
37  assert(clicks <= 0xffffffff);
38  clicks_overhead = (unsigned) clicks;
39  return clicks_overhead;
40}
41
42/*
43 * Timer_initialize
44 */
45void Timer_initialize()
46{
47
48  /*
49   *  Timer runs long and accurate enough not to require an interrupt.
50   */
51
52  if (clicks_overhead == 0) clicks_overhead = Timer_get_clicks_overhead();
53  PPC_Set_timebase_register((unsigned64) 0);
54}
55
56
57/*
58 *  Read_timer
59 */
60
61int Read_timer()
62{
63  rtems_unsigned64  total64;
64  rtems_unsigned32  total;
65
66  /* approximately CLOCK_SPEED clicks per microsecond */
67
68  total64 = PPC_Get_timebase_register();
69
70  assert( total64 <= 0xffffffff );  /* fits into a unsigned32 */
71
72  total = (rtems_unsigned32) total64;
73
74  if ( Timer_driver_Find_average_overhead == 1 )
75    return total;          /* in "clicks" of the decrementer units */
76
77  return (int) BSP_Convert_decrementer(total - clicks_overhead);
78}
79
80unsigned long long Read_long_timer()
81{
82  rtems_unsigned64  total64;
83
84  total64 = PPC_Get_timebase_register();
85  return BSP_Convert_decrementer(total64 - clicks_overhead);
86}
87
88rtems_status_code Empty_function( void )
89{
90  return RTEMS_SUCCESSFUL;
91}
92
93void Set_find_average_overhead(
94  rtems_boolean find_flag
95)
96{
97  Timer_driver_Find_average_overhead = find_flag;
98}
Note: See TracBrowser for help on using the repository browser.