diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2001-10-22 13:42:45 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2001-10-22 13:42:45 +0000 |
commit | 1ec501c567ddc0cd377d6a14766d2306e12ccefc (patch) | |
tree | d1aa683bd72fd9a10bd8757153c0093f14f130df /c/src/lib/libcpu/powerpc/mpc8260/timer/timer.c | |
parent | 2001-10-22 Joel Sherrill <joel@OARcorp.com> (diff) | |
download | rtems-1ec501c567ddc0cd377d6a14766d2306e12ccefc.tar.bz2 |
2001-10-22 Andy Dachs <a.dachs@sstl.co.uk>
* Added mpc8260 directory.
* Modified Makefile.am and configure.in to build the contents
* mpc8260/Makefile.am, mpc8260/README, mpc8260/clock/Makefile.am,
mpc8260/clock/clock.c, mpc8260/console-generic/Makefile.am,
mpc8260/console-generic/console-generic.c, mpc8260/cpm/.cvsignore,
mpc8260/cpm/Makefile.am, mpc8260/cpm/brg.c, mpc8260/cpm/cp.c,
mpc8260/cpm/dpram.c, mpc8260/exceptions/.cvsignore,
mpc8260/exceptions/Makefile.am, mpc8260/exceptions/asm_utils.S,
mpc8260/exceptions/raw_exception.c, mpc8260/exceptions/raw_exception.h,
mpc8260/include/Makefile.am, mpc8260/include/console.h,
mpc8260/include/cpm.h, mpc8260/include/mmu.h,
mpc8260/include/mpc8260.h, mpc8260/mmu/Makefile.am, mpc8260/mmu/mmu.c,
mpc8260/timer/Makefile.am, mpc8260/timer/timer.c: New files.
Diffstat (limited to '')
-rw-r--r-- | c/src/lib/libcpu/powerpc/mpc8260/timer/timer.c | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/c/src/lib/libcpu/powerpc/mpc8260/timer/timer.c b/c/src/lib/libcpu/powerpc/mpc8260/timer/timer.c new file mode 100644 index 0000000000..19f7abf075 --- /dev/null +++ b/c/src/lib/libcpu/powerpc/mpc8260/timer/timer.c @@ -0,0 +1,116 @@ +/* timer.c + * + * This file manages the interval timer on the PowerPC MPC860. + * NOTE: This is not the PIT, but rather the RTEMS interval + * timer + * We shall use the bottom 32 bits of the timebase register, + * + * The following was in the 403 version of this file. I don't + * know what it means. JTM 5/19/98 + * NOTE: It is important that the timer start/stop overhead be + * determined when porting or modifying this code. + * + * Author: Andy Dachs <a.dachs@sstl.co.uk> + * Surrey Satellite Technlogy Limited + * Modified for MPC8260 + * Derived from c/src/lib/libcpu/powerpc/mpc860/timer/timer.c: + * + * Author: Jay Monkman (jmonkman@frasca.com) + * Copywright (C) 1998 by Frasca International, Inc. + * + * Derived from c/src/lib/libcpu/ppc/ppc403/timer/timer.c: + * + * Author: Andrew Bray <andy@i-cubed.co.uk> + * + * COPYRIGHT (c) 1995 by i-cubed ltd. + * + * To anyone who acknowledges that this file is provided "AS IS" + * without any express or implied warranty: + * permission to use, copy, modify, and distribute this file + * for any purpose is hereby granted without fee, provided that + * the above copyright notice and this notice appears in all + * copies, and that the name of i-cubed limited not be used in + * advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * i-cubed limited makes no representations about the suitability + * of this software for any purpose. + * + * Derived from c/src/lib/libcpu/hppa1_1/timer/timer.c: + * + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * $Id$ + */ + +#include <rtems.h> +#include <mpc8260.h> + +static volatile rtems_unsigned32 Timer_starting; +static rtems_boolean Timer_driver_Find_average_overhead; + +extern rtems_cpu_table Cpu_table; +#define rtems_cpu_configuration_get_timer_average_overhead() \ + (Cpu_table.timer_average_overhead) + +#define rtems_cpu_configuration_get_timer_least_valid() \ + (Cpu_table.timer_least_valid) + +/* + * This is so small that this code will be reproduced where needed. + */ +static inline rtems_unsigned32 get_itimer(void) +{ + rtems_unsigned32 ret; + + asm volatile ("mftb %0" : "=r" ((ret))); /* TBLO */ + + return ret; +} + +void Timer_initialize(void) +{ + /* set interrupt level and enable timebase. This should never */ + /* generate an interrupt however. */ + +/* + m860.tbscr |= M860_TBSCR_TBIRQ(4) | M860_TBSCR_TBE; +*/ + + + Timer_starting = get_itimer(); +} + +int Read_timer(void) +{ + rtems_unsigned32 clicks; + rtems_unsigned32 total; + + clicks = get_itimer(); + + total = clicks - Timer_starting; + + if ( Timer_driver_Find_average_overhead == 1 ) + return total; /* in XXX microsecond units */ + + else { + if ( total < rtems_cpu_configuration_get_timer_least_valid() ) { + return 0; /* below timer resolution */ + } + return (total - rtems_cpu_configuration_get_timer_average_overhead()); + } +} + +rtems_status_code Empty_function(void) +{ + return RTEMS_SUCCESSFUL; +} + +void Set_find_average_overhead(rtems_boolean find_flag) +{ + Timer_driver_Find_average_overhead = find_flag; +} |