source: rtems/c/src/lib/libbsp/powerpc/ppcn_60x/timer/timer.c @ eba2e4f

4.104.114.84.95
Last change on this file since eba2e4f was 0c04c377, checked in by Joel Sherrill <joel.sherrill@…>, on 02/18/99 at 16:48:14

./clock/Makefile.in,v
./clock/clock.c,v
./console/Makefile.in,v
./console/config.c,v
./console/console.c,v
./console/console.h,v
./console/debugio.c,v
./console/i8042.c,v
./console/i8042_p.h,v
./console/i8042vga.c,v
./console/i8042vga.h,v
./console/ns16550.c,v
./console/ns16550.h,v
./console/ns16550_p.h,v
./console/ns16550cfg.c,v
./console/ns16550cfg.h,v
./console/vga.c,v
./console/vga_p.h,v
./console/z85c30.c,v
./console/z85c30.h,v
./console/z85c30_p.h,v
./console/z85c30cfg.c,v
./console/z85c30cfg.h,v
./include/Makefile.in,v
./include/bsp.h,v
./include/chain.h,v
./include/coverhd.h,v
./include/extisrdrv.h,v
./include/nvram.h,v
./include/pci.h,v
./include/tod.h,v
./network/Makefile.in,v
./network/amd79c970.c,v
./network/amd79c970.h,v
./nvram/Makefile.in,v
./nvram/ds1385.h,v
./nvram/mk48t18.h,v
./nvram/nvram.c,v
./nvram/prepnvr.h,v
./nvram/stk11c68.h,v
./pci/Makefile.in,v
./pci/pci.c,v
./start/Makefile.in,v
./start/start.s,v
./startup/Makefile.in,v
./startup/bspclean.c,v
./startup/bspstart.c,v
./startup/bsptrap.s,v
./startup/device-tree,v
./startup/genpvec.c,v
./startup/linkcmds,v
./startup/rtems-ctor.cc,v
./startup/sbrk.c,v
./startup/setvec.c,v
./startup/spurious.c,v
./startup/swap.c,v
./timer/Makefile.in,v
./timer/timer.c,v
./tod/Makefile.in,v
./tod/cmos.h,v
./tod/tod.c,v
./universe/Makefile.in,v
./universe/universe.c,v
./vectors/Makefile.in,v
./vectors/README,v
./vectors/align_h.s,v
./vectors/vectors.s,v
./wrapup/Makefile.in,v
./Makefile.in,v
./README,v
./STATUS,v
./bsp_specs,v

  • Property mode set to 100644
File size: 1.7 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-1997.
11 *  On-Line Applications Research Corporation (OAR).
12 *  Copyright assigned to U.S. Government, 1994.
13 *
14 *  The license and distribution terms for this file may in
15 *  the file LICENSE in this distribution or at
16 *  http://www.OARcorp.com/rtems/license.html.
17 *
18 *  $Id$
19 */
20
21#include <assert.h>
22
23#include <bsp.h>
24
25rtems_unsigned64 Timer_driver_Start_time;
26
27rtems_boolean Timer_driver_Find_average_overhead;
28
29/*
30 * Timer_initialize
31 */
32void 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 *  Read_timer
44 */
45int Read_timer()
46{
47  rtems_unsigned64  clicks;
48  rtems_unsigned64  total64;
49  rtems_unsigned32  total;
50
51  /* approximately CLOCK_SPEED clicks per microsecond */
52
53  clicks = PPC_Get_timebase_register();
54
55  assert( clicks > Timer_driver_Start_time );
56
57  total64 = clicks - Timer_driver_Start_time;
58
59  assert( total64 <= 0xffffffff );  /* fits into a unsigned32 */
60
61  total = (rtems_unsigned32) total64;
62
63  if ( Timer_driver_Find_average_overhead == 1 )
64    return total;          /* in "clicks" of the decrementer units */
65
66  if ( total < BSP_TIMER_LEAST_VALID )
67    return 0;            /* below timer resolution */
68
69  return BSP_Convert_decrementer(total - BSP_TIMER_AVG_OVERHEAD);
70}
71
72rtems_status_code Empty_function( void )
73{
74  return RTEMS_SUCCESSFUL;
75}
76
77void Set_find_average_overhead(
78  rtems_boolean find_flag
79)
80{
81  Timer_driver_Find_average_overhead = find_flag;
82}
Note: See TracBrowser for help on using the repository browser.