Ignore:
Timestamp:
Aug 11, 2000, 7:26:31 PM (20 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
57b1f53
Parents:
b96ca51
Message:

2000-08-11 Charles-Antoine Gauthier <charles.gauthier@…>

  • README: Updated
  • console/console.c: Fix polled input. Add support for shared printk. Add support for more flexible polled I/O with and without termios. I/O mode and console is selectable either from NVRAM or from mvme167.cfg. Clean up comments.

2000-08-11 Charles-Antoine Gauthier <charles.gauthier@…>

  • startup/page_table.c (page_table_init): Reorganize NVRAM parameters.
  • include/bsp.h: Reorganize NVRAM parameters. Add support for shared printk.
  • times: These are the times for the MVME167, not the MBX860-002.

2000-08-11 John Cotton <john.cotton@…>

  • network/network.c: Fix NVRAM configuration parameter handling from previous revision. Check J1-4, restructure NVRAM parameter handling.

2000-08-11 Charles-Antoine Gauthier <charles.gauthier@…>

  • network/network.c: Cleanup of network driver to reduce warnings. Addition of second parameter to uti596_attach.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/m68k/mvme167/console/console.c

    rb96ca51 red09fd77  
    134134#include <rtems/libio.h>
    135135
     136/* Utility functions */
     137void cd2401_udelay( unsigned long delay );
     138void cd2401_chan_cmd( rtems_unsigned8 channel, rtems_unsigned8 cmd, rtems_unsigned8 wait );
     139rtems_unsigned16 cd2401_bitrate_divisor( rtems_unsigned32 clkrate, rtems_unsigned32* bitrate );
     140void cd2401_initialize( void );
     141void cd2401_interrupts_initialize( rtems_boolean enable );
     142
     143/* ISRs */
     144rtems_isr cd2401_modem_isr( rtems_vector_number vector );
     145rtems_isr cd2401_re_isr( rtems_vector_number vector );
     146rtems_isr cd2401_rx_isr( rtems_vector_number vector );
     147rtems_isr cd2401_tx_isr( rtems_vector_number vector );
     148
     149/* Termios callbacks */
     150int cd2401_firstOpen( int major, int minor, void *arg );
     151int cd2401_lastClose( int major, int minor, void *arg );
     152int cd2401_setAttributes( int minor, const struct termios *t );
     153int cd2401_startRemoteTx( int minor );
     154int cd2401_stopRemoteTx( int minor );
     155int cd2401_write( int minor, const char *buf, int len );
     156int cd2401_drainOutput( int minor );
     157int _167Bug_pollRead( int minor );
     158int _167Bug_pollWrite( int minor, const char *buf, int len );
     159
     160
     161/* Printk function */
     162static void _BSP_output_char( char c );
     163BSP_output_char_function_type BSP_output_char = _BSP_output_char;
     164
    136165
    137166/* Channel info */
     
    146175  rtems_unsigned8  own_buf_A;   /* If true, buffer A belongs to the driver */
    147176  rtems_unsigned8  own_buf_B;   /* If true, buffer B belongs to the driver */
    148   rtems_unsigned8  txEmpty;     /* If true, the output FIFO is supposed to be empty */
     177  rtems_unsigned8  txEmpty;     /* If true, the output FIFO should be empty */
    149178} CD2401_Channel_Info[4];
    150179
     
    171200/* #define CD2401_RECORD_DEBUG_INFO */
    172201#include "console-recording.c"
    173 
    174 
    175 /* Utility functions */
    176 void cd2401_udelay( unsigned long delay );
    177 void cd2401_chan_cmd( rtems_unsigned8 channel, rtems_unsigned8 cmd, rtems_unsigned8 wait );
    178 rtems_unsigned16 cd2401_bitrate_divisor( rtems_unsigned32 clkrate, rtems_unsigned32* bitrate );
    179 void cd2401_initialize( void );
    180 void cd2401_interrupts_initialize( rtems_boolean enable );
    181 
    182 /* ISRs */
    183 rtems_isr cd2401_modem_isr( rtems_vector_number vector );
    184 rtems_isr cd2401_re_isr( rtems_vector_number vector );
    185 rtems_isr cd2401_rx_isr( rtems_vector_number vector );
    186 rtems_isr cd2401_tx_isr( rtems_vector_number vector );
    187 
    188 /* Termios callbacks */
    189 int cd2401_firstOpen( int major, int minor, void *arg );
    190 int cd2401_lastClose( int major, int minor, void *arg );
    191 int cd2401_setAttributes( int minor, const struct termios *t );
    192 int cd2401_startRemoteTx( int minor );
    193 int cd2401_stopRemoteTx( int minor );
    194 int cd2401_write( int minor, const char *buf, int len );
    195 int cd2401_drainOutput( int minor );
    196 int _167Bug_pollRead( int minor );
    197 int _167Bug_pollWrite( int minor, const char *buf, int len );
    198202
    199203
     
    260264    cd2401->car = channel;      /* Select channel */
    261265
    262     while ( cd2401->ccr != 0 ); /* Wait for completion of any previous command */
     266    while ( cd2401->ccr != 0 ); /* Wait for completion of previous command */
    263267    cd2401->ccr = cmd;          /* Send command */
    264268    if ( wait )
     
    299303  divisor = (clkrate + (divisor>>1)) / divisor; /* divisor for clk0 (CLK/8) */
    300304
    301   /*  Use highest speed clock source for best precision - try from clk0 to clk4: */
     305  /* Use highest speed clock source for best precision - try clk0 to clk4 */
    302306  for( clksource = 0; clksource < 0x0400 && divisor > 0x100; clksource += 0x0100 )
    303307      divisor >>= 2;
     
    359363   *  by the hardware, as suggested by the manual.
    360364   *
    361    *  The updated manual (part no 542400-007) has the story strait. The CD2401
    362    *  automatically initializes the LICR to contain the channel number in bits
    363    *  2 and 3. However, these bits are not preserved when the user defined bits
    364    *  are written.
     365   *  The updated manual (part no 542400-007) has the story straight. The
     366   *  CD2401 automatically initializes the LICR to contain the channel number
     367   *  in bits 2 and 3. However, these bits are not preserved when the user
     368   *  defined bits are written.
    365369   *
    366370   *  The same vector number is used for all four channels. Different vector
     
    604608    /*
    605609     *  Bus error occurred during DMA transfer. For now, just record.
    606      *  Get reason for DMA bus error and clear the report for the next occurrence
     610     *  Get reason for DMA bus error and clear the report for the next
     611     *  occurrence
    607612     */
    608613    buserr = pccchip2->SCC_error;
     
    10181023    cd2401_chan_cmd (minor, 0x40, 1);
    10191024
    1020     cd2401->car = minor;        /* Select channel */
    1021     cd2401->cmr = 0x42;         /* Interrupt Rx, DMA Tx, async mode */
     1025    cd2401->car = minor;    /* Select channel */
     1026    cd2401->cmr = 0x42;     /* Interrupt Rx, DMA Tx, async mode */
    10221027    cd2401->cor1 = parodd | parenb | ignpar | csize;
    10231028    cd2401->cor2 = sw_flow_ctl | hw_flow_ctl;
    10241029    cd2401->cor3 = extra_flow_ctl | cstopb;
    1025     cd2401->cor4 = 0x0A;        /* No DSR/DCD/CTS detect; FIFO threshold of 10 */
    1026     cd2401->cor5 = 0x0A;        /* No DSR/DCD/CTS detect; DTR threshold of 10 */
     1030    cd2401->cor4 = 0x0A;    /* No DSR/DCD/CTS detect; FIFO threshold of 10 */
     1031    cd2401->cor5 = 0x0A;    /* No DSR/DCD/CTS detect; DTR threshold of 10 */
    10271032    cd2401->cor6 = igncr | icrnl | inlcr | ignbrk | brkint | parmrk | inpck;
    1028     cd2401->cor7 = istrip;      /* No LNext; ignore XON/XOFF if frame error; no tx translations */
     1033    cd2401->cor7 = istrip;  /* No LNext; ignore XON/XOFF if frame error; no tx translations */
    10291034    /* Special char 1: XON character */
    10301035    cd2401->u1.async.schr1 = t->c_cc[VSTART];
     
    10411046    cd2401->rcor = (unsigned char)(rx_period >> 8); /* no DPLL */
    10421047    cd2401->tbpr = (unsigned char)tx_period;
    1043     cd2401->tcor = (tx_period >> 3) & 0xE0;         /* no x1 ext clk, no loopback */
     1048    cd2401->tcor = (tx_period >> 3) & 0xE0; /* no x1 ext clk, no loopback */
    10441049 
    10451050    /* Timeout for 4 chars at 9600, 8 bits per char, 1 stop bit */
     
    12391244 *  MUST NOT BE EXECUTED WITH THE CD2401 INTERRUPTS DISABLED!
    12401245 *  The txEmpty flag is set by the tx ISR.
     1246 *
     1247 *  DOES NOT WORK! DO NOT ENABLE THIS CODE. THE CD2401 DOES NOT COOPERATE!
     1248 *  The code is here to document that the output FIFO is NOT empty when
     1249 *  the CD2401 reports that the Tx buffer is empty.
    12411250 */
    12421251int cd2401_drainOutput(
     
    12731282 *
    12741283 *  CANNOT BE COMBINED WITH INTERRUPT DRIVEN I/O!
    1275  *  This function is invoked when the device driver is compiled with
    1276  *  CD2401_POLLED_IO set to 1 above. All I/O is then done through 167Bug.
    12771284 */
    12781285int _167Bug_pollRead(
     
    12821289  int char_not_available;
    12831290  unsigned char c;
    1284 
    1285   /* Check for a char in the input FIFO */
    1286   asm volatile( "movew  #0x1, -(%%sp)   /* Code for .INSTAT */
    1287                  movew  %1, -(%%sp)     /* Channel */
     1291  rtems_interrupt_level previous_level;
     1292
     1293  /*
     1294   *  Redirection of .INSTAT does not work: 167-Bug crashes.
     1295   *  Switch the input stream to the specified port.
     1296   *  Make sure this is atomic code.
     1297   */
     1298  rtems_interrupt_disable( previous_level );
     1299 
     1300  asm volatile( "movew  %1, -(%%sp)     /* Channel */
    12881301                 trap   #15             /* Trap to 167Bug */
    1289                  .short 0x60            /* Code for .REDIR */
     1302                 .short 0x61            /* Code for .REDIR_I */
     1303                 trap   #15             /* Trap to 167Bug */
     1304                                   .short 0x01            /* Code for .INSTAT */
    12901305                 move   %%cc, %0        /* Get condition codes */
    12911306                 andil  #4, %0"         /* Keep the Zero bit */
    12921307    : "=d" (char_not_available) : "d" (minor): "%%cc" );
    12931308
    1294   if (char_not_available)
     1309  if (char_not_available) {
     1310    rtems_interrupt_enable( previous_level );
    12951311    return -1;
     1312  }
    12961313
    12971314  /* Read the char and return it */
    12981315  asm volatile( "subq.l #2,%%a7         /* Space for result */
    1299                  movew  #0x0, -(%%sp)   /* Code for .INCHR */
    1300                  movew  %1, -(%%sp)     /* Channel */
    13011316                 trap   #15             /* Trap to 167 Bug */
    1302                  .short 0x60            /* Code for .REDIR */
     1317                 .short 0x00            /* Code for .INCHR */
    13031318                 moveb  (%%a7)+, %0"    /* Pop char into c */
    1304     : "=d" (c) : "d" (minor) );
    1305 
     1319    : "=d" (c) : );
     1320
     1321  rtems_interrupt_enable( previous_level );
     1322 
    13061323  return (int)c;
    13071324}
     
    13241341 *
    13251342 *  CANNOT BE COMBINED WITH INTERRUPT DRIVEN I/O!
    1326  *  This function is invoked when the device driver is compiled with
    1327  *  CD2401_POLLED_IO set to 1 above. All I/O is then done through 167Bug.
    13281343 */
    13291344int _167Bug_pollWrite(
     
    13491364
    13501365/*
    1351  *  Print functions: prototyped in bsp.h
    1352  *  Debug printing on Channel 1
    1353  */
    1354  
    1355 void printk( char *fmt, ... )
    1356 {
    1357   va_list  ap;                  /* points to each unnamed argument in turn */
    1358   static char buf[256];
    1359   unsigned int level;
     1366 *  do_poll_read
     1367 *
     1368 *  Input characters through 167Bug. Returns has soon as a character has been
     1369 *  received. Otherwise, if we wait for the number of requested characters, we
     1370 *  could be here forever!
     1371 *
     1372 *  CR is converted to LF on input. The terminal should not send a CR/LF pair
     1373 *  when the return or enter key is pressed.
     1374 *
     1375 *  Input parameters:
     1376 *    major - ignored. Should be the major number for this driver.
     1377 *    minor - selected channel.
     1378 *    arg->buffer - where to put the received characters.
     1379 *    arg->count  - number of characters to receive before returning--Ignored.
     1380 *
     1381 *  Output parameters:
     1382 *    arg->bytes_moved - the number of characters read. Always 1.
     1383 *
     1384 *  Return value: RTEMS_SUCCESSFUL
     1385 *
     1386 *  CANNOT BE COMBINED WITH INTERRUPT DRIVEN I/O!
     1387 */
     1388rtems_status_code do_poll_read(
     1389  rtems_device_major_number major,
     1390  rtems_device_minor_number minor,
     1391  void                    * arg
     1392)
     1393{
     1394  rtems_libio_rw_args_t *rw_args = arg;
     1395  int c;
     1396
     1397  while( (c = _167Bug_pollRead (minor)) == -1 );
     1398  rw_args->buffer[0] = (unsigned8)c;
     1399  if( rw_args->buffer[0] == '\r' )
     1400      rw_args->buffer[0] = '\n';
     1401  rw_args->bytes_moved = 1;
     1402  return RTEMS_SUCCESSFUL;
     1403}
     1404
     1405/*
     1406 *  do_poll_write
     1407 *
     1408 *  Output characters through 167Bug. Returns only once every character has
     1409 *  been sent.
     1410 *
     1411 *  CR is transmitted AFTER a LF on output.
     1412 *
     1413 *  Input parameters:
     1414 *    major - ignored. Should be the major number for this driver.
     1415 *    minor - selected channel
     1416 *    arg->buffer - where to get the characters to transmit.
     1417 *    arg->count  - the number of characters to transmit before returning.
     1418 *
     1419 *  Output parameters:
     1420 *    arg->bytes_moved - the number of characters read
     1421 *
     1422 *  Return value: RTEMS_SUCCESSFUL
     1423 *
     1424 *  CANNOT BE COMBINED WITH INTERRUPT DRIVEN I/O!
     1425 */
     1426rtems_status_code do_poll_write(
     1427  rtems_device_major_number major,
     1428  rtems_device_minor_number minor,
     1429  void                    * arg
     1430)
     1431{
     1432  rtems_libio_rw_args_t *rw_args = arg;
     1433  unsigned32 i;
     1434  char cr ='\r';
     1435
     1436  for( i = 0; i < rw_args->count; i++ ) {
     1437    _167Bug_pollWrite(minor, &(rw_args->buffer[i]), 1);
     1438    if ( rw_args->buffer[i] == '\n' )
     1439      _167Bug_pollWrite(minor, &cr, 1);
     1440  }
     1441  rw_args->bytes_moved = i;
     1442  return RTEMS_SUCCESSFUL;
     1443}
     1444
     1445
     1446/*
     1447 *  _BSP_output_char
     1448 *
     1449 *  printk() function prototyped in bspIo.h. Does not use termios.
     1450 */
     1451void _BSP_output_char(char c)
     1452{
     1453  rtems_device_minor_number printk_minor;
    13601454 
    1361   _CPU_ISR_Disable(level);
     1455  /*
     1456   *  Can't rely on console_initialize having been called before this function
     1457   *  is used.
     1458   */
     1459  if ( NVRAM_CONFIGURE )
     1460    /* J1-4 is on, use NVRAM info for configuration */
     1461    printk_minor = nvram->console_printk_port & 0x30;
     1462  else
     1463    printk_minor = PRINTK_MINOR;
     1464   
     1465  _167Bug_pollWrite(printk_minor, &c, 1);
     1466}
     1467
    13621468 
    1363   va_start(ap, fmt);            /* make ap point to 1st unnamed arg */
    1364   vsprintf(buf, fmt, ap);       /* send output to buffer */
    1365  
    1366   BSP_output_string(buf);       /* print buffer -- Channel 1 */
    1367  
    1368   va_end(ap);                           /* clean up and re-enable interrupts */
    1369   _CPU_ISR_Enable(level);
    1370 }
    1371 
    1372 
    1373 void BSP_output_string( char * buf )
    1374 {
    1375   int len = strlen(buf);                       
    1376   rtems_status_code sc;
    1377  
    1378   /* The first argument forces a print to Port2 (ttyS1) */
    1379   sc = _167Bug_pollWrite(1, buf, len);
    1380   if (sc != RTEMS_SUCCESSFUL)
    1381     rtems_fatal_error_occurred (sc);
    1382 }
    1383 
    1384 
    13851469/*
    13861470 ***************
     
    14011485{
    14021486  rtems_status_code status;
     1487  rtems_device_minor_number console_minor;
    14031488
    14041489  /*
    1405    * Set up TERMIOS
     1490   * Set up TERMIOS if needed
    14061491   */
    1407   rtems_termios_initialize ();
     1492  if ( NVRAM_CONFIGURE ) {
     1493    /* J1-4 is on, use NVRAM info for configuration */
     1494    console_minor = nvram->console_printk_port & 0x03;
     1495         
     1496    if ( nvram->console_mode & 0x01 )
     1497      /* termios */
     1498      rtems_termios_initialize ();
     1499  }
     1500  else {
     1501    console_minor = CONSOLE_MINOR;
     1502#if CD2401_USE_TERMIOS == 1
     1503    rtems_termios_initialize ();
     1504#endif
     1505  }
    14081506
    14091507  /*
    14101508   * Do device-specific initialization
     1509   * Does not affect 167-Bug.
    14111510   */
    14121511  cd2401_initialize ();
     
    14231522    rtems_fatal_error_occurred (status);
    14241523
    1425   status = rtems_io_register_name ("/dev/console", major, 1);
     1524  status = rtems_io_register_name ("/dev/console", major, console_minor);
    14261525  if (status != RTEMS_SUCCESSFUL)
    14271526    rtems_fatal_error_occurred (status);
     
    14471546)
    14481547{
    1449 #if CD2401_POLLED_IO
    1450 
    1451   /* I/O is limited to 167Bug console. minor is ignored! */
    1452   static const rtems_termios_callbacks callbacks = {
     1548  static const rtems_termios_callbacks pollCallbacks = {
    14531549    NULL,                       /* firstOpen */
    14541550    NULL,                       /* lastClose */
     
    14601556    0                           /* outputUsesInterrupts */
    14611557  };
    1462 
    1463 #else
    1464 
    1465   static const rtems_termios_callbacks callbacks = {
     1558 
     1559  static const rtems_termios_callbacks intrCallbacks = {
    14661560    cd2401_firstOpen,           /* firstOpen */
    14671561    cd2401_lastClose,           /* lastClose */
     
    14741568  };
    14751569
     1570  if ( NVRAM_CONFIGURE )
     1571    /* J1-4 is on, use NVRAM info for configuration */
     1572    if ( nvram->console_mode & 0x01 )
     1573      /* termios */
     1574      if ( nvram->console_mode & 0x02 )
     1575        /* interrupt-driven I/O */
     1576        return rtems_termios_open (major, minor, arg, &intrCallbacks);
     1577            else
     1578        /* polled I/O */
     1579        return rtems_termios_open (major, minor, arg, &pollCallbacks);
     1580          else
     1581            /* no termios -- default to polled I/O */
     1582            return RTEMS_SUCCESSFUL;
     1583#if CD2401_USE_TERMIOS == 1
     1584#if CD2401_IO_MODE != 1
     1585  else
     1586    /* termios & polled I/O*/
     1587    return rtems_termios_open (major, minor, arg, &pollCallbacks);
     1588#else
     1589  else
     1590    /* termios & interrupt-driven I/O*/
     1591    return rtems_termios_open (major, minor, arg, &intrCallbacks);
    14761592#endif
    1477 
    1478   return rtems_termios_open (major, minor, arg, &callbacks);
    1479 }
     1593#else
     1594  else
     1595    /* no termios -- default to polled I/O */
     1596    return RTEMS_SUCCESSFUL;
     1597#endif
     1598}
     1599
    14801600
    14811601/*
     
    14881608)
    14891609{
    1490   return rtems_termios_close (arg);
    1491 }
     1610  if ( NVRAM_CONFIGURE ) {
     1611    /* J1-4 is on, use NVRAM info for configuration */
     1612    if ( nvram->console_mode & 0x01 )
     1613      /* termios */
     1614      return rtems_termios_close (arg);
     1615    else
     1616      /* no termios */
     1617      return RTEMS_SUCCESSFUL;
     1618  }
     1619#if CD2401_USE_TERMIOS == 1
     1620  else
     1621    /* termios */
     1622    return rtems_termios_close (arg);
     1623#else
     1624  else
     1625    /* no termios */
     1626    return RTEMS_SUCCESSFUL;
     1627#endif
     1628}
     1629
    14921630
    14931631/*
     
    15001638)
    15011639{
    1502   return rtems_termios_read (arg);
    1503 }
     1640  if ( NVRAM_CONFIGURE ) {
     1641    /* J1-4 is on, use NVRAM info for configuration */
     1642    if ( nvram->console_mode & 0x01 )
     1643      /* termios */
     1644      return rtems_termios_read (arg);
     1645    else
     1646      /* no termios -- default to polled */
     1647      return do_poll_read (major, minor, arg);
     1648  }
     1649#if CD2401_USE_TERMIOS == 1
     1650  else
     1651    /* termios */
     1652    return rtems_termios_read (arg);
     1653#else
     1654  else
     1655    /* no termios -- default to polled */
     1656    return do_poll_read (major, minor, arg);
     1657#endif
     1658}
     1659
    15041660
    15051661/*
     
    15121668)
    15131669{
    1514   return rtems_termios_write (arg);
    1515 }
     1670  if ( NVRAM_CONFIGURE ) {
     1671    /* J1-4 is on, use NVRAM info for configuration */
     1672    if ( nvram->console_mode & 0x01 )
     1673      /* termios */
     1674      return rtems_termios_write (arg);
     1675    else
     1676      /* no termios -- default to polled */
     1677      return do_poll_write (major, minor, arg);
     1678  }
     1679#if CD2401_USE_TERMIOS == 1
     1680  else
     1681    /* termios */
     1682    return rtems_termios_write (arg);
     1683#else
     1684  else
     1685    /* no termios -- default to polled */
     1686    return do_poll_write (major, minor, arg);
     1687#endif
     1688}
     1689
    15161690
    15171691/*
     
    15241698)
    15251699{
    1526   return rtems_termios_ioctl (arg);
    1527 }
     1700  if ( NVRAM_CONFIGURE ) {
     1701    /* J1-4 is on, use NVRAM info for configuration */
     1702    if ( nvram->console_mode & 0x01 )
     1703      /* termios */
     1704      return rtems_termios_ioctl (arg);
     1705    else
     1706      /* no termios -- default to polled */
     1707      return RTEMS_SUCCESSFUL;
     1708  }
     1709#if CD2401_USE_TERMIOS == 1
     1710  else
     1711    /* termios */
     1712    return rtems_termios_ioctl (arg);
     1713#else
     1714  else
     1715    /* no termios -- default to polled */
     1716    return RTEMS_SUCCESSFUL;
     1717#endif
     1718}
Note: See TracChangeset for help on using the changeset viewer.