source: rtems/c/src/lib/libcpu/powerpc/mpc8260/timer/timer.c @ 6cd2074

4.115
Last change on this file since 6cd2074 was 8fbe2e6, checked in by Joel Sherrill <joel.sherrill@…>, on 09/04/14 at 13:59:49

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: 2.8 KB
Line 
1/**
2 *  @file
3 *  @brief Timer for the PowerPC MPC860
4 *
5 *  We shall use the bottom 32 bits of the timebase register,
6 *
7 *  @note This is not the PIT, but rather the RTEMS interval timer.
8 */
9
10/*
11 *  Author: Andy Dachs <a.dachs@sstl.co.uk>
12 *  Surrey Satellite Technlogy Limited
13 *   Modified for MPC8260
14 *   Derived from c/src/lib/libcpu/powerpc/mpc860/timer/timer.c:
15 *
16 *  Author: Jay Monkman (jmonkman@frasca.com)
17 *  Copywright (C) 1998 by Frasca International, Inc.
18 *
19 *  Derived from c/src/lib/libcpu/ppc/ppc403/timer/timer.c:
20 *
21 *  Author:     Andrew Bray <andy@i-cubed.co.uk>
22 *
23 *  COPYRIGHT (c) 1995 by i-cubed ltd.
24 *
25 *  To anyone who acknowledges that this file is provided "AS IS"
26 *  without any express or implied warranty:
27 *      permission to use, copy, modify, and distribute this file
28 *      for any purpose is hereby granted without fee, provided that
29 *      the above copyright notice and this notice appears in all
30 *      copies, and that the name of i-cubed limited not be used in
31 *      advertising or publicity pertaining to distribution of the
32 *      software without specific, written prior permission.
33 *      i-cubed limited makes no representations about the suitability
34 *      of this software for any purpose.
35 *
36 *  Derived from c/src/lib/libcpu/hppa1_1/timer/timer.c:
37 *
38 *  COPYRIGHT (c) 1989-2007.
39 *  On-Line Applications Research Corporation (OAR).
40 *
41 *  The license and distribution terms for this file may be
42 *  found in the file LICENSE in this distribution or at
43 *  http://www.rtems.org/license/LICENSE.
44 */
45
46#include <rtems.h>
47#include <rtems/btimer.h>
48#include <mpc8260.h>
49
50static volatile uint32_t   Timer_starting;
51static bool benchmark_timer_find_average_overhead;
52
53/*
54 *  This is so small that this code will be reproduced where needed.
55 */
56static inline uint32_t   get_itimer(void)
57{
58   uint32_t   ret;
59
60   __asm__ volatile ("mftb %0" : "=r" ((ret))); /* TBLO */
61
62   return ret;
63}
64
65void benchmark_timer_initialize(void)
66{
67  /* set interrupt level and enable timebase. This should never */
68  /*  generate an interrupt however. */
69
70/*
71  m860.tbscr |= M860_TBSCR_TBIRQ(4) | M860_TBSCR_TBE;
72*/
73
74
75  Timer_starting = get_itimer();
76}
77
78extern uint32_t bsp_timer_least_valid;
79extern uint32_t bsp_timer_average_overhead;
80benchmark_timer_t benchmark_timer_read(void)
81{
82  uint32_t   clicks;
83  uint32_t   total;
84
85  clicks = get_itimer();
86
87  total = clicks - Timer_starting;
88
89  if ( benchmark_timer_find_average_overhead == 1 )
90    return total;          /* in XXX microsecond units */
91
92  else {
93    if ( total < bsp_timer_least_valid ) {
94      return 0;            /* below timer resolution */
95    }
96    return (total - bsp_timer_average_overhead);
97  }
98}
99
100void benchmark_timer_disable_subtracting_average_overhead(bool find_flag)
101{
102  benchmark_timer_find_average_overhead = find_flag;
103}
Note: See TracBrowser for help on using the repository browser.