summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/m68k
diff options
context:
space:
mode:
Diffstat (limited to 'c/src/lib/libbsp/m68k')
-rw-r--r--c/src/lib/libbsp/m68k/dmv152/clock/ckinit.c101
-rw-r--r--c/src/lib/libbsp/m68k/dmv152/console/console.c186
-rw-r--r--c/src/lib/libbsp/m68k/dmv152/include/bsp.h169
-rw-r--r--c/src/lib/libbsp/m68k/dmv152/include/coverhd.h104
-rw-r--r--c/src/lib/libbsp/m68k/dmv152/spurious/spinit.c46
-rw-r--r--c/src/lib/libbsp/m68k/dmv152/startup/bspstart.c171
-rw-r--r--c/src/lib/libbsp/m68k/dmv152/startup/linkcmds48
-rw-r--r--c/src/lib/libbsp/m68k/dmv152/startup/vmeintr.c60
-rw-r--r--c/src/lib/libbsp/m68k/dmv152/timer/timer.c105
-rw-r--r--c/src/lib/libbsp/m68k/dmv152/timer/timerisr.s38
-rw-r--r--c/src/lib/libbsp/m68k/idp/README31
-rw-r--r--c/src/lib/libbsp/m68k/idp/clock/ckinit.c126
-rw-r--r--c/src/lib/libbsp/m68k/idp/console/console.c216
-rw-r--r--c/src/lib/libbsp/m68k/idp/console/duart.c170
-rw-r--r--c/src/lib/libbsp/m68k/idp/console/leds.c80
-rw-r--r--c/src/lib/libbsp/m68k/idp/console/mc68ec.c18
-rw-r--r--c/src/lib/libbsp/m68k/idp/include/README13
-rw-r--r--c/src/lib/libbsp/m68k/idp/include/bsp.h79
-rw-r--r--c/src/lib/libbsp/m68k/idp/include/coverhd.h106
-rw-r--r--c/src/lib/libbsp/m68k/idp/include/leds.h25
-rw-r--r--c/src/lib/libbsp/m68k/idp/startup/bspstart.c175
-rw-r--r--c/src/lib/libbsp/m68k/idp/startup/linkcmds44
-rw-r--r--c/src/lib/libbsp/m68k/idp/timer/timer.c121
-rw-r--r--c/src/lib/libbsp/m68k/idp/timer/timerisr.s38
-rw-r--r--c/src/lib/libbsp/m68k/mvme136/clock/ckinit.c111
-rw-r--r--c/src/lib/libbsp/m68k/mvme136/console/console.c159
-rw-r--r--c/src/lib/libbsp/m68k/mvme136/include/bsp.h142
-rw-r--r--c/src/lib/libbsp/m68k/mvme136/include/coverhd.h104
-rw-r--r--c/src/lib/libbsp/m68k/mvme136/shmsupp/addrconv.c32
-rw-r--r--c/src/lib/libbsp/m68k/mvme136/shmsupp/getcfg.c85
-rw-r--r--c/src/lib/libbsp/m68k/mvme136/shmsupp/lock.c75
-rw-r--r--c/src/lib/libbsp/m68k/mvme136/shmsupp/mpisr.c42
-rw-r--r--c/src/lib/libbsp/m68k/mvme136/startup/bspclean.c46
-rw-r--r--c/src/lib/libbsp/m68k/mvme136/startup/bspstart.c156
-rw-r--r--c/src/lib/libbsp/m68k/mvme136/startup/linkcmds48
-rw-r--r--c/src/lib/libbsp/m68k/mvme136/timer/timer.c108
-rw-r--r--c/src/lib/libbsp/m68k/mvme136/timer/timerisr.s39
-rw-r--r--c/src/lib/libbsp/m68k/mvme162/README124
-rw-r--r--c/src/lib/libbsp/m68k/mvme162/clock/ckinit.c91
-rw-r--r--c/src/lib/libbsp/m68k/mvme162/console/console.c193
-rw-r--r--c/src/lib/libbsp/m68k/mvme162/include/bsp.h225
-rw-r--r--c/src/lib/libbsp/m68k/mvme162/include/coverhd.h104
-rw-r--r--c/src/lib/libbsp/m68k/mvme162/startup/bspclean.c53
-rw-r--r--c/src/lib/libbsp/m68k/mvme162/startup/bspstart.c171
-rw-r--r--c/src/lib/libbsp/m68k/mvme162/startup/linkcmds50
-rw-r--r--c/src/lib/libbsp/m68k/mvme162/timer/timer.c91
-rw-r--r--c/src/lib/libbsp/m68k/mvme162/timer/timerisr.s46
-rw-r--r--c/src/lib/libbsp/m68k/mvme162/tools/sload.c542
48 files changed, 5107 insertions, 0 deletions
diff --git a/c/src/lib/libbsp/m68k/dmv152/clock/ckinit.c b/c/src/lib/libbsp/m68k/dmv152/clock/ckinit.c
new file mode 100644
index 0000000000..d5f0f5e023
--- /dev/null
+++ b/c/src/lib/libbsp/m68k/dmv152/clock/ckinit.c
@@ -0,0 +1,101 @@
+/* Clock_init()
+ *
+ * This routine initializes the Z80386 1 on the MVME136 board.
+ * The tick frequency is 1 millisecond.
+ *
+ * Input parameters: NONE
+ *
+ * Output parameters: NONE
+ *
+ * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
+ * On-Line Applications Research Corporation (OAR).
+ * All rights assigned to U.S. Government, 1994.
+ *
+ * This material may be reproduced by or for the U.S. Government pursuant
+ * to the copyright license under the clause at DFARS 252.227-7013. This
+ * notice must appear in all copies of this file and its derivatives.
+ *
+ * $Id$
+ */
+
+#include <stdlib.h>
+
+#include <rtems.h>
+#include <bsp.h>
+#include <clockdrv.h>
+
+rtems_unsigned32 Clock_isrs; /* ISRs until next tick */
+volatile rtems_unsigned32 Clock_driver_ticks;
+ /* ticks since initialization */
+rtems_isr_entry Old_ticker;
+
+rtems_device_driver Clock_initialize(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void *pargp,
+ rtems_id tid,
+ rtems_unsigned32 *rval
+)
+{
+ Install_clock( Clock_isr );
+}
+
+void ReInstall_clock(
+ rtems_isr_entry clock_isr
+)
+{
+ rtems_unsigned32 isrlevel = 0 ;
+
+ rtems_interrupt_disable( isrlevel );
+ (void) set_vector( clock_isr, TIMER_VECTOR, 1 );
+ rtems_interrupt_enable( isrlevel );
+}
+
+void Install_clock(
+ rtems_isr_entry clock_isr
+)
+{
+ rtems_unsigned8 data;
+
+ Clock_driver_ticks = 0;
+ Clock_isrs = BSP_Configuration.microseconds_per_tick / 1000;
+
+ if ( BSP_Configuration.ticks_per_timeslice ) {
+ Old_ticker = (rtems_isr_entry) set_vector( clock_isr, TIMER_VECTOR, 1 );
+
+ Z8x36_WRITE( TIMER, MASTER_CFG, 0xd4 );
+ Z8x36_READ ( TIMER, MASTER_INTR, data );
+ Z8x36_WRITE( TIMER, MASTER_INTR, (data & 0x7E) );
+ Z8x36_WRITE( TIMER, CT1_TIME_CONST_MSB, 0x04 );
+ Z8x36_WRITE( TIMER, CT1_TIME_CONST_LSB, 0xCE );
+ Z8x36_WRITE( TIMER, CT1_MODE_SPEC, 0x83 );
+ Z8x36_WRITE( TIMER, CNT_TMR_VECTOR, TIMER_VECTOR );
+ Z8x36_WRITE( TIMER, CT1_CMD_STATUS, 0x20 );
+ Z8x36_READ ( TIMER, MASTER_INTR, data );
+ Z8x36_WRITE( TIMER, MASTER_INTR, (data & 0xDA) | 0x80 );
+
+ /*
+ * ACC_IC54 - interrupt 5 will be vectored and mapped to level 6
+ */
+
+ data = (*(rtems_unsigned8 *)0x0D00000B);
+ (*(rtems_unsigned8 *)0x0D00000B) = (data & 0x7F) | 0x60;
+
+ Z8x36_WRITE( TIMER, CT1_CMD_STATUS, 0xC6 );
+
+ atexit( Clock_exit );
+ }
+}
+
+void Clock_exit( void )
+{
+ rtems_unsigned8 data;
+
+ if ( BSP_Configuration.ticks_per_timeslice ) {
+
+ Z8x36_READ ( TIMER, MASTER_INTR, data );
+ Z8x36_WRITE( TIMER, MASTER_INTR, (data & 0x01) );
+ /* do not restore old vector */
+
+ }
+}
diff --git a/c/src/lib/libbsp/m68k/dmv152/console/console.c b/c/src/lib/libbsp/m68k/dmv152/console/console.c
new file mode 100644
index 0000000000..bb0f365b9c
--- /dev/null
+++ b/c/src/lib/libbsp/m68k/dmv152/console/console.c
@@ -0,0 +1,186 @@
+/*
+ * This file contains the DMV152 console IO package.
+ *
+ * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
+ * On-Line Applications Research Corporation (OAR).
+ * All rights assigned to U.S. Government, 1994.
+ *
+ * This material may be reproduced by or for the U.S. Government pursuant
+ * to the copyright license under the clause at DFARS 252.227-7013. This
+ * notice must appear in all copies of this file and its derivatives.
+ *
+ * $Id$
+ */
+
+#define D152_INIT
+
+#include <rtems.h>
+#include "console.h"
+#include "bsp.h"
+
+/* console_initialize
+ *
+ * This routine initializes the console IO driver.
+ *
+ * Input parameters: NONE
+ *
+ * Output parameters: NONE
+ *
+ * Return values:
+ */
+
+rtems_device_driver console_initialize(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void *arg,
+ rtems_id self,
+ rtems_unsigned32 *status
+)
+{
+ *status = RTEMS_SUCCESSFUL;
+}
+
+
+/* is_character_ready
+ *
+ * This routine returns TRUE if a character is available.
+ *
+ * Input parameters: NONE
+ *
+ * Output parameters: NONE
+ *
+ * Return values:
+ */
+
+rtems_boolean is_character_ready(
+ char *ch
+)
+{
+ rtems_unsigned8 rr_0;
+
+ for ( ; ; ) {
+ Z8x30_READ_CONTROL( CONSOLE_CONTROL, RR_0, rr_0 );
+ if ( !(rr_0 & RR_0_RX_DATA_AVAILABLE) )
+ return( FALSE );
+
+ Z8x30_READ_DATA( CONSOLE_DATA, *ch );
+ return( TRUE );
+ }
+}
+
+/* inbyte
+ *
+ * This routine reads a character from the SCC.
+ *
+ * Input parameters: NONE
+ *
+ * Output parameters: NONE
+ *
+ * Return values:
+ * character read from SCC
+ */
+
+char inbyte( void )
+{
+ rtems_unsigned8 rr_0;
+ char ch;
+
+ for ( ; ; ) {
+ Z8x30_READ_CONTROL( CONSOLE_CONTROL, RR_0, rr_0 );
+ if ( (rr_0 & RR_0_RX_DATA_AVAILABLE) != 0 )
+ break;
+ }
+
+ Z8x30_READ_DATA( CONSOLE_DATA, ch );
+ return ( ch );
+}
+
+/* outbyte
+ *
+ * This routine transmits a character out the SCC. It supports
+ * XON/XOFF flow control.
+ *
+ * Input parameters:
+ * ch - character to be transmitted
+ *
+ * Output parameters: NONE
+ */
+
+void outbyte(
+ char ch
+)
+{
+ rtems_unsigned8 rr_0;
+ char flow_control;
+
+ for ( ; ; ) {
+ Z8x30_READ_CONTROL( CONSOLE_CONTROL, RR_0, rr_0 );
+ if ( (rr_0 & RR_0_TX_BUFFER_EMPTY) != 0 )
+ break;
+ }
+
+ for ( ; ; ) {
+ Z8x30_READ_CONTROL( CONSOLE_CONTROL, RR_0, rr_0 );
+ if ( (rr_0 & RR_0_RX_DATA_AVAILABLE) == 0 )
+ break;
+
+ Z8x30_READ_DATA( CONSOLE_DATA, flow_control );
+
+ if ( flow_control == XOFF )
+ do {
+ do {
+ Z8x30_READ_CONTROL( CONSOLE_CONTROL, RR_0, rr_0 );
+ } while ( (rr_0 & RR_0_RX_DATA_AVAILABLE) == 0 );
+ Z8x30_READ_DATA( CONSOLE_DATA, flow_control );
+ } while ( flow_control != XON );
+ }
+
+ Z8x30_WRITE_DATA( CONSOLE_DATA, ch );
+}
+
+/*
+ * __read -- read bytes from the serial port. Ignore fd, since
+ * we only have stdin.
+ */
+
+int __read(
+ int fd,
+ char *buf,
+ int nbytes
+)
+{
+ int i = 0;
+
+ for (i = 0; i < nbytes; i++) {
+ *(buf + i) = inbyte();
+ if ((*(buf + i) == '\n') || (*(buf + i) == '\r')) {
+ (*(buf + i++)) = '\n';
+ (*(buf + i)) = 0;
+ break;
+ }
+ }
+ return (i);
+}
+
+/*
+ * __write -- write bytes to the serial port. Ignore fd, since
+ * stdout and stderr are the same. Since we have no filesystem,
+ * open will only return an error.
+ */
+
+int __write(
+ int fd,
+ char *buf,
+ int nbytes
+)
+{
+ int i;
+
+ for (i = 0; i < nbytes; i++) {
+ if (*(buf + i) == '\n') {
+ outbyte ('\r');
+ }
+ outbyte (*(buf + i));
+ }
+ return (nbytes);
+}
diff --git a/c/src/lib/libbsp/m68k/dmv152/include/bsp.h b/c/src/lib/libbsp/m68k/dmv152/include/bsp.h
new file mode 100644
index 0000000000..7e4f423102
--- /dev/null
+++ b/c/src/lib/libbsp/m68k/dmv152/include/bsp.h
@@ -0,0 +1,169 @@
+/* bsp.h
+ *
+ * This include file contains all DMV152 board IO definitions.
+ *
+ * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
+ * On-Line Applications Research Corporation (OAR).
+ * All rights assigned to U.S. Government, 1994.
+ *
+ * This material may be reproduced by or for the U.S. Government pursuant
+ * to the copyright license under the clause at DFARS 252.227-7013. This
+ * notice must appear in all copies of this file and its derivatives.
+ *
+ * $Id$
+ */
+
+#ifndef __DMV152_h
+#define __DMV152_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <rtems.h>
+#include <iosupp.h>
+#include <z8530.h>
+#include <z8536.h>
+
+/*
+ * Define the time limits for RTEMS Test Suite test durations.
+ * Long test and short test duration limits are provided. These
+ * values are in seconds and need to be converted to ticks for the
+ * application.
+ *
+ */
+
+#define MAX_LONG_TEST_DURATION 300 /* 5 minutes = 300 seconds */
+#define MAX_SHORT_TEST_DURATION 3 /* 3 seconds */
+
+/*
+ * Define the interrupt mechanism for Time Test 27
+ */
+
+/* use a VMEbus interrupt */
+
+#define MUST_WAIT_FOR_INTERRUPT 1
+
+#define Install_tm27_vector( handler ) \
+ { \
+ set_vector( (handler), 0x50, 1 ); \
+ (*(volatile rtems_unsigned32 *)0x0d800024) = 0x50; /* set IVECT reg */ \
+ (*(volatile rtems_unsigned8 *)0x0d00000c) = 0x40; /* set VIE reg */ \
+ }
+
+#define Cause_tm27_intr() \
+ (*(volatile rtems_unsigned8 *)0x0d000003) = 0x0f /* set VINT */
+
+#define Clear_tm27_intr() /* no operation necessary */
+
+#define Lower_tm27_intr()
+
+/*
+ * Simple spin delay in microsecond units for device drivers.
+ * This is very dependent on the clock speed of the target.
+ */
+
+#define delay( microseconds ) \
+ { register rtems_unsigned32 _delay=(microseconds); \
+ register rtems_unsigned32 _tmp=123; \
+ asm volatile( "0: \
+ nbcd %0 ; \
+ nbcd %0 ; \
+ dbf %1,0b" \
+ : "=d" (_tmp), "=d" (_delay) \
+ : "0" (_tmp), "1" (_delay) ); \
+ }
+
+/* macros */
+
+#undef Z8x36_STATE0
+#undef Z8x36_WRITE
+#undef Z8x36_READ
+
+#define Z8x36_STATE0 ( z8536 ) \
+ { char *garbage; \
+ (garbage) = *(VOL8(z8536+0x7)) \
+ }
+
+#define Z8x36_WRITE( z8536, reg, data ) \
+ *(VOL8(z8536+0x7)) = (reg); \
+ *(VOL8(z8536+0x7)) = (data)
+
+#define Z8x36_READ( z8536, reg, data ) \
+ *(VOL8(z8536+0x7)) = (reg); \
+ (data) = *(VOL8(z8536+0x7))
+
+/*
+ * ACC Register Addresses
+ */
+
+#define ACC_BASE 0x0D000000
+
+#define ACC_STAT0 ((volatile rtems_unsigned8 *) (ACC_BASE + 0x00))
+#define ACC_STAT1 ((volatile rtems_unsigned8 *) (ACC_BASE + 0x01))
+#define ACC_GENCTL ((volatile rtems_unsigned8 *) (ACC_BASE + 0x02))
+#define ACC_VINT ((volatile rtems_unsigned8 *) (ACC_BASE + 0x03))
+#define ACC_VREQ ((volatile rtems_unsigned8 *) (ACC_BASE + 0x04))
+#define ACC_VARB ((volatile rtems_unsigned8 *) (ACC_BASE + 0x05))
+#define ACC_ID ((volatile rtems_unsigned8 *) (ACC_BASE + 0x06))
+#define ACC_CTL2 ((volatile rtems_unsigned8 *) (ACC_BASE + 0x07))
+#define ACC_7IS ((volatile rtems_unsigned8 *) (ACC_BASE + 0x08))
+#define ACC_LIS ((volatile rtems_unsigned8 *) (ACC_BASE + 0x09))
+#define ACC_7IE ((volatile rtems_unsigned8 *) (ACC_BASE + 0x0A))
+#define ACC_LIE ((volatile rtems_unsigned8 *) (ACC_BASE + 0x0B))
+#define ACC_VIE ((volatile rtems_unsigned8 *) (ACC_BASE + 0x0C))
+#define ACC_IC10 ((volatile rtems_unsigned8 *) (ACC_BASE + 0x0D))
+#define ACC_IC32 ((volatile rtems_unsigned8 *) (ACC_BASE + 0x0E))
+#define ACC_IC54 ((volatile rtems_unsigned8 *) (ACC_BASE + 0x0F))
+
+/* constants */
+
+#define RAM_START 0
+#define RAM_END 0x100000
+
+#define USE_CHANNEL_A 0 /* 1 = use channel A for console */
+#define USE_CHANNEL_B 1 /* 1 = use channel B for console */
+
+#define TIMER 0x0c000000
+#define TIMER_VECTOR 0x4D
+
+#if (USE_CHANNEL_A == 1)
+#define CONSOLE_CONTROL 0x0C800007
+#define CONSOLE_DATA 0x0C800005
+#elif (USE_CHANNEL_B == 1)
+#define CONSOLE_CONTROL 0x0C800001
+#define CONSOLE_DATA 0x0C800003
+#endif
+
+/* Structures */
+
+#ifdef D152_INIT
+#undef EXTERN
+#define EXTERN
+#else
+#undef EXTERN
+#define EXTERN extern
+#endif
+
+/* miscellaneous stuff assumed to exist */
+
+extern rtems_configuration_table BSP_Configuration;
+
+extern m68k_isr M68Kvec[]; /* vector table address */
+
+/* functions */
+
+void bsp_cleanup( void );
+
+m68k_isr set_vector(
+ rtems_isr_entry handler,
+ rtems_vector_number vector,
+ int type
+);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+/* end of include file */
diff --git a/c/src/lib/libbsp/m68k/dmv152/include/coverhd.h b/c/src/lib/libbsp/m68k/dmv152/include/coverhd.h
new file mode 100644
index 0000000000..0033a50502
--- /dev/null
+++ b/c/src/lib/libbsp/m68k/dmv152/include/coverhd.h
@@ -0,0 +1,104 @@
+/* coverhd.h
+ *
+ * This include file has defines to represent the overhead associated
+ * with calling a particular directive from C on this target.
+ *
+ * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
+ * On-Line Applications Research Corporation (OAR).
+ * All rights assigned to U.S. Government, 1994.
+ *
+ * This material may be reproduced by or for the U.S. Government pursuant
+ * to the copyright license under the clause at DFARS 252.227-7013. This
+ * notice must appear in all copies of this file and its derivatives.
+ *
+ * $Id$
+ */
+
+#ifndef __COVERHD_h
+#define __COVERHD_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define CALLING_OVERHEAD_INITIALIZE_EXECUTIVE 2
+#define CALLING_OVERHEAD_SHUTDOWN_EXECUTIVE 1
+#define CALLING_OVERHEAD_TASK_CREATE 3
+#define CALLING_OVERHEAD_TASK_IDENT 2
+#define CALLING_OVERHEAD_TASK_START 2
+#define CALLING_OVERHEAD_TASK_RESTART 2
+#define CALLING_OVERHEAD_TASK_DELETE 1
+#define CALLING_OVERHEAD_TASK_SUSPEND 1
+#define CALLING_OVERHEAD_TASK_RESUME 2
+#define CALLING_OVERHEAD_TASK_SET_PRIORITY 2
+#define CALLING_OVERHEAD_TASK_MODE 2
+#define CALLING_OVERHEAD_TASK_GET_NOTE 2
+#define CALLING_OVERHEAD_TASK_SET_NOTE 2
+#define CALLING_OVERHEAD_TASK_WAKE_WHEN 4
+#define CALLING_OVERHEAD_TASK_WAKE_AFTER 1
+#define CALLING_OVERHEAD_INTERRUPT_CATCH 2
+#define CALLING_OVERHEAD_CLOCK_GET 4
+#define CALLING_OVERHEAD_CLOCK_SET 4
+#define CALLING_OVERHEAD_CLOCK_TICK 1
+
+#define CALLING_OVERHEAD_TIMER_CREATE 2
+#define CALLING_OVERHEAD_TIMER_IDENT 1
+#define CALLING_OVERHEAD_TIMER_DELETE 2
+#define CALLING_OVERHEAD_TIMER_FIRE_AFTER 2
+#define CALLING_OVERHEAD_TIMER_FIRE_WHEN 5
+#define CALLING_OVERHEAD_TIMER_RESET 1
+#define CALLING_OVERHEAD_TIMER_CANCEL 1
+#define CALLING_OVERHEAD_SEMAPHORE_CREATE 2
+#define CALLING_OVERHEAD_SEMAPHORE_IDENT 1
+#define CALLING_OVERHEAD_SEMAPHORE_DELETE 2
+#define CALLING_OVERHEAD_SEMAPHORE_OBTAIN 2
+#define CALLING_OVERHEAD_SEMAPHORE_RELEASE 1
+#define CALLING_OVERHEAD_MESSAGE_QUEUE_CREATE 2
+#define CALLING_OVERHEAD_MESSAGE_QUEUE_IDENT 2
+#define CALLING_OVERHEAD_MESSAGE_QUEUE_DELETE 1
+#define CALLING_OVERHEAD_MESSAGE_QUEUE_SEND 2
+#define CALLING_OVERHEAD_MESSAGE_QUEUE_URGENT 2
+#define CALLING_OVERHEAD_MESSAGE_QUEUE_BROADCAST 2
+#define CALLING_OVERHEAD_MESSAGE_QUEUE_RECEIVE 2
+#define CALLING_OVERHEAD_MESSAGE_QUEUE_FLUSH 2
+
+#define CALLING_OVERHEAD_EVENT_SEND 2
+#define CALLING_OVERHEAD_EVENT_RECEIVE 2
+#define CALLING_OVERHEAD_SIGNAL_CATCH 2
+#define CALLING_OVERHEAD_SIGNAL_SEND 2
+#define CALLING_OVERHEAD_PARTITION_CREATE 3
+#define CALLING_OVERHEAD_PARTITION_IDENT 2
+#define CALLING_OVERHEAD_PARTITION_DELETE 2
+#define CALLING_OVERHEAD_PARTITION_GET_BUFFER 2
+#define CALLING_OVERHEAD_PARTITION_RETURN_BUFFER 2
+#define CALLING_OVERHEAD_REGION_CREATE 3
+#define CALLING_OVERHEAD_REGION_IDENT 2
+#define CALLING_OVERHEAD_REGION_DELETE 1
+#define CALLING_OVERHEAD_REGION_GET_SEGMENT 3
+#define CALLING_OVERHEAD_REGION_RETURN_SEGMENT 2
+#define CALLING_OVERHEAD_PORT_CREATE 3
+#define CALLING_OVERHEAD_PORT_IDENT 2
+#define CALLING_OVERHEAD_PORT_DELETE 2
+#define CALLING_OVERHEAD_PORT_EXTERNAL_TO_INTERNAL 2
+#define CALLING_OVERHEAD_PORT_INTERNAL_TO_EXTERNAL 2
+
+#define CALLING_OVERHEAD_IO_INITIALIZE 3
+#define CALLING_OVERHEAD_IO_OPEN 2
+#define CALLING_OVERHEAD_IO_CLOSE 2
+#define CALLING_OVERHEAD_IO_READ 2
+#define CALLING_OVERHEAD_IO_WRITE 2
+#define CALLING_OVERHEAD_IO_CONTROL 2
+#define CALLING_OVERHEAD_FATAL_ERROR_OCCURRED 1
+#define CALLING_OVERHEAD_RATE_MONOTONIC_CREATE 2
+#define CALLING_OVERHEAD_RATE_MONOTONIC_IDENT 2
+#define CALLING_OVERHEAD_RATE_MONOTONIC_DELETE 1
+#define CALLING_OVERHEAD_RATE_MONOTONIC_CANCEL 1
+#define CALLING_OVERHEAD_RATE_MONOTONIC_PERIOD 2
+#define CALLING_OVERHEAD_MULTIPROCESSING_ANNOUNCE 1
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+/* end of include file */
diff --git a/c/src/lib/libbsp/m68k/dmv152/spurious/spinit.c b/c/src/lib/libbsp/m68k/dmv152/spurious/spinit.c
new file mode 100644
index 0000000000..47f6e7c0be
--- /dev/null
+++ b/c/src/lib/libbsp/m68k/dmv152/spurious/spinit.c
@@ -0,0 +1,46 @@
+/* Spurious_driver
+ *
+ * This routine installs spurious interrupt handlers for the DMV152.
+ *
+ * Input parameters: NONE
+ *
+ * Output parameters: NONE
+ *
+ * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * This material may be reproduced by or for the U.S. Government pursuant
+ * to the copyright license under the clause at DFARS 252.227-7013. This
+ * notice must appear in all copies of this file and its derivatives.
+ *
+ * $Id$
+ */
+
+#include <rtems.h>
+#include <bsp.h>
+#include <stdio.h>
+
+rtems_isr Spurious_Isr(
+ rtems_vector_number vector
+)
+{
+ void *sp = 0;
+
+ asm volatile ( "movea.l %%sp,%0 " : "=a" (sp) : "0" (sp) );
+
+ fprintf( stderr, "Vector 0x%x sp=0x%p\n", vector, sp );
+}
+
+rtems_device_driver Spurious_Initialize(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void *pargp,
+ rtems_id tid,
+ rtems_unsigned32 *rval
+)
+{
+ rtems_vector_number vector;
+
+ for ( vector = 0x40 ; vector <= 0xFF ; vector++ )
+ (void) set_vector( Spurious_Isr, vector, 1 );
+}
diff --git a/c/src/lib/libbsp/m68k/dmv152/startup/bspstart.c b/c/src/lib/libbsp/m68k/dmv152/startup/bspstart.c
new file mode 100644
index 0000000000..a0ec9b7e71
--- /dev/null
+++ b/c/src/lib/libbsp/m68k/dmv152/startup/bspstart.c
@@ -0,0 +1,171 @@
+#define STACK_CHECKER_ON
+/* bsp_start()
+ *
+ * This routine starts the application. It includes application,
+ * board, and monitor specific initialization and configuration.
+ * The generic CPU dependent initialization has been performed
+ * before this routine is invoked.
+ *
+ * INPUT: NONE
+ *
+ * OUTPUT: NONE
+ *
+ * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
+ * On-Line Applications Research Corporation (OAR).
+ * All rights assigned to U.S. Government, 1994.
+ *
+ * This material may be reproduced by or for the U.S. Government pursuant
+ * to the copyright license under the clause at DFARS 252.227-7013. This
+ * notice must appear in all copies of this file and its derivatives.
+ *
+ * $Id$
+ */
+
+#include <rtems.h>
+#include <bsp.h>
+#include <libcsupport.h>
+#include <vmeintr.h>
+
+/*
+ * The original table from the application and our copy of it with
+ * some changes.
+ */
+
+extern rtems_configuration_table Configuration;
+rtems_configuration_table BSP_Configuration;
+
+rtems_cpu_table Cpu_table;
+
+/* Initialize whatever libc we are using
+ * called from postdriver hook
+ */
+
+void bsp_libc_init()
+{
+ extern int end;
+ rtems_unsigned32 heap_start;
+
+ heap_start = (rtems_unsigned32) &end;
+ if (heap_start & (CPU_ALIGNMENT-1))
+ heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
+
+ RTEMS_Malloc_Initialize((void *) heap_start, 64 * 1024, 0);
+
+ /*
+ * Set up for the libc handling.
+ */
+
+ if (BSP_Configuration.ticks_per_timeslice > 0)
+ libc_init(1); /* reentrant if possible */
+ else
+ libc_init(0); /* non-reentrant */
+
+ /*
+ * Initialize the stack bounds checker
+ */
+
+#ifdef STACK_CHECKER_ON
+ Stack_check_Initialize();
+#endif
+}
+
+int bsp_start(
+ int argc,
+ char **argv,
+ char **environp
+)
+{
+ m68k_isr *monitors_vector_table;
+ int index;
+ void *vbr;
+
+ monitors_vector_table = (m68k_isr *)0; /* Monitor Vectors are at 0 */
+ m68k_set_vbr( monitors_vector_table );
+
+ for ( index=2 ; index<=255 ; index++ )
+ M68Kvec[ index ] = monitors_vector_table[ 32 ];
+
+ M68Kvec[ 2 ] = monitors_vector_table[ 2 ]; /* bus error vector */
+ M68Kvec[ 4 ] = monitors_vector_table[ 4 ]; /* breakpoints vector */
+ M68Kvec[ 9 ] = monitors_vector_table[ 9 ]; /* trace vector */
+
+ /*
+ * Uncommenting this seems to confuse/break the monitor on this board.
+ * It probably assumes the vector table is at 0.
+ */
+
+ /* m68k_set_vbr( &M68Kvec ); */
+
+ /*
+ * Adjust the VMEbus mode to round-robin.
+ */
+
+ /*
+ * This is only apparent with the shared memory driver which has not
+ * yet been supported on this target.
+ */
+
+ m68k_enable_caching();
+
+ /*
+ * we only use a hook to get the C library initialized.
+ */
+
+ Cpu_table.pretasking_hook = NULL;
+
+ Cpu_table.predriver_hook = bsp_libc_init; /* RTEMS resources available */
+
+ Cpu_table.postdriver_hook = NULL; /* Call our main() for constructors */
+
+ Cpu_table.idle_task = NULL; /* do not override system IDLE task */
+
+ Cpu_table.do_zero_of_workspace = TRUE;
+
+ m68k_get_vbr( vbr );
+ Cpu_table.interrupt_vector_table = vbr;
+
+ Cpu_table.interrupt_stack_size = 4096;
+
+ Cpu_table.extra_system_initialization_stack = 0;
+
+ /*
+ * Copy the table
+ */
+
+ BSP_Configuration = Configuration;
+
+ BSP_Configuration.work_space_start = (void *)
+ (RAM_END - BSP_Configuration.work_space_size);
+
+ /*
+ * Add 1 region for Malloc in libc_low
+ */
+
+ BSP_Configuration.maximum_regions++;
+
+ /*
+ * Add 1 extension for newlib libc
+ */
+
+#ifdef RTEMS_NEWLIB
+ BSP_Configuration.maximum_extensions++;
+#endif
+
+ /*
+ * Add another extension if using the stack checker
+ */
+
+#ifdef STACK_CHECKER_ON
+ BSP_Configuration.maximum_extensions++;
+#endif
+
+ rtems_initialize_executive( &BSP_Configuration, &Cpu_table );
+ /* does not return */
+
+ /* Clock_exit is done as an atexit() function */
+
+ VME_interrupt_Disable( 0xff );
+
+ /* return like a "normal" subroutine to the monitor */
+ return 0;
+}
diff --git a/c/src/lib/libbsp/m68k/dmv152/startup/linkcmds b/c/src/lib/libbsp/m68k/dmv152/startup/linkcmds
new file mode 100644
index 0000000000..76f43eec97
--- /dev/null
+++ b/c/src/lib/libbsp/m68k/dmv152/startup/linkcmds
@@ -0,0 +1,48 @@
+/*
+ * This file contains directives for the GNU linker which are specific
+ * to the DY-4 DMV152/SVME153 boards.
+ *
+ * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
+ * On-Line Applications Research Corporation (OAR).
+ * All rights assigned to U.S. Government, 1994.
+ *
+ * This material may be reproduced by or for the U.S. Government pursuant
+ * to the copyright license under the clause at DFARS 252.227-7013. This
+ * notice must appear in all copies of this file and its derivatives.
+ *
+ * $Id$
+ */
+
+MEMORY
+ {
+ ram : org = 0x12800, l = 1M
+ }
+
+SECTIONS
+{
+ .text 0x12800 :
+ {
+ text_start = . ;
+ _text_start = . ;
+ *(.text)
+ etext = ALIGN( 0x10 ) ;
+ _etext = .;
+ }
+ .data ADDR( .text ) + SIZEOF( .text ):
+ {
+ data_start = . ;
+ _data_start = . ;
+ *(.data)
+ edata = ALIGN( 0x10 ) ;
+ _edata = .;
+ }
+ .bss ADDR( .data ) + SIZEOF( .data ):
+ {
+ bss_start = . ;
+ _bss_start = . ;
+ *(.bss)
+ *(COMMON)
+ end = . ;
+ _end = . ;
+ }
+}
diff --git a/c/src/lib/libbsp/m68k/dmv152/startup/vmeintr.c b/c/src/lib/libbsp/m68k/dmv152/startup/vmeintr.c
new file mode 100644
index 0000000000..700b06776d
--- /dev/null
+++ b/c/src/lib/libbsp/m68k/dmv152/startup/vmeintr.c
@@ -0,0 +1,60 @@
+/* vmeintr.c
+ *
+ * VMEbus support routines for the DMV152.
+ *
+ * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
+ * On-Line Applications Research Corporation (OAR).
+ * All rights assigned to U.S. Government, 1994.
+ *
+ * This material may be reproduced by or for the U.S. Government pursuant
+ * to the copyright license under the clause at DFARS 252.227-7013. This
+ * notice must appear in all copies of this file and its derivatives.
+ *
+ * $Id$
+ */
+
+#include <rtems.h>
+#include <bsp.h>
+#include <vmeintr.h>
+
+/*PAGE
+ *
+ * VME_interrupt_Disable
+ *
+ */
+
+void VME_interrupt_Disable (
+ VME_interrupt_Mask mask /* IN */
+)
+{
+ volatile rtems_unsigned8 *VME_interrupt_enable;
+ rtems_unsigned8 value;
+
+ VME_interrupt_enable = ACC_VIE;
+ value = *VME_interrupt_enable;
+
+ value &= ~mask; /* turn off interrupts for all levels in mask */
+
+ *VME_interrupt_enable = value;
+}
+
+/*PAGE
+ *
+ * VME_interrupt_Enable
+ *
+ */
+
+void VME_interrupt_Enable (
+ VME_interrupt_Mask mask /* IN */
+)
+{
+ volatile rtems_unsigned8 *VME_interrupt_enable;
+ rtems_unsigned8 value;
+
+ VME_interrupt_enable = ACC_VIE;
+ value = *VME_interrupt_enable;
+
+ value |= mask; /* turn on interrupts for all levels in mask */
+
+ *VME_interrupt_enable = value;
+}
diff --git a/c/src/lib/libbsp/m68k/dmv152/timer/timer.c b/c/src/lib/libbsp/m68k/dmv152/timer/timer.c
new file mode 100644
index 0000000000..2e91a671df
--- /dev/null
+++ b/c/src/lib/libbsp/m68k/dmv152/timer/timer.c
@@ -0,0 +1,105 @@
+/* timer.c
+ *
+ * NOTE: These routines will not work if the optimizer is enabled
+ * for some compilers. The multiple writes to the Z8036
+ * may be optimized away.
+ *
+ * It is important that the timer start/stop overhead be
+ * determined when porting or modifying this code.
+ *
+ * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
+ * On-Line Applications Research Corporation (OAR).
+ * All rights assigned to U.S. Government, 1994.
+ *
+ * This material may be reproduced by or for the U.S. Government pursuant
+ * to the copyright license under the clause at DFARS 252.227-7013. This
+ * notice must appear in all copies of this file and its derivatives.
+ *
+ * $Id$
+ */
+
+
+#include <rtems.h>
+#include <bsp.h>
+
+int Ttimer_val;
+rtems_boolean Timer_driver_Find_average_overhead;
+
+rtems_isr timerisr();
+
+void Timer_initialize()
+{
+ rtems_unsigned8 data;
+
+ (void) set_vector( timerisr, TIMER_VECTOR, 0 ); /* install ISR */
+
+ Ttimer_val = 0; /* clear timer ISR count */
+ Z8x36_READ ( TIMER, MASTER_INTR, data );
+ Z8x36_WRITE( TIMER, MASTER_INTR, (data & 0x01) );
+
+ Z8x36_WRITE( TIMER, MASTER_CFG, 0xd4 );
+ Z8x36_READ ( TIMER, MASTER_INTR, data );
+ Z8x36_WRITE( TIMER, MASTER_INTR, (data & 0x7E) );
+ Z8x36_WRITE( TIMER, CT1_TIME_CONST_MSB, 0x00 );
+ Z8x36_WRITE( TIMER, CT1_TIME_CONST_LSB, 0x00 );
+ Z8x36_WRITE( TIMER, CT1_MODE_SPEC, 0x87 );
+ Z8x36_WRITE( TIMER, CNT_TMR_VECTOR, TIMER_VECTOR );
+ Z8x36_WRITE( TIMER, CT1_CMD_STATUS, 0x20 );
+ Z8x36_WRITE( TIMER, CT1_CMD_STATUS, 0x26 );
+ Z8x36_READ ( TIMER, MASTER_INTR, data );
+ Z8x36_WRITE( TIMER, MASTER_INTR, (data & 0xDA) | 0x80 );
+
+ Z8x36_WRITE( TIMER, CT1_CMD_STATUS, 0xC6 );
+
+ /*
+ * ACC_IC54 - interrupt 5 will be vectored and mapped to level 6
+ */
+
+ data = (*(rtems_unsigned8 *)0x0D00000B);
+ (*(rtems_unsigned8 *)0x0D00000B) = (data & 0x0F) | 0x60;
+
+}
+
+#define AVG_OVERHEAD 9 /* It typically takes 3.65 microseconds */
+ /* (9 countdowns) to start/stop the timer. */
+#define LEAST_VALID 10 /* Don't trust a value lower than this */
+
+int Read_timer()
+{
+ rtems_unsigned8 data;
+ rtems_unsigned8 msb, lsb;
+ rtems_unsigned32 remaining, total;
+
+ Z8x36_WRITE( TIMER, CT1_CMD_STATUS, 0xce ); /* read the counter value */
+ Z8x36_READ( TIMER, CT1_CUR_CNT_MSB, msb );
+ Z8x36_READ( TIMER, CT1_CUR_CNT_LSB, lsb );
+
+ remaining = 0x10000 - ((msb << 8) + lsb);
+ total = (Ttimer_val * 0x10000) + remaining;
+
+ Z8x36_READ ( TIMER, MASTER_INTR, data );
+ Z8x36_WRITE( TIMER, MASTER_INTR, (data & 0x01) );
+
+ /* do not restore old vector */
+ if ( Timer_driver_Find_average_overhead == 1 )
+ return total; /* in countdown units */
+
+ if ( total < LEAST_VALID )
+ return 0; /* below timer resolution */
+
+ /* Clocked at 2.4615 Mhz */
+
+ return (int)(((float)(total-AVG_OVERHEAD)) / 2.4615 * 2.0);
+}
+
+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/m68k/dmv152/timer/timerisr.s b/c/src/lib/libbsp/m68k/dmv152/timer/timerisr.s
new file mode 100644
index 0000000000..d7ec593c62
--- /dev/null
+++ b/c/src/lib/libbsp/m68k/dmv152/timer/timerisr.s
@@ -0,0 +1,38 @@
+/* timer_isr()
+ *
+ * This routine provides the ISR for the Z8536 timer on the DMV152
+ * board. The timer is set up to generate an interrupt at maximum
+ * intervals.
+ *
+ * Input parameters: NONE
+ *
+ * Output parameters: NONE
+ *
+ * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
+ * On-Line Applications Research Corporation (OAR).
+ * All rights assigned to U.S. Government, 1994.
+ *
+ * This material may be reproduced by or for the U.S. Government pursuant
+ * to the copyright license under the clause at DFARS 252.227-7013. This
+ * notice must appear in all copies of this file and its derivatives.
+ *
+ * $Id$
+ */
+
+#include "asm.h"
+
+BEGIN_CODE
+
+.set TIMER, 0x0c000007 | port A
+.set CT1_CMD_STATUS, 0x0a | command status register
+.set RELOAD, 0x26 | clr IP & IUS,allow countdown
+
+ PUBLIC(timerisr)
+SYM (timerisr):
+ movb #CT1_CMD_STATUS,TIMER | set pointer to cmd status reg
+ movb #RELOAD,TIMER | reload countdown
+ addql #1, SYM (Ttimer_val) | increment timer value
+ rte
+
+END_CODE
+END
diff --git a/c/src/lib/libbsp/m68k/idp/README b/c/src/lib/libbsp/m68k/idp/README
new file mode 100644
index 0000000000..5479acf383
--- /dev/null
+++ b/c/src/lib/libbsp/m68k/idp/README
@@ -0,0 +1,31 @@
+This board support package has not been tested with multiprocessor
+or the timing support. The uniprocessor IDP package was tested though
+with a fairly large application (although bugs may exist). The
+$RTEMS_ROOT/src/tests/Makefile should therefore have the samples and
+the tests directories compiled first with the tmtests (timing) and
+multiprocessor directories optional.
+
+Let me know if you have any problems or bug fixes. Bug fixes are greatly
+appreciated. I do not work for RTEMS or am a member of the RTEMS support
+group in any way, however. I am just one of many that appreciate
+"free" software and enjoy contributing when possible :). You can do it too!
+
+ -- doug mcbride
+ mcbride@rodin.colorado.edu
+
+==============================================================
+Notes: Make sure that -msoft-float is defined when compiling in the
+newlib-beta-rtems/newlib/msoft-float directory subtree. You also probably
+want to add the following line to line 413 of
+newlib-beta-rtems/newlib/msoft-float/libc/stdio/vfprintf.c:
+
+#define INTEGER_ONLY
+
+That allows you to pass most of the paranoia test in the samples
+directory of RTEMS although you can't see the floating point values actually
+printed (software floating point tends to make that difficult anyway).
+In order to pass the whole paranoia test (with one flaw), however, I had to
+comment out the following line in milestone 140 (why?):
+
+/* printf ("Testing X^((X + 1) / (X - 1)) vs. exp(2) = %.17e as X -> 1.\n",
+ Exp2); */
diff --git a/c/src/lib/libbsp/m68k/idp/clock/ckinit.c b/c/src/lib/libbsp/m68k/idp/clock/ckinit.c
new file mode 100644
index 0000000000..abee1418cc
--- /dev/null
+++ b/c/src/lib/libbsp/m68k/idp/clock/ckinit.c
@@ -0,0 +1,126 @@
+/* Clock_init()
+ *
+ *
+ * This is modified by Doug McBride to get it to work for the MC68EC040
+ * IDP board. The below comments are kept to show that some prior work
+ * was done in the area and the modifications performed was application
+ * specific for the IDP board to port it to.
+ *
+ * This routine initializes the mc68230 on the MC68EC040 board.
+ * The tick frequency is 40 milliseconds.
+ *
+ * Input parameters: NONE
+ *
+ * Output parameters: NONE
+ *
+ * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
+ * On-Line Applications Research Corporation (OAR).
+ * All rights assigned to U.S. Government, 1994.
+ *
+ * This material may be reproduced by or for the U.S. Government pursuant
+ * to the copyright license under the clause at DFARS 252.227-7013. This
+ * notice must appear in all copies of this file and its derivatives.
+ *
+ * $Id$
+ */
+
+#include <stdlib.h>
+
+#include "rtems.h"
+#include "clockdrv.h"
+#include "bsp.h"
+#include "cpu.h"
+
+rtems_unsigned32 Clock_isrs; /* ISRs until next tick */
+volatile rtems_unsigned32 Clock_driver_ticks;
+ /* ticks since initialization */
+rtems_isr_entry Old_ticker;
+
+extern rtems_configuration_table Configuration;
+extern void led_putnum();
+void Disable_clock();
+
+#define TIMER_VECTOR 0x4D
+
+rtems_device_driver Clock_initialize(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void *pargp,
+ rtems_id tid,
+ rtems_unsigned32 *rval
+)
+{
+ Install_clock( Clock_isr );
+}
+
+void ReInstall_clock( clock_isr )
+rtems_isr_entry clock_isr;
+{
+ rtems_unsigned32 isrlevel = 0 ;
+
+ rtems_interrupt_disable( isrlevel );
+ (void) set_vector( clock_isr, TIMER_VECTOR, 1 );
+ rtems_interrupt_enable( isrlevel );
+}
+
+/* The following was added for debugging purposes */
+void Disable_clock()
+{
+ /* Disable timer */
+ MC68230_WRITE (TCR, 0x00);
+}
+
+void Install_clock( clock_isr )
+rtems_isr_entry clock_isr;
+{
+ Clock_driver_ticks = 0;
+ Clock_isrs = (int)(Configuration.microseconds_per_tick / 1000);
+
+ if ( Configuration.ticks_per_timeslice ) {
+/* led_putnum('c'); * for debugging purposes */
+ Old_ticker = (rtems_isr_entry) set_vector( clock_isr, TIMER_VECTOR, 1 );
+
+ /* Disable timer for initialization */
+ MC68230_WRITE (TCR, 0x00);
+
+ /* some PI/T initialization stuff here -- see comment in the ckisr.c
+ file in this directory to understand why I use the values that I do */
+ /* Set up the interrupt vector on the MC68230 chip:
+ TIVR = TIMER_VECTOR; */
+ MC68230_WRITE (TIVR, TIMER_VECTOR);
+
+ /* Set CPRH through CPRL to 193 (not 203) decimal for countdown--see ckisr.c
+ CPRH = 0x00;
+ CPRM = 0x00;
+ CPRL = 0xC1; */
+ MC68230_WRITE (CPRH, 0x00);
+ MC68230_WRITE (CPRM, 0x00);
+ MC68230_WRITE (CPRL, 0xC1);
+
+ /* Enable timer and use it as an external periodic interrupt generator
+ TCR = 0xA1; */
+/* led_putnum('a'); * for debugging purposes */
+ MC68230_WRITE (TCR, 0xA1);
+
+ /*
+ * Schedule the clock cleanup routine to execute if the application exits.
+ */
+ atexit( Clock_exit );
+ }
+}
+
+void Clock_exit( void )
+{
+ rtems_unsigned8 data;
+
+ if ( Configuration.ticks_per_timeslice ) {
+
+ /* disable timer
+ data = TCR;
+ TCR = (data & 0xFE); */
+ MC68230_READ (TCR, data);
+ MC68230_WRITE (TCR, (data & 0xFE));
+
+ /* do not restore old vector */
+ }
+}
diff --git a/c/src/lib/libbsp/m68k/idp/console/console.c b/c/src/lib/libbsp/m68k/idp/console/console.c
new file mode 100644
index 0000000000..7bb720c120
--- /dev/null
+++ b/c/src/lib/libbsp/m68k/idp/console/console.c
@@ -0,0 +1,216 @@
+/*
+ * This file contains the Motorola IDP console IO package.
+ *
+ * Written by Doug McBride, Colorado Space Grant College
+ * Based off of the board support packages of RTEMS
+ *
+ * Updated to RTEMS 3.2.0 by Joel Sherrill.
+ *
+ * $Id$
+ */
+
+#define MIDP_INIT
+
+#include "rtems.h"
+#include "console.h"
+#include "bsp.h"
+
+#include "ringbuf.h"
+
+Ring_buffer_t Buffer[ 2 ];
+
+rtems_isr C_Receive_ISR(rtems_vector_number vector);
+
+
+/* console_initialize
+ *
+ * This routine initializes the console IO driver.
+ *
+ * Input parameters: NONE
+ *
+ * Output parameters: NONE
+ *
+ * Return values:
+ */
+
+rtems_device_driver console_initialize(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void *arg,
+ rtems_id self,
+ rtems_unsigned32 *status
+)
+{
+
+ Ring_buffer_Initialize( &Buffer[ 0 ] );
+ Ring_buffer_Initialize( &Buffer[ 1 ] );
+
+ init_pit();
+
+ *status = RTEMS_SUCCESSFUL;
+}
+
+
+/* is_character_ready
+ *
+ * This routine returns TRUE if a character is available.
+ *
+ * Input parameters: NONE
+ *
+ * Output parameters: NONE
+ *
+ * Return values:
+ */
+
+rtems_boolean is_character_ready(
+ char *ch,
+ int port
+)
+{
+ if ( Ring_buffer_Is_empty( &Buffer[ port ] ) )
+ return FALSE;
+
+ Ring_buffer_Remove_character( &Buffer[ port ], *ch );
+ return TRUE;
+}
+
+/* quick_char_check
+ *
+ * This routine returns TRUE if a character is available.
+ * It is different from above because it does not disturb the ring buffer
+ *
+ * Input parameters: NONE
+ *
+ * Output parameters: NONE
+ *
+ * Return values:
+ */
+
+rtems_boolean quick_char_check(
+ int port
+)
+{
+ if ( Ring_buffer_Is_empty( &Buffer[ port ] ) )
+ return FALSE;
+
+ return TRUE;
+}
+
+/* inbyte
+ *
+ * This routine reads a character from the UART through a buffer.
+ *
+ * Input parameters: NONE
+ *
+ * Output parameters: NONE
+ *
+ * Return values:
+ * character read from UART
+ */
+
+char inbyte(
+ int port
+)
+{
+ unsigned char tmp_char;
+
+ /* If you come into this routine without checking is_character_ready() first
+ and you want nonblocking code, then it's your own fault */
+
+ while ( !is_character_ready( &tmp_char, port ) );
+
+ return tmp_char;
+}
+
+
+/* outbyte
+ *
+ * This routine transmits a character out the M68681. It supports
+ * XON/XOFF flow control.
+ *
+ * Input parameters:
+ * ch - character to be transmitted
+ *
+ * Output parameters: NONE
+ */
+
+void outbyte(
+ char ch,
+ int port
+)
+{
+ switch ( port ) {
+ case 0:
+ transmit_char( ch );
+ break;
+ case 1:
+ transmit_char_portb( ch );
+ break;
+ }
+
+}
+
+/*
+ * __read -- read bytes from the serial port. Ignore fd, since
+ * we only have stdin.
+ */
+
+int __read(
+ int fd,
+ char *buf,
+ int nbytes
+)
+{
+ int i = 0;
+ int port;
+
+ /*
+ * Map port A to stdin, stdout, and stderr.
+ * Map everything else to port B.
+ */
+
+ if ( fd <= 2 ) port = 0;
+ else port = 1;
+
+ for (i = 0; i < nbytes; i++) {
+ *(buf + i) = inbyte( port );
+ if ((*(buf + i) == '\n') || (*(buf + i) == '\r')) {
+ (*(buf + i++)) = '\n';
+ (*(buf + i)) = 0;
+ break;
+ }
+ }
+ return (i);
+}
+
+/*
+ * __write -- write bytes to the serial port. Ignore fd, since
+ * stdout and stderr are the same. Since we have no filesystem,
+ * open will only return an error.
+ */
+
+int __write(
+ int fd,
+ char *buf,
+ int nbytes
+)
+{
+ int i;
+ int port;
+
+ /*
+ * Map port A to stdin, stdout, and stderr.
+ * Map everything else to port B.
+ */
+
+ if ( fd <= 2 ) port = 0;
+ else port = 1;
+
+ for (i = 0; i < nbytes; i++) {
+ if (*(buf + i) == '\n') {
+ outbyte ('\r', port );
+ }
+ outbyte (*(buf + i), port );
+ }
+ return (nbytes);
+}
diff --git a/c/src/lib/libbsp/m68k/idp/console/duart.c b/c/src/lib/libbsp/m68k/idp/console/duart.c
new file mode 100644
index 0000000000..c3ee92b75b
--- /dev/null
+++ b/c/src/lib/libbsp/m68k/idp/console/duart.c
@@ -0,0 +1,170 @@
+/*#########################################################
+#
+# This code is a modified version of what you will find at the
+# end of the IDP User's manual. The original code is copyrighted
+# by Motorola and Motorola Semiconductor Products as well as
+# Motorola Software products group.
+#
+# Modifications to the original IDP code by Doug McBride, Colorado
+# Space Grant College. Modifications include a means of accessing
+# port B of the duart as well as port A as well as modifications for
+# buffering and RTEMS support. Modifications are provided
+# as is and may not be correct.
+#
+# Rob Savoye provided the format for the mc68681 header file
+#
+# Joel Sherrill provided inspiration for recoding my original assembly
+# for this file into C (a good idea)
+#
+##########################################################*/
+
+#include "mc68230.h"
+#include "mc68681.h"
+#include "ringbuf.h"
+#include "rtems.h"
+#include "bsp.h"
+
+rtems_isr C_Receive_ISR(rtems_vector_number vector);
+extern Ring_buffer_t Buffer[];
+
+extern unsigned char inbuf[];
+extern unsigned char inbuf_portb[];
+extern unsigned tail;
+extern unsigned tail_portb;
+unsigned char Pit_initialized = 0;
+
+/*#####################################################################
+# The volatile routine to initialize the duart -- port a and port b
+######################################################################*/
+volatile void init_pit()
+{
+ /* Disable ports A & B while configuring PIT */
+ MC68681_WRITE(DUART_IMR, 0x00); /* disable imr */
+ MC68681_WRITE(DUART_CRA, 0x08); /* disable port a transmitter */
+ MC68681_WRITE(DUART_CRA, 0x02); /* disable port a receiver */
+ MC68681_WRITE(DUART_CRB, 0x08); /* disable port b transmitter */
+ MC68681_WRITE(DUART_CRB, 0x02); /* disable port b receiver */
+
+ /* install ISR for ports A and B */
+ set_vector(C_Receive_ISR, (VECT+H3VECT), 1);
+
+ /* initialize pit */
+ MC68230_WRITE(PGCR, 0x00); /* set mode to 0 -- disable all ports */
+ MC68230_WRITE(PSRR, 0x18); /* set up pirq and piack */
+ MC68230_WRITE(PBDDR, 0x00); /* all pins on port b are input */
+ MC68230_WRITE(PBCR, 0x82); /* submode 1x, h3 interrupt enabled */
+ MC68230_WRITE(PIVR, VECT); /* setup pivr */
+ MC68230_WRITE(PGCR, 0x20); /* turn on all ports */
+
+ /* For some reason, the reset of receiver/transmitter only works for
+ the first time around -- it garbles the output otherwise (e.g., sp21) */
+ if (!Pit_initialized)
+ {
+ /* now initialize the duart registers on port b */
+ /* WARNING:OPTIMIZER MAY ONLY EXECUTE THIRD STATEMENT IF NOT VOLATILE */
+ MC68681_WRITE(DUART_CRB, 0x30); /* reset tx, channel b */
+ MC68681_WRITE(DUART_CRB, 0x20); /* reset rx, channel b */
+ MC68681_WRITE(DUART_CRB, 0x10); /* reset mr pointer, channel b */
+
+ /* now initialize the duart registers on port a */
+ /* WARNING:OPTIMIZER MAY ONLY EXECUTE THIRD STATEMENT IF NOT VOLATILE */
+ MC68681_WRITE(DUART_CRA, 0x30); /* reset tx, channel a */
+ MC68681_WRITE(DUART_CRA, 0x20); /* reset rx, channel a */
+ MC68681_WRITE(DUART_CRA, 0x10); /* reset mr pointer, channel a */
+ Pit_initialized = 1;
+ }
+
+ /* init the general registers of the duart */
+ MC68681_WRITE(DUART_IVR, 0x0f); /* init ivr */
+ MC68681_WRITE(DUART_IMR, 0x22); /* init imr */
+ MC68681_WRITE(DUART_ACR, 0x00); /* init acr */
+ MC68681_WRITE(DUART_CTUR, 0x00); /* init ctur */
+ MC68681_WRITE(DUART_CTLR, 0x02); /* init ctlr */
+ MC68681_WRITE(DUART_OPCR, 0x00); /* init opcr */
+ MC68681_WRITE(DUART_OPRSET, 0x01); /* init cts */
+
+ /* init the actual serial port for port a */
+ MC68681_WRITE(DUART_CSRA, 0xbb); /* init csra -- 9600 baud */
+ MC68681_WRITE(DUART_MR1A, 0x13); /* init mr1a */
+ MC68681_WRITE(DUART_MR2A, 0x07); /* init mr2a */
+ MC68681_WRITE(DUART_CRA, 0x05); /* init cra */
+
+ /* init the actual serial port for port b */
+ MC68681_WRITE(DUART_CSRB, 0xbb); /* init csrb -- 9600 baud */
+#define EIGHT_BITS_NO_PARITY
+#ifdef EIGHT_BITS_NO_PARITY
+ MC68681_WRITE(DUART_MR1B, 0x13); /* init mr1b */
+#else /* 7 bits, even parity */
+ MC68681_WRITE(DUART_MR1B, 0x02); /* init mr1b */
+#endif
+ MC68681_WRITE(DUART_MR2B, 0x07); /* init mr2b -- one stop bit */
+ MC68681_WRITE(DUART_CRB, 0x05); /* init crb */
+}
+
+/*#####################################################################
+# interrupt handler for receive of character from duart on ports A & B
+#####################################################################*/
+rtems_isr C_Receive_ISR(rtems_vector_number vector)
+{
+ volatile unsigned char *_addr;
+
+ _addr = (unsigned char *) (PIT_ADDR + PITSR);
+ *_addr = 0x04; /* clear pit interrupt */
+
+ /* Let's check port A first for input */
+ _addr = (unsigned char *) (DUART_ADDR + DUART_SRA);
+ if (*_addr & 0x01) /* extract rcvrdy on port A */
+ {
+ /* Read input on port A */
+ _addr = (unsigned char *) (DUART_ADDR + DUART_RBA);
+ Ring_buffer_Add_character( &Buffer[ 0 ], *_addr );
+ }
+ else /* If not on port A, let's check port B */
+ {
+ _addr = (unsigned char *) (DUART_ADDR + DUART_SRB);
+ if (*_addr & 0x01) /* extract rcvrdy on port B */
+ {
+ /* Read input on port B */
+ _addr = (unsigned char *) (DUART_ADDR + DUART_RBB);
+ Ring_buffer_Add_character( &Buffer[ 1 ], *_addr );
+ }
+ /* if not ready on port A or port B, must be an error */
+ /* if error, get out so that fifo is undisturbed */
+ }
+}
+
+/*#####################################################################
+# This is the routine that actually transmits a character one at a time
+# This routine transmits on port A of the IDP board
+#####################################################################*/
+void transmit_char(char ch)
+{
+ volatile unsigned char *_addr;
+
+ /* Get SRA (extract txrdy) */
+ _addr = (unsigned char *) (DUART_ADDR + DUART_SRA);
+ while (!(*_addr & 0x04))
+ {
+ }
+
+ /* transmit character over port A */
+ MC68681_WRITE(DUART_TBA, ch);
+}
+
+/*#####################################################################
+# This is the routine that actually transmits a character one at a time
+# This routine transmits on port B of the IDP board
+#####################################################################*/
+void transmit_char_portb(char ch)
+{
+ volatile unsigned char *_addr;
+
+ /* Get SRB (extract txrdy) */
+ _addr = (unsigned char *) (DUART_ADDR + DUART_SRB);
+ while (!(*_addr & 0x04))
+ {
+ }
+
+ /* transmit character over port B */
+ MC68681_WRITE(DUART_TBB, ch);
+}
diff --git a/c/src/lib/libbsp/m68k/idp/console/leds.c b/c/src/lib/libbsp/m68k/idp/console/leds.c
new file mode 100644
index 0000000000..4d7abaf93d
--- /dev/null
+++ b/c/src/lib/libbsp/m68k/idp/console/leds.c
@@ -0,0 +1,80 @@
+/*
+ * leds.c -- control the led's on a Motorola mc68ec0x0 board.
+ * Written by rob@cygnus.com (Rob Savoye)
+ */
+#include "leds.h"
+
+void zylons();
+void led_putnum();
+void clear_leds();
+
+/*
+ * led_putnum -- print a hex number on the LED. the value of num must be a char with
+ * the ascii value. ie... number 0 is '0', a is 'a', ' ' (null) clears
+ * the led display.
+ * Setting the bit to 0 turns it on, 1 turns it off.
+ * the LED's are controlled by setting the right bit mask in the base
+ * address.
+ * The bits are:
+ * [d.p | g | f | e | d | c | b | a ] is the byte.
+ *
+ * The locations are:
+ *
+ * a
+ * -----
+ * f | | b
+ * | g |
+ * -----
+ * | |
+ * e | | c
+ * -----
+ * d . d.p (decimal point)
+ */
+void
+led_putnum ( num )
+char num;
+{
+ static unsigned char *leds = (unsigned char *)LED_ADDR;
+ static unsigned char num_bits [18] = {
+ 0xff, /* clear all */
+ 0xc0, 0xf9, 0xa4, 0xb0, 0x99, 0x92, 0x82, 0xf8, 0x80, 0x98, /* numbers 0-9 */
+ 0x98, 0x20, 0x3, 0x27, 0x21, 0x4, 0xe /* letters a-f */
+ };
+
+ if (num >= '0' && num <= '9')
+ num = (num - '0') + 1;
+
+ if (num >= 'a' && num <= 'f')
+ num = (num - 'a') + 12;
+
+ if (num == ' ')
+ num = 0;
+
+ *leds = num_bits[(int)num];
+}
+
+/* This procedure added by Doug McBride, Colorado Space Grant College --
+ Probably should be a macro instead */
+void
+clear_leds ( )
+{
+ static unsigned char *leds = (unsigned char *)LED_ADDR;
+ *leds = 0xFF;
+}
+
+/*
+ * zylons -- draw a rotating pattern. NOTE: this function never returns.
+ */
+void
+zylons()
+{
+ unsigned char *leds = (unsigned char *)LED_ADDR;
+ unsigned char curled = 0xfe;
+
+ while (1)
+ {
+ *leds = curled;
+ curled = (curled >> 1) | (curled << 7);
+ delay ( 8000 );
+ }
+}
diff --git a/c/src/lib/libbsp/m68k/idp/console/mc68ec.c b/c/src/lib/libbsp/m68k/idp/console/mc68ec.c
new file mode 100644
index 0000000000..dd6956c3e9
--- /dev/null
+++ b/c/src/lib/libbsp/m68k/idp/console/mc68ec.c
@@ -0,0 +1,18 @@
+/*
+ * mc68ec.c -- Low level support for the Motorola mc68ec0x0 board.
+ * Written by rob@cygnus.com (Rob Savoye)
+ */
+#include "leds.h"
+
+/*
+ * delay -- delay execution. This is an ugly hack. It should
+ * use the timer, but I'm waiting for docs. (sigh)
+ */
+void delay(num)
+int num;
+{
+ while (num--)
+ {
+ asm ("nop");
+ }
+}
diff --git a/c/src/lib/libbsp/m68k/idp/include/README b/c/src/lib/libbsp/m68k/idp/include/README
new file mode 100644
index 0000000000..940cadb13d
--- /dev/null
+++ b/c/src/lib/libbsp/m68k/idp/include/README
@@ -0,0 +1,13 @@
+#
+# $Id$
+#
+
+The following files really should be made generic and allowed to
+be shared between BSPs:
+
+ mc68230.h
+ mc68681.h
+ ringbuf.h
+
+However at the moment the BSP is not tested under 3.2.0 so it is
+dangerous to do so.
diff --git a/c/src/lib/libbsp/m68k/idp/include/bsp.h b/c/src/lib/libbsp/m68k/idp/include/bsp.h
new file mode 100644
index 0000000000..ec8221f1f9
--- /dev/null
+++ b/c/src/lib/libbsp/m68k/idp/include/bsp.h
@@ -0,0 +1,79 @@
+/* bsp.h
+ *
+ * This include file contains all Motorola 680x0 IDP board IO definitions.
+ *
+ * $Id$
+ */
+
+#ifndef __IDP_BSP_H
+#define __IDP_BSP_H
+
+#include "rtems.h"
+#include "cpu.h"
+#include "console.h"
+#include "mc68230.h"
+#include "mc68681.h"
+
+/*
+ * Define the time limits for RTEMS Test Suite test durations.
+ * Long test and short test duration limits are provided. These
+ * values are in seconds and need to be converted to ticks for the
+ * application.
+ */
+
+#define MAX_LONG_TEST_DURATION 300 /* 5 minutes = 300 seconds */
+#define MAX_SHORT_TEST_DURATION 3 /* 3 seconds */
+
+/*
+ * Define the interrupt mechanism for Time Test 27
+ *
+ * NOTE: tm27 apparently not supported.
+ */
+
+#define MUST_WAIT_FOR_INTERRUPT 0
+
+#define Install_tm27_vector( handler )
+
+#define Cause_tm27_intr()
+
+#define Clear_tm27_intr()
+
+#define Lower_tm27_intr()
+
+/* Constants */
+
+#define RAM_START 0
+#define RAM_END 0x200000
+
+#ifdef MIDP_INIT
+#undef EXTERN
+#define EXTERN
+#else
+#undef EXTERN
+#define EXTERN extern
+#endif
+
+/* miscellaneous stuff assumed to exist */
+
+extern rtems_configuration_table BSP_Configuration;
+
+extern m68k_isr M68Kvec[]; /* vector table address */
+
+/* functions */
+
+void bsp_cleanup( void );
+
+m68k_isr set_vector(
+ rtems_isr_entry handler,
+ rtems_vector_number vector,
+ int type
+);
+
+void init_pit( void );
+
+void transmit_char( char ch );
+
+void transmit_char_portb( char ch );
+
+#endif
+/* end of include file */
diff --git a/c/src/lib/libbsp/m68k/idp/include/coverhd.h b/c/src/lib/libbsp/m68k/idp/include/coverhd.h
new file mode 100644
index 0000000000..671f20d197
--- /dev/null
+++ b/c/src/lib/libbsp/m68k/idp/include/coverhd.h
@@ -0,0 +1,106 @@
+/* coverhd.h
+ *
+ * This include file has defines to represent the overhead associated
+ * with calling a particular directive from C. These are used in the
+ * Timing Test Suite to ignore the overhead required to pass arguments
+ * to directives. On some CPUs and/or target boards, this overhead
+ * is significant and makes it difficult to distinguish internal
+ * RTEMS execution time from that used to call the directive.
+ * This file should be updated after running the C overhead timing
+ * test. Once this update has been performed, the RTEMS Time Test
+ * Suite should be rebuilt to account for these overhead times in the
+ * timing results.
+ *
+ * NOTE: If these are all zero, then the times reported include all
+ * all calling overhead including passing of arguments.
+ *
+ * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
+ * On-Line Applications Research Corporation (OAR).
+ * All rights assigned to U.S. Government, 1994.
+ *
+ * This material may be reproduced by or for the U.S. Government pursuant
+ * to the copyright license under the clause at DFARS 252.227-7013. This
+ * notice must appear in all copies of this file and its derivatives.
+ *
+ * $Id$
+ */
+
+#ifndef __COVERHD_h
+#define __COVERHD_h
+
+#define CALLING_OVERHEAD_INITIALIZE_EXECUTIVE 0
+#define CALLING_OVERHEAD_SHUTDOWN_EXECUTIVE 0
+#define CALLING_OVERHEAD_TASK_CREATE 0
+#define CALLING_OVERHEAD_TASK_IDENT 0
+#define CALLING_OVERHEAD_TASK_START 0
+#define CALLING_OVERHEAD_TASK_RESTART 0
+#define CALLING_OVERHEAD_TASK_DELETE 0
+#define CALLING_OVERHEAD_TASK_SUSPEND 0
+#define CALLING_OVERHEAD_TASK_RESUME 0
+#define CALLING_OVERHEAD_TASK_SET_PRIORITY 0
+#define CALLING_OVERHEAD_TASK_MODE 0
+#define CALLING_OVERHEAD_TASK_GET_NOTE 0
+#define CALLING_OVERHEAD_TASK_SET_NOTE 0
+#define CALLING_OVERHEAD_TASK_WAKE_WHEN 0
+#define CALLING_OVERHEAD_TASK_WAKE_AFTER 0
+#define CALLING_OVERHEAD_INTERRUPT_CATCH 0
+#define CALLING_OVERHEAD_CLOCK_GET 0
+#define CALLING_OVERHEAD_CLOCK_SET 0
+#define CALLING_OVERHEAD_CLOCK_TICK 0
+
+#define CALLING_OVERHEAD_TIMER_CREATE 0
+#define CALLING_OVERHEAD_TIMER_IDENT 0
+#define CALLING_OVERHEAD_TIMER_DELETE 0
+#define CALLING_OVERHEAD_TIMER_FIRE_AFTER 0
+#define CALLING_OVERHEAD_TIMER_FIRE_WHEN 0
+#define CALLING_OVERHEAD_TIMER_RESET 0
+#define CALLING_OVERHEAD_TIMER_CANCEL 0
+#define CALLING_OVERHEAD_SEMAPHORE_CREATE 0
+#define CALLING_OVERHEAD_SEMAPHORE_IDENT 0
+#define CALLING_OVERHEAD_SEMAPHORE_DELETE 0
+#define CALLING_OVERHEAD_SEMAPHORE_OBTAIN 0
+#define CALLING_OVERHEAD_SEMAPHORE_RELEASE 0
+#define CALLING_OVERHEAD_MESSAGE_QUEUE_CREATE 0
+#define CALLING_OVERHEAD_MESSAGE_QUEUE_IDENT 0
+#define CALLING_OVERHEAD_MESSAGE_QUEUE_DELETE 0
+#define CALLING_OVERHEAD_MESSAGE_QUEUE_SEND 0
+#define CALLING_OVERHEAD_MESSAGE_QUEUE_URGENT 0
+#define CALLING_OVERHEAD_MESSAGE_QUEUE_BROADCAST 0
+#define CALLING_OVERHEAD_MESSAGE_QUEUE_RECEIVE 0
+#define CALLING_OVERHEAD_MESSAGE_QUEUE_FLUSH 0
+
+#define CALLING_OVERHEAD_EVENT_SEND 0
+#define CALLING_OVERHEAD_EVENT_RECEIVE 0
+#define CALLING_OVERHEAD_SIGNAL_CATCH 0
+#define CALLING_OVERHEAD_SIGNAL_SEND 0
+#define CALLING_OVERHEAD_PARTITION_CREATE 0
+#define CALLING_OVERHEAD_PARTITION_IDENT 0
+#define CALLING_OVERHEAD_PARTITION_DELETE 0
+#define CALLING_OVERHEAD_PARTITION_GET_BUFFER 0
+#define CALLING_OVERHEAD_PARTITION_RETURN_BUFFER 0
+#define CALLING_OVERHEAD_REGION_CREATE 0
+#define CALLING_OVERHEAD_REGION_IDENT 0
+#define CALLING_OVERHEAD_REGION_DELETE 0
+#define CALLING_OVERHEAD_REGION_GET_SEGMENT 0
+#define CALLING_OVERHEAD_REGION_RETURN_SEGMENT 0
+#define CALLING_OVERHEAD_PORT_CREATE 0
+#define CALLING_OVERHEAD_PORT_IDENT 0
+#define CALLING_OVERHEAD_PORT_DELETE 0
+#define CALLING_OVERHEAD_PORT_EXTERNAL_TO_INTERNAL 0
+#define CALLING_OVERHEAD_PORT_INTERNAL_TO_EXTERNAL 0
+
+#define CALLING_OVERHEAD_IO_INITIALIZE 0
+#define CALLING_OVERHEAD_IO_OPEN 0
+#define CALLING_OVERHEAD_IO_CLOSE 0
+#define CALLING_OVERHEAD_IO_READ 0
+#define CALLING_OVERHEAD_IO_WRITE 0
+#define CALLING_OVERHEAD_IO_CONTROL 0
+#define CALLING_OVERHEAD_FATAL_ERROR_OCCURRED 0
+#define CALLING_OVERHEAD_RATE_MONOTONIC_CREATE 0
+#define CALLING_OVERHEAD_RATE_MONOTONIC_IDENT 0
+#define CALLING_OVERHEAD_RATE_MONOTONIC_DELETE 0
+#define CALLING_OVERHEAD_RATE_MONOTONIC_CANCEL 0
+#define CALLING_OVERHEAD_RATE_MONOTONIC_PERIOD 0
+#define CALLING_OVERHEAD_MULTIPROCESSING_ANNOUNCE 0
+
+#endif
diff --git a/c/src/lib/libbsp/m68k/idp/include/leds.h b/c/src/lib/libbsp/m68k/idp/include/leds.h
new file mode 100644
index 0000000000..79df8488d8
--- /dev/null
+++ b/c/src/lib/libbsp/m68k/idp/include/leds.h
@@ -0,0 +1,25 @@
+/*
+ * leds.c -- control the led's on a Motorola mc68ec0x0 board.
+ * Written by rob@cygnus.com (Rob Savoye)
+ */
+
+#ifndef __LEDS_H__
+#define __LEDS_H__
+
+#define LED_ADDR 0xd00003
+#define LED_0 ~0x1
+#define LED_1 ~0x2
+#define LED_2 ~0x4
+#define LED_3 ~0x8
+#define LED_4 ~0x10
+#define LED_5 ~0x20
+#define LED_6 ~0x40
+#define LED_7 ~0x80
+#define LEDS_OFF 0xff
+#define LEDS_ON 0x0
+
+#define FUDGE(x) ((x >= 0xa && x <= 0xf) ? (x + 'a') & 0x7f : (x + '0') & 0x7f)
+
+extern void led_putnum( char );
+
+#endif /* __LEDS_H__ */
diff --git a/c/src/lib/libbsp/m68k/idp/startup/bspstart.c b/c/src/lib/libbsp/m68k/idp/startup/bspstart.c
new file mode 100644
index 0000000000..843a137485
--- /dev/null
+++ b/c/src/lib/libbsp/m68k/idp/startup/bspstart.c
@@ -0,0 +1,175 @@
+/* bsp_start()
+ *
+ * This routine starts the application. It includes application,
+ * board, and monitor specific initialization and configuration.
+ * The generic CPU dependent initialization has been performed
+ * before this routine is invoked.
+ *
+ * INPUT: NONE
+ *
+ * OUTPUT: NONE
+ *
+ * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
+ * On-Line Applications Research Corporation (OAR).
+ * All rights assigned to U.S. Government, 1994.
+ *
+ * This material may be reproduced by or for the U.S. Government pursuant
+ * to the copyright license under the clause at DFARS 252.227-7013. This
+ * notice must appear in all copies of this file and its derivatives.
+ *
+ * $Id$
+ */
+
+#include "rtems.h"
+#include "bsp.h"
+#include "cpu.h"
+#include "libcsupport.h"
+
+unsigned char *duart_base;
+extern struct duart_regs duart_info;
+
+#define DELAY 5000
+
+void led_putnum();
+
+/*
+ * The original table from the application and our copy of it with
+ * some changes.
+ */
+
+extern rtems_configuration_table Configuration;
+rtems_configuration_table BSP_Configuration;
+
+rtems_cpu_table Cpu_table;
+
+/* Initialize whatever libc we are using
+ * called from postdriver hook
+ */
+
+void bsp_libc_init()
+{
+ extern int end;
+ rtems_unsigned32 heap_start;
+
+ heap_start = (rtems_unsigned32) &end;
+ if (heap_start & (CPU_ALIGNMENT-1))
+ heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
+
+ /* Create 64 KByte memory region for RTEMS executive */
+ RTEMS_Malloc_Initialize((void *) heap_start, 64 * 1024, 0);
+
+ /*
+ * Set up for the libc handling.
+ */
+
+ if (BSP_Configuration.ticks_per_timeslice > 0)
+ libc_init(1); /* reentrant if possible */
+ else
+ libc_init(0); /* non-reentrant */
+
+ /*
+ * Initialize the stack bounds checker
+ */
+
+#ifdef STACK_CHECKER_ON
+ Stack_check_Initialize();
+#endif
+}
+
+
+int bsp_start(
+ int argc,
+ char **argv,
+ char **environp
+)
+{
+ m68k_isr *monitors_vector_table;
+ int index;
+
+ duart_base = (unsigned char *)DUART_ADDR;
+
+ /*
+ * Set the VBR here to the monitor's default.
+ */
+
+ monitors_vector_table = (m68k_isr *)0; /* This is where
+ you set vector base
+ register = 0 */
+ m68k_set_vbr( monitors_vector_table );
+
+ /* The vector interrupt table for the 680x0 is in appendix B-2
+ of the M68000 Family Programmer's reference table */
+ for ( index=2 ; index<=255 ; index++ )
+ M68Kvec[ index ] = monitors_vector_table[ 32 ];
+
+
+ M68Kvec[ 2 ] = monitors_vector_table[ 2 ]; /* bus error vector */
+ M68Kvec[ 4 ] = monitors_vector_table[ 4 ]; /* breakpoints vector */
+ M68Kvec[ 9 ] = monitors_vector_table[ 9 ]; /* trace vector */
+
+ /*
+ * Set the VBR here if you do not want to use the monitor's vector table.
+ */
+
+ m68k_set_vbr( &M68Kvec );
+
+ m68k_enable_caching();
+
+ /*
+ * we only use a hook to get the C library initialized.
+ */
+
+ Cpu_table.pretasking_hook = NULL;
+
+ Cpu_table.predriver_hook = bsp_libc_init; /* RTEMS resources available */
+
+ Cpu_table.postdriver_hook = NULL;
+
+ Cpu_table.idle_task = NULL; /* do not override system IDLE task */
+
+ Cpu_table.do_zero_of_workspace = TRUE;
+
+ Cpu_table.interrupt_vector_table = (m68k_isr *) &M68Kvec;
+
+ Cpu_table.interrupt_stack_size = 4096;
+
+ Cpu_table.extra_system_initialization_stack = 0;
+
+ /*
+ * Copy the table
+ */
+
+ BSP_Configuration = Configuration;
+
+ BSP_Configuration.work_space_start = (void *)
+ (RAM_END - BSP_Configuration.work_space_size);
+
+ /*
+ * Add 1 region for the RTEMS Malloc
+ */
+
+ BSP_Configuration.maximum_regions++;
+
+ /*
+ * Add 1 extension for newlib libc
+ */
+
+#ifdef RTEMS_NEWLIB
+ BSP_Configuration.maximum_extensions++;
+#endif
+
+ /*
+ * Add another extension if using the stack checker
+ */
+
+#ifdef STACK_CHECKER_ON
+ BSP_Configuration.maximum_extensions++;
+#endif
+
+/* led_putnum('e'); * for debugging purposes only */
+ rtems_initialize_executive( &BSP_Configuration, &Cpu_table );/* does not return */
+
+ /* Clock_exit is done as an atexit() function */
+
+ return 0;
+}
diff --git a/c/src/lib/libbsp/m68k/idp/startup/linkcmds b/c/src/lib/libbsp/m68k/idp/startup/linkcmds
new file mode 100644
index 0000000000..be546b11f5
--- /dev/null
+++ b/c/src/lib/libbsp/m68k/idp/startup/linkcmds
@@ -0,0 +1,44 @@
+/* This file is a derivation of that found with the newlib-1.6 distribution
+ * for the idp.ld file. That file, it appears, was originally written by
+ * Rob Savoye. Other ideas came from Joel Sherrill for the RTEMS linkcmds
+ * file (this is basically a mixture of the two).
+ */
+
+/*
+ * Setup the memory map of the MC68ec0x0 Board (IDP)
+ * stack grows up towards high memory. This works for
+ * both the rom68k and the mon68k monitors.
+ */
+MEMORY
+{
+ ram : org = 0x10000, l = 2M
+}
+
+SECTIONS
+{
+ .text 0x10000:
+ {
+ text_start = . ;
+ _text_start = . ;
+ *(.text)
+ etext = ALIGN( 0x10 ) ;
+ _etext = .;
+ }
+ .data ADDR( .text ) + SIZEOF( .text ):
+ {
+ data_start = . ;
+ _data_start = .;
+ *(.data)
+ edata = ALIGN( 0x10 ) ;
+ _edata = .;
+ }
+ .bss ADDR( .data ) + SIZEOF( .data ):
+ {
+ bss_start = . ;
+ _bss_start = . ;
+ *(.bss)
+ *(COMMON)
+ end = . ;
+ _end = . ;
+ }
+}
diff --git a/c/src/lib/libbsp/m68k/idp/timer/timer.c b/c/src/lib/libbsp/m68k/idp/timer/timer.c
new file mode 100644
index 0000000000..176f393e45
--- /dev/null
+++ b/c/src/lib/libbsp/m68k/idp/timer/timer.c
@@ -0,0 +1,121 @@
+/* Timer_init()
+ *
+ * This routine initializes the MC68230 timer on the Motorola IDP board.
+ *
+ * Input parameters: NONE
+ *
+ * Output parameters: NONE
+ *
+ * NOTE: This routine will not work if the optimizer is enabled
+ * for some compilers. The multiple writes to the MC68230
+ * may be optimized away.
+ *
+ * It is important that the timer start/stop overhead be
+ * determined when porting or modifying this code.
+ *
+ * Code Modified for the MC68230 by Doug McBride, Colorado Space Grant College
+ *
+ * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
+ * On-Line Applications Research Corporation (OAR).
+ * All rights assigned to U.S. Government, 1994.
+ *
+ * This material may be reproduced by or for the U.S. Government pursuant
+ * to the copyright license under the clause at DFARS 252.227-7013. This
+ * notice must appear in all copies of this file and its derivatives.
+ *
+ * $Id$
+ */
+
+
+#include "rtems.h"
+#include "cpu.h"
+#include "bsp.h"
+#include "mc68230.h"
+
+#define TIMER_VECTOR 0x4D
+
+int Ttimer_val;
+rtems_boolean Timer_driver_Find_average_overhead;
+
+rtems_isr timerisr();
+
+void Timer_initialize()
+{
+ (void) set_vector( timerisr, TIMER_VECTOR, 0 ); /* install ISR */
+
+ Ttimer_val = 0; /* clear timer ISR count */
+
+ /* some PI/T initialization stuff here */
+ /* Set up the interrupt vector on the MC68230 chip:
+ TIVR = TIMER_VECTOR; */
+ MC68230_WRITE (TIVR, TIMER_VECTOR);
+
+ /* Set CPRH through CPRL to maximum count to reduce interrupt overhead
+ CPRH = 0xFF;
+ CPRM = 0xFF;
+ CPRL = 0xFF; */
+ MC68230_WRITE (CPRH, 0xFF);
+ MC68230_WRITE (CPRM, 0xFF);
+ MC68230_WRITE (CPRL, 0xFF);
+
+ /* Enable timer and use it as an external periodic interrupt generator
+ TCR = 0xA1; */
+ MC68230_WRITE (TCR, 0xA1);
+
+}
+
+#define AVG_OVERHEAD 9 /* may not be right -- do this later */
+#define LEAST_VALID 10 /* Don't trust a value lower than this */
+
+int Read_timer()
+{
+ rtems_unsigned8 data;
+ rtems_unsigned8 msb, osb, lsb;
+ rtems_unsigned32 remaining, total;
+
+ /* Disable timer so that timer can be read
+ data = TCR;
+ TCR = (data & 0xFE); */
+ MC68230_READ (TCR, data);
+ MC68230_WRITE (TCR, (data & 0xFE));
+
+ /* Read the counter value
+ msb = CNTRH;
+ osb = CNTRM;
+ lsb = CNTRL; */
+ MC68230_READ (CNTRH, msb);
+ MC68230_READ (CNTRM, osb);
+ MC68230_READ (CNTRL, lsb);
+
+ /* Calculate the time so far */
+ remaining = 0x1000000 - ((msb << 16) + (osb << 8) + lsb);
+ total = (Ttimer_val * 0x1000000) + remaining;
+
+ /* Enable timer so that timer can continue
+ TCR = 0xA1; */
+ MC68230_WRITE (TCR, 0xA1);
+
+ /* do not restore old vector */
+ if ( Timer_driver_Find_average_overhead == 1 )
+ return total; /* in countdown units */
+
+ if ( total < LEAST_VALID )
+ return 0; /* below timer resolution */
+
+ /* Clocked at 6.5 Mhz */
+ /* Avoid floating point problems, be lazy, and return the total minus
+ the average overhead */
+ return (total - 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;
+}
diff --git a/c/src/lib/libbsp/m68k/idp/timer/timerisr.s b/c/src/lib/libbsp/m68k/idp/timer/timerisr.s
new file mode 100644
index 0000000000..cd8173be52
--- /dev/null
+++ b/c/src/lib/libbsp/m68k/idp/timer/timerisr.s
@@ -0,0 +1,38 @@
+/* timer_isr()
+ *
+ * This routine provides the ISR for the MC68230 timer on the Motorola
+ * IDP board. The timer is set up to generate an interrupt at maximum
+ * intervals.
+ *
+ * Code modified by Doug McBride, Colorado Space Grant College
+ * countdown should be loaded automatically
+ *
+ * Input parameters: NONE
+ *
+ * Output parameters: NONE
+ *
+ * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
+ * On-Line Applications Research Corporation (OAR).
+ * All rights assigned to U.S. Government, 1994.
+ *
+ * This material may be reproduced by or for the U.S. Government pursuant
+ * to the copyright license under the clause at DFARS 252.227-7013. This
+ * notice must appear in all copies of this file and its derivatives.
+ *
+ * $Id$
+ */
+
+#include "asm.h"
+
+BEGIN_CODE
+
+.set TSR, 0x00c0106B | base address of PIT register "TSR"
+
+ PUBLIC (timerisr)
+SYM (timerisr):
+ movb #1,TSR | acknowledge interrupt
+ addql #1, SYM (Ttimer_val) | increment timer value
+ rte
+
+END_CODE
+END
diff --git a/c/src/lib/libbsp/m68k/mvme136/clock/ckinit.c b/c/src/lib/libbsp/m68k/mvme136/clock/ckinit.c
new file mode 100644
index 0000000000..de88fe9252
--- /dev/null
+++ b/c/src/lib/libbsp/m68k/mvme136/clock/ckinit.c
@@ -0,0 +1,111 @@
+/* Clock_init()
+ *
+ * This routine initializes the Z80386 1 on the MVME136 board.
+ * The tick frequency is 1 millisecond.
+ *
+ * Input parameters: NONE
+ *
+ * Output parameters: NONE
+ *
+ * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
+ * On-Line Applications Research Corporation (OAR).
+ * All rights assigned to U.S. Government, 1994.
+ *
+ * This material may be reproduced by or for the U.S. Government pursuant
+ * to the copyright license under the clause at DFARS 252.227-7013. This
+ * notice must appear in all copies of this file and its derivatives.
+ *
+ * $Id$
+ */
+
+#include <stdlib.h>
+
+#include <rtems.h>
+#include <bsp.h>
+#include <clockdrv.h>
+#include <z8036.h>
+
+#define MICRVAL 0xe2 /* disable lower chain, no vec */
+ /* set right justified addr */
+ /* and master int enable */
+#define MCCRVAL 0xc4 /* enable T1 and port B */
+ /* timers independent */
+#define MS_COUNT 0x07d0 /* T1's countdown constant (1 ms) */
+#define T1MSRVAL 0x80 /* T1 cont. cycle/pulse output */
+#define T1CSRVAL 0xc6 /* enable interrupt, allow and */
+ /* and trigger countdown */
+
+rtems_unsigned32 Clock_isrs; /* ISRs until next tick */
+volatile rtems_unsigned32 Clock_driver_ticks;
+ /* ticks since initialization */
+rtems_isr_entry Old_ticker;
+
+rtems_device_driver Clock_initialize(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void *pargp,
+ rtems_id tid,
+ rtems_unsigned32 *rval
+)
+{
+ Install_clock( Clock_isr );
+}
+
+void ReInstall_clock(
+ rtems_isr_entry clock_isr
+)
+{
+ rtems_unsigned32 isrlevel;
+
+ rtems_interrupt_disable( isrlevel );
+ (void) set_vector( clock_isr, 66, 1 );
+ rtems_interrupt_enable( isrlevel );
+}
+
+void Install_clock(
+ rtems_isr_entry clock_isr
+)
+{
+ volatile struct z8036_map *timer;
+
+ Clock_driver_ticks = 0;
+ Clock_isrs = BSP_Configuration.microseconds_per_tick / 1000;
+
+ if ( BSP_Configuration.ticks_per_timeslice ) {
+ Old_ticker = (rtems_isr_entry) set_vector( clock_isr, 66, 1 );
+ timer = (struct z8036_map *) 0xfffb0000;
+ timer->MASTER_INTR = MICRVAL;
+ timer->CT1_MODE_SPEC = T1MSRVAL;
+
+ *((rtems_unsigned16 *)0xfffb0016) = MS_COUNT; /* write countdown value */
+/*
+ timer->CT1_TIME_CONST_MSB = (MS_COUNT >> 8);
+ timer->CT1_TIME_CONST_LSB = (MS_COUNT & 0xff);
+*/
+ timer->MASTER_CFG = MCCRVAL;
+ timer->CT1_CMD_STATUS = T1CSRVAL;
+
+/*
+ * Enable interrupt via VME interrupt mask register
+ */
+ (*(rtems_unsigned8 *)0xfffb0038) &= 0xfd;
+
+
+ atexit( Clock_exit );
+ }
+
+}
+
+void Clock_exit( void )
+{
+ volatile struct z8036_map *timer;
+
+ if ( BSP_Configuration.ticks_per_timeslice ) {
+ timer = (struct z8036_map *) 0xfffb0000;
+ timer->MASTER_INTR = 0x62;
+ timer->CT1_MODE_SPEC = 0x00;
+ timer->MASTER_CFG = 0xf4;
+ timer->CT1_CMD_STATUS = 0x00;
+ /* do not restore old vector */
+ }
+}
diff --git a/c/src/lib/libbsp/m68k/mvme136/console/console.c b/c/src/lib/libbsp/m68k/mvme136/console/console.c
new file mode 100644
index 0000000000..6bfcf84481
--- /dev/null
+++ b/c/src/lib/libbsp/m68k/mvme136/console/console.c
@@ -0,0 +1,159 @@
+/*
+ * This file contains the MVME136 console IO package.
+ *
+ * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
+ * On-Line Applications Research Corporation (OAR).
+ * All rights assigned to U.S. Government, 1994.
+ *
+ * This material may be reproduced by or for the U.S. Government pursuant
+ * to the copyright license under the clause at DFARS 252.227-7013. This
+ * notice must appear in all copies of this file and its derivatives.
+ *
+ * $Id$
+ */
+
+#define M136_INIT
+
+#include <rtems.h>
+#include "console.h"
+#include "bsp.h"
+
+/* console_initialize
+ *
+ * This routine initializes the console IO driver.
+ *
+ * Input parameters: NONE
+ *
+ * Output parameters: NONE
+ *
+ * Return values:
+ */
+
+rtems_device_driver console_initialize(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void *arg,
+ rtems_id self,
+ rtems_unsigned32 *status
+)
+{
+ _Write_m681 = ( struct w_m681_info * ) M681ADDR;
+ _Read_m681 = ( struct r_m681_info * ) M681ADDR;
+ *status = RTEMS_SUCCESSFUL;
+}
+
+
+/* is_character_ready
+ *
+ * This routine returns TRUE if a character is available.
+ *
+ * Input parameters: NONE
+ *
+ * Output parameters: NONE
+ *
+ * Return values:
+ */
+
+rtems_boolean is_character_ready(
+ char *ch
+)
+{
+ if ( !(_Read_m681->srb & RXRDYB) )
+ return(FALSE);
+
+ *ch = _Read_m681->rbb;
+ return(TRUE);
+}
+
+/* inbyte
+ *
+ * This routine reads a character from the UART.
+ *
+ * Input parameters: NONE
+ *
+ * Output parameters: NONE
+ *
+ * Return values:
+ * character read from UART
+ */
+
+char inbyte( void )
+{
+ while ( !(_Read_m681->srb & RXRDYB) );
+ return _Read_m681->rbb;
+}
+
+
+/* outbyte
+ *
+ * This routine transmits a character out the M68681. It supports
+ * XON/XOFF flow control.
+ *
+ * Input parameters:
+ * ch - character to be transmitted
+ *
+ * Output parameters: NONE
+ */
+
+void outbyte(
+ char ch
+)
+{
+ while ( ! (_Read_m681->srb & TXRDYB) ) ;
+ while ( _Read_m681->srb & RXRDYB ) /* must be an XOFF */
+ if ( _Read_m681->rbb == XOFF )
+ do {
+ while ( ! (_Read_m681->srb & RXRDYB) ) ;
+ } while ( _Read_m681->rbb != XON );
+
+ _Write_m681->tbb = ch;
+ if ( ch == '\n' )
+ outbyte( CR );
+}
+
+/*
+ * __read -- read bytes from the serial port. Ignore fd, since
+ * we only have stdin.
+ */
+
+int __read(
+ int fd,
+ char *buf,
+ int nbytes
+)
+{
+ int i = 0;
+
+ for (i = 0; i < nbytes; i++) {
+ *(buf + i) = inbyte();
+ if ((*(buf + i) == '\n') || (*(buf + i) == '\r')) {
+ (*(buf + i++)) = '\n';
+ (*(buf + i)) = 0;
+ break;
+ }
+ }
+ return (i);
+}
+
+/*
+ * __write -- write bytes to the serial port. Ignore fd, since
+ * stdout and stderr are the same. Since we have no filesystem,
+ * open will only return an error.
+ */
+
+int __write(
+ int fd,
+ char *buf,
+ int nbytes
+)
+{
+ int i;
+
+ for (i = 0; i < nbytes; i++) {
+ if (*(buf + i) == '\n') {
+ outbyte ('\r');
+ }
+ outbyte (*(buf + i));
+ }
+ return (nbytes);
+}
diff --git a/c/src/lib/libbsp/m68k/mvme136/include/bsp.h b/c/src/lib/libbsp/m68k/mvme136/include/bsp.h
new file mode 100644
index 0000000000..f89a1b0461
--- /dev/null
+++ b/c/src/lib/libbsp/m68k/mvme136/include/bsp.h
@@ -0,0 +1,142 @@
+/* bsp.h
+ *
+ * This include file contains all MVME136 board IO definitions.
+ *
+ * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
+ * On-Line Applications Research Corporation (OAR).
+ * All rights assigned to U.S. Government, 1994.
+ *
+ * This material may be reproduced by or for the U.S. Government pursuant
+ * to the copyright license under the clause at DFARS 252.227-7013. This
+ * notice must appear in all copies of this file and its derivatives.
+ *
+ * $Id$
+ */
+
+#ifndef __MVME136_h
+#define __MVME136_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <rtems.h>
+#include <iosupp.h>
+
+/*
+ * Define the time limits for RTEMS Test Suite test durations.
+ * Long test and short test duration limits are provided. These
+ * values are in seconds and need to be converted to ticks for the
+ * application.
+ *
+ */
+
+#define MAX_LONG_TEST_DURATION 300 /* 5 minutes = 300 seconds */
+#define MAX_SHORT_TEST_DURATION 3 /* 3 seconds */
+
+/*
+ * Define the interrupt mechanism for Time Test 27
+ *
+ * NOTE: Use the MPCSR vector for the MVME136
+ */
+
+#define MUST_WAIT_FOR_INTERRUPT 0
+
+#define Install_tm27_vector( handler ) set_vector( (handler), 75, 1 )
+
+#define Cause_tm27_intr() (*(volatile rtems_unsigned8 *)0xfffb006b) = 0x80
+
+#define Clear_tm27_intr() (*(volatile rtems_unsigned8 *)0xfffb006b) = 0x00
+
+#define Lower_tm27_intr()
+
+/*
+ * Simple spin delay in microsecond units for device drivers.
+ * This is very dependent on the clock speed of the target.
+ */
+
+#define delay( microseconds ) \
+ { register rtems_unsigned32 _delay=(microseconds); \
+ register rtems_unsigned32 _tmp=123; \
+ asm volatile( "0: \
+ nbcd %0 ; \
+ nbcd %0 ; \
+ dbf %1,0b" \
+ : "=d" (_tmp), "=d" (_delay) \
+ : "0" (_tmp), "1" (_delay) ); \
+ }
+
+/* Constants */
+
+#define RAM_START 0
+#define RAM_END 0x100000
+
+#define M681ADDR 0xfffb0040 /* address of the M68681 chip */
+#define RXRDYB 0x01 /* status reg recv ready mask */
+#define TXRDYB 0x04 /* status reg trans ready mask */
+#define PARITYERR 0x20 /* status reg parity error mask */
+#define FRAMEERR 0x40 /* status reg frame error mask */
+
+
+#define FOREVER 1 /* infinite loop */
+
+/* Structures */
+
+struct r_m681_info {
+ char fill1[ 5 ]; /* channel A regs ( not used ) */
+ char isr; /* interrupt status reg */
+ char fill2[ 2 ]; /* counter regs (not used) */
+ char mr1mr2b; /* MR1B and MR2B regs */
+ char srb; /* status reg channel B */
+ char fill3; /* do not access */
+ char rbb; /* receive buffer channel B */
+ char ivr; /* interrupt vector register */
+};
+
+struct w_m681_info {
+ char fill1[ 4 ]; /* channel A regs (not used) */
+ char acr; /* auxillary control reg */
+ char imr; /* interrupt mask reg */
+ char fill2[ 2 ]; /* counter regs (not used) */
+ char mr1mr2b; /* MR1B and MR2B regs */
+ char csrb; /* clock select reg */
+ char crb; /* command reg */
+ char tbb; /* transmit buffer channel B */
+ char ivr; /* interrupt vector register */
+};
+
+#ifdef M136_INIT
+#undef EXTERN
+#define EXTERN
+#else
+#undef EXTERN
+#define EXTERN extern
+#endif
+
+/* miscellaneous stuff assumed to exist */
+
+extern rtems_configuration_table BSP_Configuration;
+
+/* M68681 DUART chip register variables */
+
+EXTERN volatile struct r_m681_info *_Read_m681; /* M68681 read registers */
+EXTERN volatile struct w_m681_info *_Write_m681; /* M68681 write registers */
+
+extern m68k_isr M68Kvec[]; /* vector table address */
+
+/* functions */
+
+void bsp_cleanup( void );
+
+m68k_isr set_vector(
+ rtems_isr_entry handler,
+ rtems_vector_number vector,
+ int type
+);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+/* end of include file */
diff --git a/c/src/lib/libbsp/m68k/mvme136/include/coverhd.h b/c/src/lib/libbsp/m68k/mvme136/include/coverhd.h
new file mode 100644
index 0000000000..7497514e97
--- /dev/null
+++ b/c/src/lib/libbsp/m68k/mvme136/include/coverhd.h
@@ -0,0 +1,104 @@
+/* coverhd.h
+ *
+ * This include file has defines to represent the overhead associated
+ * with calling a particular directive from C on this target.
+ *
+ * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
+ * On-Line Applications Research Corporation (OAR).
+ * All rights assigned to U.S. Government, 1994.
+ *
+ * This material may be reproduced by or for the U.S. Government pursuant
+ * to the copyright license under the clause at DFARS 252.227-7013. This
+ * notice must appear in all copies of this file and its derivatives.
+ *
+ * $Id$
+ */
+
+#ifndef __COVERHD_h
+#define __COVERHD_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define CALLING_OVERHEAD_INITIALIZE_EXECUTIVE 2
+#define CALLING_OVERHEAD_SHUTDOWN_EXECUTIVE 1
+#define CALLING_OVERHEAD_TASK_CREATE 3
+#define CALLING_OVERHEAD_TASK_IDENT 2
+#define CALLING_OVERHEAD_TASK_START 2
+#define CALLING_OVERHEAD_TASK_RESTART 2
+#define CALLING_OVERHEAD_TASK_DELETE 1
+#define CALLING_OVERHEAD_TASK_SUSPEND 1
+#define CALLING_OVERHEAD_TASK_RESUME 2
+#define CALLING_OVERHEAD_TASK_SET_PRIORITY 2
+#define CALLING_OVERHEAD_TASK_MODE 2
+#define CALLING_OVERHEAD_TASK_GET_NOTE 2
+#define CALLING_OVERHEAD_TASK_SET_NOTE 2
+#define CALLING_OVERHEAD_TASK_WAKE_WHEN 4
+#define CALLING_OVERHEAD_TASK_WAKE_AFTER 1
+#define CALLING_OVERHEAD_INTERRUPT_CATCH 2
+#define CALLING_OVERHEAD_CLOCK_GET 5
+#define CALLING_OVERHEAD_CLOCK_SET 4
+#define CALLING_OVERHEAD_CLOCK_TICK 1
+
+#define CALLING_OVERHEAD_TIMER_CREATE 2
+#define CALLING_OVERHEAD_TIMER_IDENT 1
+#define CALLING_OVERHEAD_TIMER_DELETE 2
+#define CALLING_OVERHEAD_TIMER_FIRE_AFTER 2
+#define CALLING_OVERHEAD_TIMER_FIRE_WHEN 5
+#define CALLING_OVERHEAD_TIMER_RESET 1
+#define CALLING_OVERHEAD_TIMER_CANCEL 1
+#define CALLING_OVERHEAD_SEMAPHORE_CREATE 3
+#define CALLING_OVERHEAD_SEMAPHORE_DELETE 1
+#define CALLING_OVERHEAD_SEMAPHORE_IDENT 2
+#define CALLING_OVERHEAD_SEMAPHORE_OBTAIN 2
+#define CALLING_OVERHEAD_SEMAPHORE_RELEASE 1
+#define CALLING_OVERHEAD_MESSAGE_QUEUE_CREATE 2
+#define CALLING_OVERHEAD_MESSAGE_QUEUE_IDENT 2
+#define CALLING_OVERHEAD_MESSAGE_QUEUE_DELETE 1
+#define CALLING_OVERHEAD_MESSAGE_QUEUE_SEND 2
+#define CALLING_OVERHEAD_MESSAGE_QUEUE_URGENT 2
+#define CALLING_OVERHEAD_MESSAGE_QUEUE_BROADCAST 2
+#define CALLING_OVERHEAD_MESSAGE_QUEUE_RECEIVE 3
+#define CALLING_OVERHEAD_MESSAGE_QUEUE_FLUSH 2
+
+#define CALLING_OVERHEAD_EVENT_SEND 2
+#define CALLING_OVERHEAD_EVENT_RECEIVE 2
+#define CALLING_OVERHEAD_SIGNAL_CATCH 2
+#define CALLING_OVERHEAD_SIGNAL_SEND 2
+#define CALLING_OVERHEAD_PARTITION_CREATE 3
+#define CALLING_OVERHEAD_PARTITION_IDENT 2
+#define CALLING_OVERHEAD_PARTITION_DELETE 1
+#define CALLING_OVERHEAD_PARTITION_GET_BUFFER 2
+#define CALLING_OVERHEAD_PARTITION_RETURN_BUFFER 2
+#define CALLING_OVERHEAD_REGION_CREATE 3
+#define CALLING_OVERHEAD_REGION_IDENT 2
+#define CALLING_OVERHEAD_REGION_DELETE 2
+#define CALLING_OVERHEAD_REGION_GET_SEGMENT 3
+#define CALLING_OVERHEAD_REGION_RETURN_SEGMENT 2
+#define CALLING_OVERHEAD_PORT_CREATE 3
+#define CALLING_OVERHEAD_PORT_IDENT 2
+#define CALLING_OVERHEAD_PORT_DELETE 1
+#define CALLING_OVERHEAD_PORT_EXTERNAL_TO_INTERNAL 2
+#define CALLING_OVERHEAD_PORT_INTERNAL_TO_EXTERNAL 2
+
+#define CALLING_OVERHEAD_IO_INITIALIZE 2
+#define CALLING_OVERHEAD_IO_OPEN 2
+#define CALLING_OVERHEAD_IO_CLOSE 3
+#define CALLING_OVERHEAD_IO_READ 2
+#define CALLING_OVERHEAD_IO_WRITE 2
+#define CALLING_OVERHEAD_IO_CONTROL 2
+#define CALLING_OVERHEAD_FATAL_ERROR_OCCURRED 1
+#define CALLING_OVERHEAD_RATE_MONOTONIC_CREATE 2
+#define CALLING_OVERHEAD_RATE_MONOTONIC_IDENT 2
+#define CALLING_OVERHEAD_RATE_MONOTONIC_DELETE 1
+#define CALLING_OVERHEAD_RATE_MONOTONIC_CANCEL 1
+#define CALLING_OVERHEAD_RATE_MONOTONIC_PERIOD 2
+#define CALLING_OVERHEAD_MULTIPROCESSING_ANNOUNCE 1
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+/* end of include file */
diff --git a/c/src/lib/libbsp/m68k/mvme136/shmsupp/addrconv.c b/c/src/lib/libbsp/m68k/mvme136/shmsupp/addrconv.c
new file mode 100644
index 0000000000..8e1502f789
--- /dev/null
+++ b/c/src/lib/libbsp/m68k/mvme136/shmsupp/addrconv.c
@@ -0,0 +1,32 @@
+/* Shm_Convert_address
+ *
+ * This MVME136 has a "normal" view of the VME address space.
+ * No address range conversion is required.
+ *
+ * Input parameters:
+ * address - address to convert
+ *
+ * Output parameters:
+ * returns - converted address
+ *
+ * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
+ * On-Line Applications Research Corporation (OAR).
+ * All rights assigned to U.S. Government, 1994.
+ *
+ * This material may be reproduced by or for the U.S. Government pursuant
+ * to the copyright license under the clause at DFARS 252.227-7013. This
+ * notice must appear in all copies of this file and its derivatives.
+ *
+ * $Id$
+ */
+
+#include <rtems.h>
+#include <bsp.h>
+#include <shm.h>
+
+void *Shm_Convert_address(
+ void *address
+)
+{
+ return ( address );
+}
diff --git a/c/src/lib/libbsp/m68k/mvme136/shmsupp/getcfg.c b/c/src/lib/libbsp/m68k/mvme136/shmsupp/getcfg.c
new file mode 100644
index 0000000000..d4db200ad2
--- /dev/null
+++ b/c/src/lib/libbsp/m68k/mvme136/shmsupp/getcfg.c
@@ -0,0 +1,85 @@
+/* void Shm_Get_configuration( localnode, &shmcfg )
+ *
+ * This routine initializes, if necessary, and returns a pointer
+ * to the Shared Memory Configuration Table for the Cyclone CVME961.
+ *
+ * INPUT PARAMETERS:
+ * localnode - local node number
+ * shmcfg - address of pointer to SHM Config Table
+ *
+ * OUTPUT PARAMETERS:
+ * *shmcfg - pointer to SHM Config Table
+ *
+ * NOTES: The MPCSR interrupt on the MVME136 is used as an interprocessor
+ * interrupt. The capablities of the MPCSR are used to generate
+ * interprocessor interrupts for up to eight nodes.
+ *
+ * The following table illustrates the configuration limitations:
+ *
+ * BUS MAX
+ * MODE ENDIAN NODES
+ * ========= ====== =======
+ * POLLED LITTLE 2+
+ * INTERRUPT LITTLE 2-8
+ *
+ * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
+ * On-Line Applications Research Corporation (OAR).
+ * All rights assigned to U.S. Government, 1994.
+ *
+ * This material may be reproduced by or for the U.S. Government pursuant
+ * to the copyright license under the clause at DFARS 252.227-7013. This
+ * notice must appear in all copies of this file and its derivatives.
+ *
+ * $Id$
+ */
+
+#include <rtems.h>
+#include "shm.h"
+
+#define INTERRUPT 1 /* MVME136 target supports both */
+#define POLLING 0 /* polling and interrupt modes */
+
+shm_config_table BSP_shm_cfgtbl;
+
+rtems_unsigned32 *BSP_int_address()
+{
+ rtems_unsigned32 id, offset;
+
+ id = (rtems_unsigned32) *(rtems_unsigned8 *)0xfffb0061;
+ offset = ((id & 0x1f) << 5) | ((id & 0xe0) << 8);
+ offset |= 0xffff000b;
+ return( (rtems_unsigned32 * ) offset );
+}
+
+void Shm_Get_configuration(
+ rtems_unsigned32 localnode,
+ shm_config_table **shmcfg
+)
+{
+ BSP_shm_cfgtbl.base = (rtems_unsigned32 *)0x20000000;
+ BSP_shm_cfgtbl.length = 1 * MEGABYTE;
+ BSP_shm_cfgtbl.format = SHM_BIG;
+
+ BSP_shm_cfgtbl.cause_intr = Shm_Cause_interrupt;
+
+#ifdef NEUTRAL_BIG
+ BSP_shm_cfgtbl.convert = NULL_CONVERT;
+#else
+ BSP_shm_cfgtbl.convert = CPU_swap_u32;
+#endif
+
+#if (POLLING==1)
+ BSP_shm_cfgtbl.poll_intr = POLLED_MODE;
+ BSP_shm_cfgtbl.Intr.address = NO_INTERRUPT;
+ BSP_shm_cfgtbl.Intr.value = NO_INTERRUPT;
+ BSP_shm_cfgtbl.Intr.length = NO_INTERRUPT;
+#else
+ BSP_shm_cfgtbl.poll_intr = INTR_MODE;
+ BSP_shm_cfgtbl.Intr.address = BSP_int_address();
+ BSP_shm_cfgtbl.Intr.value = 0x80;
+ BSP_shm_cfgtbl.Intr.length = BYTE;
+#endif
+
+ *shmcfg = &BSP_shm_cfgtbl;
+
+}
diff --git a/c/src/lib/libbsp/m68k/mvme136/shmsupp/lock.c b/c/src/lib/libbsp/m68k/mvme136/shmsupp/lock.c
new file mode 100644
index 0000000000..5ccc406af5
--- /dev/null
+++ b/c/src/lib/libbsp/m68k/mvme136/shmsupp/lock.c
@@ -0,0 +1,75 @@
+/* Shared Memory Lock Routines
+ *
+ * This shared memory locked queue support routine need to be
+ * able to lock the specified locked queue. Interrupts are
+ * disabled while the queue is locked to prevent preemption
+ * and deadlock when two tasks poll for the same lock.
+ * previous level.
+ *
+ * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
+ * On-Line Applications Research Corporation (OAR).
+ * All rights assigned to U.S. Government, 1994.
+ *
+ * This material may be reproduced by or for the U.S. Government pursuant
+ * to the copyright license under the clause at DFARS 252.227-7013. This
+ * notice must appear in all copies of this file and its derivatives.
+ *
+ * $Id$
+ */
+
+#include <rtems.h>
+#include <bsp.h>
+#include <shm.h>
+
+/*
+ * Shm_Initialize_lock
+ *
+ * Initialize the lock for the specified locked queue.
+ */
+
+void Shm_Initialize_lock(
+ Shm_Locked_queue_Control *lq_cb
+)
+{
+ lq_cb->lock = LQ_UNLOCKED;
+}
+
+/* void _Shm_Lock( &lq_cb )
+ *
+ * This shared memory locked queue support routine locks the
+ * specified locked queue. It disables interrupts to prevent
+ * a deadlock condition.
+ */
+
+void Shm_Lock(
+ Shm_Locked_queue_Control *lq_cb
+)
+{
+ rtems_unsigned32 isr_level;
+ rtems_unsigned32 *lockptr = (rtems_unsigned32 *)&lq_cb->lock;
+
+ rtems_interrupt_disable( isr_level );
+ Shm_isrstat = isr_level;
+ asm volatile( "lockit:" : : );
+ asm volatile( "tas %0@" : "=a" (lockptr) : "0" (lockptr) );
+ asm volatile( "bne lockit" : : );
+/* should delay */
+}
+
+/*
+ * Shm_Unlock
+ *
+ * Unlock the lock for the specified locked queue.
+ */
+
+void Shm_Unlock(
+ Shm_Locked_queue_Control *lq_cb
+)
+{
+ rtems_unsigned32 isr_level;
+
+ lq_cb->lock = SHM_UNLOCK_VALUE;
+ isr_level = Shm_isrstat;
+ rtems_interrupt_enable( isr_level );
+}
+
diff --git a/c/src/lib/libbsp/m68k/mvme136/shmsupp/mpisr.c b/c/src/lib/libbsp/m68k/mvme136/shmsupp/mpisr.c
new file mode 100644
index 0000000000..6591d28a11
--- /dev/null
+++ b/c/src/lib/libbsp/m68k/mvme136/shmsupp/mpisr.c
@@ -0,0 +1,42 @@
+/* Shm_isr_mvme136()
+ *
+ * NOTE: This routine is not used when in polling mode. Either
+ * this routine OR Shm_clockisr is used in a particular system.
+ *
+ * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
+ * On-Line Applications Research Corporation (OAR).
+ * All rights assigned to U.S. Government, 1994.
+ *
+ * This material may be reproduced by or for the U.S. Government pursuant
+ * to the copyright license under the clause at DFARS 252.227-7013. This
+ * notice must appear in all copies of this file and its derivatives.
+ *
+ * $Id$
+ */
+
+#include <rtems.h>
+#include <bsp.h>
+#include <shm.h>
+
+rtems_isr Shm_isr_mvme136()
+{
+ Shm_Interrupt_count += 1;
+ rtems_multiprocessing_announce();
+ (*(volatile rtems_unsigned8 *)0xfffb006b) = 0; /* clear MPCSR intr */
+}
+
+/* void _Shm_setvec( )
+ *
+ * This driver routine sets the SHM interrupt vector to point to the
+ * driver's SHM interrupt service routine.
+ *
+ * Input parameters: NONE
+ *
+ * Output parameters: NONE
+ */
+
+void Shm_setvec()
+{
+ /* may need to disable intr */
+ set_vector( Shm_isr_mvme136, 75, 1 );
+}
diff --git a/c/src/lib/libbsp/m68k/mvme136/startup/bspclean.c b/c/src/lib/libbsp/m68k/mvme136/startup/bspclean.c
new file mode 100644
index 0000000000..4366603a55
--- /dev/null
+++ b/c/src/lib/libbsp/m68k/mvme136/startup/bspclean.c
@@ -0,0 +1,46 @@
+/*
+ * This routine returns control to 135Bug.
+ *
+ * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
+ * On-Line Applications Research Corporation (OAR).
+ * All rights assigned to U.S. Government, 1994.
+ *
+ * This material may be reproduced by or for the U.S. Government pursuant
+ * to the copyright license under the clause at DFARS 252.227-7013. This
+ * notice must appear in all copies of this file and its derivatives.
+ *
+ * $Id$
+ */
+
+#include <rtems.h>
+#include <bsp.h>
+#include <clockdrv.h>
+#include <z8036.h>
+
+void bsp_return_to_monitor_trap()
+{
+ extern void start( void );
+
+ register volatile void *start_addr;
+
+ m68k_set_vbr( 0 ); /* restore 135Bug vectors */
+ asm volatile( "trap #15" ); /* trap to 135Bug */
+ asm volatile( ".short 0x63" ); /* return to 135Bug (.RETURN) */
+ /* restart program */
+ start_addr = start;
+
+ asm volatile ( "jmp %0@" : "=a" (start_addr) : "0" (start_addr) );
+}
+
+#define TIMER 0xfffb0000
+
+void bsp_cleanup( void )
+{
+ Z8x36_WRITE( TIMER, MASTER_INTR, 0x62 ); /* redo timer */
+ Z8x36_WRITE( TIMER, CT1_MODE_SPEC, 0x00 );
+ Z8x36_WRITE( TIMER, MASTER_CFG, 0xf4 );
+ Z8x36_WRITE( TIMER, CT1_CMD_STATUS, 0x00 );
+
+ M68Kvec[ 45 ] = bsp_return_to_monitor_trap; /* install handler */
+ asm volatile( "trap #13" ); /* insures SUPV mode */
+}
diff --git a/c/src/lib/libbsp/m68k/mvme136/startup/bspstart.c b/c/src/lib/libbsp/m68k/mvme136/startup/bspstart.c
new file mode 100644
index 0000000000..514340d9ea
--- /dev/null
+++ b/c/src/lib/libbsp/m68k/mvme136/startup/bspstart.c
@@ -0,0 +1,156 @@
+/* bsp_start()
+ *
+ * This routine starts the application. It includes application,
+ * board, and monitor specific initialization and configuration.
+ * The generic CPU dependent initialization has been performed
+ * before this routine is invoked.
+ *
+ * INPUT: NONE
+ *
+ * OUTPUT: NONE
+ *
+ * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
+ * On-Line Applications Research Corporation (OAR).
+ * All rights assigned to U.S. Government, 1994.
+ *
+ * This material may be reproduced by or for the U.S. Government pursuant
+ * to the copyright license under the clause at DFARS 252.227-7013. This
+ * notice must appear in all copies of this file and its derivatives.
+ *
+ * $Id$
+ */
+
+#include <rtems.h>
+#include <bsp.h>
+#include <libcsupport.h>
+#include <z8036.h>
+
+#include "stackchk.h"
+
+/*
+ * The original table from the application and our copy of it with
+ * some changes.
+ */
+
+extern rtems_configuration_table Configuration;
+rtems_configuration_table BSP_Configuration;
+
+rtems_cpu_table Cpu_table;
+
+/* Initialize whatever libc we are using
+ * called from postdriver hook
+ */
+
+void bsp_libc_init()
+{
+ extern int end;
+ rtems_unsigned32 heap_start;
+
+ heap_start = (rtems_unsigned32) &end;
+ if (heap_start & (CPU_ALIGNMENT-1))
+ heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
+
+ RTEMS_Malloc_Initialize((void *) heap_start, 64 * 1024, 0);
+
+ /*
+ * Set up for the libc handling.
+ */
+
+ if (BSP_Configuration.ticks_per_timeslice > 0)
+ libc_init(1); /* reentrant if possible */
+ else
+ libc_init(0); /* non-reentrant */
+
+ /*
+ * Initialize the stack bounds checker
+ */
+
+#ifdef STACK_CHECKER_ON
+ Stack_check_Initialize();
+#endif
+}
+
+int bsp_start(
+ int argc,
+ char **argv,
+ char **environp
+)
+{
+ m68k_isr *monitors_vector_table;
+ int index;
+
+ monitors_vector_table = (m68k_isr *)0; /* 135Bug Vectors are at 0 */
+ m68k_set_vbr( monitors_vector_table );
+
+ for ( index=2 ; index<=255 ; index++ )
+ M68Kvec[ index ] = monitors_vector_table[ 32 ];
+
+ M68Kvec[ 2 ] = monitors_vector_table[ 2 ]; /* bus error vector */
+ M68Kvec[ 4 ] = monitors_vector_table[ 4 ]; /* breakpoints vector */
+ M68Kvec[ 9 ] = monitors_vector_table[ 9 ]; /* trace vector */
+ M68Kvec[ 47 ] = monitors_vector_table[ 47 ]; /* system call vector */
+
+ m68k_set_vbr( &M68Kvec );
+
+ (*(rtems_unsigned8 *)0xfffb0067) = 0x7f; /* make VME access round-robin */
+
+ m68k_enable_caching();
+
+ /*
+ * we only use a hook to get the C library initialized.
+ */
+
+ Cpu_table.pretasking_hook = NULL;
+
+ Cpu_table.predriver_hook = bsp_libc_init; /* RTEMS resources available */
+
+ Cpu_table.postdriver_hook = NULL;
+
+ Cpu_table.idle_task = NULL; /* do not override system IDLE task */
+
+ Cpu_table.do_zero_of_workspace = TRUE;
+
+ Cpu_table.interrupt_vector_table = (m68k_isr *) &M68Kvec;
+
+ Cpu_table.interrupt_stack_size = 4096;
+
+ Cpu_table.extra_system_initialization_stack = 0;
+
+ /*
+ * Copy the table
+ */
+
+ BSP_Configuration = Configuration;
+
+ BSP_Configuration.work_space_start = (void *)
+ (RAM_END - BSP_Configuration.work_space_size);
+
+ /*
+ * Add 1 region for the RTEMS Malloc
+ */
+
+ BSP_Configuration.maximum_regions++;
+
+ /*
+ * Add 1 extension for newlib libc
+ */
+
+#ifdef RTEMS_NEWLIB
+ BSP_Configuration.maximum_extensions++;
+#endif
+
+ /*
+ * Add another extension if using the stack checker
+ */
+
+#ifdef STACK_CHECKER_ON
+ BSP_Configuration.maximum_extensions++;
+#endif
+
+ rtems_initialize_executive( &BSP_Configuration, &Cpu_table );
+ /* does not return */
+
+ bsp_cleanup();
+
+ return 0;
+}
diff --git a/c/src/lib/libbsp/m68k/mvme136/startup/linkcmds b/c/src/lib/libbsp/m68k/mvme136/startup/linkcmds
new file mode 100644
index 0000000000..13317a724e
--- /dev/null
+++ b/c/src/lib/libbsp/m68k/mvme136/startup/linkcmds
@@ -0,0 +1,48 @@
+/*
+ * This file contains directives for the GNU linker which are specific
+ * to the Motorola MVME136/MVME135 boards.
+ *
+ * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
+ * On-Line Applications Research Corporation (OAR).
+ * All rights assigned to U.S. Government, 1994.
+ *
+ * This material may be reproduced by or for the U.S. Government pursuant
+ * to the copyright license under the clause at DFARS 252.227-7013. This
+ * notice must appear in all copies of this file and its derivatives.
+ *
+ * $Id$
+ */
+
+MEMORY
+ {
+ ram : org = 0x3000, l = 1M
+ }
+
+SECTIONS
+{
+ .text 0x3000 :
+ {
+ text_start = . ;
+ _text_start = . ;
+ *(.text)
+ etext = ALIGN( 0x10 ) ;
+ _etext = .;
+ }
+ .data ADDR( .text ) + SIZEOF( .text ):
+ {
+ data_start = . ;
+ _data_start = .;
+ *(.data)
+ edata = ALIGN( 0x10 ) ;
+ _edata = .;
+ }
+ .bss ADDR( .data ) + SIZEOF( .data ):
+ {
+ bss_start = . ;
+ _bss_start = . ;
+ *(.bss)
+ *(COMMON)
+ end = . ;
+ _end = . ;
+ }
+}
diff --git a/c/src/lib/libbsp/m68k/mvme136/timer/timer.c b/c/src/lib/libbsp/m68k/mvme136/timer/timer.c
new file mode 100644
index 0000000000..8c3ecd45f2
--- /dev/null
+++ b/c/src/lib/libbsp/m68k/mvme136/timer/timer.c
@@ -0,0 +1,108 @@
+/* Timer_init()
+ *
+ * This routine initializes the Z8036 timer on the MVME136 board.
+ *
+ * Input parameters: NONE
+ *
+ * Output parameters: NONE
+ *
+ * NOTE: This routine will not work if the optimizer is enabled
+ * for some compilers. The multiple writes to the Z8036
+ * may be optimized away.
+ *
+ * It is important that the timer start/stop overhead be
+ * determined when porting or modifying this code.
+ *
+ * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
+ * On-Line Applications Research Corporation (OAR).
+ * All rights assigned to U.S. Government, 1994.
+ *
+ * This material may be reproduced by or for the U.S. Government pursuant
+ * to the copyright license under the clause at DFARS 252.227-7013. This
+ * notice must appear in all copies of this file and its derivatives.
+ *
+ * $Id$
+ */
+
+
+#include <rtems.h>
+#include <bsp.h>
+#include <z8036.h>
+
+#define TIMER 0xfffb0000 /* address of Z8036 on MVME136 */
+
+int Ttimer_val;
+rtems_boolean Timer_driver_Find_average_overhead;
+
+rtems_isr timerisr();
+
+void Timer_initialize()
+{
+ (void) set_vector( timerisr, 66, 0 ); /* install ISR */
+
+ Ttimer_val = 0; /* clear timer ISR count */
+ Z8x36_WRITE( TIMER, MASTER_INTR, 0x01 ); /* reset */
+ Z8x36_WRITE( TIMER, MASTER_INTR, 0x00 ); /* clear reset */
+ Z8x36_WRITE( TIMER, MASTER_INTR, 0xe2 ); /* disable lower chain, no vec */
+ /* set right justified addr */
+ /* and master int enable */
+ Z8x36_WRITE( TIMER, CT1_MODE_SPEC, 0x80 ); /* T1 continuous, and */
+ /* cycle/pulse output */
+
+ *((rtems_unsigned16 *)0xfffb0016) = 0x0000; /* write countdown value */
+/*
+ Z8x36_WRITE( TIMER, CT1_TIME_CONST_MSB, 0x00 );
+ Z8x36_WRITE( TIMER, CT1_TIME_CONST_LSB, 0x00 );
+*/
+ Z8x36_WRITE( TIMER, MASTER_CFG, 0xc4 ); /* enable timer1 */
+
+ Z8x36_WRITE( TIMER, CT1_CMD_STATUS, 0xc6 ); /* set INTR enable (IE), */
+ /* trigger command */
+ /* (TCB) and gate */
+ /* command (GCB) bits */
+ *((rtems_unsigned8 *)0xfffb0038) &= 0xfd; /* enable timer INTR on */
+ /* VME controller */
+}
+
+#define AVG_OVERHEAD 6 /* It typically takes 3.0 microseconds */
+ /* (6 countdowns) to start/stop the timer. */
+#define LEAST_VALID 10 /* Don't trust a value lower than this */
+
+int Read_timer()
+{
+/*
+ rtems_unsigned8 msb, lsb;
+*/
+ rtems_unsigned32 remaining, total;
+
+ Z8x36_WRITE( TIMER, CT1_CMD_STATUS, 0xce ); /* read the counter value */
+remaining = 0xffff - *((rtems_unsigned16 *) 0xfffb0010);
+/*
+ Z8x36_READ( TIMER, CT1_CUR_CNT_MSB, msb );
+ Z8x36_READ( TIMER, CT1_CUR_CNT_LSB, lsb );
+
+ remaining = 0xffff - ((msb << 8) + lsb);
+*/
+ total = (Ttimer_val * 0x10000) + remaining;
+
+ 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/m68k/mvme136/timer/timerisr.s b/c/src/lib/libbsp/m68k/mvme136/timer/timerisr.s
new file mode 100644
index 0000000000..a8f7e7b212
--- /dev/null
+++ b/c/src/lib/libbsp/m68k/mvme136/timer/timerisr.s
@@ -0,0 +1,39 @@
+# timer_isr()
+#
+# This routine provides the ISR for the Z8036 timer on the MVME136
+# board. The timer is set up to generate an interrupt at maximum
+# intervals.
+#
+# Input parameters: NONE
+#
+# Output parameters: NONE
+#
+# COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
+# On-Line Applications Research Corporation (OAR).
+# All rights assigned to U.S. Government, 1994.
+#
+# This material may be reproduced by or for the U.S. Government pursuant
+# to the copyright license under the clause at DFARS 252.227-7013. This
+# notice must appear in all copies of this file and its derivatives.
+#
+# $Id$
+#
+
+#include "asm.h"
+
+BEGIN_CODE
+
+.set CT1_CMD_STATUS, 0xfffb000a | port A
+.set RELOAD, 0x24 | clr IP & IUS,allow countdown
+
+ PUBLIC (timerisr)
+SYM (timerisr):
+ movl a0,a7@- | save a0
+ movl #CT1_CMD_STATUS,a0 | a0 = addr of cmd status reg
+ movb #RELOAD,a0@ | reload countdown
+ addql #1, SYM (Ttimer_val) | increment timer value
+ movl a7@+,a0 | save a0
+ rte
+
+END_CODE
+END
diff --git a/c/src/lib/libbsp/m68k/mvme162/README b/c/src/lib/libbsp/m68k/mvme162/README
new file mode 100644
index 0000000000..cdb1f28348
--- /dev/null
+++ b/c/src/lib/libbsp/m68k/mvme162/README
@@ -0,0 +1,124 @@
+--
+-- EISCAT Scientific Association. M.Savitski
+--
+-- This material is a part of the MVME162 Board Support Package
+-- for the RTEMS executive. Its licensing policies are those of the
+-- RTEMS distribution.
+--
+-- Updated by Joel Sherrill (jsherril@redstone.army.mil) after
+-- inclusion in the standard release.
+--
+-- $Id$
+--
+
+This is a README file for the MVME162 port of RTEMS.
+
+Disclaimer
+----------
+This is my first attempt at porting RTEMS. The resulting code obviously
+contains bugs (know and unknown) and limitations. I assume no
+responsibility for quality and support of the software in question.
+
+Now on more optimistic note:
+
+I have run most of the standard RTEMS sptests, and neither of them
+failed. My present (short) experience of developing RTEMS applications
+is essentially positive and suggestive of a long-term commitment. In
+any case I am ready to answer questions regarding the port and intend
+to follow the future RTEMS versions. I will do my best to provide
+whatever support I can afford time-wise.
+
+Installation
+------------
+Nothing unique to the MVME162. It has been incorporated into the
+standard release.
+
+Port Description
+----------------
+The port was done using already existing ports to the M68020 boards,
+DMV152 and MVME136.
+
+The host system was SUN/Solaris 2.3, and the cross-development
+environment consisted of Free Software Foundation (FSF)'s GNU C
+compiler (version 2.6), GNU Assembler (version 2.3) and GNU binary
+utilities binutils version 2.5.2, built with m68k as a target. The
+recent/latest versions of other GNU programs (flex, make, etc) were
+also used at the build stage.
+
+In all subdirectories of the RTEMS distribution tree, the directories
+mvme136 were duplicated as mvme162.
+
+Essential modifications are detailed below:
+
+- the MVME162-specific hardware registers were described in bsp.h
+
+- timer and clock routines were made to use the MVME162's Tick Timers 1
+and 2, respectively
+
+- shared memory support was replaced by stubs for the time being
+
+- console IO was lifted entirely from the DMV152 support code, thanks
+to the fact that Z8530 SCC used in DMV152 is upwards compatible with
+the Z85230 SCC of the MVME162. (Only the memory mapping of the SCC
+registers had to be changed.)
+
+- symbols in several *.s files were prepended with underscores to
+comply with the xgcc configuration used (it prepends underscores to all
+symbols defined in c code)
+
+- linkcmds file was modified to place the linked code into the memory
+configured for the board in use
+
+- bspstart.c was modified as follows:
+
+ monitors_vector_table = (m68k_isr *)0xFFE00000;
+
+was made to point to the power-up location of MVME162 interrupt vector
+table.
+
+- The shutdown is a temporary solution. To exit cleanly, it has to disable
+all enabled interrupts and restore the board to its power-up status.
+Presently this is not done satisfactorily, as a result, the board needs
+a hardware reset from the external VMEbus master or from the front
+panel to ensure correct operation for subsequent downloads.
+
+Host System
+-----------
+The VMEbus master used to externally control and download the MVME162
+is a FORCE CPU-2CE board running Solaris 2.3. A simple program to load
+s-records and start/reset the MVME162 was written. The code is in the
+file tools/sload.c
+
+This code depends on the external VMEbus master's vme driver and is
+provided as an example, without the Makefile. The bulk of the program
+which parses the s-records is courtesy of Kym Newbery,
+(8918927y@lux.levels.unisa.edu.au).
+
+In general, apart from x-gcc, the tools most often used while building
+RTEMS for MVME162 were: find, grep, diff, and, of course
+
+MVME162 Embedded Controller Programmer's Reference Guide,
+Motorola, MVME162PG/D1.
+
+Thanks
+------
+- to On-Line Applications Research Corporation (OAR) for developing
+RTEMS and making it available on a Technology Transfer basis;
+- to Joel Sherril, the leader of the RTEMS development group for
+stimulating and helpful discussions;
+- to Kym Newbery (8918927y@lux.levels.unisa.edu.au) for his s-record
+parser;
+- to Gerd Truschinski (gt@first.gmd.de) for creating and running the
+crossgcc mailing list
+- to FSF and Cygnus Support for great free software;
+
+
++----------------------------------+-------------------------------+
+| Dr. Mikhail (Misha) Savitski | Voice : +46-980-79162 |
+| Software Systems Engineer | Fax : +46-980-79161 |
+| EISCAT Svalbard Radar Project | E-mail: mms@eiscathq.irf.se |
+| EISCAT Scientific Association |----------- /\_/\ -----------|
+| Box 812 S-98128 Kiruna, Sweden | EIS { o o } CAT |
++----------------------------------+-------oQQQ--(>I<)--QQQo-------+
+
+
diff --git a/c/src/lib/libbsp/m68k/mvme162/clock/ckinit.c b/c/src/lib/libbsp/m68k/mvme162/clock/ckinit.c
new file mode 100644
index 0000000000..95e35e5f66
--- /dev/null
+++ b/c/src/lib/libbsp/m68k/mvme162/clock/ckinit.c
@@ -0,0 +1,91 @@
+/* Clock_init()
+ *
+ * This routine initializes the Tick Timer 2 on the MVME162 board.
+ * The tick frequency is 1 millisecond.
+ *
+ * Input parameters: NONE
+ *
+ * Output parameters: NONE
+ *
+ * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
+ * On-Line Applications Research Corporation (OAR).
+ * All rights assigned to U.S. Government, 1994.
+ *
+ * This material may be reproduced by or for the U.S. Government pursuant
+ * to the copyright license under the clause at DFARS 252.227-7013. This
+ * notice must appear in all copies of this file and its derivatives.
+ *
+ * Modifications of respective RTEMS file: COPYRIGHT (c) 1994.
+ * EISCAT Scientific Association. M.Savitski
+ *
+ * This material is a part of the MVME162 Board Support Package
+ * for the RTEMS executive. Its licensing policies are those of the
+ * RTEMS above.
+ *
+ * $Id$
+ */
+
+#include <stdlib.h>
+
+#include <rtems.h>
+#include <bsp.h>
+#include <clockdrv.h>
+
+#define MS_COUNT 1000 /* T2's countdown constant (1 ms) */
+#define CLOCK_INT_LEVEL 6 /* T2's interrupt level */
+
+rtems_unsigned32 Clock_isrs; /* ISRs until next tick */
+volatile rtems_unsigned32 Clock_driver_ticks;
+ /* ticks since initialization */
+rtems_isr_entry Old_ticker;
+
+rtems_device_driver Clock_initialize(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void *pargp,
+ rtems_id tid,
+ rtems_unsigned32 *rval
+)
+{
+ Install_clock( Clock_isr );
+}
+
+void ReInstall_clock( clock_isr )
+rtems_isr_entry clock_isr;
+{
+ rtems_unsigned32 isrlevel;
+
+ rtems_interrupt_disable( isrlevel );
+ (void) set_vector( clock_isr, (VECTOR_BASE >> 28) * 0x10 + 0x9, 1 );
+ rtems_interrupt_enable( isrlevel );
+}
+
+void Install_clock( clock_isr )
+rtems_isr_entry clock_isr;
+{
+
+ Clock_driver_ticks = 0;
+ Clock_isrs = BSP_Configuration.microseconds_per_tick / 1000;
+
+ if ( BSP_Configuration.ticks_per_timeslice ) {
+ Old_ticker = (rtems_isr_entry)
+ set_vector( clock_isr, (VECTOR_BASE >> 28) * 0x10 + 0x9, 1 );
+
+ lcsr->vector_base = 0x67800000; /* set vb, enable interrupts */
+ lcsr->to_ctl = 0xE7; /* prescaler to 1 MHz (see Appendix A1) */
+ lcsr->timer_cmp_2 = MS_COUNT;
+ lcsr->timer_cnt_2 = 0; /* clear counter */
+ lcsr->board_ctl |= 0x700; /* increment, reset-on-compare, clear-ovfl-cnt */
+
+ lcsr->intr_level[0] |= CLOCK_INT_LEVEL * 0x10; /* set int level */
+ lcsr->intr_ena |= 0x02000000; /* enable tick timer 2 interrupt */
+
+ atexit( Clock_exit );
+ }
+
+}
+
+void Clock_exit( void )
+{
+/* Dummy for now. See other m68k BSP's for code examples */
+}
diff --git a/c/src/lib/libbsp/m68k/mvme162/console/console.c b/c/src/lib/libbsp/m68k/mvme162/console/console.c
new file mode 100644
index 0000000000..7e8f5132f9
--- /dev/null
+++ b/c/src/lib/libbsp/m68k/mvme162/console/console.c
@@ -0,0 +1,193 @@
+/*
+ * This file contains the MVME162 console IO package.
+ *
+ * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
+ * On-Line Applications Research Corporation (OAR).
+ * All rights assigned to U.S. Government, 1994.
+ *
+ * This material may be reproduced by or for the U.S. Government pursuant
+ * to the copyright license under the clause at DFARS 252.227-7013. This
+ * notice must appear in all copies of this file and its derivatives.
+ *
+ * Modifications of respective RTEMS file: COPYRIGHT (c) 1994.
+ * EISCAT Scientific Association. M.Savitski
+ *
+ * This material is a part of the MVME162 Board Support Package
+ * for the RTEMS executive. Its licensing policies are those of the
+ * RTEMS above.
+ *
+ * $Id$
+ */
+
+#define M162_INIT
+
+#include <rtems.h>
+#include "console.h"
+#include "bsp.h"
+
+/* console_initialize
+ *
+ * This routine initializes the console IO driver.
+ *
+ * Input parameters: NONE
+ *
+ * Output parameters: NONE
+ *
+ * Return values:
+ */
+
+rtems_device_driver console_initialize(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void *arg,
+ rtems_id self,
+ rtems_unsigned32 *status
+)
+{
+ *status = RTEMS_SUCCESSFUL;
+}
+
+
+/* is_character_ready
+ *
+ * This routine returns TRUE if a character is available.
+ *
+ * Input parameters: NONE
+ *
+ * Output parameters: NONE
+ *
+ * Return values:
+ */
+
+rtems_boolean is_character_ready(
+ char *ch
+)
+{
+ rtems_unsigned8 rr_0;
+
+ Z8x30_READ_CONTROL( CONSOLE_CONTROL, RR_0, rr_0 );
+ if ( !(rr_0 & RR_0_RX_DATA_AVAILABLE) )
+ return( FALSE );
+
+ Z8x30_READ_DATA( CONSOLE_DATA, *ch );
+
+ return(TRUE);
+}
+
+/* inbyte
+ *
+ * This routine reads a character from the SCC.
+ *
+ * Input parameters: NONE
+ *
+ * Output parameters: NONE
+ *
+ * Return values:
+ * character read from SCC
+ */
+
+char inbyte( void )
+{
+ rtems_unsigned8 rr_0;
+ char ch;
+
+ while ( 1 ) {
+ Z8x30_READ_CONTROL( CONSOLE_CONTROL, RR_0, rr_0 );
+ if ( (rr_0 & RR_0_RX_DATA_AVAILABLE) != 0 )
+ break;
+ }
+
+ Z8x30_READ_DATA( CONSOLE_DATA, ch );
+ return ch;
+}
+
+
+/* outbyte
+ *
+ * This routine transmits a character out the SCC. It supports
+ * XON/XOFF flow control.
+ *
+ * Input parameters:
+ * ch - character to be transmitted
+ *
+ * Output parameters: NONE
+ */
+
+void outbyte(
+ char ch
+)
+{
+ rtems_unsigned8 rr_0;
+ char flow_control;
+
+ while ( 1 ) {
+ Z8x30_READ_CONTROL( CONSOLE_CONTROL, RR_0, rr_0 );
+ if ( (rr_0 & RR_0_TX_BUFFER_EMPTY) != 0 )
+ break;
+ }
+
+ while ( 1 ) {
+ Z8x30_READ_CONTROL( CONSOLE_CONTROL, RR_0, rr_0 );
+ if ( (rr_0 & RR_0_RX_DATA_AVAILABLE) == 0 )
+ break;
+
+ Z8x30_READ_DATA( CONSOLE_DATA, flow_control );
+
+ if ( flow_control == XOFF )
+ do {
+ do {
+ Z8x30_READ_CONTROL( CONSOLE_CONTROL, RR_0, rr_0 );
+ } while ( (rr_0 & RR_0_RX_DATA_AVAILABLE) == 0 );
+ Z8x30_READ_DATA( CONSOLE_DATA, flow_control );
+ } while ( flow_control != XON );
+ }
+
+ Z8x30_WRITE_DATA( CONSOLE_DATA, ch );
+}
+
+/*
+ * __read -- read bytes from the serial port. Ignore fd, since
+ * we only have stdin.
+ */
+
+int __read(
+ int fd,
+ char *buf,
+ int nbytes
+)
+{
+ int i = 0;
+
+ for (i = 0; i < nbytes; i++) {
+ *(buf + i) = inbyte();
+ if ((*(buf + i) == '\n') || (*(buf + i) == '\r')) {
+ (*(buf + i++)) = '\n';
+ (*(buf + i)) = 0;
+ break;
+ }
+ }
+ return (i);
+}
+
+/*
+ * __write -- write bytes to the serial port. Ignore fd, since
+ * stdout and stderr are the same. Since we have no filesystem,
+ * open will only return an error.
+ */
+
+int __write(
+ int fd,
+ char *buf,
+ int nbytes
+)
+{
+ int i;
+
+ for (i = 0; i < nbytes; i++) {
+ if (*(buf + i) == '\n') {
+ outbyte ('\r');
+ }
+ outbyte (*(buf + i));
+ }
+ return (nbytes);
+}
diff --git a/c/src/lib/libbsp/m68k/mvme162/include/bsp.h b/c/src/lib/libbsp/m68k/mvme162/include/bsp.h
new file mode 100644
index 0000000000..0b3a7d76d8
--- /dev/null
+++ b/c/src/lib/libbsp/m68k/mvme162/include/bsp.h
@@ -0,0 +1,225 @@
+/* bsp.h
+ *
+ * This include file contains all MVME162 board IO definitions.
+ *
+ * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
+ * On-Line Applications Research Corporation (OAR).
+ * All rights assigned to U.S. Government, 1994.
+ *
+ * This material may be reproduced by or for the U.S. Government pursuant
+ * to the copyright license under the clause at DFARS 252.227-7013. This
+ * notice must appear in all copies of this file and its derivatives.
+ *
+ * Modifications of respective RTEMS file: COPYRIGHT (c) 1994.
+ * EISCAT Scientific Association. M.Savitski
+ *
+ * This material is a part of the MVME162 Board Support Package
+ * for the RTEMS executive. Its licensing policies are those of the
+ * RTEMS above.
+ *
+ * $Id$
+ */
+
+#ifndef __MVME162_h
+#define __MVME162_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <rtems.h>
+#include <iosupp.h>
+#include <z8530.h>
+
+/*
+// Following defines must reflect the setup of the particular MVME162
+//-----------------------------------
+*/
+#define GROUP_BASE_ADDRESS 0x0000F200
+#define BOARD_BASE_ADDRESS 0x00000000
+/* Base for local interrupters' vectors (with enable bit set) */
+#define VECTOR_BASE 0x67800000
+/* RAM limits */
+#define RAM_START 0x00100000
+#define RAM_END 0x00200000
+/*
+//-----------------------------------
+*/
+static volatile struct lcsr {
+ unsigned long slave_adr[2];
+ unsigned long slave_trn[2];
+ unsigned long slave_ctl;
+ unsigned long mastr_adr[4];
+ unsigned long mastr_trn;
+ unsigned long mastr_att;
+ unsigned long mastr_ctl;
+ unsigned long dma_ctl_1;
+ unsigned long dma_ctl_2;
+ unsigned long dma_loc_cnt;
+ unsigned long dma_vme_cnt;
+ unsigned long dma_byte_cnt;
+ unsigned long dma_adr_cnt;
+ unsigned long dma_status;
+ unsigned long to_ctl;
+ unsigned long timer_cmp_1;
+ unsigned long timer_cnt_1;
+ unsigned long timer_cmp_2;
+ unsigned long timer_cnt_2;
+ unsigned long board_ctl;
+ unsigned long prescaler_cnt;
+ unsigned long intr_stat;
+ unsigned long intr_ena;
+ unsigned long intr_soft_set;
+ unsigned long intr_clear;
+ unsigned long intr_level[4];
+ unsigned long vector_base;
+} *lcsr = (void *) 0xFFF40000;
+
+#define USE_CHANNEL_A 1 /* 1 = use channel A for console */
+#define USE_CHANNEL_B 0 /* 1 = use channel B for console */
+
+/* Constants */
+
+#if (USE_CHANNEL_A == 1)
+ #define CONSOLE_CONTROL 0xFFF45005
+ #define CONSOLE_DATA 0xFFF45007
+#elif (USE_CHANNEL_B == 1)
+ #define CONSOLE_CONTROL 0xFFF45001
+ #define CONSOLE_DATA 0xFFF45003
+#endif
+
+/*
+// The following registers are located in the VMEbus short
+// IO space and respond to address modifier codes $29 and $2D.
+// On FORCE SPARC CPU use address gcsr_vme and device /dev/vme16d32.
+*/
+static volatile struct gcsr {
+ unsigned char chip_revision;
+ unsigned char chip_id;
+ unsigned char lmsig;
+ unsigned char board_scr;
+ unsigned short gpr[6];
+} *gcsr_vme = (void *) (GROUP_BASE_ADDRESS + BOARD_BASE_ADDRESS),
+ *gcsr = (void *) 0xFFF40100;
+
+static volatile unsigned short *ipio[6] = { (unsigned short *) 0xFFF58000,
+ (unsigned short *) 0xFFF58100,
+ (unsigned short *) 0xFFF58200,
+ (unsigned short *) 0xFFF58300,
+ (unsigned short *) 0xFFF58400,
+ (unsigned short *) 0xFFF58500
+ };
+
+static volatile unsigned short *ipid[6] = { (unsigned short *) 0xFFF58080,
+ (unsigned short *) 0xFFF58180,
+ (unsigned short *) 0xFFF58280,
+ (unsigned short *) 0xFFF58380,
+ (unsigned short *) 0xFFF58080,
+ (unsigned short *) 0xFFF58280
+ };
+
+static volatile struct ipic_space {
+ struct sing {
+ unsigned short io_space[64];
+ unsigned short id_space[32];
+ unsigned short id_reptd[32];
+ } single[4];
+ struct twin {
+ unsigned short io_space[128];
+ unsigned short io_reptd[128];
+ } twin[2];
+} *ipic_space = (void *) 0xFFF58000;
+
+static volatile struct ipic_csr {
+ unsigned char chip_id;
+ unsigned char chip_rev;
+ unsigned char res[2];
+ unsigned short a_31_16_base;
+ unsigned short b_31_16_base;
+ unsigned short c_31_16_base;
+ unsigned short d_31_16_base;
+ unsigned char a_23_16_size;
+ unsigned char b_23_16_size;
+ unsigned char c_23_16_size;
+ unsigned char d_23_16_size;
+ unsigned short a_intr_cnt;
+ unsigned short b_intr_cnt;
+ unsigned short c_intr_cnt;
+ unsigned short d_intr_cnt;
+} *ipic_csr = (void *) 0xFFFBC000;
+
+/*
+ * Define the time limits for RTEMS Test Suite test durations.
+ * Long test and short test duration limits are provided. These
+ * values are in seconds and need to be converted to ticks for the
+ * application.
+ *
+ */
+
+#define MAX_LONG_TEST_DURATION 300 /* 5 minutes = 300 seconds */
+#define MAX_SHORT_TEST_DURATION 3 /* 3 seconds */
+
+/*
+ * Define the interrupt mechanism for Time Test 27
+ *
+ * NOTE: Not implemented
+ */
+
+#define MUST_WAIT_FOR_INTERRUPT 0
+
+#define Install_tm27_vector( handler )
+
+#define Cause_tm27_intr()
+
+#define Clear_tm27_intr()
+
+#define Lower_tm27_intr()
+
+/*
+ * Simple spin delay in microsecond units for device drivers.
+ * This is very dependent on the clock speed of the target.
+ */
+
+#define delay( microseconds ) \
+ { register rtems_unsigned32 _delay=(microseconds); \
+ register rtems_unsigned32 _tmp=123; \
+ asm volatile( "0: \
+ nbcd %0 ; \
+ nbcd %0 ; \
+ dbf %1,0b" \
+ : "=d" (_tmp), "=d" (_delay) \
+ : "0" (_tmp), "1" (_delay) ); \
+ }
+
+/* Constants */
+
+#ifdef 1626_INIT
+#undef EXTERN
+#define EXTERN
+#else
+#undef EXTERN
+#define EXTERN extern
+#endif
+
+/* miscellaneous stuff assumed to exist */
+
+extern rtems_configuration_table BSP_Configuration;
+
+extern m68k_isr M68Kvec[]; /* vector table address */
+
+/* functions */
+
+void bsp_cleanup( void );
+
+m68k_isr set_vector(
+ rtems_isr_entry handler,
+ rtems_vector_number vector,
+ int type
+);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+/* end of include file */
diff --git a/c/src/lib/libbsp/m68k/mvme162/include/coverhd.h b/c/src/lib/libbsp/m68k/mvme162/include/coverhd.h
new file mode 100644
index 0000000000..0033a50502
--- /dev/null
+++ b/c/src/lib/libbsp/m68k/mvme162/include/coverhd.h
@@ -0,0 +1,104 @@
+/* coverhd.h
+ *
+ * This include file has defines to represent the overhead associated
+ * with calling a particular directive from C on this target.
+ *
+ * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
+ * On-Line Applications Research Corporation (OAR).
+ * All rights assigned to U.S. Government, 1994.
+ *
+ * This material may be reproduced by or for the U.S. Government pursuant
+ * to the copyright license under the clause at DFARS 252.227-7013. This
+ * notice must appear in all copies of this file and its derivatives.
+ *
+ * $Id$
+ */
+
+#ifndef __COVERHD_h
+#define __COVERHD_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define CALLING_OVERHEAD_INITIALIZE_EXECUTIVE 2
+#define CALLING_OVERHEAD_SHUTDOWN_EXECUTIVE 1
+#define CALLING_OVERHEAD_TASK_CREATE 3
+#define CALLING_OVERHEAD_TASK_IDENT 2
+#define CALLING_OVERHEAD_TASK_START 2
+#define CALLING_OVERHEAD_TASK_RESTART 2
+#define CALLING_OVERHEAD_TASK_DELETE 1
+#define CALLING_OVERHEAD_TASK_SUSPEND 1
+#define CALLING_OVERHEAD_TASK_RESUME 2
+#define CALLING_OVERHEAD_TASK_SET_PRIORITY 2
+#define CALLING_OVERHEAD_TASK_MODE 2
+#define CALLING_OVERHEAD_TASK_GET_NOTE 2
+#define CALLING_OVERHEAD_TASK_SET_NOTE 2
+#define CALLING_OVERHEAD_TASK_WAKE_WHEN 4
+#define CALLING_OVERHEAD_TASK_WAKE_AFTER 1
+#define CALLING_OVERHEAD_INTERRUPT_CATCH 2
+#define CALLING_OVERHEAD_CLOCK_GET 4
+#define CALLING_OVERHEAD_CLOCK_SET 4
+#define CALLING_OVERHEAD_CLOCK_TICK 1
+
+#define CALLING_OVERHEAD_TIMER_CREATE 2
+#define CALLING_OVERHEAD_TIMER_IDENT 1
+#define CALLING_OVERHEAD_TIMER_DELETE 2
+#define CALLING_OVERHEAD_TIMER_FIRE_AFTER 2
+#define CALLING_OVERHEAD_TIMER_FIRE_WHEN 5
+#define CALLING_OVERHEAD_TIMER_RESET 1
+#define CALLING_OVERHEAD_TIMER_CANCEL 1
+#define CALLING_OVERHEAD_SEMAPHORE_CREATE 2
+#define CALLING_OVERHEAD_SEMAPHORE_IDENT 1
+#define CALLING_OVERHEAD_SEMAPHORE_DELETE 2
+#define CALLING_OVERHEAD_SEMAPHORE_OBTAIN 2
+#define CALLING_OVERHEAD_SEMAPHORE_RELEASE 1
+#define CALLING_OVERHEAD_MESSAGE_QUEUE_CREATE 2
+#define CALLING_OVERHEAD_MESSAGE_QUEUE_IDENT 2
+#define CALLING_OVERHEAD_MESSAGE_QUEUE_DELETE 1
+#define CALLING_OVERHEAD_MESSAGE_QUEUE_SEND 2
+#define CALLING_OVERHEAD_MESSAGE_QUEUE_URGENT 2
+#define CALLING_OVERHEAD_MESSAGE_QUEUE_BROADCAST 2
+#define CALLING_OVERHEAD_MESSAGE_QUEUE_RECEIVE 2
+#define CALLING_OVERHEAD_MESSAGE_QUEUE_FLUSH 2
+
+#define CALLING_OVERHEAD_EVENT_SEND 2
+#define CALLING_OVERHEAD_EVENT_RECEIVE 2
+#define CALLING_OVERHEAD_SIGNAL_CATCH 2
+#define CALLING_OVERHEAD_SIGNAL_SEND 2
+#define CALLING_OVERHEAD_PARTITION_CREATE 3
+#define CALLING_OVERHEAD_PARTITION_IDENT 2
+#define CALLING_OVERHEAD_PARTITION_DELETE 2
+#define CALLING_OVERHEAD_PARTITION_GET_BUFFER 2
+#define CALLING_OVERHEAD_PARTITION_RETURN_BUFFER 2
+#define CALLING_OVERHEAD_REGION_CREATE 3
+#define CALLING_OVERHEAD_REGION_IDENT 2
+#define CALLING_OVERHEAD_REGION_DELETE 1
+#define CALLING_OVERHEAD_REGION_GET_SEGMENT 3
+#define CALLING_OVERHEAD_REGION_RETURN_SEGMENT 2
+#define CALLING_OVERHEAD_PORT_CREATE 3
+#define CALLING_OVERHEAD_PORT_IDENT 2
+#define CALLING_OVERHEAD_PORT_DELETE 2
+#define CALLING_OVERHEAD_PORT_EXTERNAL_TO_INTERNAL 2
+#define CALLING_OVERHEAD_PORT_INTERNAL_TO_EXTERNAL 2
+
+#define CALLING_OVERHEAD_IO_INITIALIZE 3
+#define CALLING_OVERHEAD_IO_OPEN 2
+#define CALLING_OVERHEAD_IO_CLOSE 2
+#define CALLING_OVERHEAD_IO_READ 2
+#define CALLING_OVERHEAD_IO_WRITE 2
+#define CALLING_OVERHEAD_IO_CONTROL 2
+#define CALLING_OVERHEAD_FATAL_ERROR_OCCURRED 1
+#define CALLING_OVERHEAD_RATE_MONOTONIC_CREATE 2
+#define CALLING_OVERHEAD_RATE_MONOTONIC_IDENT 2
+#define CALLING_OVERHEAD_RATE_MONOTONIC_DELETE 1
+#define CALLING_OVERHEAD_RATE_MONOTONIC_CANCEL 1
+#define CALLING_OVERHEAD_RATE_MONOTONIC_PERIOD 2
+#define CALLING_OVERHEAD_MULTIPROCESSING_ANNOUNCE 1
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+/* end of include file */
diff --git a/c/src/lib/libbsp/m68k/mvme162/startup/bspclean.c b/c/src/lib/libbsp/m68k/mvme162/startup/bspclean.c
new file mode 100644
index 0000000000..215a53cc46
--- /dev/null
+++ b/c/src/lib/libbsp/m68k/mvme162/startup/bspclean.c
@@ -0,0 +1,53 @@
+/*
+ * This routine returns control to 162Bug.
+ *
+ * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
+ * On-Line Applications Research Corporation (OAR).
+ * All rights assigned to U.S. Government, 1994.
+ *
+ * This material may be reproduced by or for the U.S. Government pursuant
+ * to the copyright license under the clause at DFARS 252.227-7013. This
+ * notice must appear in all copies of this file and its derivatives.
+ *
+ *
+ * Modifications of respective RTEMS file: COPYRIGHT (c) 1994.
+ * EISCAT Scientific Association. M.Savitski
+ *
+ * This material is a part of the MVME162 Board Support Package
+ * for the RTEMS executive. Its licensing policies are those of the
+ * RTEMS above.
+ *
+ * $Id$
+ */
+
+#include <rtems.h>
+#include <bsp.h>
+#include <z8036.h>
+
+void bsp_return_to_monitor_trap()
+{
+ extern void start( void );
+
+ lcsr->intr_ena = 0; /* disable interrupts */
+ m68k_set_vbr(0xFFE00000); /* restore 162Bug vectors */
+ asm volatile( "trap #15" ); /* trap to 162Bug */
+ asm volatile( ".short 0x63" ); /* return to 162Bug (.RETURN) */
+ /* restart program */
+ /*
+ * This does not work on the 162....
+ */
+#if 0
+ { register volatile void *start_addr;
+
+ start_addr = start;
+
+ asm volatile ( "jmp %0@" : "=a" (start_addr) : "0" (start_addr) );
+ }
+#endif
+}
+
+void bsp_cleanup( void )
+{
+ M68Kvec[ 45 ] = bsp_return_to_monitor_trap; /* install handler */
+ asm volatile( "trap #13" ); /* insures SUPV mode */
+}
diff --git a/c/src/lib/libbsp/m68k/mvme162/startup/bspstart.c b/c/src/lib/libbsp/m68k/mvme162/startup/bspstart.c
new file mode 100644
index 0000000000..fb137f7ebc
--- /dev/null
+++ b/c/src/lib/libbsp/m68k/mvme162/startup/bspstart.c
@@ -0,0 +1,171 @@
+/* bsp_start()
+ *
+ * This routine starts the application. It includes application,
+ * board, and monitor specific initialization and configuration.
+ * The generic CPU dependent initialization has been performed
+ * before this routine is invoked.
+ *
+ * INPUT: NONE
+ *
+ * OUTPUT: NONE
+ *
+ * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
+ * On-Line Applications Research Corporation (OAR).
+ * All rights assigned to U.S. Government, 1994.
+ *
+ * This material may be reproduced by or for the U.S. Government pursuant
+ * to the copyright license under the clause at DFARS 252.227-7013. This
+ * notice must appear in all copies of this file and its derivatives.
+ *
+ * Modifications of respective RTEMS file: COPYRIGHT (c) 1994.
+ * EISCAT Scientific Association. M.Savitski
+ *
+ * This material is a part of the MVME162 Board Support Package
+ * for the RTEMS executive. Its licensing policies are those of the
+ * RTEMS above.
+ *
+ * $Id$
+ */
+
+#include <rtems.h>
+#include <bsp.h>
+#include <libcsupport.h>
+#include <z8036.h>
+
+/*
+ * The original table from the application and our copy of it with
+ * some changes.
+ */
+
+extern rtems_configuration_table Configuration;
+rtems_configuration_table BSP_Configuration;
+
+rtems_cpu_table Cpu_table;
+
+/* Initialize whatever libc we are using
+ * called from postdriver hook
+ */
+
+void bsp_libc_init()
+{
+ extern int end;
+ rtems_unsigned32 heap_start;
+
+ heap_start = (rtems_unsigned32) &end;
+ if (heap_start & (CPU_ALIGNMENT-1))
+ heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
+
+ RTEMS_Malloc_Initialize((void *) heap_start, 64 * 1024, 0);
+
+ /*
+ * Set up for the libc handling.
+ */
+
+ if (BSP_Configuration.ticks_per_timeslice > 0)
+ libc_init(1); /* reentrant if possible */
+ else
+ libc_init(0); /* non-reentrant */
+
+ /*
+ * Initialize the stack bounds checker
+ */
+
+#ifdef STACK_CHECKER_ON
+ Stack_check_Initialize();
+#endif
+}
+
+int bsp_start(
+ int argc,
+ char **argv,
+ char **environp
+)
+{
+ m68k_isr *monitors_vector_table;
+ int index;
+
+ /*
+ * 162Bug Vectors are at 0xFFE00000
+ */
+
+ monitors_vector_table = (m68k_isr *)0xFFE00000;
+
+ m68k_set_vbr( monitors_vector_table );
+
+ for ( index=2 ; index<=255 ; index++ )
+ M68Kvec[ index ] = monitors_vector_table[ 32 ];
+
+ M68Kvec[ 2 ] = monitors_vector_table[ 2 ]; /* bus error vector */
+ M68Kvec[ 4 ] = monitors_vector_table[ 4 ]; /* breakpoints vector */
+ M68Kvec[ 9 ] = monitors_vector_table[ 9 ]; /* trace vector */
+ M68Kvec[ 47 ] = monitors_vector_table[ 47 ]; /* system call vector */
+
+ m68k_set_vbr( &M68Kvec );
+
+ /*
+ * You may wish to make VME access round-robin here, currently
+ * we leave it as it is.
+ */
+
+ lcsr->vector_base = VECTOR_BASE; /* set the vector base register */
+
+ m68k_enable_caching();
+
+ /*
+ * we only use a hook to get the C library initialized.
+ */
+
+ Cpu_table.pretasking_hook = NULL;
+
+ Cpu_table.predriver_hook = bsp_libc_init; /* RTEMS resources available */
+
+ Cpu_table.postdriver_hook = NULL; /* Call our main() for constructors */
+
+ Cpu_table.idle_task = NULL; /* do not override system IDLE task */
+
+ Cpu_table.do_zero_of_workspace = TRUE;
+
+ Cpu_table.interrupt_vector_table = (m68k_isr *) &M68Kvec;
+
+ Cpu_table.interrupt_stack_size = 4096;
+
+ Cpu_table.extra_system_initialization_stack = 0;
+
+ /*
+ * Copy the table
+ */
+
+ BSP_Configuration = Configuration;
+
+ /*
+ * Add 1 region for the RTEMS Malloc
+ */
+
+ BSP_Configuration.maximum_regions++;
+
+ /*
+ * Add 1 extension for newlib libc
+ */
+
+#ifdef RTEMS_NEWLIB
+ BSP_Configuration.maximum_extensions++;
+#endif
+
+ /*
+ * Add another extension if using the stack checker
+ */
+
+#ifdef STACK_CHECKER_ON
+ BSP_Configuration.maximum_extensions++;
+#endif
+
+ BSP_Configuration.work_space_start = (void *)
+ (RAM_END - BSP_Configuration.work_space_size);
+
+ rtems_initialize_executive( &BSP_Configuration, &Cpu_table );
+ /* does not return */
+
+ bsp_cleanup();
+
+ return 0;
+}
diff --git a/c/src/lib/libbsp/m68k/mvme162/startup/linkcmds b/c/src/lib/libbsp/m68k/mvme162/startup/linkcmds
new file mode 100644
index 0000000000..21a844ca88
--- /dev/null
+++ b/c/src/lib/libbsp/m68k/mvme162/startup/linkcmds
@@ -0,0 +1,50 @@
+/*
+ * This file contains directives for the GNU linker which are specific
+ * to the Motorola MVME162 board.
+ *
+ * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
+ * On-Line Applications Research Corporation (OAR).
+ * All rights assigned to U.S. Government, 1994.
+ *
+ * This material may be reproduced by or for the U.S. Government pursuant
+ * to the copyright license under the clause at DFARS 252.227-7013. This
+ * notice must appear in all copies of this file and its derivatives.
+ *
+ * Modifications of respective RTEMS file: COPYRIGHT (c) 1994.
+ * EISCAT Scientific Association. M.Savitski
+ *
+ * This material is a part of the MVME162 Board Support Package
+ * for the RTEMS executive. Its licensing policies are those of the
+ * RTEMS above.
+ *
+ * $Id$
+ */
+
+MEMORY
+ {
+ ram : org = 0x100000, l = 1M
+ }
+
+SECTIONS
+{
+ .text 0x100000 :
+ {
+ text_start = . ;
+ *(.text)
+ etext = ALIGN( 0x10 ) ;
+ }
+ .data ADDR( .text ) + SIZEOF( .text ):
+ {
+ data_start = . ;
+ *(.data)
+ edata = ALIGN( 0x10 ) ;
+ }
+ .bss ADDR( .data ) + SIZEOF( .data ):
+ {
+ bss_start = . ;
+ *(.bss)
+ *(COMMON)
+ end = . ;
+ _end = . ;
+ }
+}
diff --git a/c/src/lib/libbsp/m68k/mvme162/timer/timer.c b/c/src/lib/libbsp/m68k/mvme162/timer/timer.c
new file mode 100644
index 0000000000..c000fadd28
--- /dev/null
+++ b/c/src/lib/libbsp/m68k/mvme162/timer/timer.c
@@ -0,0 +1,91 @@
+/* Timer_init()
+ *
+ * This routine initializes the Tick Timer 1 on the MVME162 board.
+ *
+ * Input parameters: NONE
+ *
+ * Output parameters: NONE
+ *
+ * NOTE: This routine will not work if the optimizer is enabled
+ * for some compilers. The multiple writes
+ * may be optimized away.
+ *
+ * It is important that the timer start/stop overhead be
+ * determined when porting or modifying this code.
+ *
+ * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
+ * On-Line Applications Research Corporation (OAR).
+ * All rights assigned to U.S. Government, 1994.
+ *
+ * This material may be reproduced by or for the U.S. Government pursuant
+ * to the copyright license under the clause at DFARS 252.227-7013. This
+ * notice must appear in all copies of this file and its derivatives.
+ *
+ * Modifications of respective RTEMS file: COPYRIGHT (c) 1994.
+ * EISCAT Scientific Association. M.Savitski
+ *
+ * This material is a part of the MVME162 Board Support Package
+ * for the RTEMS executive. Its licensing policies are those of the
+ * RTEMS above.
+ *
+ * $Id$
+ */
+
+
+#include <rtems.h>
+#include <bsp.h>
+
+/* Periodic tick interval */
+#define TICK_INTERVAL 0x10000
+#define TIMER_INT_LEVEL 6
+
+int Ttimer_val;
+rtems_boolean Timer_driver_Find_average_overhead;
+
+rtems_isr timerisr();
+
+void Timer_initialize()
+{
+ (void) set_vector( timerisr, (VECTOR_BASE >> 28) * 0x10 + 0x8, 0 );
+
+ Ttimer_val = 0; /* clear timer ISR count */
+ lcsr->vector_base = 0x67800000; /* set vb, enable interrupts */
+ lcsr->to_ctl = 0xE7; /* prescaler to 1 MHz (see Appendix A1) */
+ lcsr->timer_cmp_1 = TICK_INTERVAL;
+ lcsr->timer_cnt_1 = 0; /* clear counter */
+ lcsr->board_ctl |= 7; /* increment, reset-on-compare, clear-ovfl-cnt */
+
+ lcsr->intr_level[0] |= TIMER_INT_LEVEL; /* set int level */
+ lcsr->intr_ena |= 0x01000000; /* enable tick timer 1 interrupt */
+}
+
+#define AVG_OVERHEAD 6 /* It typically takes 3.0 microseconds */
+ /* (6 countdowns) to start/stop the timer. */
+#define LEAST_VALID 10 /* Don't trust a value lower than this */
+
+int Read_timer()
+{
+ unsigned long total;
+
+ total = (Ttimer_val * TICK_INTERVAL) + lcsr->timer_cnt_1;
+
+ if ( Timer_driver_Find_average_overhead == 1 )
+ return total; /* in one-half microsecond units */
+
+ if ( total < LEAST_VALID )
+ return 0; /* below timer resolution */
+
+ return (total-AVG_OVERHEAD); /* in musec units */
+}
+
+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/m68k/mvme162/timer/timerisr.s b/c/src/lib/libbsp/m68k/mvme162/timer/timerisr.s
new file mode 100644
index 0000000000..af31e4276b
--- /dev/null
+++ b/c/src/lib/libbsp/m68k/mvme162/timer/timerisr.s
@@ -0,0 +1,46 @@
+/* timer_isr()
+ *
+ * This routine provides the ISR for the Z8036 timer on the MVME136
+ * board. The timer is set up to generate an interrupt at maximum
+ * intervals.
+ *
+ * Input parameters: NONE
+ *
+ * Output parameters: NONE
+ *
+ * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
+ * On-Line Applications Research Corporation (OAR).
+ * All rights assigned to U.S. Government, 1994.
+ *
+ * This material may be reproduced by or for the U.S. Government pursuant
+ * to the copyright license under the clause at DFARS 252.227-7013. This
+ * notice must appear in all copies of this file and its derivatives.
+ *
+ * Modifications of respective RTEMS file: COPYRIGHT (c) 1994.
+ * EISCAT Scientific Association. M.Savitski
+ *
+ * This material is a part of the MVME162 Board Support Package
+ * for the RTEMS executive. Its licensing policies are those of the
+ * RTEMS above.
+ *
+ * $Id$
+ */
+
+#include "asm.h"
+
+BEGIN_CODE
+
+.set INTR_CLEAR_REG, 0xfff40074 | interrupt clear register
+.set RELOAD, 0x01000000 | clear tick 1 interrupt
+
+ PUBLIC (timerisr)
+SYM (timerisr):
+ move.l a0, -(a7) | save a0
+ movea.l #INTR_CLEAR_REG, a0 | a0 = addr of cmd status reg
+ ori.l #RELOAD, (a0) | reload countdown
+ addq.l #1, SYM (Ttimer_val) | increment timer value
+ move.l (a7)+, a0 | restore a0
+ rte
+
+END_CODE
+END
diff --git a/c/src/lib/libbsp/m68k/mvme162/tools/sload.c b/c/src/lib/libbsp/m68k/mvme162/tools/sload.c
new file mode 100644
index 0000000000..8ce44d7a4b
--- /dev/null
+++ b/c/src/lib/libbsp/m68k/mvme162/tools/sload.c
@@ -0,0 +1,542 @@
+/*
+ *
+ * Copyright (c) 1994 by EISCAT Scientific Association.
+ * All Rights Reserved.
+ * M.Savitski
+ *
+ * S-record code - courtesy of Kym Newbery
+ * 8918927y@lux.levels.unisa.edu.au
+ *
+ * Loading S-records into the VMEbus memory.
+ *
+ * Loads an executable in s-record format into the MVME dual-ported
+ * memory and directs the MVME CPU to start execution.
+ * VMEbus access is done via the FORCE CPU-2CE vmeplus driver in
+ * read/write mode for loading and in mmap mode for accessing MVME registers.
+ * See mvme162.h for #define's dependent on the MVME162 setup.
+ *
+ * $Id$
+ *
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
+
+
+#include <sys/types.h>
+#include <sys/fcntl.h>
+#include <sys/resource.h>
+#include <unistd.h>
+#include <sys/vme.h>
+#include <sys/mman.h>
+
+#include "../include/bsp.h"
+
+#define FALSE 0
+#define TRUE 1
+
+#define DATA19 0
+#define DATA28 1
+#define DATA37 3
+#define HEADER 4
+#define TERMINATOR 5
+#define NONE 6
+
+unsigned int ahdtoi(unsigned char digit);
+int issrec(char *str);
+int validrec(char *str);
+void hdr2str(char *sstr, char *pstr);
+unsigned long getaddr(char *str);
+unsigned int datasize(char *str);
+void usage (void);
+int MVMEControl(u_long entry, int reset, int go);
+
+unsigned int ahdtoi(unsigned char digit)
+/* converts a hexadecimal char to an integer
+ *
+ * entry : digit = character to convert
+ * : 0..15 = result
+ * : -1 = char is not a digit
+ */
+{
+/* check digit */
+ if (!isxdigit(digit))
+ return(-1);
+
+ switch (toupper(digit)) {
+ case 'A' : return(0xA);
+ case 'B' : return(0xB);
+ case 'C' : return(0xC);
+ case 'D' : return(0xD);
+ case 'E' : return(0xE);
+ case 'F' : return(0xF);
+ default : return(digit - 0x30);
+ }
+}
+
+int issrec(char *str)
+/* attempts to identify the type of Srecord string passed
+ *
+ * entry : str = pointer to null terminated string
+ * returns : 0,1,2,3,5,7,8,9 for S0..S9 except S6 & S4
+ * : -1 = invalid header or header not found
+ * : -2 = invalid header number
+ */
+{
+/* Check first character for S */
+ if ((isupper(str[0]) && (str[0] == 'S')) ||
+ (islower(str[0]) && (str[0] == 's')))
+ {
+ /* check for valid header number */
+ switch (str[1]) {
+ case '0' : return 0; /* header record */
+ case '1' : return 1; /* data record, 2byte addr */
+ case '2' : return 2; /* " " , 3byte addr */
+ case '3' : return 3; /* " " , 4byte addr */
+ case '5' : return 5; /* number of S1,S2,S3 blocks */
+ case '7' : return 7; /* S3 terminator */
+ case '8' : return 8; /* S2 terminator */
+ case '9' : return 9; /* S1 terminator */
+ default : return -2; /* all others are invalid */
+ }
+ }
+ return(-1);
+}
+
+int validrec(char *str)
+/* Tests for a valid srecord. tests checksum & for nondigit characters
+ * doesn't rely on any other srecord routines.
+ *
+ * entry : str = pointer to null terminated string
+ * returns : -1 = srecord contains invalid characters
+ * : -2 = srecord checksum is invalid
+ * : -3 = srecord record length is invalid
+ * : 0 = srecord is valid
+ */
+{
+ int cn = 1, rlen=0;
+ int mchksum=0, rchksum=0;
+
+/* first check if there are any non-digit characters except S */
+ while (str[cn]!=0)
+ if (!isxdigit(str[cn++]))
+ return(-1);
+
+/* test number of data bytes */
+ rlen = ahdtoi(str[2])* 0x10 + ahdtoi(str[3]);
+ if (((strlen(str)-4)/2U) != rlen) return(-3);
+
+/* get checksum from string */
+ rchksum = ahdtoi(str[rlen*2+2])*0x10 + ahdtoi(str[rlen*2+3]);
+ /* string chksum */
+
+/* now calculate my own checksum */
+ for (cn=2; cn <= rlen*2; )
+ mchksum += ahdtoi(str[cn++])*0x10 + ahdtoi(str[cn++]);
+ mchksum = ~mchksum & 0xFF;
+ if (mchksum != rchksum) return(-2); /* return -2 in not equal */
+
+/* return OK if we didn't fail any of these tests */
+ return(0);
+}
+
+void hdr2str(char *sstr, char *pstr)
+/* converts header record (S0) string into a plain string
+ *
+ * entry : sstr = pointer to S0 string record
+ * exit : pstr = pointer to string long enough to hold string
+ * (caller must allocate enough space for string)
+ */
+{
+ int rlen, cn, pn=0;
+
+ rlen = ahdtoi(sstr[2])*0x10 + ahdtoi(sstr[3]);
+ for (cn=8; cn <= rlen*2; )
+ pstr[pn++] = ahdtoi(sstr[cn++])*0x10 + ahdtoi(sstr[cn++]);
+ pstr[pn]=0;
+}
+
+unsigned long getaddr(char *str)
+/* returns the address of the srecord in str. assumes record is valid.
+ *
+ * entry : str = pointer to srecord string
+ * exit : address of data, word or long.
+ */
+{
+ unsigned long addr=0;
+
+ switch (issrec(str)) {
+ case 0 :
+ case 1 :
+ case 5 :
+ case 9 :
+ addr = ahdtoi(str[4])*0x1000 + ahdtoi(str[5])*0x100
+ + ahdtoi(str[6])*0x10 + ahdtoi(str[7]);
+ return(addr);
+ case 2 :
+ case 8 :
+ addr = ahdtoi(str[4])*0x100000 + ahdtoi(str[5])*0x10000
+ + ahdtoi(str[6])*0x1000 + ahdtoi(str[7])*0x100
+ + ahdtoi(str[8])*0x10 + ahdtoi(str[9]);
+ return(addr);
+ case 3 :
+ case 7 :
+ addr = ahdtoi(str[4])*0x10000000 + ahdtoi(str[5])*0x1000000
+ + ahdtoi(str[6])*0x100000 + ahdtoi(str[7])*0x10000
+ + ahdtoi(str[8])*0x1000 + ahdtoi(str[9])*0x100
+ + ahdtoi(str[10])*0x10 + ahdtoi(str[11]);
+ return(addr);
+ default : return(-1);
+ }
+}
+
+unsigned int datasize(char *str)
+/*
+ * returns the number of data bytes in the srecord. assumes record is valid.
+ *
+ * entry : str = pointer to srecord string
+ * exit : number of bytes of data in the data field.
+ */
+{
+ unsigned int size=0;
+
+ switch (issrec(str)) {
+ case 0 :
+ case 1 :
+ case 5 :
+ case 7 :
+ case 8 :
+ case 9 : size = ahdtoi(str[2])*0x10 + ahdtoi(str[3]);
+ return(size-3);
+ case 2 : size = ahdtoi(str[2])*0x10 + ahdtoi(str[3]);
+ return(size-4);
+ case 3 : size = ahdtoi(str[2])*0x10 + ahdtoi(str[3]);
+ return(size-5);
+ default : return(-1);
+ }
+}
+
+void usage (void)
+/*
+ * prints correct usage on stdout
+ */
+{
+ printf("\nUSAGE : sload [-v][-g][-r] [file]\n");
+ printf(" file is an s-record file\n");
+ printf(" -v for verbose summary of s-records loaded\n");
+ printf(" -g to start execution\n");
+ printf(" -r to reset MVME162\n\n");
+}
+
+int MVMEControl(u_long entry, int reset, int go)
+/* Controls MVME-162 from other VME master:
+ * if entry != 0, loads it as start address
+ * if go != 0, starts program execution from entry
+ * if reset != 0, resets mvme162's local bus
+ * Depends upon #define'ed GROUP_BASE_ADDRESS and BOARD_BASE_ADDRESS
+ * which in turn are set by the 162-BUG's ENV command.
+ */
+{
+ int vme;
+ char vmedev[32] = "/dev/vme16d32"; /* d32 is important !!! */
+ u_long pagesize;
+ struct gcsr *gcsr_map;
+
+ pagesize = sysconf(_SC_PAGESIZE); /* mmap likes to be page-aligned */
+
+ if ((vme = open(vmedev, O_RDWR)) == -1) {
+ perror("open");
+ fprintf(stderr, "Cannot open vme as %s to access GCSR\n", vmedev);
+ return 1;
+ }
+
+/* "MAP_SHARED" is important here */
+ gcsr_map = (struct gcsr *)
+ mmap(0, 0x1000, PROT_WRITE|PROT_READ, MAP_SHARED,
+ vme, (u_long)gcsr_vme / pagesize * pagesize);
+ if (gcsr_map == (struct gcsr *) - 1) {
+ perror("mmap");
+ fprintf(stderr, "Cannot mmap() to remote bus address 0x%08X\n",
+ (u_long)gcsr_vme / pagesize * pagesize);
+ return 1;
+ }
+
+/*
+ * use GCSR to start execution in MVME162
+ * adjust pointer to compensate for page alignement
+ */
+ gcsr_map = (struct gcsr *)((u_long)gcsr_map +
+ (u_long)gcsr_vme % pagesize);
+
+ if (reset) { /* reset the local bus... */
+ gcsr_map->board_scr |= 0x80;
+ }
+ if (entry) { /* ...load start address... */
+ gcsr_map->gpr[0] = entry >> 16U;
+ gcsr_map->gpr[1] = entry & 0x0000FFFF;
+ }
+ if (go) { /* ... and kick it in the ass! */
+ gcsr_map->lmsig = 0x1;
+ }
+}
+
+/*=================================================================== */
+main(int argc, char *argv[])
+{
+ char inpstr[256];
+ u_char image[256];
+ char hdrstr[64];
+ int i, j, k, result, size, line=0, lastrec=0;
+ long addr, tsize=0, naddr=0, blksize=0, blknum=1;
+ FILE *in;
+ char infile[256] = "";
+ char vmedev[32] = "/dev/vme32d32"; /* Assume "/dev/vme32d32" */
+ int vme, verbose = 0, go = 0, reset = 0, havefile = 0;
+
+/* Parse the command line */
+
+ --argc;
+
+ while (argv++, argc--) {
+ if (**argv != '-') {
+ strcpy(infile, *argv);
+ havefile = 1;
+ } else if (!strcmp(*argv, "-v")) {
+ verbose = 1;
+ } else if (!strcmp(*argv, "-g")) {
+ go = 1;
+ } else if (!strcmp(*argv, "-r")) {
+ reset = 1;
+/* } else if (!strcmp(*argv, "-vme32")) { */
+/* strcpy(vmedev, "/dev/vme32d32"); */
+/* } else if (!strcmp(*argv, "-vme24")) { */
+/* strcpy(vmedev, "/dev/vme24d32"); */
+/* } else if (!strcmp(*argv, "-vme16")) { */
+/* strcpy(vmedev, "/dev/vme16d32"); */
+ } else if (!strcmp(*argv, "-")) {
+ usage();
+ exit(0);
+ } else {
+ usage();
+ exit(0);
+ }
+ }
+
+ if (!havefile) {
+ if (!reset && !go) {
+ usage();
+ }
+ else {
+ MVMEControl(0, reset, go);
+ }
+ exit(0);
+ }
+
+ if ((in = fopen(infile, "r")) == NULL) {
+ perror("open");
+ fprintf(stderr, "Cannot open input file %s\n", infile);
+ exit(1);
+ }
+
+ if ((vme = open(vmedev, O_RDWR)) == -1) {
+ fprintf(stderr, "Cannot open vme as %s\n", vmedev);
+ }
+
+ while (fscanf(in, "%s", &inpstr) != EOF) {
+ line++;
+ if (validrec(inpstr) == 0) {
+ switch (issrec(inpstr)) {
+ case 0 :
+ hdr2str(inpstr, hdrstr);
+ if (verbose) printf("HEADER string = `%s'\n", hdrstr);
+ lastrec=HEADER;
+ break;
+ case 1 :
+ addr = getaddr(inpstr);
+ size = datasize(inpstr);
+ if (blksize == 0) {
+ blksize+=size;
+ naddr=addr+size;
+ if (verbose) printf("DATA\tS19\t$%04lX", addr);
+ lastrec=DATA19;
+ }
+ else if ((blksize!=0) && (addr==naddr)) {
+ blksize+=size;
+ naddr=addr+size;
+ }
+ else {
+ if (verbose) printf("\t$%04lX\t%lu", naddr-1, blksize);
+ if (verbose) printf("\t%d\n", blknum);
+ blknum+=1;
+ naddr=addr+size;
+ blksize=size;
+ if (verbose) printf("DATA\tS19\t$%04lX", addr);
+ lastrec=DATA19;
+ }
+ tsize += size;
+ if (vme == -1) break;
+ for (i = 0, j = 8, k = size; k-- > 0; i += 1, j += 2) {
+ image[i] = ahdtoi(inpstr[j])*0x10 + ahdtoi(inpstr[j+1]);
+ }
+ if (lseek(vme, addr, SEEK_SET) == -1) {
+ fprintf(stderr, "lseek() to vme address %08X failed\n", addr);
+ }
+ else {
+ if (write(vme, (u_char *)image, size) != size) {
+ fprintf(stderr, "Write to vme address %08X failed\n", addr);
+ }
+ }
+ break;
+ case 2 :
+ addr = getaddr(inpstr);
+ size = datasize(inpstr);
+ if (blksize == 0) {
+ blksize+=size;
+ naddr=addr+size;
+ if (verbose) printf("DATA\tS28\t$%06lX",addr);
+ lastrec=DATA28;
+ }
+ else if ((blksize!=0) && (addr==naddr)) {
+ blksize+=size;
+ naddr=addr+size;
+ }
+ else {
+ if (verbose) printf("\t$%06lX\t%lu",naddr-1,blksize);
+ if (verbose) printf("\t%d\n",blknum);
+ blknum+=1;
+ naddr=addr+size;
+ blksize=size;
+ if (verbose) printf("DATA\tS28\t$%06lX",addr);
+ lastrec=DATA28;
+ }
+ tsize += size;
+ if (vme == -1) break;
+ for (i = 0, j = 10, k = size; k-- > 0; i += 1, j += 2) {
+ image[i] = ahdtoi(inpstr[j])*0x10 + ahdtoi(inpstr[j+1]);
+ }
+ if (lseek(vme, addr, SEEK_SET) == -1) {
+ fprintf(stderr, "lseek() to vme address %08X failed\n", addr);
+ }
+ else {
+ if (write(vme, (u_char *)image, size) != size) {
+ fprintf(stderr, "Write to vme address %08X failed\n", addr);
+ }
+ }
+ break;
+ case 3 :
+ addr = getaddr(inpstr);
+ size = datasize(inpstr);
+ if (blksize == 0) {
+ blksize+=size;
+ naddr=addr+size;
+ if (verbose) printf("DATA\tS37\t$%08lX",addr);
+ lastrec=DATA37;
+ }
+ else if ((blksize!=0) && (addr==naddr)) {
+ blksize+=size;
+ naddr=addr+size;
+ }
+ else {
+ if (verbose) printf("\t$%08lX\t%lu",naddr-1,blksize);
+ if (verbose) printf("\t%d\n",blknum);
+ blknum+=1;
+ naddr=addr+size;
+ blksize=size;
+ if (verbose) printf("DATA\tS37\t$%08lX",addr);
+ lastrec=DATA37;
+ }
+ tsize += size;
+ if (vme == -1) break;
+ for (i = 0, j = 12, k = size; k-- > 0; i += 1, j += 2) {
+ image[i] = ahdtoi(inpstr[j])*0x10 + ahdtoi(inpstr[j+1]);
+ }
+ if (lseek(vme, addr, SEEK_SET) == -1) {
+ fprintf(stderr, "lseek() to vme address %08X failed\n", addr);
+ }
+ else {
+ if (write(vme, (u_char *)image, size) != size) {
+ fprintf(stderr, "Write to vme address %08X failed\n", addr);
+ }
+ }
+ break;
+ case 7 :
+ if (lastrec==DATA19){
+ if (verbose) printf("\t$%04lX\t%lu",naddr-1,blksize);
+ }
+ if (lastrec==DATA28){
+ if (verbose) printf("\t$%06lX\t%lu",naddr-1,blksize);
+ }
+ if (lastrec==DATA37){
+ if (verbose) printf("\t$%08lX\t%lu",naddr-1,blksize);
+ }
+ if (verbose) printf("\t%d\n",blknum);
+ addr = getaddr(inpstr);
+ if (verbose) printf("TERM\tS37");
+ printf("\nExecution address = $%08lX\n", addr);
+ lastrec=TERMINATOR;
+ break;
+ case 8 :
+ if (lastrec==DATA19){
+ if (verbose) printf("\t$%04lX\t%lu",naddr-1,blksize);
+ }
+ if (lastrec==DATA28){
+ if (verbose) printf("\t$%06lX\t%lu",naddr-1,blksize);
+ }
+ if (lastrec==DATA37){
+ if (verbose) printf("\t$%08lX\t%lu",naddr-1,blksize);
+ }
+ if (verbose) printf("\t%d\n",blknum);
+ addr = getaddr(inpstr);
+ if (verbose) printf("TERM\tS28");
+ printf("\nExecution address = $%06lX\n", addr);
+ lastrec=TERMINATOR;
+ break;
+ case 9 :
+ if (lastrec==DATA19){
+ if (verbose) printf("\t$%04lX\t%lu",naddr-1,blksize);
+ }
+ if (lastrec==DATA28){
+ if (verbose) printf("\t$%06lX\t%lu",naddr-1,blksize);
+ }
+ if (lastrec==DATA37){
+ if (verbose) printf("\t$%08lX\t%lu",naddr-1,blksize);
+ }
+ if (verbose) printf("\t%d\n",blknum);
+ addr = getaddr(inpstr);
+ if (verbose) printf("TERM\tS19");
+ printf("\nExecution address = $%04lX\n", addr);
+ lastrec=TERMINATOR;
+ break;
+ }
+ }
+ else {
+ printf("\nError on line %d. ",line);
+ switch (validrec(inpstr)) {
+ case -1 : {printf("SRecord contains invalid characters.\n"); break; }
+ case -2 : {printf("SRecord checksum is invalid.\n"); break;}
+ case -3 : {printf("SRecord length is invalid.\n"); break;}
+ }
+ exit(1);
+ }
+ }
+
+ if ((lastrec==DATA19) || (lastrec==DATA28) || (lastrec==DATA37)) {
+ if (lastrec==DATA19){
+ if (verbose) printf("\t$%04lX\t%lu",naddr-1,blksize);
+ }
+ if (lastrec==DATA28){
+ if (verbose) printf("\t$%06lX\t%lu",naddr-1,blksize);
+ }
+ if (lastrec==DATA37){
+ if (verbose) printf("\t$%08lX\t%lu",naddr-1,blksize);
+ }
+ if (verbose) printf("\t%d\n",blknum);
+ printf("ERROR: terminator record not found.\n");
+ }
+ else {
+ for (i = 0x000FFFF; i-- > 0;) ; /* mystique delay... */
+ MVMEControl(addr, reset, go);
+ }
+ if (verbose) printf("total data size = %lu bytes\n", tsize);
+}