diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2007-03-28 18:03:26 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2007-03-28 18:03:26 +0000 |
commit | 2fc3592d353e3ec5f0cbffada671481362b54ec8 (patch) | |
tree | 17d65f61a6ab897b1e997659f2cd41a24123124d /c | |
parent | 2007-03-27 Ralf Corsépius <ralf.corsepius@rtems.org> (diff) | |
download | rtems-2fc3592d353e3ec5f0cbffada671481362b54ec8.tar.bz2 |
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.
Diffstat (limited to 'c')
-rw-r--r-- | c/src/lib/libbsp/shared/ChangeLog | 5 | ||||
-rw-r--r-- | c/src/lib/libbsp/shared/bsppost.c | 43 |
2 files changed, 31 insertions, 17 deletions
diff --git a/c/src/lib/libbsp/shared/ChangeLog b/c/src/lib/libbsp/shared/ChangeLog index b533dffe28..1c0f2b4346 100644 --- a/c/src/lib/libbsp/shared/ChangeLog +++ b/c/src/lib/libbsp/shared/ChangeLog @@ -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. diff --git a/c/src/lib/libbsp/shared/bsppost.c b/c/src/lib/libbsp/shared/bsppost.c index 3b44239ff5..e86420ebb7 100644 --- a/c/src/lib/libbsp/shared/bsppost.c +++ b/c/src/lib/libbsp/shared/bsppost.c @@ -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' ); } |