source: rtems/c/src/lib/libcpu/powerpc/mpc8260/timer/timer.c @ 66c373bf

4.104.114.84.95
Last change on this file since 66c373bf was 66c373bf, checked in by Ralf Corsepius <ralf.corsepius@…>, on 03/31/04 at 02:04:00

2004-03-30 Ralf Corsepius <ralf_corsepius@…>

  • mpc505/timer/timer.c, mpc5xx/timer/timer.c, mpc6xx/clock/c_clock.c, mpc6xx/timer/timer.c, mpc8260/clock/clock.c, mpc8260/console-generic/console-generic.c, mpc8260/cpm/cp.c, mpc8260/cpm/dpram.c, mpc8260/include/cpm.h, mpc8260/include/mmu.h, mpc8260/include/mpc8260.h, mpc8260/mmu/mmu.c, mpc8260/timer/timer.c, mpc8xx/clock/clock.c, mpc8xx/console-generic/console-generic.c, mpc8xx/cpm/cp.c, mpc8xx/cpm/dpram.c, mpc8xx/include/cpm.h, mpc8xx/include/mmu.h, mpc8xx/include/mpc8xx.h, mpc8xx/mmu/mmu.c, mpc8xx/timer/timer.c, ppc403/clock/clock.c, ppc403/console/console.c, ppc403/console/console405.c, ppc403/ictrl/ictrl.c, ppc403/ictrl/ictrl.h, ppc403/timer/timer.c, ppc403/tty_drv/tty_drv.c, rtems/powerpc/cache.h, shared/src/cache.c: Convert to using c99 fixed size types.
  • Property mode set to 100644
File size: 3.2 KB
Line 
1/*  timer.c
2 *
3 *  This file manages the interval timer on the PowerPC MPC860.
4 *  NOTE: This is not the PIT, but rather the RTEMS interval
5 *        timer
6 *  We shall use the bottom 32 bits of the timebase register,
7 *
8 *  The following was in the 403 version of this file. I don't
9 *  know what it means. JTM 5/19/98
10 *  NOTE: It is important that the timer start/stop overhead be
11 *        determined when porting or modifying this code.
12 *
13 *  Author: Andy Dachs <a.dachs@sstl.co.uk>
14 *  Surrey Satellite Technlogy Limited
15 *   Modified for MPC8260
16 *   Derived from c/src/lib/libcpu/powerpc/mpc860/timer/timer.c:
17 *
18 *  Author: Jay Monkman (jmonkman@frasca.com)
19 *  Copywright (C) 1998 by Frasca International, Inc.
20 *
21 *  Derived from c/src/lib/libcpu/ppc/ppc403/timer/timer.c:
22 *
23 *  Author:     Andrew Bray <andy@i-cubed.co.uk>
24 *
25 *  COPYRIGHT (c) 1995 by i-cubed ltd.
26 *
27 *  To anyone who acknowledges that this file is provided "AS IS"
28 *  without any express or implied warranty:
29 *      permission to use, copy, modify, and distribute this file
30 *      for any purpose is hereby granted without fee, provided that
31 *      the above copyright notice and this notice appears in all
32 *      copies, and that the name of i-cubed limited not be used in
33 *      advertising or publicity pertaining to distribution of the
34 *      software without specific, written prior permission.
35 *      i-cubed limited makes no representations about the suitability
36 *      of this software for any purpose.
37 *
38 *  Derived from c/src/lib/libcpu/hppa1_1/timer/timer.c:
39 *
40 *  COPYRIGHT (c) 1989-1999.
41 *  On-Line Applications Research Corporation (OAR).
42 *
43 *  The license and distribution terms for this file may be
44 *  found in the file LICENSE in this distribution or at
45 *  http://www.rtems.com/license/LICENSE.
46 *
47 *  $Id$
48 */
49
50#include <rtems.h>
51#include <mpc8260.h>
52
53static volatile uint32_t   Timer_starting;
54static rtems_boolean Timer_driver_Find_average_overhead;
55
56extern rtems_cpu_table Cpu_table;
57#define rtems_cpu_configuration_get_timer_average_overhead() \
58   (Cpu_table.timer_average_overhead)
59
60#define rtems_cpu_configuration_get_timer_least_valid() \
61   (Cpu_table.timer_least_valid)
62
63/*
64 *  This is so small that this code will be reproduced where needed.
65 */
66static inline uint32_t   get_itimer(void)
67{
68   uint32_t   ret;
69
70   asm volatile ("mftb %0" : "=r" ((ret))); /* TBLO */
71
72   return ret;
73}
74
75void Timer_initialize(void)
76{
77  /* set interrupt level and enable timebase. This should never */
78  /*  generate an interrupt however. */
79
80/*
81  m860.tbscr |= M860_TBSCR_TBIRQ(4) | M860_TBSCR_TBE;
82*/
83                               
84
85  Timer_starting = get_itimer();
86}
87
88int Read_timer(void)
89{
90  uint32_t   clicks;
91  uint32_t   total;
92
93  clicks = get_itimer();
94
95  total = clicks - Timer_starting;
96
97  if ( Timer_driver_Find_average_overhead == 1 )
98    return total;          /* in XXX microsecond units */
99
100  else {
101    if ( total < rtems_cpu_configuration_get_timer_least_valid() ) {
102      return 0;            /* below timer resolution */
103    }
104    return (total - rtems_cpu_configuration_get_timer_average_overhead());
105  }
106}
107
108rtems_status_code Empty_function(void)
109{
110  return RTEMS_SUCCESSFUL;
111}
112
113void Set_find_average_overhead(rtems_boolean find_flag)
114{
115  Timer_driver_Find_average_overhead = find_flag;
116}
Note: See TracBrowser for help on using the repository browser.