source: rtems/bsps/powerpc/tqm8xx/btimer/btimer.c @ a2dad96

5
Last change on this file since a2dad96 was e0dd8a5a, checked in by Sebastian Huber <sebastian.huber@…>, on 04/20/18 at 10:08:42

bsps: Move benchmark timer to bsps

This patch is a part of the BSP source reorganization.

Update #3285.

  • Property mode set to 100644
File size: 3.0 KB
Line 
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|                                                                 |
18| http://www.rtems.org/license/LICENSE.                           |
19|                                                                 |
20+-----------------------------------------------------------------+
21| this file contains the console driver                           |
22\*===============================================================*/
23/*
24 * benchmark_timer_initialize()
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
46 *  http://www.rtems.org/license/LICENSE.
47 */
48
49#include <rtems.h>
50#include <bsp.h>
51#include <rtems/btimer.h>
52#include <mpc8xx.h>
53
54bool benchmark_timer_find_average_overhead;
55
56void
57benchmark_timer_initialize (void)
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 */
88benchmark_timer_t benchmark_timer_read(void)
89{
90  uint32_t retval;
91  retval = *(uint32_t*)&m8xx.tcn1;
92  retval = retval * 1000000LL / BSP_bus_frequency;
93  return retval;
94}
95
96void benchmark_timer_disable_subtracting_average_overhead(
97  bool find_flag
98)
99{
100  benchmark_timer_find_average_overhead = find_flag;
101}
Note: See TracBrowser for help on using the repository browser.