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

4.104.114.95
Last change on this file since 3c6fe2e was 3c6fe2e, checked in by Thomas Doerfler <Thomas.Doerfler@…>, on 07/14/08 at 08:46:06

added haleakala BSP contributed by Michael Hamel

  • 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.com/license/LICENSE.
32 *
33 *  Modifications for PPC405GP by Dennis Ehlin
34 *
35 *  Further mods for PPC405EX/EXr by Michael Hamel
36 *
37 *  $Id$
38 *
39 */
40
41#include <rtems.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 rtems_boolean            subtractOverhead;
49
50void Timer_initialize()
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
56int Read_timer()
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
70rtems_status_code Empty_function( void )
71{
72        return RTEMS_SUCCESSFUL;
73}
74
75void Set_find_average_overhead( rtems_boolean find_flag)
76{
77        subtractOverhead = find_flag;
78}
Note: See TracBrowser for help on using the repository browser.