summaryrefslogtreecommitdiffstats
path: root/c/src/lib
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1999-12-21 17:06:31 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1999-12-21 17:06:31 +0000
commit5d807b57107bd7a0719c1818c87ef86b3861c799 (patch)
tree068e30b05a392c81aecd40732650b7dcbba72f77 /c/src/lib
parentNew file. (diff)
downloadrtems-5d807b57107bd7a0719c1818c87ef86b3861c799.tar.bz2
New files.
Diffstat (limited to 'c/src/lib')
-rw-r--r--c/src/lib/libcpu/powerpc/mpc6xx/timer/Makefile.in65
-rw-r--r--c/src/lib/libcpu/powerpc/mpc6xx/timer/timer.c100
2 files changed, 165 insertions, 0 deletions
diff --git a/c/src/lib/libcpu/powerpc/mpc6xx/timer/Makefile.in b/c/src/lib/libcpu/powerpc/mpc6xx/timer/Makefile.in
new file mode 100644
index 0000000000..45342ebf39
--- /dev/null
+++ b/c/src/lib/libcpu/powerpc/mpc6xx/timer/Makefile.in
@@ -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
diff --git a/c/src/lib/libcpu/powerpc/mpc6xx/timer/timer.c b/c/src/lib/libcpu/powerpc/mpc6xx/timer/timer.c
new file mode 100644
index 0000000000..307cfcac6b
--- /dev/null
+++ b/c/src/lib/libcpu/powerpc/mpc6xx/timer/timer.c
@@ -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;
+}