diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 1999-02-18 16:48:14 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 1999-02-18 16:48:14 +0000 |
commit | 0c04c377bc8ac177d28bd0e0096d7c6940d33cd4 (patch) | |
tree | ba3062eb819e89de2eee14397ffe61b202ad10de /c/src/lib/libbsp/powerpc/ppcn_60x/timer/timer.c | |
parent | ./clock/Makefile.in,v (diff) | |
download | rtems-0c04c377bc8ac177d28bd0e0096d7c6940d33cd4.tar.bz2 |
./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
Diffstat (limited to '')
-rw-r--r-- | c/src/lib/libbsp/powerpc/ppcn_60x/timer/timer.c | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/c/src/lib/libbsp/powerpc/ppcn_60x/timer/timer.c b/c/src/lib/libbsp/powerpc/ppcn_60x/timer/timer.c new file mode 100644 index 0000000000..c96587a233 --- /dev/null +++ b/c/src/lib/libbsp/powerpc/ppcn_60x/timer/timer.c @@ -0,0 +1,82 @@ +/* timer.c + * + * This file implements a benchmark timer using the General Purpose Timer. + * + * Notes: + * + * BSP_TIMER_AVG_OVERHEAD and BSP_TIMER_LEAST_VALID are required to be + * provided in bsp.h + * + * COPYRIGHT (c) 1989-1997. + * On-Line Applications Research Corporation (OAR). + * Copyright assigned to U.S. Government, 1994. + * + * The license and distribution terms for this file may in + * the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * $Id$ + */ + +#include <assert.h> + +#include <bsp.h> + +rtems_unsigned64 Timer_driver_Start_time; + +rtems_boolean Timer_driver_Find_average_overhead; + +/* + * Timer_initialize + */ +void Timer_initialize() +{ + + /* + * Timer runs long and accurate enough not to require an interrupt. + */ + + Timer_driver_Start_time = PPC_Get_timebase_register(); +} + +/* + * Read_timer + */ +int Read_timer() +{ + rtems_unsigned64 clicks; + rtems_unsigned64 total64; + rtems_unsigned32 total; + + /* approximately CLOCK_SPEED clicks per microsecond */ + + clicks = PPC_Get_timebase_register(); + + assert( clicks > Timer_driver_Start_time ); + + total64 = clicks - Timer_driver_Start_time; + + assert( total64 <= 0xffffffff ); /* fits into a unsigned32 */ + + total = (rtems_unsigned32) total64; + + if ( Timer_driver_Find_average_overhead == 1 ) + return total; /* in "clicks" of the decrementer units */ + + if ( total < BSP_TIMER_LEAST_VALID ) + return 0; /* below timer resolution */ + + return BSP_Convert_decrementer(total - BSP_TIMER_AVG_OVERHEAD); +} + +rtems_status_code Empty_function( void ) +{ + return RTEMS_SUCCESSFUL; +} + +void Set_find_average_overhead( + rtems_boolean find_flag +) +{ + Timer_driver_Find_average_overhead = find_flag; +} |