forked from Imagelibrary/rtems
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:
@@ -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>
|
2007-03-09 Joel Sherrill <joel@OARcorp.com>
|
||||||
|
|
||||||
* bootcard.c: Change XXX to real comment.
|
* bootcard.c: Change XXX to real comment.
|
||||||
|
|||||||
@@ -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"
|
* COPYRIGHT (c) 1989-2007.
|
||||||
* and open stdin, stdout, stderr files
|
* On-Line Applications Research Corporation (OAR).
|
||||||
*
|
*
|
||||||
* Newlib will automatically associate the files with these
|
* The license and distribution terms for this file may be
|
||||||
* (it hardcodes the numbers)
|
* found in the file LICENSE in this distribution or at
|
||||||
|
* http://www.rtems.com/license/LICENSE.
|
||||||
*
|
*
|
||||||
* $Id$
|
* $Id$
|
||||||
*/
|
*/
|
||||||
@@ -14,23 +18,28 @@
|
|||||||
#include <rtems/libio.h>
|
#include <rtems/libio.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
void
|
void bsp_postdriver_hook(void)
|
||||||
bsp_postdriver_hook(void)
|
|
||||||
{
|
{
|
||||||
int stdin_fd, stdout_fd, stderr_fd;
|
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;
|
/*
|
||||||
|
* Attempt to open /dev/console.
|
||||||
if ((stdin_fd = open("/dev/console", O_RDONLY, 0)) == -1)
|
*/
|
||||||
rtems_fatal_error_occurred( error_code | 'D' << 8 | '0' );
|
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)
|
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)
|
if ((stderr_fd = open("/dev/console", O_WRONLY, 0)) == -1)
|
||||||
rtems_fatal_error_occurred( error_code | 'D' << 8 | '2' );
|
rtems_fatal_error_occurred( error_code | '2' );
|
||||||
|
|
||||||
if ((stdin_fd != 0) || (stdout_fd != 1) || (stderr_fd != 2))
|
|
||||||
rtems_fatal_error_occurred( error_code | 'I' << 8 | 'O' );
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user