source: rtems/c/src/lib/libbsp/shared/bsppost.c @ a185db7

4.104.114.84.95
Last change on this file since a185db7 was a185db7, checked in by Joel Sherrill <joel.sherrill@…>, on 03/28/07 at 18:03:38

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

PR 1232/bsps

  • bsppost.c: It should not be a fatal error to not have a console.
  • Property mode set to 100644
File size: 1.2 KB
Line 
1/*
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.
6 *
7 *  COPYRIGHT (c) 1989-2007.
8 *  On-Line Applications Research Corporation (OAR).
9 *
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.
13 *
14 *  $Id$
15 */
16
17#include <rtems.h>
18#include <rtems/libio.h>
19#include <fcntl.h>
20
21void bsp_postdriver_hook(void)
22{
23  int stdin_fd, stdout_fd, stderr_fd;
24  int error_code = 'S' << 24 | 'T' << 16 | 'D' << 8;
25
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  }
35
36  /*
37   *  But if we find /dev/console once, we better find it twice more
38   *  or something is REALLY wrong.
39   */
40  if ((stdout_fd = open("/dev/console", O_WRONLY, 0)) == -1)
41    rtems_fatal_error_occurred( error_code | '1' );
42
43  if ((stderr_fd = open("/dev/console", O_WRONLY, 0)) == -1)
44    rtems_fatal_error_occurred( error_code | '2' );
45}
Note: See TracBrowser for help on using the repository browser.