Changeset aefbb57 in rtems


Ignore:
Timestamp:
May 22, 2008, 8:12:08 PM (12 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.9, master
Children:
b6be4217
Parents:
0f91b23
Message:

2008-05-22 Joel Sherrill <joel.sherrill@…>

  • console/console.c: Properly inform termios of our initial baud rate. If it is not the default, this causes problems when an application changes any termios attributes since termios thinks our baud rate is one thing when in fact, it is another.
Location:
c/src/lib/libbsp/powerpc/gen5200
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/powerpc/gen5200/ChangeLog

    r0f91b23 raefbb57  
     12008-05-22      Joel Sherrill <joel.sherrill@oarcorp.com>
     2
     3        * console/console.c: Properly inform termios of our initial baud rate.
     4        If it is not the default, this causes problems when an application
     5        changes any termios attributes since termios thinks our baud rate is
     6        one thing when in fact, it is another.
     7
    182008-05-15      Joel Sherrill <joel.sherrill@OARcorp.com>
    29
  • c/src/lib/libbsp/powerpc/gen5200/console/console.c

    r0f91b23 raefbb57  
    5959/*   eric@skatter.usask.ca                                             */
    6060/*                                                                     */
    61 /*   COPYRIGHT (c) 1989-1998.                                          */
     61/*   COPYRIGHT (c) 1989-2008.                                          */
    6262/*   On-Line Applications Research Corporation (OAR).                  */
    6363/*                                                                     */
     
    104104#include <rtems/libio.h>
    105105#include <string.h>
     106#include <rtems/termiostypes.h>
    106107
    107108
     
    186187  switch(t->c_cflag & CBAUD)
    187188    {
    188         default:      baud = -1;      break;
     189    default:      baud = -1;      break;
    189190    case B50:     baud = 50;      break;
    190191    case B75:     baud = 75;      break;
     
    212213
    213214   /*
    214         * Calculate baud rate
    215         * round divider to nearest!
     215    * Calculate baud rate
     216    * round divider to nearest!
    216217    */
    217218    baud = (IPB_CLOCK + baud *16) / (baud * 32);
     
    241242    {
    242243
    243         if(t->c_cflag & CSTOPB)
    244           cstopb = 0x0F;           /* Two stop bits */
    245         else
     244    if(t->c_cflag & CSTOPB)
     245      cstopb = 0x0F;           /* Two stop bits */
     246    else
    246247      cstopb = 0x07;           /* One stop bit */
    247248
     
    339340
    340341     /*
    341           * get the character
     342      * get the character
    342343      */
    343344      c = (psc->rb_tb >> 24);
    344345
    345346      if (ttyp[minor] != NULL) {
    346         nb_overflow = rtems_termios_enqueue_raw_characters((void *)ttyp[minor], (char *)&c, (int)1);
    347         channel_info[minor].rx_characters++;
     347        nb_overflow = rtems_termios_enqueue_raw_characters(
     348           (void *)ttyp[minor], (char *)&c, (int)1);
     349        channel_info[minor].rx_characters++;
    348350      }
    349351
     
    363365
    364366    /*
    365         * mask interrupt
    366         */
    367         psc->isr_imr = channel_info[minor].shadow_imr &= ~(IMR_TX_RDY);
    368 
    369         if (ttyp[minor] != NULL) {
     367    * mask interrupt
     368    */
     369    psc->isr_imr = channel_info[minor].shadow_imr &= ~(IMR_TX_RDY);
     370
     371    if (ttyp[minor] != NULL) {
    370372#ifndef SINGLE_CHAR_MODE
    371373           rtems_termios_dequeue_characters((void *)ttyp[minor], channel_info[minor].cur_tx_len);
     
    377379           channel_info[minor].tx_characters++;
    378380#endif
    379         }
     381      }
    380382    }
    381383
     
    384386
    385387    if(isr & ISR_RB)
    386           channel_info[minor].breaks_detected++;
    387 
    388         if(isr & ISR_FE)
    389           channel_info[minor].framing_errors++;
    390 
    391         if(isr & ISR_PE)
    392           channel_info[minor].parity_errors++;
    393 
    394         if(isr & ISR_OE)
    395           channel_info[minor].overrun_errors++;
    396 
    397         /*
    398         *  Reset error status
    399         */
     388      channel_info[minor].breaks_detected++;
     389
     390    if(isr & ISR_FE)
     391      channel_info[minor].framing_errors++;
     392
     393    if(isr & ISR_PE)
     394      channel_info[minor].parity_errors++;
     395
     396    if(isr & ISR_OE)
     397      channel_info[minor].overrun_errors++;
     398
     399    /*
     400     *  Reset error status
     401     */
    400402    psc->cr = ((4 << 4) << 8);
    401403
     
    498500  psc->tfalarm = 1;
    499501
    500   baud_divider = (IPB_CLOCK + GEN5200_CONSOLE_BAUD *16) / (GEN5200_CONSOLE_BAUD * 32);
     502  baud_divider =
     503    (IPB_CLOCK + GEN5200_CONSOLE_BAUD *16) / (GEN5200_CONSOLE_BAUD * 32);
    501504
    502505  /*
     
    599602
    600603    while(!(psc->sr_csr & (1 << 11)))
    601           continue;
    602 
    603         /*rtems_cache_flush_multiple_data_lines( (void *)buf, 1);*/
    604 
    605         psc->rb_tb = (*tmp_buf << 24);
    606 
    607         tmp_buf++;
     604      continue;
     605
     606    /*rtems_cache_flush_multiple_data_lines( (void *)buf, 1);*/
     607
     608    psc->rb_tb = (*tmp_buf << 24);
     609
     610    tmp_buf++;
    608611
    609612    }
     
    684687 * Initialize and register the device
    685688 */
    686 rtems_device_driver console_initialize(rtems_device_major_number major, rtems_device_minor_number minor, void *arg)
     689rtems_device_driver console_initialize(
     690  rtems_device_major_number major,
     691  rtems_device_minor_number minor,
     692  void *arg
     693)
    687694  {
    688695
     
    714721      if(status != RTEMS_SUCCESSFUL)
    715722        {
    716             rtems_fatal_error_occurred(status);
     723        rtems_fatal_error_occurred(status);
    717724        }
    718725
    719           tty_num++;
     726      tty_num++;
    720727    }
    721728  }
     
    736743 * Open the device
    737744 */
    738 rtems_device_driver console_open(rtems_device_major_number major, rtems_device_minor_number minor, void *arg)
    739   {
    740 #ifdef UARTS_USE_TERMIOS_INT
     745rtems_device_driver console_open(
     746  rtems_device_major_number  major,
     747  rtems_device_minor_number  minor,
     748  void                      *arg
     749)
     750{
    741751  rtems_libio_open_close_args_t *args = arg;
    742 #endif
    743752  rtems_status_code sc;
    744753
     
    746755  static const rtems_termios_callbacks intrCallbacks =
    747756    {
    748     NULL,                               /* firstOpen */
    749     NULL,                               /* lastClose */
     757    NULL,                           /* firstOpen */
     758    NULL,                           /* lastClose */
    750759    NULL,                           /* pollRead */
    751     mpc5200_uart_write,             /* write */
     760    mpc5200_uart_write,             /* write */
    752761    mpc5200_uart_setAttributes,     /* setAttributes */
    753762    NULL,
    754763    NULL,
    755     1                                   /* outputUsesInterrupts */
     764    1                               /* outputUsesInterrupts */
    756765    };
    757766#else
    758767  static const rtems_termios_callbacks pollCallbacks =
    759768    {
    760     NULL,                               /* firstOpen */
    761     NULL,                               /* lastClose */
    762     mpc5200_uart_pollRead,              /* pollRead */
     769    NULL,                           /* firstOpen */
     770    NULL,                           /* lastClose */
     771    mpc5200_uart_pollRead,          /* pollRead */
    763772    mpc5200_uart_pollWrite,         /* write */
    764773    mpc5200_uart_setAttributes,     /* setAttributes */
    765774    NULL,
    766775    NULL,
    767     0                                   /* output don't use Interrupts */
     776    0                               /* output don't use Interrupts */
    768777    };
    769778#endif
     
    774783#ifdef UARTS_USE_TERMIOS_INT
    775784  sc = rtems_termios_open( major, minor, arg, &intrCallbacks );
    776   ttyp[minor] = args->iop->data1;   /* Keep cookie returned by termios_open */
    777785#else                               /* RTEMS polled I/O with termios */
    778786  sc = rtems_termios_open( major, minor, arg, &pollCallbacks );
    779787#endif
    780788
     789  ttyp[minor] = args->iop->data1;   /* Keep cookie returned by termios_open */
     790
     791  if ( !sc )
     792    rtems_termios_set_initial_baud( ttyp[minor], GEN5200_CONSOLE_BAUD );
     793
    781794  return sc;
    782795
    783   }
     796}
    784797
    785798
Note: See TracChangeset for help on using the changeset viewer.