Changeset caeb33b2 in rtems


Ignore:
Timestamp:
07/03/01 17:56:32 (22 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
b8c8cab
Parents:
6c5e3215
Message:

2001-07-03 Mike Seirs <mike@…>

  • comm/tty_drv.c, comm/uart.c, comm/uart.h: Adds the capability to use task driven serial I/O to ti386 BSPs. This patch leaves thex default I/O mode to be IRQ. If you want to use task I/O mode, then the tty_drv.c file needs to be modified. Basically, all you need to change is the data values of the termios callbacks structure. This callback structure is used in the tty1_open and tty2_open functions. The values you need to set are commented out in the source code.
Location:
c/src/lib/libbsp/i386/shared
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/i386/shared/ChangeLog

    r6c5e3215 rcaeb33b2  
     1
     2        * comm/tty_drv.c, comm/uart.c, comm/uart.h:  Adds the capability
     3        to use task driven serial I/O to ti386 BSPs. This patch leaves thex
     4        default I/O mode to be IRQ.  If you want to use task I/O mode,
     5        then the tty_drv.c file needs to be modified.  Basically, all
     6        you need to change is the data values of the termios callbacks
     7        structure.  This callback structure is used in the tty1_open
     8        and tty2_open functions.  The values you need to set are commented
     9        out in the source code.
     10
     112001-06-19      Ralf Corsepius <corsepiu@faw.uni-ulm.de>
    112
    213        * comm/Makefile.am: Use *_HEADERS instead of *H_FILES.
  • c/src/lib/libbsp/i386/shared/comm/tty_drv.c

    r6c5e3215 rcaeb33b2  
    1919 *
    2020 * $Log$
     21 * Revision 1.3  2000/12/05 16:37:38  joel
     22 * 2000-12-01   Joel Sherrill <joel@OARcorp.com>
     23 *
     24 *      * pc386/console/console.c, pc386/console/serial_mouse.c,
     25 *      pc386/console/vgainit.c, shared/comm/tty_drv.c: Remove warnings.
     26 *
    2127 * Revision 1.2  2000/10/18 16:10:50  joel
    2228 * 2000-10-18    Charles-Antoine Gauthier <charles.gauthier@nrc.ca>
     
    4854#include <irq.h>
    4955#include <rtems/libio.h>
     56#include <rtems/termiostypes.h>
    5057#include <termios.h>
    5158#include <uart.h>
     
    176183{
    177184  rtems_status_code  status;
     185#ifndef USE_TASK_DRIVEN
    178186  static rtems_termios_callbacks cb =
    179187  {
    180     NULL,                     /* firstOpen */
    181     tty1_last_close,       /* lastClose */
    182     NULL,                 /* poll read */
     188    NULL,                        /* firstOpen */
     189    tty1_last_close,             /* lastClose */
     190    NULL,                        /* poll read */
    183191    BSP_uart_termios_write_com1, /* write */
    184     tty1_conSetAttr,         /* setAttributes */
    185     NULL,                     /* stopRemoteTx */
    186     NULL,                     /* startRemoteTx */
    187     1                         /* outputUsesInterrupts */
     192    tty1_conSetAttr,             /* setAttributes */
     193    NULL,                        /* stopRemoteTx */
     194    NULL,                        /* startRemoteTx */
     195    TERMIOS_IRQ_DRIVEN           /* outputUsesInterrupts */
    188196  };
     197#else
     198  static rtems_termios_callbacks cb =
     199  {
     200    NULL,                        /* firstOpen */
     201    tty1_last_close,             /* lastClose */
     202    BSP_uart_termios_read_com1,  /* poll read */
     203    BSP_uart_termios_write_com1, /* write */
     204    tty1_conSetAttr,             /* setAttributes */
     205    NULL,                        /* stopRemoteTx */
     206    NULL,                        /* startRemoteTx */
     207    TERMIOS_TASK_DRIVEN          /* outputUsesInterrupts */
     208  };
     209#endif
    189210
    190211  status = rtems_termios_open( major, minor, arg, &cb );
     
    452473{
    453474  rtems_status_code              status;
     475#ifndef USE_TASK_DRIVEN
    454476  static rtems_termios_callbacks cb =
    455477  {
    456     NULL,                     /* firstOpen */
    457     tty2_last_close,       /* lastClose */
    458     NULL,                 /* poll read */
     478    NULL,                        /* firstOpen */
     479    tty2_last_close,             /* lastClose */
     480    NULL,                        /* poll read */
    459481    BSP_uart_termios_write_com2, /* write */
    460     tty2_conSetAttr,                  /* setAttributes */
    461     NULL,                     /* stopRemoteTx */
    462     NULL,                     /* startRemoteTx */
    463     1                         /* outputUsesInterrupts */
     482    tty2_conSetAttr,             /* setAttributes */
     483    NULL,                        /* stopRemoteTx */
     484    NULL,                        /* startRemoteTx */
     485    TERMIOS_IRQ_DRIVEN           /* outputUsesInterrupts */
    464486  };
     487#else
     488  static rtems_termios_callbacks cb =
     489  {
     490    NULL,                        /* firstOpen */
     491    tty2_last_close,             /* lastClose */
     492    BSP_uart_termios_read_com2,  /* poll read */
     493    BSP_uart_termios_write_com2, /* write */
     494    tty2_conSetAttr,             /* setAttributes */
     495    NULL,                        /* stopRemoteTx */
     496    NULL,                        /* startRemoteTx */
     497    TERMIOS_TASK_DRIVEN          /* outputUsesInterrupts */
     498  };
     499#endif
    465500
    466501  status = rtems_termios_open (major, minor, arg, &cb);
  • c/src/lib/libbsp/i386/shared/comm/uart.c

    r6c5e3215 rcaeb33b2  
    88 */
    99
     10#include <stdio.h>
    1011#include <bsp.h>
    1112#include <irq.h>
    1213#include <uart.h>
    1314#include <rtems/libio.h>
     15#include <rtems/termiostypes.h>
     16#include <termios.h>
    1417#include <assert.h>
    1518
     
    2023struct uart_data
    2124{
     25  int ioMode;
    2226  int hwFlow;
     27  unsigned int  ier;
    2328  unsigned long baud;
    2429  unsigned long databits;
     
    233238BSP_uart_intr_ctrl(int uart, int cmd)
    234239{
     240  int iStatus = (int)INTERRUPT_DISABLE;
    235241
    236242  assert(uart == BSP_UART_COM1 || uart == BSP_UART_COM2);
     
    238244  switch(cmd)
    239245    {
    240     case BSP_UART_INTR_CTRL_DISABLE:
    241       uwrite(uart, IER, INTERRUPT_DISABLE);
    242       break;
    243246    case BSP_UART_INTR_CTRL_ENABLE:
    244       if(uart_data[uart].hwFlow)
    245         {
    246           uwrite(uart, IER,
    247                  (RECEIVE_ENABLE  |
    248                   TRANSMIT_ENABLE |
    249                   RECEIVER_LINE_ST_ENABLE |
    250                   MODEM_ENABLE
    251                  )
    252                 );
    253         }
    254       else
    255         {
    256           uwrite(uart, IER,
    257                  (RECEIVE_ENABLE  |
    258                   TRANSMIT_ENABLE |
    259                   RECEIVER_LINE_ST_ENABLE
    260                  )
    261                 );
    262         }
     247      iStatus |= (RECEIVE_ENABLE | RECEIVER_LINE_ST_ENABLE | TRANSMIT_ENABLE);
     248      if ( uart_data[uart].hwFlow ) {
     249        iStatus |= MODEM_ENABLE;
     250      }
    263251      break;
    264252    case BSP_UART_INTR_CTRL_TERMIOS:
    265       if(uart_data[uart].hwFlow)
    266         {
    267           uwrite(uart, IER,
    268                  (RECEIVE_ENABLE  |
    269                   RECEIVER_LINE_ST_ENABLE |
    270                   MODEM_ENABLE
    271                  )
    272                 );
    273         }
    274       else
    275         {
    276           uwrite(uart, IER,
    277                  (RECEIVE_ENABLE  |
    278                   RECEIVER_LINE_ST_ENABLE
    279                  )
    280                 );
    281         }
     253      iStatus |= (RECEIVE_ENABLE | RECEIVER_LINE_ST_ENABLE);
     254      if ( uart_data[uart].hwFlow ) {
     255        iStatus |= MODEM_ENABLE;
     256      }
    282257      break;
    283258    case BSP_UART_INTR_CTRL_GDB:
    284       uwrite(uart, IER, RECEIVE_ENABLE);
     259      iStatus |= RECEIVE_ENABLE;
    285260      break;
    286     default:
    287       assert(0);
    288       break;
    289     }
     261    }
     262
     263  uart_data[uart].ier = iStatus;
     264  uwrite(uart, IER, iStatus);
    290265 
    291266  return;
     
    495470BSP_uart_termios_set(int uart, void *ttyp)
    496471{
     472  struct rtems_termios_tty *p = (struct rtems_termios_tty *)ttyp;
    497473  unsigned char val;
    498474  assert(uart == BSP_UART_COM1 || uart == BSP_UART_COM2);
     
    500476  if(uart == BSP_UART_COM1)
    501477    {
     478      uart_data[uart].ioMode = p->device.outputUsesInterrupts;
    502479      if(uart_data[uart].hwFlow)
    503480        {
     
    517494  else
    518495    {
     496      uart_data[uart].ioMode = p->device.outputUsesInterrupts;
    519497      if(uart_data[uart].hwFlow)
    520498        {
     
    537515
    538516int
     517BSP_uart_termios_read_com1(int uart)
     518{
     519  int     off = (int)0;
     520  char    buf[40];
     521
     522  /* read bytes */
     523  while (( off < sizeof(buf) ) && ( uread(BSP_UART_COM1, LSR) & DR )) {
     524    buf[off++] = uread(BSP_UART_COM1, RBR);
     525  }
     526
     527  /* write out data */
     528  if ( off > 0 ) {
     529    rtems_termios_enqueue_raw_characters(termios_ttyp_com1, buf, off);
     530  }
     531
     532  /* enable receive interrupts */
     533  uart_data[BSP_UART_COM1].ier |= (RECEIVE_ENABLE | RECEIVER_LINE_ST_ENABLE);
     534  uwrite(BSP_UART_COM1, IER, uart_data[BSP_UART_COM1].ier);
     535
     536  return ( EOF );
     537}
     538
     539int
     540BSP_uart_termios_read_com2(int uart)
     541{
     542  int     off = (int)0;
     543  char    buf[40];
     544
     545  /* read current byte */
     546  while (( off < sizeof(buf) ) && ( uread(BSP_UART_COM1, LSR) & DR )) {
     547    buf[off++] = uread(BSP_UART_COM1, RBR);
     548  }
     549
     550  /* write out data */
     551  if ( off > 0 ) {
     552    rtems_termios_enqueue_raw_characters(termios_ttyp_com2, buf, off);
     553  }
     554
     555  /* enable receive interrupts */
     556  uart_data[BSP_UART_COM2].ier |= (RECEIVE_ENABLE | RECEIVER_LINE_ST_ENABLE);
     557  uwrite(BSP_UART_COM2, IER, uart_data[BSP_UART_COM2].ier);
     558
     559  return ( EOF );
     560}
     561
     562int
    539563BSP_uart_termios_write_com1(int minor, const char *buf, int len)
    540564{
     
    561585
    562586  /* Enable interrupts if necessary */
    563   if(!termios_tx_active_com1 && uart_data[BSP_UART_COM1].hwFlow)
    564     {
    565       termios_tx_active_com1 = 1;
    566       uwrite(BSP_UART_COM1, IER,
    567              (RECEIVE_ENABLE  |
    568               TRANSMIT_ENABLE |
    569               RECEIVER_LINE_ST_ENABLE |
    570               MODEM_ENABLE
    571              )
    572             );
    573     }
    574   else if(!termios_tx_active_com1)
    575     {
    576       termios_tx_active_com1 = 1;
    577       uwrite(BSP_UART_COM1, IER,
    578              (RECEIVE_ENABLE  |
    579               TRANSMIT_ENABLE |
    580               RECEIVER_LINE_ST_ENABLE
    581              )
    582             );
    583     }
     587  if ( !termios_tx_active_com1 ) {
     588    termios_tx_active_com1 = 1;
     589    uart_data[BSP_UART_COM1].ier |= TRANSMIT_ENABLE;
     590    uwrite(BSP_UART_COM1, IER, uart_data[BSP_UART_COM1].ier);
     591  }
    584592
    585593  return 0;
     
    609617
    610618  /* Write character */
    611 
    612619  uwrite(BSP_UART_COM2, THR, *buf & 0xff);
    613620
    614621  /* Enable interrupts if necessary */
    615   if(!termios_tx_active_com2 && uart_data[BSP_UART_COM2].hwFlow)
    616     {
    617       termios_tx_active_com2 = 1;
    618       uwrite(BSP_UART_COM2, IER,
    619              (RECEIVE_ENABLE  |
    620               TRANSMIT_ENABLE |
    621               RECEIVER_LINE_ST_ENABLE |
    622               MODEM_ENABLE
    623              )
    624             );
    625     }
    626   else if(!termios_tx_active_com2)
    627     {
    628       termios_tx_active_com2 = 1;
    629       uwrite(BSP_UART_COM2, IER,
    630              (RECEIVE_ENABLE  |
    631               TRANSMIT_ENABLE |
    632               RECEIVER_LINE_ST_ENABLE
    633              )
    634             );
    635     }
     622  if ( !termios_tx_active_com2 ) {
     623    termios_tx_active_com2 = 1;
     624    uart_data[BSP_UART_COM2].ier |= TRANSMIT_ENABLE;
     625    uwrite(BSP_UART_COM2, IER, uart_data[BSP_UART_COM2].ier);
     626  }
    636627
    637628  return 0;
     
    698689           */
    699690
     691          /* If nothing else to send disable interrupts */
    700692          ret = rtems_termios_dequeue_characters(termios_ttyp_com1, 1);
    701 
    702           /* If nothing else to send disable interrupts */
    703           if(ret == 0 && uart_data[BSP_UART_COM1].hwFlow)
    704             {
    705               uwrite(BSP_UART_COM1, IER,
    706                      (RECEIVE_ENABLE  |
    707                       RECEIVER_LINE_ST_ENABLE |
    708                       MODEM_ENABLE
    709                      )
    710                     );
    711               termios_tx_active_com1 = 0;
    712             }
    713           else if(ret == 0)
    714             {
    715               uwrite(BSP_UART_COM1, IER,
    716                      (RECEIVE_ENABLE  |
    717                       RECEIVER_LINE_ST_ENABLE
    718                      )
    719                     );
    720               termios_tx_active_com1 = 0;
    721             }
     693          if ( ret == 0 ) {
     694            termios_tx_active_com1 = 0;
     695            uart_data[BSP_UART_COM1].ier &= ~(TRANSMIT_ENABLE);
     696            uwrite(BSP_UART_COM1, IER, uart_data[BSP_UART_COM1].ier);
     697          }
    722698          break;
    723699        case RECEIVER_DATA_AVAIL :
    724700        case CHARACTER_TIMEOUT_INDICATION:
    725           /* RX data ready */
    726           assert(off < sizeof(buf));
    727           buf[off++] = uread(BSP_UART_COM1, RBR);
     701          if ( uart_data[BSP_UART_COM1].ioMode == TERMIOS_TASK_DRIVEN ) {
     702            /* ensure interrupts are enabled */
     703            if ( uart_data[BSP_UART_COM1].ier & RECEIVE_ENABLE ) {
     704              /* disable interrupts and notify termios */
     705              uart_data[BSP_UART_COM1].ier &= ~(RECEIVE_ENABLE | RECEIVER_LINE_ST_ENABLE);
     706              uwrite(BSP_UART_COM1, IER, uart_data[BSP_UART_COM1].ier);
     707              rtems_termios_rxirq_occured(termios_ttyp_com1);
     708            }
     709          }
     710          else {
     711            /* RX data ready */
     712            assert(off < sizeof(buf));
     713            buf[off++] = uread(BSP_UART_COM1, RBR);
     714          }
    728715          break;
    729716        case RECEIVER_ERROR:
     
    797784           */
    798785
     786          /* If nothing else to send disable interrupts */
    799787          ret = rtems_termios_dequeue_characters(termios_ttyp_com2, 1);
    800 
    801           /* If nothing else to send disable interrupts */
    802           if(ret == 0 && uart_data[BSP_UART_COM2].hwFlow)
    803             {
    804               uwrite(BSP_UART_COM2, IER,
    805                      (RECEIVE_ENABLE  |
    806                       RECEIVER_LINE_ST_ENABLE |
    807                       MODEM_ENABLE
    808                      )
    809                     );
    810               termios_tx_active_com2 = 0;
    811             }
    812           else if(ret == 0)
    813             {
    814               uwrite(BSP_UART_COM2, IER,
    815                      (RECEIVE_ENABLE  |
    816                       RECEIVER_LINE_ST_ENABLE
    817                      )
    818                     );
    819               termios_tx_active_com2 = 0;
    820             }
     788          if ( ret == 0 ) {
     789            termios_tx_active_com2 = 0;
     790            uart_data[BSP_UART_COM2].ier &= ~(TRANSMIT_ENABLE);
     791            uwrite(BSP_UART_COM2, IER, uart_data[BSP_UART_COM2].ier);
     792          }
    821793          break;
    822794        case RECEIVER_DATA_AVAIL :
    823795        case CHARACTER_TIMEOUT_INDICATION:
    824           /* RX data ready */
    825           assert(off < sizeof(buf));
    826           buf[off++] = uread(BSP_UART_COM2, RBR);
     796          if ( uart_data[BSP_UART_COM2].ioMode == TERMIOS_TASK_DRIVEN ) {
     797            /* ensure interrupts are enabled */
     798            if ( uart_data[BSP_UART_COM2].ier & RECEIVE_ENABLE ) {
     799              /* disable interrupts and notify termios */
     800              uart_data[BSP_UART_COM2].ier &= ~(RECEIVE_ENABLE | RECEIVER_LINE_ST_ENABLE);
     801              uwrite(BSP_UART_COM2, IER, uart_data[BSP_UART_COM2].ier);
     802              rtems_termios_rxirq_occured(termios_ttyp_com2);
     803            }
     804          }
     805          else {
     806            /* RX data ready */
     807            assert(off < sizeof(buf));
     808            buf[off++] = uread(BSP_UART_COM2, RBR);
     809          }
    827810          break;
    828811        case RECEIVER_ERROR:
  • c/src/lib/libbsp/i386/shared/comm/uart.h

    r6c5e3215 rcaeb33b2  
    2121int  BSP_uart_polled_read(int uart);
    2222void BSP_uart_termios_set(int uart, void *ttyp);
     23int  BSP_uart_termios_read_com1(int uart);
     24int  BSP_uart_termios_read_com2(int uart);
    2325int  BSP_uart_termios_write_com1(int minor, const char *buf, int len);
    2426int  BSP_uart_termios_write_com2(int minor, const char *buf, int len);
Note: See TracChangeset for help on using the changeset viewer.