2007-03-28 Joel Sherrill <joel@OARcorp.com>

PR 1232/bsps
	* bsppost.c: It should not be a fatal error to not have a console.
This commit is contained in:
Joel Sherrill
2007-03-28 18:03:26 +00:00
parent 884fba65b2
commit 2fc3592d35
2 changed files with 31 additions and 17 deletions

View File

@@ -1,3 +1,8 @@
2007-03-28 Joel Sherrill <joel@OARcorp.com>
PR 1232/bsps
* bsppost.c: It should not be a fatal error to not have a console.
2007-02-06 Ralf Corsépius <ralf.corsepius@rtems.org>
* vmeUniverse/vmeUniverse.c: Use size_t for sizes.

View File

@@ -1,11 +1,15 @@
/*
* This is a basic BSP post driver hook.
* This is a shared BSP post driver hook designed to open
* /dev/console for stdin, stdout, and stderr if it exists.
* Newlib will automatically associate the file descriptors
* with the first thress files opened.
*
* After drivers are setup, register some "filenames"
* and open stdin, stdout, stderr files
* COPYRIGHT (c) 1989-2007.
* On-Line Applications Research Corporation (OAR).
*
* Newlib will automatically associate the files with these
* (it hardcodes the numbers)
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*
* $Id$
*/
@@ -14,23 +18,28 @@
#include <rtems/libio.h>
#include <fcntl.h>
void
bsp_postdriver_hook(void)
void bsp_postdriver_hook(void)
{
int stdin_fd, stdout_fd, stderr_fd;
int error_code;
int error_code = 'S' << 24 | 'T' << 16 | 'D' << 8;
error_code = 'S' << 24 | 'T' << 16;
if ((stdin_fd = open("/dev/console", O_RDONLY, 0)) == -1)
rtems_fatal_error_occurred( error_code | 'D' << 8 | '0' );
/*
* Attempt to open /dev/console.
*/
if ((stdin_fd = open("/dev/console", O_RDONLY, 0)) == -1) {
/*
* There may not be a console driver so this is OK.
*/
return;
}
/*
* But if we find /dev/console once, we better find it twice more
* or something is REALLY wrong.
*/
if ((stdout_fd = open("/dev/console", O_WRONLY, 0)) == -1)
rtems_fatal_error_occurred( error_code | 'D' << 8 | '1' );
rtems_fatal_error_occurred( error_code | '1' );
if ((stderr_fd = open("/dev/console", O_WRONLY, 0)) == -1)
rtems_fatal_error_occurred( error_code | 'D' << 8 | '2' );
if ((stdin_fd != 0) || (stdout_fd != 1) || (stderr_fd != 2))
rtems_fatal_error_occurred( error_code | 'I' << 8 | 'O' );
rtems_fatal_error_occurred( error_code | '2' );
}