From ac7d5ef06a6d6e8d84abbd1f0b82162725f98326 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Thu, 11 May 1995 17:39:37 +0000 Subject: Initial revision --- c/src/lib/libbsp/m68k/idp/README | 31 ++++ c/src/lib/libbsp/m68k/idp/clock/ckinit.c | 126 ++++++++++++++++ c/src/lib/libbsp/m68k/idp/console/console.c | 216 +++++++++++++++++++++++++++ c/src/lib/libbsp/m68k/idp/console/duart.c | 170 +++++++++++++++++++++ c/src/lib/libbsp/m68k/idp/console/leds.c | 80 ++++++++++ c/src/lib/libbsp/m68k/idp/console/mc68ec.c | 18 +++ c/src/lib/libbsp/m68k/idp/include/README | 13 ++ c/src/lib/libbsp/m68k/idp/include/bsp.h | 79 ++++++++++ c/src/lib/libbsp/m68k/idp/include/coverhd.h | 106 +++++++++++++ c/src/lib/libbsp/m68k/idp/include/leds.h | 25 ++++ c/src/lib/libbsp/m68k/idp/startup/bspstart.c | 175 ++++++++++++++++++++++ c/src/lib/libbsp/m68k/idp/startup/linkcmds | 44 ++++++ c/src/lib/libbsp/m68k/idp/timer/timer.c | 121 +++++++++++++++ c/src/lib/libbsp/m68k/idp/timer/timerisr.s | 38 +++++ 14 files changed, 1242 insertions(+) create mode 100644 c/src/lib/libbsp/m68k/idp/README create mode 100644 c/src/lib/libbsp/m68k/idp/clock/ckinit.c create mode 100644 c/src/lib/libbsp/m68k/idp/console/console.c create mode 100644 c/src/lib/libbsp/m68k/idp/console/duart.c create mode 100644 c/src/lib/libbsp/m68k/idp/console/leds.c create mode 100644 c/src/lib/libbsp/m68k/idp/console/mc68ec.c create mode 100644 c/src/lib/libbsp/m68k/idp/include/README create mode 100644 c/src/lib/libbsp/m68k/idp/include/bsp.h create mode 100644 c/src/lib/libbsp/m68k/idp/include/coverhd.h create mode 100644 c/src/lib/libbsp/m68k/idp/include/leds.h create mode 100644 c/src/lib/libbsp/m68k/idp/startup/bspstart.c create mode 100644 c/src/lib/libbsp/m68k/idp/startup/linkcmds create mode 100644 c/src/lib/libbsp/m68k/idp/timer/timer.c create mode 100644 c/src/lib/libbsp/m68k/idp/timer/timerisr.s (limited to 'c/src/lib/libbsp/m68k/idp') 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 + +#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 -- cgit v1.2.3