summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/m68k/idp/console
diff options
context:
space:
mode:
Diffstat (limited to 'c/src/lib/libbsp/m68k/idp/console')
-rw-r--r--c/src/lib/libbsp/m68k/idp/console/console.c227
-rw-r--r--c/src/lib/libbsp/m68k/idp/console/duart.c263
-rw-r--r--c/src/lib/libbsp/m68k/idp/console/leds.c81
-rw-r--r--c/src/lib/libbsp/m68k/idp/console/mc68ec.c19
4 files changed, 0 insertions, 590 deletions
diff --git a/c/src/lib/libbsp/m68k/idp/console/console.c b/c/src/lib/libbsp/m68k/idp/console/console.c
deleted file mode 100644
index 200d52e40b..0000000000
--- a/c/src/lib/libbsp/m68k/idp/console/console.c
+++ /dev/null
@@ -1,227 +0,0 @@
-/*
- * 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.
- */
-
-#define MIDP_INIT
-
-#include <bsp.h>
-#include <rtems/libio.h>
-
-#include <rtems/ringbuf.h>
-
-Ring_buffer_t Console_Buffer[ 2 ];
-
-rtems_isr C_Receive_ISR(rtems_vector_number vector);
-
-/* console_initialize
- *
- * This routine initializes the console IO driver.
- */
-rtems_device_driver console_initialize(
- rtems_device_major_number major,
- rtems_device_minor_number minor,
- void *arg
-)
-{
- rtems_status_code status;
-
- Ring_buffer_Initialize( &Console_Buffer[ 0 ] );
- Ring_buffer_Initialize( &Console_Buffer[ 1 ] );
-
- init_pit();
-
- status = rtems_io_register_name(
- "/dev/console",
- major,
- (rtems_device_minor_number) 0
- );
-
- if (status != RTEMS_SUCCESSFUL)
- rtems_fatal_error_occurred(status);
-
- status = rtems_io_register_name(
- "/dev/tty00",
- major,
- (rtems_device_minor_number) 0
- );
-
- if (status != RTEMS_SUCCESSFUL)
- rtems_fatal_error_occurred(status);
-
- status = rtems_io_register_name(
- "/dev/tty01",
- major,
- (rtems_device_minor_number) 1
- );
-
- if (status != RTEMS_SUCCESSFUL)
- rtems_fatal_error_occurred(status);
-
- return RTEMS_SUCCESSFUL;
-}
-
-/* is_character_ready
- *
- * This routine returns TRUE if a character is available.
- */
-static bool is_character_ready(
- char *ch,
- int port
-)
-{
- if ( Ring_buffer_Is_empty( &Console_Buffer[ port ] ) )
- return false;
-
- Ring_buffer_Remove_character( &Console_Buffer[ port ], *ch );
- return true;
-}
-
-/* inbyte
- *
- * This routine reads a character from the UART through a buffer.
- */
-static char inbyte(
- int port
-)
-{
- 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.
- */
-static void outbyte(
- char ch,
- int port
-)
-{
- switch ( port ) {
- case 0:
- transmit_char( ch );
- break;
- case 1:
- transmit_char_portb( ch );
- break;
- }
-
-}
-
-/*
- * Open entry point
- */
-rtems_device_driver console_open(
- rtems_device_major_number major,
- rtems_device_minor_number minor,
- void * arg
-)
-{
- return RTEMS_SUCCESSFUL;
-}
-
-/*
- * Close entry point
- */
-rtems_device_driver console_close(
- rtems_device_major_number major,
- rtems_device_minor_number minor,
- void * arg
-)
-{
- return RTEMS_SUCCESSFUL;
-}
-
-/*
- * read bytes from the serial port. We only have stdin.
- */
-rtems_device_driver console_read(
- rtems_device_major_number major,
- rtems_device_minor_number minor,
- void * arg
-)
-{
- rtems_libio_rw_args_t *rw_args;
- char *buffer;
- int maximum;
- int count = 0;
-
- rw_args = (rtems_libio_rw_args_t *) arg;
-
- buffer = rw_args->buffer;
- maximum = rw_args->count;
-
- if ( minor > 1 )
- return RTEMS_INVALID_NUMBER;
-
- for (count = 0; count < maximum; count++) {
- buffer[ count ] = inbyte( minor );
- if (buffer[ count ] == '\n' || buffer[ count ] == '\r') {
- buffer[ count++ ] = '\n';
- break;
- }
- }
-
- rw_args->bytes_moved = count;
- return (count >= 0) ? RTEMS_SUCCESSFUL : RTEMS_UNSATISFIED;
-}
-
-/*
- * write bytes to the serial port. Stdout and stderr are the same.
- */
-rtems_device_driver console_write(
- rtems_device_major_number major,
- rtems_device_minor_number minor,
- void * arg
-)
-{
- int count;
- int maximum;
- rtems_libio_rw_args_t *rw_args;
- char *buffer;
-
- rw_args = (rtems_libio_rw_args_t *) arg;
-
- buffer = rw_args->buffer;
- maximum = rw_args->count;
-
- if ( minor > 1 )
- return RTEMS_INVALID_NUMBER;
-
- for (count = 0; count < maximum; count++) {
- if ( buffer[ count ] == '\n') {
- outbyte('\r', minor );
- }
- outbyte( buffer[ count ], minor );
- }
-
- rw_args->bytes_moved = maximum;
- return 0;
-}
-
-/*
- * IO Control entry point
- */
-
-rtems_device_driver console_control(
- rtems_device_major_number major,
- rtems_device_minor_number minor,
- void * arg
-)
-{
- return RTEMS_SUCCESSFUL;
-}
diff --git a/c/src/lib/libbsp/m68k/idp/console/duart.c b/c/src/lib/libbsp/m68k/idp/console/duart.c
deleted file mode 100644
index d0a7d9af4d..0000000000
--- a/c/src/lib/libbsp/m68k/idp/console/duart.c
+++ /dev/null
@@ -1,263 +0,0 @@
-/*#########################################################
-#
-# 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 <bsp.h>
-#include <rtems/ringbuf.h>
-
-rtems_isr C_Receive_ISR(rtems_vector_number vector);
-extern Ring_buffer_t Console_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
-######################################################################*/
-void init_pit()
-{
- /*
- * ports A & B while configuring PIT by:
- *
- * + disable Interrupt Mask Register
- * + disable port A transmitter
- * + disable port A receiver
- * + disable port B transmitter
- * + disable port B receiver
- */
-
- MC68681_WRITE(DUART_ADDR, MC68681_INTERRUPT_MASK_REG, 0x00);
- MC68681_WRITE(DUART_ADDR, MC68681_COMMAND_REG_A ,MC68681_MODE_REG_DISABLE_TX);
- MC68681_WRITE(DUART_ADDR, MC68681_COMMAND_REG_A, MC68681_MODE_REG_DISABLE_RX);
- MC68681_WRITE(DUART_ADDR, MC68681_COMMAND_REG_B, MC68681_MODE_REG_DISABLE_TX);
- MC68681_WRITE(DUART_ADDR, MC68681_COMMAND_REG_B, MC68681_MODE_REG_DISABLE_RX);
-
- /*
- * install ISR for ports A and B
- */
- set_vector(C_Receive_ISR, (MC68230_VECT+MC68230_H3VECT), 1);
-
- /*
- * initialize pit
- *
- * set mode to 0 -- disable all ports
- * set up pirq and piack
- * all pins on port b are input
- * submode 1x, h3 interrupt enabled
- * setup pivr
- * turn on all ports
- */
- MC68230_WRITE(MC68230_PGCR, 0x00);
- MC68230_WRITE(MC68230_PSRR, 0x18);
- MC68230_WRITE(MC68230_PBDDR, 0x00);
- MC68230_WRITE(MC68230_PBCR, 0x82);
- MC68230_WRITE(MC68230_PIVR, MC68230_VECT);
- MC68230_WRITE(MC68230_PGCR, 0x20);
-
- /*
- * 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)
- {
- /*
- * initialize the duart registers on port b
- * WARNING:OPTIMIZER MAY ONLY EXECUTE THIRD STATEMENT IF NOT VOLATILE
- *
- * reset tx, channel b
- * reset rx, channel b
- * reset mr pointer, ch
- */
- MC68681_WRITE(DUART_ADDR, MC68681_COMMAND_REG_B, MC68681_MODE_REG_RESET_TX);
- MC68681_WRITE(DUART_ADDR, MC68681_COMMAND_REG_B, MC68681_MODE_REG_RESET_RX);
- MC68681_WRITE(DUART_ADDR, MC68681_COMMAND_REG_B, MC68681_MODE_REG_RESET_MR_PTR);
-
- /*
- * initialize the duart registers on port a
- * WARNING:OPTIMIZER MAY ONLY EXECUTE THIRD STATEMENT IF NOT VOLATILE
- *
- * reset tx, channel a
- * reset rx, channel a
- * reset mr pointer, ch
- */
- MC68681_WRITE(DUART_ADDR, MC68681_COMMAND_REG_A, MC68681_MODE_REG_RESET_TX);
- MC68681_WRITE(DUART_ADDR, MC68681_COMMAND_REG_A, MC68681_MODE_REG_RESET_RX);
- MC68681_WRITE(DUART_ADDR, MC68681_COMMAND_REG_A, MC68681_MODE_REG_RESET_MR_PTR);
-
- Pit_initialized = 1;
- }
-
- /*
- * Init the general registers of the duart
- *
- * init ivr
- * init imr
- * init acr
- * init ctur
- * init ctlr
- * init opcr
- * init cts
- */
- MC68681_WRITE(DUART_ADDR, MC68681_INTERRUPT_VECTOR_REG,
- MC68681_INTERRUPT_VECTOR_INIT);
- MC68681_WRITE(DUART_ADDR, MC68681_INTERRUPT_MASK_REG,
- MC68681_IR_RX_READY_A | MC68681_IR_RX_READY_B);
- MC68681_WRITE(DUART_ADDR, MC68681_AUX_CTRL_REG, MC68681_CLEAR);
- MC68681_WRITE(DUART_ADDR, MC68681_COUNTER_TIMER_UPPER_REG, 0x00);
- MC68681_WRITE(DUART_ADDR, MC68681_COUNTER_TIMER_LOWER_REG, 0x02);
- MC68681_WRITE(DUART_ADDR, MC68681_OUTPUT_PORT_CONFIG_REG, MC68681_CLEAR);
- MC68681_WRITE(DUART_ADDR, MC68681_OUTPUT_PORT_SET_REG, 0x01);
-
- /*
- * init the actual serial port for port a
- *
- * Set Baud Rate to 9600
- * Set Stop bit length of 1
- * enable Transmit and receive
- */
- MC68681_WRITE(DUART_ADDR, MC68681_CLOCK_SELECT_REG_A, MC68681_BAUD_RATE_MASK_9600);
- MC68681_WRITE(DUART_ADDR, MC68681_MODE_REG_1A,
- (MC68681_8BIT_CHARS | MC68681_NO_PARITY));
- MC68681_WRITE(DUART_ADDR, MC68681_MODE_REG_2A,MC68681_STOP_BIT_LENGTH_1);
- MC68681_WRITE(DUART_ADDR, MC68681_COMMAND_REG_A,
- (MC68681_MODE_REG_ENABLE_TX | MC68681_MODE_REG_ENABLE_RX));
-
- /*
- * init the actual serial port for port b
- * init csrb -- 9600 baud
- */
- MC68681_WRITE(DUART_ADDR, MC68681_CLOCK_SELECT_REG_B, MC68681_BAUD_RATE_MASK_9600);
-
-#define EIGHT_BITS_NO_PARITY
-#ifdef EIGHT_BITS_NO_PARITY
- /*
- * Set 8 Bit characters with no parity
- */
- MC68681_WRITE(DUART_ADDR, MC68681_MODE_REG_1B,
- (MC68681_NO_PARITY | MC68681_8BIT_CHARS) );
-#else
- /*
- * Set 7 Bit Characters with parity
- */
- MC68681_WRITE(DUART_ADDR, MC68681_MODE_REG_1B,
- (MC68681_WITH_PARITY | MC68681_7BIT_CHARS) );
-#endif
-
- /*
- * Set Stop Bit length to 1
- * Disable Recieve and transmit on B
- */
- MC68681_WRITE(DUART_ADDR, MC68681_MODE_REG_2B,MC68681_STOP_BIT_LENGTH_1);
- MC68681_WRITE(DUART_ADDR, MC68681_COMMAND_REG_B,
- (MC68681_MODE_REG_ENABLE_TX | MC68681_MODE_REG_ENABLE_RX) );
-}
-
-/*#####################################################################
-# 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;
-
- /*
- * Clear pit interrupt.
- */
- _addr = (unsigned char *) (MC68230_PIT_ADDR + MC68230_PITSR);
- *_addr = 0x04;
-
- /*
- * check port A first for input
- * extract rcvrdy on port B
- * set ptr to recieve buffer and read character into ring buffer
- */
- _addr = (unsigned char *) (DUART_ADDR + MC68681_STATUS_REG_A);
- if (*_addr & MC68681_RX_READY) /* extract rcvrdy on port A */
- {
- _addr = (unsigned char *) (DUART_ADDR + MC68681_RECEIVE_BUFFER_A);
- Ring_buffer_Add_character( &Console_Buffer[ 0 ], *_addr );
- }
-
- /*
- * If not on port A, let's check port B
- * extract rcvrdy on port B
- * set ptr to recieve buffer and read character into ring buffer
- */
- else
- {
- _addr = (unsigned char *) (DUART_ADDR + MC68681_STATUS_REG_B);
- if (*_addr & MC68681_RX_READY) /* extract rcvrdy on port B */
- {
- _addr = (unsigned char *) (DUART_ADDR + MC68681_RECEIVE_BUFFER_B);
- Ring_buffer_Add_character( &Console_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 + MC68681_STATUS_REG_A);
- while (!(*_addr & MC68681_TX_READY))
- {
- }
-
- /*
- * transmit character over port A
- */
- MC68681_WRITE(DUART_ADDR, MC68681_TRANSMIT_BUFFER_A, 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 + MC68681_STATUS_REG_B);
- while (!(*_addr & MC68681_TX_READY))
- {
- }
-
- /*
- * transmit character over port B
- */
- MC68681_WRITE(DUART_ADDR, MC68681_TRANSMIT_BUFFER_B, ch);
-}
diff --git a/c/src/lib/libbsp/m68k/idp/console/leds.c b/c/src/lib/libbsp/m68k/idp/console/leds.c
deleted file mode 100644
index d2478c5d84..0000000000
--- a/c/src/lib/libbsp/m68k/idp/console/leds.c
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * leds.c -- control the led's on a Motorola mc68ec0x0 board.
- * Written by rob@cygnus.com (Rob Savoye)
- */
-#include "leds.h"
-
-void zylons(void);
-void clear_leds(void);
-
-/*
- * 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 ( 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;
-}
-
-void rtems_bsp_delay( int );
-
-/*
- * 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);
- rtems_bsp_delay ( 8000 );
- }
-}
diff --git a/c/src/lib/libbsp/m68k/idp/console/mc68ec.c b/c/src/lib/libbsp/m68k/idp/console/mc68ec.c
deleted file mode 100644
index 9041ca527b..0000000000
--- a/c/src/lib/libbsp/m68k/idp/console/mc68ec.c
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * mc68ec.c -- Low level support for the Motorola mc68ec0x0 board.
- * Written by rob@cygnus.com (Rob Savoye)
- */
-
-#include <bsp.h>
-#include "leds.h"
-
-/*
- * rtems_bsp_delay -- delay execution. This is an ugly hack. It should
- * use the timer, but I'm waiting for docs. (sigh)
- */
-void rtems_bsp_delay(int num)
-{
- while (num--)
- {
- __asm__ ("nop");
- }
-}