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