source: rtems/c/src/lib/libcpu/powerpc/mpc821/timer/timer.c @ 3084de2

4.104.114.84.95
Last change on this file since 3084de2 was 3084de2, checked in by Joel Sherrill <joel.sherrill@…>, on 04/07/99 at 15:57:05

MPC821 support and PPC patches from Andrew Bray <andy@…>:

In c/src/exec/score/cpu/powerpc/rtems/score/ppc.h:

A lot of hardware interrupts were omitted. Patch enclosed.
I have also added the 821.

In c/src/exec/score/cpu/powerpc/rtems/score/cpu.h:

My patch adds the 821.

In c/src/exec/score/cpu/powerpc/cpu.c:

I have added the MPC821, and also fixed up for the missing hardware
interrupts. It is also inconsistent with
c/src/lib/libcpu/powerpc/mpc860/vectors/vectors.S. This has been fixed.

In c/src/lib/libcpu/powerpc/mpc860/vectors/vectors.S:

Fixed an inconsistency with cpu.c.

I also include some new files to go with the above patches. These are the
cpu library rtems-19990331/c/src/lib/libcpu/powerpc/mpc821/* and
c/src/exec/score/cpu/powerpc/mpc821.h which are minor modifications of
the 860 equivalents.

Other comments:

The various accesses to the DPRAM on the 860 are done with a linktime
symbol. This could be done dynamically at run time by reading the immr
register, and masking off the lower 16 bits. This takes the same amount
of time as loading an address constant, and the same number of
instructions as well (2).

In c/src/lib/libcpu/powerpc/mpc860/console-generic/console-generic.c:

This will silently fail if you attempt to use SCC1. This is only relevant
if you are not using SCC1 for ethernet.

This file also sets one of port B output pins for each port. This is NOT
generic, it should be in the BSP specific console driver.

  • Property mode set to 100644
File size: 2.9 KB
Line 
1/*  timer.c
2 *
3 *  This file manages the interval timer on the PowerPC MPC821.
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: Jay Monkman (jmonkman@frasca.com)
14 *  Copywright (C) 1998 by Frasca International, Inc.
15 *
16 *  Derived from c/src/lib/libcpu/ppc/ppc403/timer/timer.c:
17 *
18 *  Author:     Andrew Bray <andy@i-cubed.co.uk>
19 *
20 *  COPYRIGHT (c) 1995 by i-cubed ltd.
21 *
22 *  To anyone who acknowledges that this file is provided "AS IS"
23 *  without any express or implied warranty:
24 *      permission to use, copy, modify, and distribute this file
25 *      for any purpose is hereby granted without fee, provided that
26 *      the above copyright notice and this notice appears in all
27 *      copies, and that the name of i-cubed limited not be used in
28 *      advertising or publicity pertaining to distribution of the
29 *      software without specific, written prior permission.
30 *      i-cubed limited makes no representations about the suitability
31 *      of this software for any purpose.
32 *
33 *  Derived from c/src/lib/libcpu/hppa1_1/timer/timer.c:
34 *
35 *  COPYRIGHT (c) 1989-1998.
36 *  On-Line Applications Research Corporation (OAR).
37 *  Copyright assigned to U.S. Government, 1994.
38 *
39 *  The license and distribution terms for this file may be
40 *  found in the file LICENSE in this distribution or at
41 *  http://www.OARcorp.com/rtems/license.html.
42 *
43 *  $Id$
44 */
45
46#include <bsp.h>
47#include <rtems.h>
48#include <mpc821.h>
49
50extern rtems_cpu_table           Cpu_table;             /* owned by BSP */
51
52static volatile rtems_unsigned32 Timer_starting;
53static rtems_boolean Timer_driver_Find_average_overhead;
54
55/*
56 *  This is so small that this code will be reproduced where needed.
57 */
58static inline rtems_unsigned32 get_itimer(void)
59{
60   rtems_unsigned32 ret;
61
62   asm volatile ("mftb %0" : "=r" ((ret))); /* TBLO */
63
64   return ret;
65}
66
67void Timer_initialize(void)
68{
69  /* set interrupt level and enable timebase. This should never */
70  /*  generate an interrupt however. */
71  m821.tbscr |= M821_TBSCR_TBIRQ(4) | M821_TBSCR_TBE;
72 
73  Timer_starting = get_itimer();
74}
75
76int Read_timer(void)
77{
78  rtems_unsigned32 clicks;
79  rtems_unsigned32 total;
80
81  clicks = get_itimer();
82
83  total = clicks - Timer_starting;
84
85  if ( Timer_driver_Find_average_overhead == 1 )
86    return total;          /* in XXX microsecond units */
87
88  else {
89    if ( total < Cpu_table.timer_least_valid ) {
90      return 0;            /* below timer resolution */
91    }
92    return (total - Cpu_table.timer_average_overhead);
93  }
94}
95
96rtems_status_code Empty_function(void)
97{
98  return RTEMS_SUCCESSFUL;
99}
100
101void Set_find_average_overhead(rtems_boolean find_flag)
102{
103  Timer_driver_Find_average_overhead = find_flag;
104}
Note: See TracBrowser for help on using the repository browser.