summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/i960/rxgen960/timer
diff options
context:
space:
mode:
Diffstat (limited to 'c/src/lib/libbsp/i960/rxgen960/timer')
-rw-r--r--c/src/lib/libbsp/i960/rxgen960/timer/Makefile.in59
-rw-r--r--c/src/lib/libbsp/i960/rxgen960/timer/timer.c133
-rw-r--r--c/src/lib/libbsp/i960/rxgen960/timer/timerisr.s65
3 files changed, 257 insertions, 0 deletions
diff --git a/c/src/lib/libbsp/i960/rxgen960/timer/Makefile.in b/c/src/lib/libbsp/i960/rxgen960/timer/Makefile.in
new file mode 100644
index 0000000000..34600c156e
--- /dev/null
+++ b/c/src/lib/libbsp/i960/rxgen960/timer/Makefile.in
@@ -0,0 +1,59 @@
+#
+# $Id$
+#
+
+@SET_MAKE@
+srcdir = @srcdir@
+VPATH = @srcdir@
+RTEMS_ROOT = @top_srcdir@
+PROJECT_ROOT = @PROJECT_ROOT@
+
+PGM=${ARCH}/timer.rel
+
+# 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) $(H_FILES) $(S_FILES)
+OBJS=$(C_O_FILES) $(S_O_FILES)
+
+include $(RTEMS_ROOT)/make/custom/$(RTEMS_BSP).cfg
+include $(RTEMS_ROOT)/make/leaf.cfg
+
+#
+# (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 +=
+
+${PGM}: ${SRCS} ${OBJS}
+ $(make-rel)
+
+all: ${ARCH} $(SRCS) $(PGM)
+
+# the .rel file built here will be put into libbsp.a by ../wrapup/Makefile
+install: all
diff --git a/c/src/lib/libbsp/i960/rxgen960/timer/timer.c b/c/src/lib/libbsp/i960/rxgen960/timer/timer.c
new file mode 100644
index 0000000000..8b166090e2
--- /dev/null
+++ b/c/src/lib/libbsp/i960/rxgen960/timer/timer.c
@@ -0,0 +1,133 @@
+/* Timer_init()
+ *
+ * This routine initializes the Z8536 timer on the SQSIO4 SQUALL
+ * board for the CVME961 board. The timer is setup to provide a
+ * tick every 1 millisecond.
+ *
+ * Input parameters: NONE
+ *
+ * Output parameters: NONE
+ *
+ * NOTE: This routine will not work if the optimizer is enabled
+ * for most compilers. The multiple writes to the Z8536
+ * will be optimized away.
+ *
+ * It is important that the timer start/stop overhead be
+ * determined when porting or modifying this code.
+ *
+ * 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 <rtems.h>
+#include <bsp.h>
+#include <stdlib.h>
+#include <i960RP.h>
+#include <rtems/libio.h>
+
+
+#define TIMER_VECTOR 34
+
+int Ttimer_val;
+rtems_boolean Timer_driver_Find_average_overhead = 0;
+
+void flush_reg();
+rtems_isr timerisr();
+
+void Timer_initialize()
+{
+ volatile unsigned int *tmr1 = (unsigned int *) TMR1_ADDR;
+ volatile unsigned int *trr1 = (unsigned int *) TRR1_ADDR;
+ volatile unsigned int *tcr1 = (unsigned int *) TCR1_ADDR;
+ volatile unsigned int *imsk = (unsigned int *) IMSK_ADDR;
+ volatile unsigned int *icon = (unsigned int *) ICON_ADDR;
+ volatile unsigned int *ipnd = (unsigned int *) IPND_ADDR;
+ volatile unsigned int *imap2 = (unsigned int *) IMAP2_ADDR;
+
+ #define BUS_CLOCK_1 0
+ #define TMR_WRITE_CNTL 8
+ #define TMR_AUTO_RELOAD 4
+ #define TMR_ENABLE 2
+ #define TMR_TERM_CNT_STAT 1
+
+ *tmr1 = BUS_CLOCK_1 | TMR_AUTO_RELOAD;
+ *icon = 0x6000;
+
+
+ set_vector( (((unsigned int) timerisr) | 0x2), TIMER_VECTOR, 1 );
+
+ *imap2 = (*imap2 & 0xff0fffff) | (((TIMER_VECTOR >> 4) & 0xf) << 20);
+
+ /* initialize the i960RP timer 1 here */
+
+ /* set the timer countdown */
+ *trr1 = 33 * BSP_Configuration.microseconds_per_tick;
+ *tcr1 = 33 * BSP_Configuration.microseconds_per_tick;
+
+ *ipnd &= ~(1<<13);
+ *imsk |= (1 << 13);
+ Ttimer_val = 0;
+ *tmr1 = BUS_CLOCK_1 | TMR_AUTO_RELOAD | TMR_ENABLE;
+
+}
+
+
+
+rtems_isr timerisr(
+ rtems_vector_number vector
+)
+{
+ /* enable_tracing(); */
+ Ttimer_val++;
+ i960_clear_intr( 13 );
+}
+
+#define AVG_OVERHEAD 4 /* It typically takes 5.5 microseconds */
+ /* (11 countdowns) to start/stop the timer. */
+#define LEAST_VALID 5 /* Don't trust a value lower than this */
+
+int Read_timer()
+{
+ volatile unsigned int *tcr1 = (unsigned int *) TCR1_ADDR;
+ volatile unsigned int *trr1 = (unsigned int *) TRR1_ADDR;
+ rtems_unsigned32 remaining, total;
+
+ /* this routine is supposed to count in 1/2 uSec units */
+ /* pretty funny when using a 33MHz clock for the counter */
+ remaining = *tcr1;
+ remaining = *trr1 - remaining;
+ total = (2 * ((Ttimer_val * *trr1) + remaining)) / 33;
+/*
+ putnum(remaining);
+ console_sps_putc(':');
+ putnum(total);
+*/
+
+ if ( Timer_driver_Find_average_overhead == 1 )
+ return total; /* in one-half microsecond units */
+ else {
+ if ( total < LEAST_VALID )
+ return 0; /* below timer resolution */
+ return (total-AVG_OVERHEAD) >> 1;
+ }
+}
+
+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;
+}
diff --git a/c/src/lib/libbsp/i960/rxgen960/timer/timerisr.s b/c/src/lib/libbsp/i960/rxgen960/timer/timerisr.s
new file mode 100644
index 0000000000..3c1368f130
--- /dev/null
+++ b/c/src/lib/libbsp/i960/rxgen960/timer/timerisr.s
@@ -0,0 +1,65 @@
+/* timer_isr()
+ *
+ * This routine initializes the Z8536 timer on the SQSIO4 SQUALL
+ * board for the CVME961 board. The timer is setup to provide a
+ * tick every 0x10000 / 2 milliseconds. This is used to time
+ * executing code.
+ *
+ * Input parameters: NONE
+ *
+ * Output parameters: NONE
+ *
+ * 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 "asm.h"
+
+.set PORT_A, 0xc00000a8 # port A
+.set PORT_B, 0xc00000a4 # port B
+.set PORT_C, 0xc00000a0 # port C
+.set CTL_PORT, 0xc00000ac # control port
+
+.set T1CSR, 0x0a # T1 command/status reg
+.set RELOAD, 0x24 # clr IP & IUS,allow countdown
+
+/*
+ * Duplicating this symbol is stupid but eliminates
+ * toolset variation problems.
+ */
+ PUBLIC(timerisr)
+ PUBLIC(_timerisr)
+SYM (timerisr):
+SYM (_timerisr):
+ #ldconst 1,r4
+ #modpc 0,r4,r4 # enable tracing
+
+ ld _Ttimer_val,r6 # r6 = test timer
+
+ ldconst T1CSR,r4 # r4 = T1 control status reg
+ stob r4,CTL_PORT # select T1CSR
+ ldconst RELOAD,r5 # r5 = reset value
+ stob r5,CTL_PORT # reset countdown
+ addo 1,r6,r6
+ st r6,_Ttimer_val # increment test timer
+loop_til_cleared:
+ clrbit 4,sf0,sf0
+ bbs 4,sf0,loop_til_cleared
+leaf: ret
+
+ .leafproc _flush_reg, flush_reg.lf
+ .globl _flush_reg, flush_reg.lf
+_flush_reg:
+ lda leaf,g14 # g14 = exit address
+flush_reg.lf:
+ flushreg
+ mov g14,g0 # g0 = exit address
+ ldconst 0,g14 # set g14 for non-leaf
+ bx (g0)