Changeset 00ff4cd in rtems


Ignore:
Timestamp:
08/25/00 17:24:49 (24 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
f018b1a
Parents:
060d538
Message:

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

  • README:
  • console/console.c:
  • include/bsp.h:
  • network/network.c:
  • startup/bspstart.c: Add support for configuration parameters in NVRAM
Location:
c/src/lib/libbsp/powerpc/mbx8xx
Files:
6 edited

Legend:

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

    r060d538 r00ff4cd  
     12000-08-11  Charles-Antoine Gauthier  <charles.gauthier@nrc.ca>
     2
     3        * README:
     4        * console/console.c:
     5        * include/bsp.h:
     6        * network/network.c:
     7        * startup/bspstart.c:
     8        Add support for configuration parameters in NVRAM
     9
    1102000-08-11  Charles-Antoine Gauthier  <charles.gauthier@nrc.ca>
    211
  • c/src/lib/libbsp/powerpc/mbx8xx/README

    r060d538 r00ff4cd  
     1#
     2#  $Id$
     3#
     4
    15This is a README file for the MBX860/MBX821 port of RTEMS 4.5.0
    26
    37Please send any comments, improvements, or bug reports to:
    48
    5 Darlene A. Stewart
     9Charles-Antoine Gauthier
     10charles.gauthier@nrc.ca
     11
     12or
     13
     14Darlene Stewart
     15Darlene.Stewart@nrc.ca
     16 
    617Software Engineering Group
    718Institute for Information Technology
    819National Research Council of Canada
    920Ottawa, ON, K1A 0R6
    10 Canada
    11 
    12 Darlene.Stewart@nrc.ca
    13  
     21Canada 
    1422
    1523
     
    125133Board description
    126134-----------------
    127 Clock rate:     50MHz Entry level boards, 40 MHz others.
    128 Bus width:      8/32 bit Flash, 32 bit DRAM
    129 FLASH:            2-4MB, 120ns
    130 RAM:                4-16MB EDO, 60ns DRAM DIMM
     135Clock rate:     50MHz Entry level boards, 40 MHz others.
     136Bus width:      8/32 bit Flash, 32 bit DRAM
     137FLASH:          2-4MB, 120ns
     138RAM:            4-16MB EDO, 60ns DRAM DIMM
    131139
    132140
     
    166174---------------
    167175
    168 This BSP includes an termios-capable asynchronous serial line driver
    169 that supports SMC1, SMC2, SCC2, and SCC3 and SCC4 if present. The RTEMS
    170 console is selected in rtems/make/custom/mbx8xx.cfg with the
    171 CONSOLE_MINOR variable. We normally run with the RTEMS application
    172 console on SMC2. SMC1 is used by the debugger.
     176This BSP includes an termios-capable asynchronous serial line driver that
     177supports SMC1, SMC2, SCC2, and SCC3 and SCC4 if present. The RTEMS console is
     178selected in rtems/make/custom/mbx8xx.cfg with the CONSOLE_MINOR variable, or
     179in NVRAM if that option is enabled in the rtems/make/custom/mbx8xx.cfg file.
     180We normally run with the RTEMS application console on SMC2. SMC1 is used by
     181the debugger.
    173182
    174183Support is provided for five different modes of operation:
     
    181190     support.
    182191     
    183 The mode of operation of the serial driver is determined at build time
    184 by the value of the UARTS_IO_MODE constant in rtems/make/custom/mbx8xx.cfg.
    185 Edit the file to select the type of I/O desired before building RTEMS.
    186 The choices are:
     192If NVRAM_CONFIGURE is set to 1 in rtems/make/custom/mbx8xx.cfg, the mode of
     193operation of the driver is determined at boot time from the values stored
     194in the user area in NVRAM. See the Configuration Parameters section below for
     195instructions on setting up NVRAM. Otherwise, the mode of operation of the
     196serial driver is determined at build time in part by the value of the
     197UARTS_IO_MODE constant in rtems/make/custom/mbx8xx.cfg. Edit the file to select
     198the type of I/O desired before building RTEMS. The choices are:
    187199
    188200  0 - polled I/O done by the supplied device driver,
     
    190202  2 - polled I/O done by EPPC-Bug.
    191203 
    192 Also set the value of UARTS_USE_TERMIOS to select whether termios should
    193 be used to perform buffering and input/output processing. Without termios
    194 support, input processing is limited to the substitution of LF for a
    195 received CR, and output processing is limited to the transmission of a
    196 CR following the transmission of a LF. The choices for UARTS_USE_TERMIOS are:
     204Also, if NVRAM_CONFIGURE is not set to 1 in rtems/make/custom/mbx8xx.cfg, set
     205the value of UARTS_USE_TERMIOS to select whether termios should be used to
     206perform buffering and input/output processing. Without termios support, input
     207processing is limited to the substitution of LF for a received CR, and output
     208processing is limited to the transmission of a CR following the transmission of
     209a LF. The choices for UARTS_USE_TERMIOS are:
    197210
    198211  0 - do not use termios
     
    227240port at build time in rtems/make/custom/mbx8xx.cfg by setting the value
    228241of PRINTK_MINOR to one of SMC1_MINOR, SMC2_MINOR, SCC2_MINOR, SCC3_MINOR,
    229 or SCC4_MINOR.
     242or SCC4_MINOR. Alternatively, if NVRAM_CONFIGURE is set to 1 in
     243rtems/make/custom/mbx8xx.cfg, the printk port is selected based on data that
     244is stored in the user area in NVRAM. See the Configuration Parameters section
     245below for instructions on setting up NVRAM.
    230246
    231247Select the type of output desired for printk() by setting the value of
     
    233249
    234250  0 - polled I/O done by the supplied device driver,
    235   1 - interrupt-driven I/O done by the supplied device driver,
     251  1 - polled I/O done by the supplied device driver,
    236252  2 - polled I/O done by EPPC-Bug.
    237253 
     
    240256If the printk() port is opened by RTEMS, then PRINK_IO_MODE mode must have
    241257the same value as UARTS_IO_MODE, otherwise the I/O functions will be in
    242 conflict. Interrupt-driven printk() output is only possible if the port is
    243 opened before hand by an RTEMS application, and is of dubious value...
     258conflict. Interrupt-driven printk() output did not work, although we think
     259that it should have. It would have been of dubious value anyways. If
     260interrupt-driven I/O is selected (value of 1), the driver defaults to using
     261polled I/O through the RTEMS driver.
     262
     263IMPORTANT: Polled I/O through the RTEMS driver requires that the driver be
     264initialized. Consequently, to debug startup code using printk prior to the
     265initialization of the serial driver, use mode 2: polled I/O through EPPC-Bug,
     266and read the next section.
    244267
    245268
     
    306329
    307330IMPORTANT: When using EPPC-Bug on SMC1, either for debugging or for polled I/O,
    308 EPPCBUG_SMC1 must be defined in rtems/make/custom/mbx8xx.cfg. Defining this
    309 constant prevents the device driver from re-initializing SMC1. It also causes
    310 the network driver, the clock driver, and the asynchronous serial line driver
    311 to maintain simask_copy for use by gdb.
     331EPPCBUG_SMC1 must be defined in rtems/make/custom/mbx8xx.cfg, or the eppc_bug
     332field set to non-zero in NVRAM. Defining this constant prevents the device
     333driver from re-initializing SMC1. It also causes the network driver, the clock
     334driver, and the asynchronous serial line driver to maintain simask_copy for use
     335by gdb.
     336
     337Polled I/O through EPPC-Bug is pretty funky... If your are old enough, it might
     338bring back fond memories of the days of 300 baud modems. If not, you can
     339experience for yourself what the state of the art used to be.
    312340
    313341
     
    318346get compiled with the appropriate -mcpu flag. The nof variants of the gcc
    319347runtime libraries should be used for linking.
     348
     349
     350Configuration Parameters
     351------------------------
     352
     353If NVRAM_CONFIGURE is set in rtems/make/custom/mbx8xx.cfg, certain
     354configuration parameters will be read from the first 31 bytes of the  NVRAM
     355User Area, which starts at 0xFA001000. The user is responsible for writing
     356the appropriate values in NVRAM (via EPPC-Bug). The paramaters
     357that are configurable and their default settings are described below.
     358               
     359  Cache Mode (0xFA001000 - 1 byte)
     360    Set the following bits in the byte to control the caches:
     361      bit 0
     362        0 - data cache disable
     363        1 - data cache enable
     364      bit 1
     365        0 - instruction cache disable
     366        1 - instruction cache enable
     367    If enabled, all of RAM except for the last 512 KB will be cached using
     368    copyback mode. The last 512 KB of RAMis for the use of EPPC-Bug.
     369   
     370  Console driver I/O mode (0xFA001001 - 1 byte)
     371    Set the following bits in the byte to set the desired I/O mode
     372    for the rtems ports:
     373      bit 0
     374        0 - do not use termios
     375        1 - use termios
     376      bit 2 & 1
     377        00 - polled I/O through RTEMS driver
     378        01 - interrupt-driven I/O
     379        10 - polled I/O through EPPC-Bug
     380    Set the following bits in the byte to set the desired I/O mode
     381    for printk:
     382      bit 5 & 4
     383        00 - polled I/O through RTEMS driver
     384        01 - polled I/O through RTEMS driver
     385        10 - polled I/O through EPPC-Bug
     386
     387  Console driver ports (0xFA001002 - 1 byte)
     388    Set the following bits in the byte to select the console and printk ports:
     389    bit 2, 1  & 0 select the RTEMS console port
     390        000 - /dev/tty0, SMC1
     391        001 - /dev/tty1, SMC2
     392        011 - /dev/tty2, SCC2
     393        100 - /dev/tty3, SCC3
     394        101 - /dev/tty4, SCC4
     395    bit 6, 5 & 4 select the RTEMS printk port
     396        000 - /dev/tty0, SMC1
     397        001 - /dev/tty1, SMC2
     398        011 - /dev/tty2, SCC2
     399        100 - /dev/tty3, SCC3
     400        101 - /dev/tty4, SCC4
     401  If the printk port is the same as some other port that will be opened by an
     402  RTEMS application, then the driver must use polled I/O, or the printk port
     403  must not be used.
     404
     405  EPPC-Bug in use on SMC1 (0xFA001003 - 1 byte)
     406    Set to non-zero to indicate that EPPC-Bug is using SMC1. This will prevent
     407    the SMC1 port from being re-initialized.
     408
     409  IP Address (0xFA001004 - 4 bytes)
     410    Write the hexadecimal representation of the IP address of the board in this
     411    location, e.g. 192.168.1.2 = 0xC0A80102
     412
     413  Netmask (0xFA001008 - 4 bytes)
     414    Write the hexadecimal representation of the netmask in this location
     415    for example, 255.255.255.0 = 0xFFFFFF00
     416
     417  Ethernet Address (0xFA00100C - 6 bytes)
     418    Write the Ethernet address of the board in this location
     419
     420  Processor ID (0xFA001012 - 2 bytes)
     421    Reserved for future use
     422               
     423  RMA start (0xFA001014 - 4 bytes)
     424    Reserved for future use
     425               
     426  VMA start (0xFA001018 - 4 bytes)
     427    Reserved for future use
     428               
     429  RamSize (0xFA00101C - 4 bytes)
     430    Reserved for future use
    320431
    321432
     
    350461objects.
    351462
    352 The cpuuse and malloctest tests do not work properly, either with polled I/O
    353 or interrupt-driven I/O. They are known not to work with interrupt-driven I/O,
    354 but should work with polled I/O?
    355 
    356 Output stops prematurely in the termios test when the console is operating in
    357 interrupt-driven mode because the serial port is re-initialized before all
    358 characters in the last raw output buffer are sent. Adding calls to tcdrain()
    359 in the test task helps, but it does not solve the problem. What happens is
    360 that the CD2401 raises a transmit interrupt when the last character in the
    361 DMA buffer is written into the transmit FIFO, not when the last character
    362 has been transmitted. When tcdrain() returns, there might be up to 16
    363 characters in the output FIFO. The call to tcsetattr() causes the serial port
    364 to re-initialize, at which point the output FIFO is cleared. We could not find
    365 a way to detect whether characters are still in the FIFO and to wait for them
    366 to be transmitted.
    367 
    368 The first raw buffer to be transmitted after the console is re-initialized
    369 with tcsetattr() is garbled. At this time, it does not seem worth while to
    370 track this problem down.
    371 
    372 In the stackchk test, an access fault exception is raised after the stack is
    373 blown. This is one case were overwritting the first or last 16 bytes of the
    374 stack does cause problems (but hey, an exception occurred, which is better
    375 than propagating the error).
    376 
    377 When using interrupt-driven I/O, psx08 produces all the expected output, but
    378 it does not return control to 167Bug. Is this test supposed to work with
    379 interrupt-driven console I/O?
    380 
    381 
    382 What's new
     463When using interrupt-driven I/O, psx08 fails with an internal assertion error.
     464
     465
     466What is new
    383467----------
    384468
    385469All known problems with use of the caches on the MBX860-002 and MBX821-001
    386470have been resolved.
     471
     472Configuration of the console and network is now possible at boot time through
     473NVRAM parameters.
    387474
    388475
  • c/src/lib/libbsp/powerpc/mbx8xx/console/console.c

    r060d538 r00ff4cd  
    8282#include <termios.h>
    8383
    84 #if UARTS_IO_MODE == 0
    85 #define BSP_WRITE m8xx_uart_pollWrite
    86 #define BSP_READ  m8xx_uart_pollRead
    87 #elif UARTS_IO_MODE == 1
    88 #define BSP_WRITE m8xx_uart_write
    89 #elif UARTS_IO_MODE == 2
    90 #define BSP_WRITE _EPPCBug_pollWrite
    91 #define BSP_READ  _EPPCBug_pollRead
    92 #endif
    93 
    9484static int _EPPCBug_pollRead( int minor );
    9585static int _EPPCBug_pollWrite( int minor, const char *buf, int len );
    9686static void _BSP_output_char( char c );
     87static rtems_status_code do_poll_read( rtems_device_major_number major, rtems_device_minor_number minor, void * arg);
     88static rtems_status_code do_poll_write( rtems_device_major_number major, rtems_device_minor_number minor, void * arg);
     89
    9790
    9891BSP_output_char_function_type BSP_output_char = _BSP_output_char;
     
    113106 *                -1 if no character is present in the input FIFO.
    114107 */
    115 int _EPPCBug_pollRead(
     108static int _EPPCBug_pollRead(
    116109  int minor
    117110)
     
    221214 *  Return value: IGNORED
    222215 */
    223 int _EPPCBug_pollWrite(
     216static int _EPPCBug_pollWrite(
    224217  int minor,
    225218  const char *buf,
     
    332325
    333326/*
     327 *  do_poll_read
     328 *
     329 *  Input characters through polled I/O. Returns has soon as a character has
     330 *  been received. Otherwise, if we wait for the number of requested characters,
     331 *  we could be here forever!
     332 *
     333 *  CR is converted to LF on input. The terminal should not send a CR/LF pair
     334 *  when the return or enter key is pressed.
     335 *
     336 *  Input parameters:
     337 *    major - ignored. Should be the major number for this driver.
     338 *    minor - selected channel.
     339 *    arg->buffer - where to put the received characters.
     340 *    arg->count  - number of characters to receive before returning--Ignored.
     341 *
     342 *  Output parameters:
     343 *    arg->bytes_moved - the number of characters read. Always 1.
     344 *
     345 *  Return value: RTEMS_SUCCESSFUL
     346 *
     347 *  CANNOT BE COMBINED WITH INTERRUPT DRIVEN I/O!
     348 */
     349static rtems_status_code do_poll_read(
     350  rtems_device_major_number major,
     351  rtems_device_minor_number minor,
     352  void                    * arg
     353)
     354{
     355  rtems_libio_rw_args_t *rw_args = arg;
     356  int c;
     357
     358#if NVRAM_CONFIGURE == 1
     359
     360  int (*pollRead)( int minor );
     361 
     362  if ( (nvram->console_mode & 0x06) == 0x04 )
     363    pollRead = _EPPCBug_pollRead;
     364  else
     365    pollRead = m8xx_uart_pollRead;
     366
     367  while( (c = (*pollRead)(minor)) == -1 );
     368  rw_args->buffer[0] = (unsigned8)c;
     369  if( rw_args->buffer[0] == '\r' )
     370      rw_args->buffer[0] = '\n';
     371  rw_args->bytes_moved = 1;
     372  return RTEMS_SUCCESSFUL;
     373
     374#else
     375
     376#if UARTS_IO_MODE == 2
     377#define BSP_READ  _EPPCBug_pollRead
     378#else
     379#define BSP_READ  m8xx_uart_pollRead
     380#endif
     381
     382  while( (c = BSP_READ(minor)) == -1 );
     383  rw_args->buffer[0] = (unsigned8)c;
     384  if( rw_args->buffer[0] == '\r' )
     385      rw_args->buffer[0] = '\n';
     386  rw_args->bytes_moved = 1;
     387  return RTEMS_SUCCESSFUL;
     388
     389#endif
     390}
     391
     392
     393/*
     394 *  do_poll_write
     395 *
     396 *  Output characters through polled I/O. Returns only once every character has
     397 *  been sent.
     398 *
     399 *  CR is transmitted AFTER a LF on output.
     400 *
     401 *  Input parameters:
     402 *    major - ignored. Should be the major number for this driver.
     403 *    minor - selected channel
     404 *    arg->buffer - where to get the characters to transmit.
     405 *    arg->count  - the number of characters to transmit before returning.
     406 *
     407 *  Output parameters:
     408 *    arg->bytes_moved - the number of characters read
     409 *
     410 *  Return value: RTEMS_SUCCESSFUL
     411 *
     412 *  CANNOT BE COMBINED WITH INTERRUPT DRIVEN I/O!
     413 */
     414static rtems_status_code do_poll_write(
     415  rtems_device_major_number major,
     416  rtems_device_minor_number minor,
     417  void                    * arg
     418)
     419{
     420  rtems_libio_rw_args_t *rw_args = arg;
     421  unsigned32 i;
     422  char cr ='\r';
     423
     424#if NVRAM_CONFIGURE == 1
     425
     426  int (*pollWrite)(int minor, const char *buf, int len);
     427 
     428  if ( (nvram->console_mode & 0x06) == 0x04 )
     429    pollWrite = _EPPCBug_pollWrite;
     430  else
     431    pollWrite = m8xx_uart_pollWrite;
     432
     433  for( i = 0; i < rw_args->count; i++ ) {
     434    (*pollWrite)(minor, &(rw_args->buffer[i]), 1);
     435    if ( rw_args->buffer[i] == '\n' )
     436      (*pollWrite)(minor, &cr, 1);
     437  }
     438  rw_args->bytes_moved = i;
     439  return RTEMS_SUCCESSFUL;
     440
     441#else
     442
     443#if UARTS_IO_MODE == 2
     444#define BSP_WRITE _EPPCBug_pollWrite
     445#else
     446#define BSP_WRITE m8xx_uart_pollWrite
     447#endif
     448
     449  for( i = 0; i < rw_args->count; i++ ) {
     450    BSP_WRITE(minor, &(rw_args->buffer[i]), 1);
     451    if ( rw_args->buffer[i] == '\n' )
     452      BSP_WRITE(minor, &cr, 1);
     453  }
     454  rw_args->bytes_moved = i;
     455  return RTEMS_SUCCESSFUL;
     456
     457#endif
     458}
     459
     460
     461/*
    334462 *  Print functions prototyped in bspIo.h
    335463 */
    336464
    337 void _BSP_output_char( char c )
     465static void _BSP_output_char( char c )
    338466{
    339467  char cr = '\r';
    340468 
    341   BSP_WRITE( PRINTK_MINOR, &c, 1 );
     469  /*
     470   *  Can't rely on console_initialize having been called before this function
     471   *  is used, so it may fail unless output is done through EPPC-Bug.
     472   */
     473#if NVRAM_CONFIGURE == 1
     474
     475  rtems_device_minor_number printk_minor;
     476
     477  /* Use NVRAM info for configuration */
     478  printk_minor = (nvram->console_printk_port & 0x70) >> 4;
     479  if( (nvram->console_mode & 0x30) == 0x20 ) {
     480    _EPPCBug_pollWrite( printk_minor, &c, 1 );
     481    if( c == '\n' )
     482      _EPPCBug_pollWrite( printk_minor, &cr, 1 );
     483  }
     484  else {
     485    m8xx_uart_pollWrite( printk_minor, &c, 1 );
     486    if( c == '\n' )
     487      m8xx_uart_pollWrite( PRINTK_MINOR, &cr, 1 );
     488        }
     489       
     490#else 
     491
     492#if PRINTK_IO_MODE == 2
     493#define PRINTK_WRITE _EPPCBug_pollWrite
     494#else
     495#define PRINTK_WRITE m8xx_uart_pollWrite
     496#endif
     497
     498  PRINTK_WRITE( PRINTK_MINOR, &c, 1 );
    342499  if( c == '\n' )
    343     BSP_WRITE( PRINTK_MINOR, &cr, 1 );
     500    PRINTK_WRITE( PRINTK_MINOR, &cr, 1 );
     501   
     502#endif
    344503}
    345504
     
    363522{
    364523  rtems_status_code status;
     524  rtems_device_minor_number console_minor;
    365525 
    366526  /*
    367    * Set up TERMIOS
     527   * Set up TERMIOS if needed
    368528   */
     529#if NVRAM_CONFIGURE == 1
     530  /* Use NVRAM info for configuration */
     531  console_minor = nvram->console_printk_port & 0x07;
     532       
     533  if ( nvram->console_mode & 0x01 )
     534    /* termios */
     535    rtems_termios_initialize ();
     536
     537  /*
     538   *  Do common initialization.
     539   */
     540  m8xx_uart_initialize();
     541 
     542  /*
     543   * Do device-specific initialization
     544   */
     545  if ( !nvram->eppcbug_smc1 &&
     546    ( ((nvram->console_mode & 0x30) != 0x20) ||
     547     (((nvram->console_printk_port & 0x30) >> 4) != SMC1_MINOR) ) )
     548    m8xx_uart_smc_initialize(SMC1_MINOR); /* /dev/tty0 */
     549
     550  if ( ((nvram->console_mode & 0x30) != 0x20) ||
     551      (((nvram->console_printk_port & 0x30) >> 4) != SMC2_MINOR) )
     552    m8xx_uart_smc_initialize(SMC2_MINOR); /* /dev/tty1 */                             
     553
     554  if ( ((nvram->console_mode & 0x30) != 0x20) ||
     555      (((nvram->console_printk_port & 0x30) >> 4) != SCC2_MINOR) )
     556    m8xx_uart_scc_initialize(SCC2_MINOR); /* /dev/tty2    */
     557                           
     558#ifdef mpc860
     559
     560  if ( ((nvram->console_mode & 0x30) != 0x20) ||
     561      (((nvram->console_printk_port & 0x30) >> 4) != SCC3_MINOR) )
     562    m8xx_uart_scc_initialize(SCC3_MINOR); /* /dev/tty3    */
     563
     564  if ( ((nvram->console_mode & 0x30) != 0x20) ||
     565      (((nvram->console_printk_port & 0x30) >> 4) != SCC4_MINOR) )
     566    m8xx_uart_scc_initialize(SCC4_MINOR); /* /dev/tty4    */
     567
     568#endif /* mpc860 */
     569
     570#else /* NVRAM_CONFIGURE != 1 */
     571
     572    console_minor = CONSOLE_MINOR;
     573   
    369574#if UARTS_USE_TERMIOS == 1
    370   rtems_termios_initialize();
    371 #endif
     575
     576    rtems_termios_initialize ();
     577   
     578#endif /* UARTS_USE_TERMIOS */
     579   
    372580  /*
    373581   *  Do common initialization.
     
    401609
    402610#endif /* mpc860 */
     611
     612#endif /* NVRAM_CONFIGURE != 1 */
     613
    403614
    404615  /*
     
    431642   
    432643  /* Now register the RTEMS console */
    433   status = rtems_io_register_name ("/dev/console", major, CONSOLE_MINOR);
     644  status = rtems_io_register_name ("/dev/console", major, console_minor);
    434645  if (status != RTEMS_SUCCESSFUL)
    435646    rtems_fatal_error_occurred (status);
     
    449660{
    450661  /* Used to track termios private data for callbacks */
    451 #if UARTS_IO_MODE == 1
    452662  extern struct rtems_termios_tty *ttyp[];
     663 
    453664  rtems_libio_open_close_args_t *args = arg;
    454 #endif
    455 
    456665  rtems_status_code sc;
    457 
    458 #if UARTS_USE_TERMIOS == 1
     666 
    459667  static const rtems_termios_callbacks sccEPPCBugCallbacks = {
    460668    NULL,                               /* firstOpen */
     
    466674    0                                   /* outputUsesInterrupts */
    467675  };
     676 
    468677  static const rtems_termios_callbacks intrCallbacks = {
    469678    NULL,                               /* firstOpen */
     
    476685    1                                   /* outputUsesInterrupts */
    477686  };
     687 
    478688  static const rtems_termios_callbacks pollCallbacks = {
    479689    NULL,                               /* firstOpen */
     
    486696    0                                   /* outputUsesInterrupts */
    487697  };
    488 #endif
    489698   
    490699  if ( minor > NUM_PORTS-1 )
    491700    return RTEMS_INVALID_NUMBER;
    492701
     702#if NVRAM_CONFIGURE == 1
     703
     704  /* Use NVRAM info for configuration */
     705  if ( nvram->console_mode & 0x01 ) {
     706    /* Use termios */
     707    if ( (nvram->console_mode & 0x06) == 0x02 ) {
     708      /* interrupt-driven I/O */
     709      sc = rtems_termios_open( major, minor, arg, &intrCallbacks );
     710      ttyp[minor] = args->iop->data1;        /* Keep cookie returned by termios_open */
     711      return sc;
     712    }
     713    else if ( (nvram->console_mode & 0x06) == 0x04 )
     714      /* polled I/O through EPPC-Bug, better be through SMC1 */
     715      return rtems_termios_open( major, minor, arg, &sccEPPCBugCallbacks );
     716    else
     717      /* normal polled I/O */
     718      return rtems_termios_open( major, minor, arg, &pollCallbacks );
     719  }
     720  else
     721    /* no termios -- default to polled I/O */
     722    return RTEMS_SUCCESSFUL;
     723         
     724#else /* NVRAM_CONFIGURE != 1 */
     725
    493726#if UARTS_USE_TERMIOS == 1
    494727
    495728#if UARTS_IO_MODE == 2    /* EPPCBug polled I/O with termios */
    496 
    497   sc = rtems_termios_open (major, minor, arg, &sccEPPCBugCallbacks);
    498  
     729  sc = rtems_termios_open( major, minor, arg, &sccEPPCBugCallbacks );
    499730#elif UARTS_IO_MODE == 1  /* RTEMS interrupt-driven I/O with termios */
    500 
    501   sc = rtems_termios_open (major, minor, arg, &intrCallbacks);
     731  sc = rtems_termios_open( major, minor, arg, &intrCallbacks );
    502732  ttyp[minor] = args->iop->data1;        /* Keep cookie returned by termios_open */
    503  
    504733#else                     /* RTEMS polled I/O with termios */
    505 
    506   sc = rtems_termios_open (major, minor, arg, &pollCallbacks);
    507  
    508 #endif
    509 
    510 #else                     /* Nothing to do if termios is not used */
    511 
     734  sc = rtems_termios_open( major, minor, arg, &pollCallbacks );
     735#endif
     736
     737#else /* UARTS_USE_TERMIOS != 1 */
     738  /* no termios -- default to polled I/O */
    512739  sc = RTEMS_SUCCESSFUL;
    513  
    514 #endif
     740#endif /* UARTS_USE_TERMIOS != 1 */
    515741
    516742  return sc;
     743 
     744#endif /* NVRAM_CONFIGURE != 1 */
    517745}
    518746
     
    530758    return RTEMS_INVALID_NUMBER;
    531759
     760#if NVRAM_CONFIGURE == 1
     761
     762  /* Use NVRAM info for configuration */
     763  if ( nvram->console_mode & 0x01 )
     764    /* use termios */
     765    return rtems_termios_close( arg );
     766  else
     767    /* no termios */
     768    return RTEMS_SUCCESSFUL;
     769
     770#else /* NVRAM_CONFIGURE != 1 */
     771
    532772#if UARTS_USE_TERMIOS == 1
    533   return rtems_termios_close (arg);
     773  return rtems_termios_close( arg );
    534774#else
    535775  return RTEMS_SUCCESSFUL;
    536776#endif
     777
     778#endif /* NVRAM_CONFIGURE != 1 */
    537779}
    538780
     
    547789)
    548790{
    549 #if UARTS_USE_TERMIOS != 1
    550   rtems_libio_rw_args_t *rw_args = arg;
    551   int c;
    552 #endif
    553  
    554791  if ( minor > NUM_PORTS-1 )
    555792    return RTEMS_INVALID_NUMBER;
    556793
     794#if NVRAM_CONFIGURE == 1
     795
     796  /* Use NVRAM info for configuration */
     797  if ( nvram->console_mode & 0x01 )
     798    /* use termios */
     799    return rtems_termios_read( arg );
     800  else
     801    /* no termios -- default to polled */
     802    return do_poll_read( major, minor, arg );
     803
     804#else
     805
    557806#if UARTS_USE_TERMIOS == 1
    558 
    559   return rtems_termios_read(arg);
    560  
    561 #else
    562 
    563 #if UARTS_IO_MODE != 1    /* Polled I/O without termios */
    564 
    565   while( (c = BSP_READ( minor )) == -1 );
    566   rw_args->buffer[0] = (unsigned8)c;
    567   if( rw_args->buffer[0] == '\r' )
    568       rw_args->buffer[0] = '\n';
    569   rw_args->bytes_moved = 1;
    570   return RTEMS_SUCCESSFUL;
    571  
    572 #else                     /* RTEMS interrupt-driven I/O without termios */
    573 
    574   #error "Interrupt-driven input without termios is not yet supported"
    575  
     807  return rtems_termios_read( arg );
     808#else
     809  return do_poll_read( major, minor, arg );
    576810#endif
    577811
     
    589823)
    590824{
    591 #if UARTS_USE_TERMIOS != 1
    592   rtems_libio_rw_args_t *rw_args = arg;
    593   unsigned32 i;
    594   char cr = '\r';
    595 #endif
    596 
    597825  if ( minor > NUM_PORTS-1 )
    598826    return RTEMS_INVALID_NUMBER;
    599827
     828#if NVRAM_CONFIGURE == 1
     829
     830  /* Use NVRAM info for configuration */
     831  if ( nvram->console_mode & 0x01 )
     832    /* use termios */
     833    return rtems_termios_write( arg );
     834  else
     835    /* no termios -- default to polled */
     836    return do_poll_write( major, minor, arg );
     837
     838#else
     839
    600840#if UARTS_USE_TERMIOS == 1
    601 
    602   return rtems_termios_write(arg);
    603  
    604 #else
    605 
    606 #if UARTS_IO_MODE != 1     /* Polled I/O without termios*/
    607 
    608   /* Must add carriage return to line feeds */
    609   for( i = 0; i < rw_args->count; i++ ) {
    610     BSP_WRITE( minor, &(rw_args->buffer[i]), 1 );
    611     if( rw_args->buffer[i] == '\n' )
    612       BSP_WRITE( minor, &cr, 1 );
    613   }
    614   rw_args->bytes_moved = i;
    615   return RTEMS_SUCCESSFUL;
    616    
    617 #else                     /* RTEMS interrupt-driven I/O without termios */
    618 
    619   #error "Interrupt-driven output without termios is not yet supported"
    620  
     841  return rtems_termios_write( arg );
     842#else
     843    /* no termios -- default to polled */
     844  return do_poll_write( major, minor, arg );
    621845#endif
    622846
     
    637861    return RTEMS_INVALID_NUMBER;
    638862
     863#if NVRAM_CONFIGURE == 1
     864
     865  /* Uuse NVRAM info for configuration */
     866  if ( nvram->console_mode & 0x01 )
     867    /* termios */
     868    return rtems_termios_ioctl( arg );
     869  else
     870    /* no termios -- default to polled */
     871    return RTEMS_SUCCESSFUL;
     872
     873#else
     874
    639875#if UARTS_USE_TERMIOS == 1
    640   return rtems_termios_ioctl (arg);
     876  return rtems_termios_ioctl( arg );
    641877#else
    642878  return RTEMS_SUCCESSFUL;
    643879#endif
    644 }
    645 
     880
     881#endif
     882}
     883
  • c/src/lib/libbsp/powerpc/mbx8xx/include/bsp.h

    r060d538 r00ff4cd  
    3030#include <mpc8xx/mmu.h>
    3131#include <mpc8xx/console.h>
     32
     33
     34/*
     35 *  Representation of initialization data in NVRAM
     36 */
     37typedef volatile struct nvram_config_ {
     38  unsigned char  cache_mode;            /* 0xFA001000 */
     39  unsigned char  console_mode;          /* 0xFA001001 */
     40  unsigned char  console_printk_port;   /* 0xFA001002 */
     41  unsigned char  eppcbug_smc1;          /* 0xFA001003 */
     42  unsigned long  ipaddr;                /* 0xFA001004 */
     43  unsigned long  netmask;               /* 0xFA001008 */
     44  unsigned char  enaddr[6];             /* 0xFA00100C */
     45  unsigned short processor_id;          /* 0xFA001012 */
     46  unsigned long  rma_start;             /* 0xFA001014 */
     47  unsigned long  vma_start;             /* 0xFA001018 */
     48  unsigned long  ramsize;               /* 0xFA00101C */
     49} nvram_config;
     50
     51/*
     52 *  Pointer to the base of User Area NVRAM
     53 */
     54#define nvram                   ((nvram_config * const) 0xFA001000)
     55
    3256
    3357/*
     
    7195#define Lower_tm27_intr()
    7296
    73 /* Constants -- THESE SHOULD BE DEFINED IN THE LINKER SCRIPT */
    74 
    75 #define RAM_START 0
    76 #define RAM_END   0x100000
    77 
    7897/* miscellaneous stuff assumed to exist */
    7998
  • c/src/lib/libbsp/powerpc/mbx8xx/network/network.c

    r060d538 r00ff4cd  
    5353#define TX_BD_PER_BUF    4
    5454
     55#define INET_ADDR_MAX_BUF_SIZE (sizeof "255.255.255.255")
     56
     57
    5558/*
    5659 * RTEMS event used by interrupt handler to signal daemons.
     
    15381541  int unitNumber;
    15391542  char *unitName;
     1543  char *pAddr;
     1544  unsigned long addr;
    15401545
    15411546        /*
     
    15621567   * Process options
    15631568   */
     1569 #if NVRAM_CONFIGURE == 1
     1570 
     1571  /* Configure from NVRAM */
     1572  if ( (addr = nvram->ipaddr) ) {
     1573    /* We have a non-zero entry, copy the value */
     1574    if ( (pAddr = malloc ( INET_ADDR_MAX_BUF_SIZE, 0, M_NOWAIT )) )
     1575      config->ip_address = (char *)inet_ntop(AF_INET, &addr, pAddr, INET_ADDR_MAX_BUF_SIZE -1 );
     1576    else
     1577      rtems_panic("Can't allocate ip_address buffer!\n");
     1578  }
     1579 
     1580  if ( (addr = nvram->netmask) ) {
     1581    /* We have a non-zero entry, copy the value */
     1582    if ( (pAddr = malloc ( INET_ADDR_MAX_BUF_SIZE, 0, M_NOWAIT )) )
     1583      config->ip_netmask = (char *)inet_ntop(AF_INET, &addr, pAddr, INET_ADDR_MAX_BUF_SIZE -1 );
     1584    else
     1585      rtems_panic("Can't allocate ip_netmask buffer!\n");
     1586  }
     1587
     1588  /* Ethernet address requires special handling -- it must be copied into
     1589   * the arpcom struct. The following if construct serves only to give the
     1590   * User Area NVRAM parameter the highest priority.
     1591   *
     1592   * If the ethernet address is specified in NVRAM, go ahead and copy it.
     1593   * (ETHER_ADDR_LEN = 6 bytes).
     1594   */
     1595  if ( nvram->enaddr[0] || nvram->enaddr[1] || nvram->enaddr[2] ) {
     1596    /* Anything in the first three bytes indicates a non-zero entry, copy value */
     1597        memcpy ((void *)sc->arpcom.ac_enaddr, &nvram->enaddr, ETHER_ADDR_LEN);
     1598  }
     1599  else if ( config->hardware_address ) {
     1600    /* There is no entry in NVRAM, but there is in the ifconfig struct, so use it. */
     1601    memcpy ((void *)sc->arpcom.ac_enaddr, config->hardware_address, ETHER_ADDR_LEN);
     1602  }
     1603  else {
     1604    /* There is no ethernet address provided, so it could be read
     1605     * from the Ethernet protocol block of SCC1 in DPRAM.
     1606     */
     1607    rtems_panic("No Ethernet address specified!\n");
     1608  }
     1609   
     1610 #else /* NVRAM_CONFIGURE != 1 */
     1611 
    15641612  if (config->hardware_address) {
    15651613    memcpy (sc->arpcom.ac_enaddr, config->hardware_address, ETHER_ADDR_LEN);
    15661614  }
    15671615  else {
    1568                 /* FIXME to read the enaddr from NVRAM */
    1569   }
     1616    /* There is no ethernet address provided, so it could be read
     1617     * from the Ethernet protocol block of SCC1 in DPRAM.
     1618     */
     1619    rtems_panic("No Ethernet address specified!\n");
     1620  }
     1621 
     1622#endif /* NVRAM_CONFIGURE != 1 */
    15701623
    15711624  if (config->mtu)
  • c/src/lib/libbsp/powerpc/mbx8xx/startup/bspstart.c

    r060d538 r00ff4cd  
    136136   * Enable instruction and data caches. Do not force writethrough mode.
    137137   */
    138   #ifdef INSTRUCTION_CACHE_ENABLE
    139         rtems_cache_enable_instruction();
    140   #endif
    141 
    142   #ifdef DATA_CACHE_ENABLE
    143         rtems_cache_enable_data();
    144   #endif
     138#if NVRAM_CONFIGURE == 1
     139  if ( nvram->cache_mode & 0x02 )
     140    rtems_cache_enable_instruction();
     141  if ( nvram->cache_mode & 0x01 )
     142    rtems_cache_enable_data();
     143#else
     144#ifdef INSTRUCTION_CACHE_ENABLE
     145  rtems_cache_enable_instruction();
     146#endif
     147#ifdef DATA_CACHE_ENABLE
     148  rtems_cache_enable_data();
     149#endif
     150#endif
    145151   
    146152  /*
Note: See TracChangeset for help on using the changeset viewer.