source: rtems/c/src/lib/libbsp/powerpc/score603e/timer/timer.c @ c00b49f8

4.104.115
Last change on this file since c00b49f8 was 42b6dd2a, checked in by Jennifer Averett <Jennifer.Averett@…>, on 05/05/09 at 16:24:04

2009-05-05 Jennifer Averett <jennifer.averett@…>

  • Makefile.am, configure.ac, preinstall.am, PCI_bus/PCI.c, PCI_bus/PCI.h, PCI_bus/flash.c, PCI_bus/universe.c, console/85c30.c, console/85c30.h, console/console.c, console/consolebsp.h, console/tbl85c30.c, include/bsp.h, include/gen2.h, include/irq-config.h, include/tm27.h, irq/FPGA.c, irq/irq.h, irq/irq_init.c, start/start.S, startup/Hwr_init.c, startup/bspstart.c, startup/linkcmds, timer/timer.c, tod/tod.c, vme/VMEConfig.h: Updated and tested with latest interrupt source. Modified with latest memory allocation, but this needs testing.
  • irq/no_pic.c: New file.
  • Property mode set to 100644
File size: 1.6 KB
Line 
1/*  timer.c
2 *
3 *  This file implements a benchmark timer using the General Purpose Timer.
4 *
5 *  Notes:
6 *
7 *  BSP_TIMER_AVG_OVERHEAD and BSP_TIMER_LEAST_VALID are required to be
8 *  provided in bsp.h
9 *
10 *  COPYRIGHT (c) 1989-2009.
11 *  On-Line Applications Research Corporation (OAR).
12 *
13 *  The license and distribution terms for this file may be
14 *  found in the file LICENSE in this distribution or at
15 *  http://www.rtems.com/license/LICENSE.
16 *
17 *  $Id$
18 */
19
20#include <assert.h>
21
22#include <bsp.h>
23
24uint64_t         Timer_driver_Start_time;
25
26bool benchmark_timer_find_average_overhead;
27
28/*
29 * benchmark_timer_initialize
30 */
31
32void benchmark_timer_initialize()
33{
34
35  /*
36   *  Timer runs long and accurate enough not to require an interrupt.
37   */
38
39  Timer_driver_Start_time = PPC_Get_timebase_register();
40}
41
42/*
43 *  benchmark_timer_read
44 */
45
46int benchmark_timer_read()
47{
48  uint64_t          clicks;
49  uint64_t          total64;
50  uint32_t          total;
51
52  /* approximately CLOCK_SPEED clicks per microsecond */
53
54  clicks = PPC_Get_timebase_register();
55
56  assert( clicks > Timer_driver_Start_time );
57
58  total64 = clicks - Timer_driver_Start_time;
59
60  assert( total64 <= 0xffffffff );  /* fits into a uint32_t   */
61
62  total = (uint32_t) total64;
63
64  if ( benchmark_timer_find_average_overhead == true )
65    return total;          /* in "clicks" of the decrementer units */
66
67  if ( total < BSP_TIMER_LEAST_VALID )
68    return 0;            /* below timer resolution */
69
70  return BSP_Convert_decrementer(total - BSP_TIMER_AVG_OVERHEAD);
71}
72
73void benchmark_timer_disable_subtracting_average_overhead(
74  bool find_flag
75)
76{
77  benchmark_timer_find_average_overhead = find_flag;
78}
Note: See TracBrowser for help on using the repository browser.