[63de714c] | 1 | /*===============================================================*\ |
---|
| 2 | | Project: RTEMS TQM8xx BSP | |
---|
| 3 | +-----------------------------------------------------------------+ |
---|
| 4 | | This file has been adapted to MPC8xx by | |
---|
| 5 | | Thomas Doerfler <Thomas.Doerfler@embedded-brains.de> | |
---|
| 6 | | Copyright (c) 2008 | |
---|
| 7 | | Embedded Brains GmbH | |
---|
| 8 | | Obere Lagerstr. 30 | |
---|
| 9 | | D-82178 Puchheim | |
---|
| 10 | | Germany | |
---|
| 11 | | rtems@embedded-brains.de | |
---|
| 12 | | | |
---|
| 13 | | See the other copyright notice below for the original parts. | |
---|
| 14 | +-----------------------------------------------------------------+ |
---|
| 15 | | The license and distribution terms for this file may be | |
---|
| 16 | | found in the file LICENSE in this distribution or at | |
---|
| 17 | | | |
---|
[c499856] | 18 | | http://www.rtems.org/license/LICENSE. | |
---|
[63de714c] | 19 | | | |
---|
| 20 | +-----------------------------------------------------------------+ |
---|
| 21 | | this file contains the console driver | |
---|
| 22 | \*===============================================================*/ |
---|
| 23 | /* |
---|
[290da88f] | 24 | * benchmark_timer_initialize() |
---|
[63de714c] | 25 | * |
---|
| 26 | * Use TIMER 1 and TIMER 2 for Timing Test Suite |
---|
| 27 | * |
---|
| 28 | * this is derived from "timer.c" available in the m68k/gen68360 BSP |
---|
| 29 | * adapted by Thomas Doerfler <Thomas.Doerfler@embedded-brains.de> |
---|
| 30 | */ |
---|
| 31 | |
---|
| 32 | /* |
---|
| 33 | * |
---|
| 34 | * Input parameters: NONE |
---|
| 35 | * |
---|
| 36 | * Output parameters: NONE |
---|
| 37 | * |
---|
| 38 | * NOTE: It is important that the timer start/stop overhead be |
---|
| 39 | * determined when porting or modifying this code. |
---|
| 40 | * |
---|
| 41 | * COPYRIGHT (c) 1989-1999. |
---|
| 42 | * On-Line Applications Research Corporation (OAR). |
---|
| 43 | * |
---|
| 44 | * The license and distribution terms for this file may be |
---|
| 45 | * found in the file LICENSE in this distribution or at |
---|
[c499856] | 46 | * http://www.rtems.org/license/LICENSE. |
---|
[63de714c] | 47 | */ |
---|
| 48 | |
---|
| 49 | #include <rtems.h> |
---|
| 50 | #include <bsp.h> |
---|
[d085040] | 51 | #include <rtems/btimer.h> |
---|
[63de714c] | 52 | #include <mpc8xx.h> |
---|
| 53 | |
---|
[290da88f] | 54 | bool benchmark_timer_find_average_overhead; |
---|
| 55 | |
---|
[63de714c] | 56 | void |
---|
[290da88f] | 57 | benchmark_timer_initialize (void) |
---|
[63de714c] | 58 | { |
---|
| 59 | /* |
---|
| 60 | * Reset timers 1 and 2 |
---|
| 61 | */ |
---|
| 62 | m8xx.tgcr &= ~0x00FF; |
---|
| 63 | m8xx.tcn1 = 0; |
---|
| 64 | m8xx.tcn2 = 0; |
---|
| 65 | m8xx.ter1 = 0xFFFF; |
---|
| 66 | m8xx.ter2 = 0xFFFF; |
---|
| 67 | |
---|
| 68 | /* |
---|
| 69 | * Cascade timers 1 and 2 |
---|
| 70 | */ |
---|
| 71 | m8xx.tgcr |= M8xx_TGCR_CAS2; |
---|
| 72 | |
---|
| 73 | /* |
---|
| 74 | * Configure timers 1 and 2 to a single 32-bit, BUS_clock timer. |
---|
| 75 | */ |
---|
| 76 | m8xx.tmr2 = (0 << 8) | 0x2; |
---|
| 77 | m8xx.tmr1 = 0; |
---|
| 78 | |
---|
| 79 | /* |
---|
| 80 | * Start the timers |
---|
| 81 | */ |
---|
| 82 | m8xx.tgcr |= 0x0011; |
---|
| 83 | } |
---|
| 84 | |
---|
| 85 | /* |
---|
| 86 | * Return timer value in microsecond units |
---|
| 87 | */ |
---|
[8fbe2e6] | 88 | benchmark_timer_t benchmark_timer_read(void) |
---|
[63de714c] | 89 | { |
---|
[d085040] | 90 | uint32_t retval; |
---|
[63de714c] | 91 | retval = *(uint32_t*)&m8xx.tcn1; |
---|
| 92 | retval = retval * 1000000LL / BSP_bus_frequency; |
---|
| 93 | return retval; |
---|
| 94 | } |
---|
| 95 | |
---|
[290da88f] | 96 | void benchmark_timer_disable_subtracting_average_overhead( |
---|
| 97 | bool find_flag |
---|
| 98 | ) |
---|
[63de714c] | 99 | { |
---|
[290da88f] | 100 | benchmark_timer_find_average_overhead = find_flag; |
---|
[63de714c] | 101 | } |
---|