diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2007-03-28 18:03:38 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2007-03-28 18:03:38 +0000 |
commit | a185db71d8a57ca653540a4e9b30d9cd9a421b27 (patch) | |
tree | 7dc390ab2a4fb863c3025e6efec0614a1f78d1e7 /c/src/lib/libbsp/shared | |
parent | 2007-03-28 Ralf Corsépius <ralf.corsepius@rtems.org> (diff) | |
download | rtems-a185db71d8a57ca653540a4e9b30d9cd9a421b27.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/src/lib/libbsp/shared')
-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 a5d52157f3..00724ca587 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-03-09 Joel Sherrill <joel@OARcorp.com> * bootcard.c: Change XXX to real comment. 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' ); } |