New files.

This commit is contained in:
Joel Sherrill
1999-12-21 17:06:31 +00:00
parent a3ba9f9886
commit 5d807b5710
2 changed files with 165 additions and 0 deletions

View File

@@ -0,0 +1,65 @@
#
# $Id$
#
@SET_MAKE@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = ../../..
subdir = powerpc/mpc6xx/timer
RTEMS_ROOT = @RTEMS_ROOT@
PROJECT_ROOT = @PROJECT_ROOT@
VPATH = @srcdir@
# C source names, if any, go here -- minus the .c
C_PIECES = timer
C_FILES = $(C_PIECES:%=%.c)
C_O_FILES = $(C_PIECES:%=${ARCH}/%.o)
H_FILES =
# Assembly source names, if any, go here -- minus the .S
S_PIECES =
S_FILES = $(S_PIECES:%=%.S)
S_O_FILES = $(S_FILES:%.S=${ARCH}/%.o)
SRCS = $(C_FILES) $(CC_FILES) $(H_FILES) $(S_FILES)
OBJS = $(C_O_FILES) $(CC_O_FILES) $(S_O_FILES)
include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
include $(RTEMS_ROOT)/make/leaf.cfg
INSTALL_CHANGE = @INSTALL_CHANGE@
#
# (OPTIONAL) Add local stuff here using +=
#
DEFINES +=
CPPFLAGS +=
CFLAGS +=
LD_PATHS +=
LD_LIBS +=
LDFLAGS +=
#
# Add your list of files to delete here. The config files
# already know how to delete some stuff, so you may want
# to just run 'make clean' first to see what gets missed.
# 'make clobber' already includes 'make clean'
#
CLEAN_ADDITIONS +=
CLOBBER_ADDITIONS +=
all: ${ARCH} $(SRCS) $(OBJS)
# the .rel file built here will be put into libbsp.a by ../wrapup/Makefile
install: all
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
cd $(top_builddir) \
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status

View File

@@ -0,0 +1,100 @@
/* 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 <libcpu/cpu.h>
#include <bsp.h>
rtems_unsigned64 Timer_driver_Start_time;
rtems_boolean Timer_driver_Find_average_overhead = 0;
unsigned clicks_overhead = 0;
/*
* Timer Get overhead
*/
int Timer_get_clicks_overhead()
{
rtems_unsigned64 clicks;
PPC_Set_timebase_register((unsigned64) 0);
clicks = PPC_Get_timebase_register();
assert(clicks <= 0xffffffff);
clicks_overhead = (unsigned) clicks;
return clicks_overhead;
}
/*
* Timer_initialize
*/
void Timer_initialize()
{
/*
* Timer runs long and accurate enough not to require an interrupt.
*/
if (clicks_overhead == 0) clicks_overhead = Timer_get_clicks_overhead();
PPC_Set_timebase_register((unsigned64) 0);
}
/*
* Read_timer
*/
int Read_timer()
{
rtems_unsigned64 total64;
rtems_unsigned32 total;
/* approximately CLOCK_SPEED clicks per microsecond */
total64 = PPC_Get_timebase_register();
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 */
return (int) BSP_Convert_decrementer(total - clicks_overhead);
}
unsigned long long Read_long_timer()
{
rtems_unsigned64 total64;
total64 = PPC_Get_timebase_register();
return BSP_Convert_decrementer(total64 - clicks_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;
}