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

4.11
Last change on this file since 8fbe2e6 was 8fbe2e6, checked in by Joel Sherrill <joel.sherrill@…>, on Sep 4, 2014 at 1:59:49 PM

Use correct prototype of benchmark_timer_read()

This change starts with removing the effectively empty file
timerdrv.h. The prototypes for benchmark_timer_XXX() were in
btimer.h which was not universally used. Thus every use of
timerdrv.h had to be changed to btimer.h. Then the prototypes
for benchmark_timer_read() had to be adjusted to return
benchmark_timer_t rather than int or uint32_t.

I took this opportunity to also correct the file headers to
separate the copyright from the file description comments which
is needed to ensure the copyright isn't propagated into Doxygen
output.

  • Property mode set to 100644
File size: 1.9 KB
Line 
1/**
2 *  @file
3 *  @brief
4 *
5 *  This file implements a benchmark timer using the PPC Timebase
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2000.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may in
13 *  the file LICENSE in this distribution or at
14 *  http://www.rtems.org/license/LICENSE.
15 */
16
17#include <bsp.h>
18#include <rtems.h>
19#include <rtems/system.h>
20#include <rtems/btimer.h>
21#include <assert.h>
22#include <libcpu/powerpc-utility.h>
23
24
25uint64_t   Timer_driver_Start_time;
26
27bool benchmark_timer_find_average_overhead = false;
28unsigned clicks_overhead = 0;
29
30/*
31 * Timer Get overhead
32 */
33
34int Timer_get_clicks_overhead(void)
35{
36  uint64_t    clicks;
37
38  PPC_Set_timebase_register((uint64_t) 0);
39  clicks = PPC_Get_timebase_register();
40  assert(clicks <= 0xffffffff);
41  clicks_overhead = (unsigned) clicks;
42  return clicks_overhead;
43}
44
45/*
46 * benchmark_timer_initialize
47 */
48void benchmark_timer_initialize(void)
49{
50
51  /*
52   *  Timer runs long and accurate enough not to require an interrupt.
53   */
54
55  if (clicks_overhead == 0) clicks_overhead = Timer_get_clicks_overhead();
56  PPC_Set_timebase_register((uint64_t) 0);
57}
58
59
60/*
61 *  benchmark_timer_read
62 */
63
64benchmark_timer_t benchmark_timer_read(void)
65{
66  uint64_t    total64;
67  uint32_t    total;
68
69  /* approximately CLOCK_SPEED clicks per microsecond */
70
71  total64 = PPC_Get_timebase_register();
72
73  assert( total64 <= 0xffffffff );  /* fits into a uint32_t   */
74
75  total = (uint32_t) total64;
76
77  if ( benchmark_timer_find_average_overhead == true )
78    return total;          /* in "clicks" of the decrementer units */
79
80  return (int) BSP_Convert_decrementer(total - clicks_overhead);
81}
82
83unsigned long long Read_long_timer(void)
84{
85  uint64_t    total64;
86
87  total64 = PPC_Get_timebase_register();
88  return BSP_Convert_decrementer(total64 - clicks_overhead);
89}
90
91void benchmark_timer_disable_subtracting_average_overhead(bool find_flag)
92{
93  benchmark_timer_find_average_overhead = find_flag;
94}
Note: See TracBrowser for help on using the repository browser.