source: rtems/c/src/lib/libcpu/powerpc/ppc403/timer/timer.c @ c499856

4.11
Last change on this file since c499856 was c499856, checked in by Chris Johns <chrisj@…>, on Mar 20, 2014 at 9:10:47 PM

Change all references of rtems.com to rtems.org.

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