diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2018-04-20 12:08:42 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2018-04-20 13:52:19 +0200 |
commit | e0dd8a5ad830798bc8082b03b8c42c32fb9660e0 (patch) | |
tree | d147bfc4d670fcdfbd2e2d2e75eb209f92e07df1 /bsps/powerpc/tqm8xx | |
parent | bsps: Move startup files to bsps (diff) | |
download | rtems-e0dd8a5ad830798bc8082b03b8c42c32fb9660e0.tar.bz2 |
bsps: Move benchmark timer to bsps
This patch is a part of the BSP source reorganization.
Update #3285.
Diffstat (limited to 'bsps/powerpc/tqm8xx')
-rw-r--r-- | bsps/powerpc/tqm8xx/btimer/btimer.c | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/bsps/powerpc/tqm8xx/btimer/btimer.c b/bsps/powerpc/tqm8xx/btimer/btimer.c new file mode 100644 index 0000000000..06c43c56be --- /dev/null +++ b/bsps/powerpc/tqm8xx/btimer/btimer.c @@ -0,0 +1,101 @@ +/*===============================================================*\ +| Project: RTEMS TQM8xx BSP | ++-----------------------------------------------------------------+ +| This file has been adapted to MPC8xx by | +| Thomas Doerfler <Thomas.Doerfler@embedded-brains.de> | +| Copyright (c) 2008 | +| Embedded Brains GmbH | +| Obere Lagerstr. 30 | +| D-82178 Puchheim | +| Germany | +| rtems@embedded-brains.de | +| | +| See the other copyright notice below for the original parts. | ++-----------------------------------------------------------------+ +| The license and distribution terms for this file may be | +| found in the file LICENSE in this distribution or at | +| | +| http://www.rtems.org/license/LICENSE. | +| | ++-----------------------------------------------------------------+ +| this file contains the console driver | +\*===============================================================*/ +/* + * benchmark_timer_initialize() + * + * Use TIMER 1 and TIMER 2 for Timing Test Suite + * + * this is derived from "timer.c" available in the m68k/gen68360 BSP + * adapted by Thomas Doerfler <Thomas.Doerfler@embedded-brains.de> + */ + +/* + * + * Input parameters: NONE + * + * Output parameters: NONE + * + * NOTE: It is important that the timer start/stop overhead be + * determined when porting or modifying this code. + * + * 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.rtems.org/license/LICENSE. + */ + +#include <rtems.h> +#include <bsp.h> +#include <rtems/btimer.h> +#include <mpc8xx.h> + +bool benchmark_timer_find_average_overhead; + +void +benchmark_timer_initialize (void) +{ + /* + * Reset timers 1 and 2 + */ + m8xx.tgcr &= ~0x00FF; + m8xx.tcn1 = 0; + m8xx.tcn2 = 0; + m8xx.ter1 = 0xFFFF; + m8xx.ter2 = 0xFFFF; + + /* + * Cascade timers 1 and 2 + */ + m8xx.tgcr |= M8xx_TGCR_CAS2; + + /* + * Configure timers 1 and 2 to a single 32-bit, BUS_clock timer. + */ + m8xx.tmr2 = (0 << 8) | 0x2; + m8xx.tmr1 = 0; + + /* + * Start the timers + */ + m8xx.tgcr |= 0x0011; +} + +/* + * Return timer value in microsecond units + */ +benchmark_timer_t benchmark_timer_read(void) +{ + uint32_t retval; + retval = *(uint32_t*)&m8xx.tcn1; + retval = retval * 1000000LL / BSP_bus_frequency; + return retval; +} + +void benchmark_timer_disable_subtracting_average_overhead( + bool find_flag +) +{ + benchmark_timer_find_average_overhead = find_flag; +} |