diff options
-rw-r--r-- | c/src/lib/libbsp/powerpc/dmv177/console/Makefile.in | 2 | ||||
-rw-r--r-- | c/src/lib/libbsp/powerpc/dmv177/console/console.c | 518 | ||||
-rw-r--r-- | c/src/lib/libbsp/powerpc/dmv177/console/debugio.c | 114 | ||||
-rw-r--r-- | c/src/lib/libbsp/powerpc/dmv177/console/duart.c | 181 | ||||
-rw-r--r-- | c/src/lib/libbsp/powerpc/dmv177/console/mc68681cfg.c | 53 | ||||
-rw-r--r-- | c/src/lib/libbsp/powerpc/dmv177/console/mc68681cfg.h | 52 | ||||
-rw-r--r-- | c/src/lib/libbsp/powerpc/dmv177/console/z85c30cfg.c | 86 | ||||
-rw-r--r-- | c/src/lib/libbsp/powerpc/dmv177/console/z85c30cfg.h | 50 |
8 files changed, 504 insertions, 552 deletions
diff --git a/c/src/lib/libbsp/powerpc/dmv177/console/Makefile.in b/c/src/lib/libbsp/powerpc/dmv177/console/Makefile.in index cf4d17a5be..b7dffb0303 100644 --- a/c/src/lib/libbsp/powerpc/dmv177/console/Makefile.in +++ b/c/src/lib/libbsp/powerpc/dmv177/console/Makefile.in @@ -11,7 +11,7 @@ PROJECT_ROOT = @PROJECT_ROOT@ PGM=${ARCH}/console.rel # C source names, if any, go here -- minus the .c -C_PIECES=console duart +C_PIECES=config console debugio mc68681cfg z85c30cfg C_FILES=$(C_PIECES:%=%.c) C_O_FILES=$(C_PIECES:%=${ARCH}/%.o) diff --git a/c/src/lib/libbsp/powerpc/dmv177/console/console.c b/c/src/lib/libbsp/powerpc/dmv177/console/console.c index 393fa67e95..15e64145f0 100644 --- a/c/src/lib/libbsp/powerpc/dmv177/console/console.c +++ b/c/src/lib/libbsp/powerpc/dmv177/console/console.c @@ -1,11 +1,22 @@ /* - * console.c + * This file contains the TTY driver for the PPCn_60x * * This driver uses the termios pseudo driver. * - * Currently only polled mode is supported. + * COPYRIGHT (c) 1998 by Radstone Technology * - * COPYRIGHT (c) 1989-1998. + * + * THIS FILE IS PROVIDED TO YOU, THE USER, "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK + * AS TO THE QUALITY AND PERFORMANCE OF ALL CODE IN THIS FILE IS WITH YOU. + * + * You are hereby granted permission to use, copy, modify, and distribute + * this file, provided that this notice, plus the above copyright notice + * and disclaimer, appears in all copies. Radstone Technology will provide + * no support for this code. + * + * COPYRIGHT (c) 1989-1997. * On-Line Applications Research Corporation (OAR). * Copyright assigned to U.S. Government, 1994. * @@ -13,290 +24,123 @@ * found in the file LICENSE in this distribution or at * http://www.OARcorp.com/rtems/license.html. * - * $Id: console.c + * $Id$ */ -#include <stdlib.h> -#include <motorola/mc68681.h> #include <bsp.h> #include <rtems/libio.h> +#include <stdlib.h> #include <assert.h> +#include <termios.h> -#define COM1 0 -#define COM2 1 -#define NUM_PORTS 2 -#define USE_FOR_CONSOLE COM2 +#include <libchip/serial.h> /* - * Define RDB_BREAK_IN if you need to be able to break in to the - * program with a ctrl-c during remote target debugging. If so, - * UART B will not be accessible from rtems during remote debugging - * if interrupt driven console is used. Does not affect UART A, polled - * mode or when the program runs without remote debugging. + * Load configuration table */ -#define RDB_BREAK_IN - -/* Proto-types for Duart.C */ -void console_initialize_interrupts( void ); -int console_inbyte_nonblocking( int port ); -void console_outbyte_polled(int port, char ch); -rtems_isr console_isr (rtems_vector_number vector); -volatile void init_mc88681(); -/* PAGE - * - * console_initialize - * - * This routine initializes the console IO driver. - * - * Input parameters: - * major - console device major number - * minor - console device minor number - * arg - pointer to optional device driver arguments - * - * Output parameters: NONE - * - * Return values: - * rtems_device_driver status code - */ +extern console_data Console_Port_Data[]; +extern unsigned long Console_Port_Count; +extern rtems_device_minor_number Console_Port_Minor; -rtems_device_driver console_initialize( - rtems_device_major_number major, - rtems_device_minor_number minor, - void *arg -) -{ - rtems_status_code status; - int console; - - /* - * initialize the termio interface. - */ - rtems_termios_initialize(); - - /* - * Register Device Names - */ - console = USE_FOR_CONSOLE; - status = rtems_io_register_name( "/dev/console", major, console ); - if (status != RTEMS_SUCCESSFUL) - rtems_fatal_error_occurred(status); - - /* - * Initialize Hardware - */ - - init_mc88681 (); - -#if CONSOLE_USE_INTERRUPTS - console_initialize_interrupts(); -#endif - - return RTEMS_SUCCESSFUL; -} - -/* PAGE - * - * console_write_support - * - * This routine is Console Termios output entry point. - * - * Input parameters: - * minor - console device minor number - * buf - buffer of data to be written - * len - length of data to be written - * - * Output parameters: NONE - * - * Return values: - * int number of bytes written - */ - -int console_write_support( - int minor, - const char *buf, - int len) -{ - int nwrite = 0; - int port = minor; - - /* - * verify port Number - */ - assert ( port < NUM_PORTS ); - - /* - * poll each byte in the string out of the port. - */ - while (nwrite < len) { -#if CONSOLE_USE_INTERRUPTS -#else - console_outbyte_polled(port, *buf++); -#endif - nwrite++; - } - - /* - * return the number of bytes written. - */ - return nwrite; -} - - -/* PAGE - * - * DEBUG_puts - * - * This should be safe in the event of an error. It attempts to insure - * that no TX empty interrupts occur while it is doing polled IO. Then - * it restores the state of that external interrupt. - * - * Input parameters: - * string - pointer to debug output string - * - * Output parameters: NONE - * - * Return values: NONE - */ - -void DEBUG_puts( - char *string -) -{ - char *s; - rtems_unsigned32 isrlevel; - - rtems_interrupt_disable( isrlevel ); - for ( s = string ; *s ; s++ ) - console_outbyte_polled( 0, *s ); - - console_outbyte_polled( 0, '\r' ); - console_outbyte_polled( 0, '\n' ); - rtems_interrupt_enable( isrlevel ); -} - - /* PAGE * * console_open * - * This routine is the console device driver open entry point. - * - * Input parameters: - * major - console device major number - * minor - console device minor number - * arg - pointer to optional device driver arguments + * open a port as a termios console. * - * Output parameters: NONE - * - * Return values: - * rtems_device_driver status code */ - rtems_device_driver console_open( rtems_device_major_number major, rtems_device_minor_number minor, void * arg ) { - rtems_status_code sc; - int port = minor; - static const rtems_termios_callbacks pollCallbacks = { - NULL, /* firstOpen */ - NULL, /* lastClose */ - console_inbyte_nonblocking, /* pollRead */ - console_write_support, /* write */ - NULL, /* setAttributes */ - NULL, /* stopRemoteTx */ - NULL, /* startRemoteTx */ - 0 /* outputUsesInterrupts */ - }; + rtems_status_code status; + rtems_libio_open_close_args_t *args = arg; + rtems_libio_ioctl_args_t IoctlArgs; + struct termios Termios; + rtems_termios_callbacks Callbacks; + console_tbl *cptr; /* - * Verify the minor number is valid. + * Verify the port number is valid. */ - if (minor < 0) + if ( minor > Console_Port_Count ) { return RTEMS_INVALID_NUMBER; - - if ( port > NUM_PORTS ) - return RTEMS_INVALID_NUMBER; + } /* - * open the port as a termios console driver. + * Open the port as a termios console driver. */ - sc = rtems_termios_open (major, minor, arg, &pollCallbacks); - return sc; -} - - + cptr = &Console_Port_Tbl[minor]; + Callbacks.firstOpen = cptr->pDeviceFns->deviceFirstOpen; + Callbacks.lastClose = cptr->pDeviceFns->deviceLastClose; + Callbacks.pollRead = cptr->pDeviceFns->deviceRead; + Callbacks.write = cptr->pDeviceFns->deviceWrite; + Callbacks.setAttributes = cptr->pDeviceFns->deviceSetAttributes; + Callbacks.stopRemoteTx = cptr->pDeviceFlow->deviceStopRemoteTx; + Callbacks.startRemoteTx = cptr->pDeviceFlow->deviceStartRemoteTx; + Callbacks.outputUsesInterrupts = cptr->pDeviceFns->deviceOutputUsesInterrupts; + + /* XXX what about + * Console_Port_Tbl[minor].ulMargin, + * Console_Port_Tbl[minor].ulHysteresis); + */ -/* PAGE - * - * console_reserve_resources - * - * This routine reserves resources for each port which may be - * used as a console. - * - * Input parameters: - * configuration - rtems configuration table. - * - * Output parameters: NONE - * - * Return values: NONE - */ + status = rtems_termios_open ( major, minor, arg, &Callbacks ); + Console_Port_Data[minor].termios_data = args->iop->data1; + + if (minor!=Console_Port_Minor) { + /* + * If this is not the console we do not want ECHO and + * so forth + */ + IoctlArgs.iop=args->iop; + IoctlArgs.command=RTEMS_IO_GET_ATTRIBUTES; + IoctlArgs.buffer=&Termios; + rtems_termios_ioctl(&IoctlArgs); + Termios.c_lflag=ICANON; + IoctlArgs.command=RTEMS_IO_SET_ATTRIBUTES; + rtems_termios_ioctl(&IoctlArgs); + } + + if ( (args->iop->flags&LIBIO_FLAGS_READ) && + Console_Port_Tbl[minor].pDeviceFlow && + Console_Port_Tbl[minor].pDeviceFlow->deviceStartRemoteTx) { + Console_Port_Tbl[minor].pDeviceFlow->deviceStartRemoteTx(minor); + } + return status; +} + void console_reserve_resources( rtems_configuration_table *configuration ) { - rtems_termios_reserve_resources( configuration, NUM_PORTS ); + rtems_termios_reserve_resources( configuration, 4 ); } -/* PAGE - * - * console_close - * - * This routine is the console device driver close entry point. - * - * Input parameters: - * major - console device major number - * minor - console device minor number - * arg - pointer to optional device driver arguments - * - * Output parameters: NONE - * - * Return values: - * rtems_device_driver status code - */ - + rtems_device_driver console_close( rtems_device_major_number major, rtems_device_minor_number minor, void * arg ) { + rtems_libio_open_close_args_t *args = arg; + + if ( (args->iop->flags&LIBIO_FLAGS_READ) && + Console_Port_Tbl[minor].pDeviceFlow && + Console_Port_Tbl[minor].pDeviceFlow->deviceStopRemoteTx) { + Console_Port_Tbl[minor].pDeviceFlow->deviceStopRemoteTx(minor); + } + return rtems_termios_close (arg); } -/* PAGE - * - * console_read - * - * This routine is the console device driver read entry point. - * - * Input parameters: - * major - console device major number - * minor - console device minor number - * arg - pointer to optional device driver arguments - * - * Output parameters: NONE - * - * Return values: - * rtems_device_driver status code - * - */ - rtems_device_driver console_read( +rtems_device_driver console_read( rtems_device_major_number major, rtems_device_minor_number minor, void * arg @@ -305,23 +149,6 @@ rtems_device_driver console_close( return rtems_termios_read (arg); } -/* PAGE - * - * console_write - * - * This routine is the console device driver write entry point. - * - * Input parameters: - * major - console device major number - * minor - console device minor number - * arg - pointer to optional device driver arguments - * - * Output parameters: NONE - * - * Return values: - * rtems_device_driver status code - * - */ rtems_device_driver console_write( rtems_device_major_number major, rtems_device_minor_number minor, @@ -331,23 +158,6 @@ rtems_device_driver console_write( return rtems_termios_write (arg); } -/* PAGE - * - * console_control - * - * This routine is console device driver control entry point - * - * Input parameters: - * major - console device major number - * minor - console device minor number - * arg - pointer to optional device driver arguments - * - * Output parameters: NONE - * - * Return values: - * rtems_device_driver status code - * - */ rtems_device_driver console_control( rtems_device_major_number major, rtems_device_minor_number minor, @@ -357,118 +167,86 @@ rtems_device_driver console_control( return rtems_termios_ioctl (arg); } - -/* - * Interrupt driven console IO - */ - -#if CONSOLE_USE_INTERRUPTS - -/* - * Buffers between task and ISRs - */ - -#include <ringbuf.h> -extern Ring_buffer_t TX_Buffer[2]; -extern Ring_buffer_t RX_Buffer[2]; - -/* - * console_inbyte_interrupts - * - * This routine reads a character from the UART. - * - * Input parameters: NONE +/* PAGE * - * Output parameters: NONE + * console_initialize * - * Return values: - * character read from UART + * Routine called to initialize the console device driver. */ - -char console_inbyte_interrupts( int port ) -{ - char ch; - while ( Ring_buffer_Is_empty( &RX_Buffer[ port ] ) ); - - Ring_buffer_Remove_character( &RX_Buffer[ port ], ch ); - return ch; -} - -/* - * console_outbyte_interrupts - * - * This routine transmits a character out. - * - * Input parameters: - * port - port to transmit character to - * ch - character to be transmitted - * - * Output parameters: NONE - * - * Return values: NONE - */ - -void console_outbyte_interrupts( - int port, - char ch +rtems_device_driver console_initialize( + rtems_device_major_number major, + rtems_device_minor_number minor, + void *arg ) { - /* - * If this is the first character then we need to prime the pump - */ - - if ( Is_TX_active[ port ] == FALSE ) { - Is_TX_active[ port ] = TRUE; - console_outbyte_polled( port, ch ); - return; - } - - while ( Ring_buffer_Is_full( &TX_Buffer[ port ] ) ); - - Ring_buffer_Add_character( &TX_Buffer[ port ], ch ); -} - -/* - * console_exit - * - * This routine allows the console to exit by masking its associated interrupt - * vectors. - * - * Input parameters: NONE - * - * Output parameters: NONE - * - * Return values: NONE - */ - -void console_exit() -{ - volatile unsigned char *_addr; - int port; + rtems_status_code status; /* - * Although the interrupts for the UART are unmasked, the PIL is set to - * disable all external interrupts. So we might as well do this first. + * initialize the termio interface. */ - /* ??? Mask All UART Interrupts */ + rtems_termios_initialize(); - for (port = MC68681_PORT_A; port <= MC68681_PORT_B; port++) { - while (!Ring_buffer_Is_empty (&TX_Buffer[port])) { - Ring_buffer_Remove_character (&TX_Buffer[port],ch); - console_outbyte_polled (port,ch); + for (minor=0; minor<Console_Port_Count; minor++) { + /* + * First perform the configuration dependent probe, then the + * device dependent probe + */ + + if ((!Console_Port_Tbl[minor].deviceProbe || + Console_Port_Tbl[minor].deviceProbe(minor)) && + Console_Port_Tbl[minor].pDeviceFns->deviceProbe(minor)) { + /* + * Use this device for the console + */ + break; } } + if ( minor==Console_Port_Count ) { + /* + * Failed to find a working device + */ + rtems_fatal_error_occurred(RTEMS_IO_ERROR); + } + + Console_Port_Minor=minor; /* - * Now wait for all the data to actually get out ... the send register - * should be empty. + * Register Device Names */ - _addr = (unsigned char *) (DUART_ADDR + MC68681_STATUS_REG_A); - while (!(*_addr & MC68681_TX_EMPTY)); + status = rtems_io_register_name("/dev/console", major, Console_Port_Minor ); + if (status != RTEMS_SUCCESSFUL) { + rtems_fatal_error_occurred(status); + } + Console_Port_Tbl[minor].pDeviceFns->deviceInitialize(Console_Port_Minor); + + for (minor++;minor<Console_Port_Count;minor++) { + /* + * First perform the configuration dependent probe, then the + * device dependent probe + */ + + if ( (!Console_Port_Tbl[minor].deviceProbe || + Console_Port_Tbl[minor].deviceProbe(minor)) && + Console_Port_Tbl[minor].pDeviceFns->deviceProbe(minor)) { + status = rtems_io_register_name( + Console_Port_Tbl[minor].sDeviceName, + major, + minor ); + if (status != RTEMS_SUCCESSFUL) { + rtems_fatal_error_occurred(status); + } + + /* + * Initialize the hardware device. + */ + + Console_Port_Tbl[minor].pDeviceFns->deviceInitialize(minor); - _addr = (unsigned char *) (DUART_ADDR + MC68681_STATUS_REG_B); - while (!(*_addr & MC68681_TX_EMPTY)); + } + } + + return RTEMS_SUCCESSFUL; } -#endif /* CONSOLE_USE_INTERRUPTS */ + diff --git a/c/src/lib/libbsp/powerpc/dmv177/console/debugio.c b/c/src/lib/libbsp/powerpc/dmv177/console/debugio.c new file mode 100644 index 0000000000..d23df205a3 --- /dev/null +++ b/c/src/lib/libbsp/powerpc/dmv177/console/debugio.c @@ -0,0 +1,114 @@ +/* + * This file contains the debug IO support. + * + * COPYRIGHT (c) 1998 by Radstone Technology + * + * + * THIS FILE IS PROVIDED TO YOU, THE USER, "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK + * AS TO THE QUALITY AND PERFORMANCE OF ALL CODE IN THIS FILE IS WITH YOU. + * + * You are hereby granted permission to use, copy, modify, and distribute + * this file, provided that this notice, plus the above copyright notice + * and disclaimer, appears in all copies. Radstone Technology will provide + * no support for this code. + * + * COPYRIGHT (c) 1989-1997. + * On-Line Applications Research Corporation (OAR). + * Copyright assigned to U.S. Government, 1994. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * $Id$ + */ + +#include <bsp.h> +#include <rtems/libio.h> +#include <stdlib.h> +#include <assert.h> +#include <termios.h> + +#include <libchip/serial.h> + +/* + * Load configuration table + */ + +extern console_data Console_Port_Data[]; +extern rtems_device_minor_number Console_Port_Minor; + +/* PAGE + * + * DEBUG_puts + * + * This should be safe in the event of an error. It attempts to ensure + * that no TX empty interrupts occur while it is doing polled IO. Then + * it restores the state of that external interrupt. + * + * Input parameters: + * string - pointer to debug output string + * + * Output parameters: NONE + * + * Return values: NONE + */ + +void DEBUG_puts( + char *string +) +{ + char *s; + unsigned32 Irql; + + rtems_interrupt_disable(Irql); + + for ( s = string ; *s ; s++ ) { + Console_Port_Tbl[Console_Port_Minor].pDeviceFns-> + deviceWritePolled(Console_Port_Minor, *s); + } + + rtems_interrupt_enable(Irql); +} + +/* PAGE + * + * DEBUG_puth + * + * This should be safe in the event of an error. It attempts to ensure + * that no TX empty interrupts occur while it is doing polled IO. Then + * it restores the state of that external interrupt. + * + * Input parameters: + * ulHexNum - value to display + * + * Output parameters: NONE + * + * Return values: NONE + */ + +void DEBUG_puth( + unsigned32 ulHexNum +) +{ + unsigned long i,d; + unsigned32 Irql; + void (*poll)(int minor, char cChar); + + poll = Console_Port_Tbl[Console_Port_Minor].pDeviceFns->deviceWritePolled; + + rtems_interrupt_disable(Irql); + + (*poll)(Console_Port_Minor, '0'); + (*poll)(Console_Port_Minor, 'x'); + + for ( i=32 ; i ; ) { + i -= 4; + d = (ulHexNum>>i)&0xf; + (*poll)(Console_Port_Minor, (d<=9) ? d+'0' : d+'a'-0xa); + } + rtems_interrupt_enable(Irql); +} + diff --git a/c/src/lib/libbsp/powerpc/dmv177/console/duart.c b/c/src/lib/libbsp/powerpc/dmv177/console/duart.c deleted file mode 100644 index 540a268d7c..0000000000 --- a/c/src/lib/libbsp/powerpc/dmv177/console/duart.c +++ /dev/null @@ -1,181 +0,0 @@ -/* - * duart.c - * - * 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) - * - * COPYRIGHT (c) 1989-1998. - * On-Line Applications Research Corporation (OAR). - * Copyright assigned to U.S. Government, 1994. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.OARcorp.com/rtems/license.html. - * - * $Id: duart.c - */ - -#define MC68681_OFFSET_MULTIPLIER 8 -#include <motorola/mc68681.h> -#include <bsp.h> -#include <ringbuf.h> - -rtems_isr console_isr (rtems_vector_number vector); - -Ring_buffer_t TX_Buffer[2]; -Ring_buffer_t RX_Buffer[2]; - -/*PAGE - * - * init_mc88681 - * - * volatile routine to initialize duart - * - * Input parameters: NONE - * - * Output parameters: NONE - * - * Return Values: NONE - */ - -volatile void init_mc88681() -{ - /* - * Initialize Ring buffers - */ - Ring_buffer_Initialize( &RX_Buffer[ 0 ] ); - Ring_buffer_Initialize( &RX_Buffer[ 1 ] ); - - Ring_buffer_Initialize( &TX_Buffer[ 0 ] ); - Ring_buffer_Initialize( &TX_Buffer[ 1 ] ); -} - -/*PAGE - * - * console_isr - * - * interrupt handler for receive of character from duart on ports A & B - * - * Input parameters: NONE - * - * Output parameters: NONE - * - * Return Values: NONE - */ - -rtems_isr console_isr (rtems_vector_number vector) -{ - - /* - * Fill me in later ... - */ - -} - - -/*PAGE - * - * console_outbyte_polled - * - * This routine transmits a character out. - * - * Input parameters: - * port - port to transmit character to - * ch - character to be transmitted - * - * Output parameters: NONE - * - * Return values: NONE - */ - -void console_outbyte_polled( - int port, - char ch -) -{ - unsigned char status; - unsigned char data; - unsigned char t = 0; - - if (port == MC68681_PORT_A) { - status = MC68681_STATUS_REG_A; - data = MC68681_TRANSMIT_BUFFER_A; - } else { - status = MC68681_STATUS_REG_B; - data = MC68681_TRANSMIT_BUFFER_B; - } - - while ( !(MC68681_READ(DUART_ADDR, status) & MC68681_TX_READY) ){ - if (t == 0) { - t++; - } - } - - MC68681_WRITE(DUART_ADDR, data, ch); -} - - -/*PAGE - * - * console_inbyte_nonblocking - * - * This routine reads a character from the UART. - * - * Input parameters: - * port - port to read character from - * - * Output parameters: NONE - * - * Return values: - * character read from UART - */ - -#define MC68681_RECEIVE_ERRORS \ - (MC68681_OVERRUN_ERROR | MC68681_PARITY_ERROR | MC68681_FRAMING_ERROR) - -int console_inbyte_nonblocking( int port ) -{ - char status; - char data; - char cmd; - unsigned char status_info; - - /* - * Set Port A or B unique variables. - */ - if (port == MC68681_PORT_A) { - status = MC68681_STATUS_REG_A; - data = MC68681_RECEIVE_BUFFER_A; - cmd = MC68681_COMMAND_REG_A; - } else { - status = MC68681_STATUS_REG_B; - data = MC68681_RECEIVE_BUFFER_B; - cmd = MC68681_COMMAND_REG_B; - } - - /* Wait for the Ready bit and Clear any errors */ - for ( ; ; ) { - status_info = MC68681_READ(DUART_ADDR, status); - if ( status_info & MC68681_RX_READY ) - break; - - if ( status_info & MC68681_RECEIVE_ERRORS ) - MC68681_WRITE( DUART_ADDR, cmd, MC68681_MODE_REG_RESET_ERROR ); - } - - return MC68681_READ(DUART_ADDR, data); -} - diff --git a/c/src/lib/libbsp/powerpc/dmv177/console/mc68681cfg.c b/c/src/lib/libbsp/powerpc/dmv177/console/mc68681cfg.c new file mode 100644 index 0000000000..0ea7243546 --- /dev/null +++ b/c/src/lib/libbsp/powerpc/dmv177/console/mc68681cfg.c @@ -0,0 +1,53 @@ +/* + * This file contains the console driver chip level routines for the + * mc68681 chip. + * + * COPYRIGHT (c) 1989-1997. + * On-Line Applications Research Corporation (OAR). + * Copyright assigned to U.S. Government, 1994. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * $Id$ + */ + +#include <rtems.h> +#include <bsp.h> + +#define CALCULATE_REGISTER_ADDRESS( _base, _reg ) \ + (unsigned8 *)((_base) + ((_reg) * 8 )) + +/* + * Read_mc68681_register + */ + +unsigned8 Read_mc68681_register( + unsigned32 ulCtrlPort, + unsigned8 ucRegNum +) +{ + unsigned8 *port; + + port = CALCULATE_REGISTER_ADDRESS( ulCtrlPort, ucRegNum ); + + return *port; +} + +/* + * Write_mc68681_register + */ + +void Write_mc68681_register( + unsigned32 ulCtrlPort, + unsigned8 ucRegNum, + unsigned8 ucData +) +{ + unsigned8 *port; + + port = CALCULATE_REGISTER_ADDRESS( ulCtrlPort, ucRegNum ); + + *port = ucData; +} diff --git a/c/src/lib/libbsp/powerpc/dmv177/console/mc68681cfg.h b/c/src/lib/libbsp/powerpc/dmv177/console/mc68681cfg.h new file mode 100644 index 0000000000..3dd113b3a7 --- /dev/null +++ b/c/src/lib/libbsp/powerpc/dmv177/console/mc68681cfg.h @@ -0,0 +1,52 @@ +/* + * This include file contains all console driver definitions for the + * Motorola MC68681 compatible DUART used as the first two serial + * ports on the DMV177. + * + * COPYRIGHT (c) 1989-1997. + * On-Line Applications Research Corporation (OAR). + * Copyright assigned to U.S. Government, 1994. + * + * The license and distribution terms for this file may in + * the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * $Id$ + */ + +#ifndef __MC68681_CONFIG_H +#define __MC68681_CONFIG_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Board specific register access routines + */ + +unsigned8 Read_mc68681_register( + unsigned32 ulCtrlPort, + unsigned8 ucRegNum +); + +void Write_mc68681_register( + unsigned32 ulCtrlPort, + unsigned8 ucRegNum, + unsigned8 ucData +); + +unsigned8 Read_mc68681_data( + unsigned32 ulDataPort +); + +void Write_mc68681_data( + unsigned32 ulDataPort, + unsigned8 ucData +); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/c/src/lib/libbsp/powerpc/dmv177/console/z85c30cfg.c b/c/src/lib/libbsp/powerpc/dmv177/console/z85c30cfg.c new file mode 100644 index 0000000000..46988e5ad0 --- /dev/null +++ b/c/src/lib/libbsp/powerpc/dmv177/console/z85c30cfg.c @@ -0,0 +1,86 @@ +/* + * This file contains the console driver chip level routines for the + * z85c30 chip. + * + * COPYRIGHT (c) 1989-1997. + * On-Line Applications Research Corporation (OAR). + * Copyright assigned to U.S. Government, 1994. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * $Id$ + */ + +#include <rtems.h> +#include <bsp.h> + +/* + * Read_z85c30_register + */ + +unsigned8 Read_z85c30_register( + unsigned32 ulCtrlPort, + unsigned8 ucRegNum +) +{ + unsigned8 *port; + + port = (unsigned8 *)ulCtrlPort; + + if(ucRegNum) { + *port = ucRegNum; + } + return *port; + +} + +/* + * Write_z85c30_register + */ + +void Write_z85c30_register( + unsigned32 ulCtrlPort, + unsigned8 ucRegNum, + unsigned8 ucData +) +{ + unsigned8 *port; + + port = (unsigned8 *)ulCtrlPort; + + if(ucRegNum) { + *port = ucRegNum; + } + *port = ucData; +} + +/* + * Read_z85c30_data + */ + +unsigned8 Read_z85c30_data( + unsigned32 ulDataPort +) +{ + unsigned8 *port; + + port = (unsigned8 *)ulDataPort; + return *port; +} + +/* + * Write_z85c30_data + */ + +void Write_z85c30_data( + unsigned32 ulDataPort, + unsigned8 ucData +) +{ + unsigned8 *port; + + port = (unsigned8 *)ulDataPort; + *port = ucData; +} diff --git a/c/src/lib/libbsp/powerpc/dmv177/console/z85c30cfg.h b/c/src/lib/libbsp/powerpc/dmv177/console/z85c30cfg.h new file mode 100644 index 0000000000..63ad0fce6c --- /dev/null +++ b/c/src/lib/libbsp/powerpc/dmv177/console/z85c30cfg.h @@ -0,0 +1,50 @@ +/* + * This include file contains all console driver definitions for the z85c30 + * + * COPYRIGHT (c) 1989-1997. + * On-Line Applications Research Corporation (OAR). + * Copyright assigned to U.S. Government, 1994. + * + * The license and distribution terms for this file may in + * the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * $Id$ + */ + +#ifndef __Z85C30_CONFIG_H +#define __Z85C30_CONFIG_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Board specific register access routines + */ + +unsigned8 Read_z85c30_register( + unsigned32 ulCtrlPort, + unsigned8 ucRegNum +); + +void Write_z85c30_register( + unsigned32 ulCtrlPort, + unsigned8 ucRegNum, + unsigned8 ucData +); + +unsigned8 Read_z85c30_data( + unsigned32 ulDataPort +); + +void Write_z85c30_data( + unsigned32 ulDataPort, + unsigned8 ucData +); + +#ifdef __cplusplus +} +#endif + +#endif |