Ignore:
Timestamp:
Mar 28, 2007, 6:03:26 PM (13 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Children:
a2a6187
Parents:
884fba6
Message:

2007-03-28 Joel Sherrill <joel@…>

PR 1232/bsps

  • bsppost.c: It should not be a fatal error to not have a console.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/shared/bsppost.c

    r884fba6 r2fc3592d  
    11/*
    2  *  This is a basic BSP post driver hook.
     2 *  This is a shared BSP post driver hook designed to open
     3 *  /dev/console for stdin, stdout, and stderr if it exists.
     4 *  Newlib will automatically associate the file descriptors
     5 *  with the first thress files opened.
    36 *
    4  * After drivers are setup, register some "filenames"
    5  * and open stdin, stdout, stderr files
     7 *  COPYRIGHT (c) 1989-2007.
     8 *  On-Line Applications Research Corporation (OAR).
    69 *
    7  * Newlib will automatically associate the files with these
    8  * (it hardcodes the numbers)
     10 *  The license and distribution terms for this file may be
     11 *  found in the file LICENSE in this distribution or at
     12 *  http://www.rtems.com/license/LICENSE.
    913 *
    1014 *  $Id$
     
    1519#include <fcntl.h>
    1620
    17 void
    18 bsp_postdriver_hook(void)
     21void bsp_postdriver_hook(void)
    1922{
    2023  int stdin_fd, stdout_fd, stderr_fd;
    21   int error_code;
     24  int error_code = 'S' << 24 | 'T' << 16 | 'D' << 8;
    2225
    23   error_code = 'S' << 24 | 'T' << 16;
     26  /*
     27   * Attempt to open /dev/console.
     28   */
     29  if ((stdin_fd = open("/dev/console", O_RDONLY, 0)) == -1) {
     30    /*
     31     * There may not be a console driver so this is OK.
     32     */
     33    return;
     34  }
    2435
    25   if ((stdin_fd = open("/dev/console", O_RDONLY, 0)) == -1)
    26     rtems_fatal_error_occurred( error_code | 'D' << 8 | '0' );
    27 
     36  /*
     37   *  But if we find /dev/console once, we better find it twice more
     38   *  or something is REALLY wrong.
     39   */
    2840  if ((stdout_fd = open("/dev/console", O_WRONLY, 0)) == -1)
    29     rtems_fatal_error_occurred( error_code | 'D' << 8 | '1' );
     41    rtems_fatal_error_occurred( error_code | '1' );
    3042
    3143  if ((stderr_fd = open("/dev/console", O_WRONLY, 0)) == -1)
    32     rtems_fatal_error_occurred( error_code | 'D' << 8 | '2' );
    33 
    34   if ((stdin_fd != 0) || (stdout_fd != 1) || (stderr_fd != 2))
    35     rtems_fatal_error_occurred( error_code | 'I' << 8 | 'O' );
     44    rtems_fatal_error_occurred( error_code | '2' );
    3645}
Note: See TracChangeset for help on using the changeset viewer.