Ignore:
Timestamp:
Apr 12, 2004, 10:04:28 PM (17 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
e69307b7
Parents:
db87589
Message:

2004-04-12 David Querbach <querbach@…>

  • README, configure.ac, mpc5xx/Makefile.am, mpc5xx/exceptions/raw_exception.c, mpc5xx/exceptions/raw_exception.h, mpc5xx/timer/timer.c, shared/include/cpuIdent.h: addition of a significant amount of MPC5xx support as part of the addition of the SS555 BSP.
  • mpc5xx/README, mpc5xx/clock/clock.c, mpc5xx/console-generic/console-generic.c, mpc5xx/include/console.h, mpc5xx/include/mpc5xx.h, mpc5xx/irq/irq.c, mpc5xx/irq/irq.h, mpc5xx/irq/irq_asm.S, mpc5xx/irq/irq_init.c, mpc5xx/vectors/vectors.S, mpc5xx/vectors/vectors.h, mpc5xx/vectors/vectors_init.c: New files.
  • mpc5xx/exceptions/asm_utils.S: Removed.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libcpu/powerpc/mpc5xx/timer/timer.c

    rdb87589 r8430205  
    11/*  timer.c
    22 *
    3  *  This file manages the benchmark timer used by the RTEMS Timing Test
    4  *  Suite.  Each measured time period is demarcated by calls to
    5  *  Timer_initialize() and Read_timer().  Read_timer() usually returns
    6  *  the number of microseconds since Timer_initialize() exitted.
     3 *  This file manages the interval timer on the PowerPC MPC5xx.
     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,
    77 *
     8 *  The following was in the 403 version of this file. I don't
     9 *  know what it means. JTM 5/19/98
    810 *  NOTE: It is important that the timer start/stop overhead be
    911 *        determined when porting or modifying this code.
    1012 *
    11  *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
     13 *
     14 *  MPC5xx port sponsored by Defence Research and Development Canada - Suffield
     15 *  Copyright (C) 2004, Real-Time Systems Inc. (querbach@realtime.bc.ca)
     16 *
     17 *  Derived from c/src/lib/libcpu/powerpc/mpc8xx/timer/timer.c:
     18 *
     19 *  Author: Jay Monkman (jmonkman@frasca.com)
     20 *  Copywright (C) 1998 by Frasca International, Inc.
     21 *
     22 *  Derived from c/src/lib/libcpu/ppc/ppc403/timer/timer.c:
     23 *
     24 *  Author:     Andrew Bray <andy@i-cubed.co.uk>
     25 *
     26 *  COPYRIGHT (c) 1995 by i-cubed ltd.
     27 *
     28 *  To anyone who acknowledges that this file is provided "AS IS"
     29 *  without any express or implied warranty:
     30 *      permission to use, copy, modify, and distribute this file
     31 *      for any purpose is hereby granted without fee, provided that
     32 *      the above copyright notice and this notice appears in all
     33 *      copies, and that the name of i-cubed limited not be used in
     34 *      advertising or publicity pertaining to distribution of the
     35 *      software without specific, written prior permission.
     36 *      i-cubed limited makes no representations about the suitability
     37 *      of this software for any purpose.
     38 *
     39 *  Derived from c/src/lib/libcpu/hppa1_1/timer/timer.c:
     40 *
     41 *  COPYRIGHT (c) 1989-1998.
    1242 *  On-Line Applications Research Corporation (OAR).
    13  *  All rights assigned to U.S. Government, 1994.
    1443 *
    15  *  This material may be reproduced by or for the U.S. Government pursuant
    16  *  to the copyright license under the clause at DFARS 252.227-7013.  This
    17  *  notice must appear in all copies of this file and its derivatives.
     44 *  The license and distribution terms for this file may be
     45 *  found in the file LICENSE in this distribution or at
     46 *  http://www.rtems.com/license/LICENSE.
    1847 *
    19  *  timer.c,v 1.2 1995/05/31 16:56:39 joel Exp
     48 *  $Id$
    2049 */
    2150
    2251#include <rtems.h>
     52#include <mpc5xx.h>
    2353
    24 rtems_boolean Timer_driver_Find_average_overhead;
     54static volatile rtems_unsigned32 Timer_starting;
     55static rtems_boolean Timer_driver_Find_average_overhead;
    2556
    26 static unsigned int volatile lastInitValue;
     57/*
     58 *  This is so small that this code will be reproduced where needed.
     59 */
     60static inline rtems_unsigned32 get_itimer(void)
     61{
     62   rtems_unsigned32 ret;
    2763
    28 void Timer_initialize( void )
    29 {
    30   asm volatile( " mftb %0": "=r" (lastInitValue) );
     64   asm volatile ("mftb %0" : "=r" ((ret))); /* TBLO */
     65
     66   return ret;
    3167}
    3268
    33 /*
    34  *  The following controls the behavior of Read_timer().
    35  *
    36  *  AVG_OVEREHAD is the overhead for starting and stopping the timer.  It
    37  *  is usually deducted from the number returned.
    38  *
    39  *  LEAST_VALID is the lowest number this routine should trust.  Numbers
    40  *  below this are "noise" and zero is returned.
    41  */
    42 
    43 #define AVG_OVERHEAD      0  /* It typically takes X.X microseconds */
    44                              /* (Y countdowns) to start/stop the timer. */
    45                              /* This value is in microseconds. */
    46 #define LEAST_VALID       1  /* Don't trust a clicks value lower than this */
    47 
    48 int Read_timer( void )
     69void Timer_initialize(void)
    4970{
    50   uint32_t   value;
    51   asm volatile ( " mftb %0": "=r" (value) );
    52   return value - lastInitValue;
     71  /* set interrupt level and enable timebase. This should never */
     72  /*  generate an interrupt however. */
     73  usiu.tbscrk = USIU_UNLOCK_KEY;
     74  usiu.tbscr |= USIU_TBSCR_TBIRQ(4)     /* interrupt priority level */
     75              | USIU_TBSCR_TBF          /* freeze timebase during debug */
     76              | USIU_TBSCR_TBE;         /* enable timebase */
     77  usiu.tbscrk = 0;
     78 
     79  Timer_starting = get_itimer();
    5380}
    5481
    55 /*
    56  *  Empty function call used in loops to measure basic cost of looping
    57  *  in Timing Test Suite.
    58  */
     82#ifndef  rtems_cpu_configuration_get_timer_least_valid
     83#define  rtems_cpu_configuration_get_timer_least_valid() 0
     84#endif
    5985
    60 rtems_status_code Empty_function( void )
     86#ifndef  rtems_cpu_configuration_get_timer_average_overhead
     87#define  rtems_cpu_configuration_get_timer_average_overhead() 0
     88#endif
     89
     90int Read_timer(void)
     91{
     92  rtems_unsigned32 clicks;
     93  rtems_unsigned32 total;
     94
     95  clicks = get_itimer();
     96
     97  total = clicks - Timer_starting;
     98
     99  if ( Timer_driver_Find_average_overhead == 1 )
     100    return total;          /* in XXX microsecond units */
     101
     102  else {
     103    if ( total < rtems_cpu_configuration_get_timer_least_valid() ) {
     104      return 0;            /* below timer resolution */
     105    }
     106    return (total - rtems_cpu_configuration_get_timer_average_overhead());
     107  }
     108}
     109
     110rtems_status_code Empty_function(void)
    61111{
    62112  return RTEMS_SUCCESSFUL;
    63113}
    64114
    65 void Set_find_average_overhead(
    66   rtems_boolean find_flag
    67 )
     115void Set_find_average_overhead(rtems_boolean find_flag)
    68116{
    69117  Timer_driver_Find_average_overhead = find_flag;
Note: See TracChangeset for help on using the changeset viewer.