source: rtems/c/src/lib/libcpu/powerpc/ppc403/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.2 KB
Line 
1/**
2 *  @file
3 *  @brief Timer Driver for the PowerPC 405.
4 *
5 *  This file manages the interval timer on the PowerPC 405.
6 *  We shall use the bottom 32 bits of the timebase register,
7 */
8
9/*
10 *  Author: Andrew Bray <andy@i-cubed.co.uk>
11 *
12 *  COPYRIGHT (c) 1995 by i-cubed ltd.
13 *
14 *  To anyone who acknowledges that this file is provided "AS IS"
15 *  without any express or implied warranty:
16 *      permission to use, copy, modify, and distribute this file
17 *      for any purpose is hereby granted without fee, provided that
18 *      the above copyright notice and this notice appears in all
19 *      copies, and that the name of i-cubed limited not be used in
20 *      advertising or publicity pertaining to distribution of the
21 *      software without specific, written prior permission.
22 *      i-cubed limited makes no representations about the suitability
23 *      of this software for any purpose.
24 *
25 *  Derived from c/src/lib/libcpu/hppa1.1/timer/timer.c:
26 *
27 *  COPYRIGHT (c) 1989-2007.
28 *  On-Line Applications Research Corporation (OAR).
29 *
30 *  The license and distribution terms for this file may be
31 *  found in the file LICENSE in this distribution or at
32 *  http://www.rtems.org/license/LICENSE.
33 *
34 *  Modifications for PPC405GP by Dennis Ehlin
35 *
36 *  Further mods for PPC405EX/EXr by Michael Hamel
37 *
38 */
39
40#include <rtems.h>
41#include <rtems/btimer.h>
42#include <libcpu/powerpc-utility.h>
43
44extern uint32_t bsp_timer_least_valid;
45extern uint32_t bsp_timer_average_overhead;
46
47static volatile uint32_t        startedAt;
48static bool                     subtractOverhead;
49
50void benchmark_timer_initialize(void)
51{
52  /* We are going to rely on clock.c to sort out where the clock comes from */
53  startedAt = ppc_time_base();
54}
55
56benchmark_timer_t benchmark_timer_read(void)
57{
58        uint32_t   clicks, total;
59
60        clicks = ppc_time_base();
61        total = clicks - startedAt;
62        if ( ! subtractOverhead )
63                return total;          /* in XXX microsecond units */
64        else if ( total < bsp_timer_least_valid )
65                return 0;            /* below timer resolution */
66        else
67                return (total - bsp_timer_average_overhead);
68}
69
70void benchmark_timer_disable_subtracting_average_overhead(bool find_flag)
71{
72        subtractOverhead = find_flag;
73}
Note: See TracBrowser for help on using the repository browser.